- moved contents of gl_templates.h to files outside of gl/

This commit is contained in:
Christoph Oelckers 2018-04-01 11:59:12 +02:00
commit 1461059dae
16 changed files with 48 additions and 118 deletions

View file

@ -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();
}
};