haiku/headers/private/media/TList.h
beveloper 1299bfb29f added real media_server node management, removed bugs, added debug output
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1467 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-10-08 23:59:43 +00:00

57 lines
964 B
C++

#ifndef _MEDIA_T_LIST_H
#define _MEDIA_T_LIST_H
template<class value> class List
{
public:
List() : count(0) {}
void Insert(const value &v)
{
value temp;
if (count == MAXENT) debugger("template List out of memory");
list[count] = v;
count++;
}
// you can't Remove() while iterating through the list using GetAt()
bool GetAt(int32 index, value *v)
{
if (index < 0 || index >= count)
return false;
*v = list[index];
return true;
}
bool GetPointerAt(int32 index, value **v)
{
if (index < 0 || index >= count)
return false;
*v = &list[index];
return true;
}
// you can't Remove() while iterating through the map using GetAt()
bool Remove(int32 index)
{
if (index < 0 || index >= count)
return false;
count--;
if (count > 0)
list[index] = list[count];
return true;
}
void MakeEmpty()
{
count = 0;
}
private:
enum { MAXENT = 64 };
value list[MAXENT];
int count;
};
#endif // _MEDIA_T_LIST_H