ppsspp/Common/FixedSizeUnorderedSet.h
Henrik Rydgard b214a1a1da Revert "Better wrapper system, and fixed warnings"
This reverts commit a00b1855cb.

Conflicts:

	Core/HLE/FunctionWrappers.h
	Core/HLE/sceCtrl.cpp
	Core/HLE/sceKernelModule.cpp
2012-11-05 10:05:09 +01:00

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_;
};