- moved contents of gl_templates.h to files outside of gl/
This commit is contained in:
parent
e49cd2cb83
commit
1461059dae
16 changed files with 48 additions and 118 deletions
38
src/tarray.h
38
src/tarray.h
|
|
@ -1221,3 +1221,41 @@ protected:
|
|||
hash_t Position;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// an array to hold a small number of unique entries
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
template<class T> class UniqueList
|
||||
{
|
||||
TArray<T*> Array;
|
||||
|
||||
public:
|
||||
|
||||
T * Get(T * t)
|
||||
{
|
||||
for (unsigned i = 0; i<Array.Size(); i++)
|
||||
{
|
||||
if (!memcmp(t, Array[i], sizeof(T))) return Array[i];
|
||||
}
|
||||
T * newo = new T;
|
||||
|
||||
*newo = *t;
|
||||
Array.Push(newo);
|
||||
return newo;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
for (unsigned i = 0; i<Array.Size(); i++) delete Array[i];
|
||||
Array.Clear();
|
||||
}
|
||||
|
||||
~UniqueList()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue