add header guards and two new functions to modify the stored data.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@723 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2002-08-12 20:10:24 +00:00
parent 16f59f6874
commit 9b9d18dc97
+23 -1
View File
@@ -1,3 +1,5 @@
#ifndef _MEDIA_T_MAP_H
#define _MEDIA_T_MAP_H
template<class key, class value> class Map
{
@@ -13,7 +15,7 @@ public:
list[count].v = v;
count++;
}
bool Get(const key &k, value *v)
{
for (int i = 0; i < count; i++)
@@ -33,6 +35,25 @@ public:
return true;
}
bool GetPointer(const key &k, value **v)
{
for (int i = 0; i < count; i++)
if (list[i].k == k) {
*v = &(list[i].v);
return true;
}
return false;
}
// you can't Remove() while iterating through the map using GetAt()
bool GetPointerAt(int32 index, value **v)
{
if (index < 0 || index >= count)
return false;
*v = &(list[index].v);
return true;
}
// you can't Remove() while iterating through the map using GetAt()
bool Remove(const key &k)
{
@@ -58,3 +79,4 @@ private:
int count;
};
#endif // _MEDIA_T_MAP_H