mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 23:40:39 +00:00
b214a1a1da
This reverts commit a00b1855cb
.
Conflicts:
Core/HLE/FunctionWrappers.h
Core/HLE/sceCtrl.cpp
Core/HLE/sceKernelModule.cpp
66 lines
1.0 KiB
C++
66 lines
1.0 KiB
C++
#pragma once
|
|
|
|
// Really stupid but much faster than a vector for keeping breakpoints in
|
|
// and looking them up in debug mode. STL is SOOO SLOW in debug mode on Windows.
|
|
|
|
|
|
template<class T, size_t maxCount>
|
|
class FixedSizeUnorderedSet
|
|
{
|
|
public:
|
|
bool insert(T item)
|
|
{
|
|
if (count_ < maxCount - 1)
|
|
{
|
|
data_[count_++] = item;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool remove(T item)
|
|
{
|
|
for (int i = 0; i < count_; i++)
|
|
{
|
|
if (data_[i] == item)
|
|
{
|
|
if (i == count_ - 1)
|
|
{
|
|
count_--;
|
|
}
|
|
else
|
|
{
|
|
data_[i] = data_[count_ - 1];
|
|
count_--;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
size_t size()
|
|
{
|
|
return count_;
|
|
}
|
|
|
|
T &operator[](size_t index) {
|
|
return data_[index];
|
|
}
|
|
|
|
const T &operator[](size_t index) const {
|
|
return data_[index];
|
|
}
|
|
|
|
void clear() {
|
|
count_ = 0;
|
|
}
|
|
|
|
bool empty() const {
|
|
return count_ != 0;
|
|
}
|
|
|
|
private:
|
|
T data_[maxCount];
|
|
int count_;
|
|
}; |