From 9b9d18dc9771de931cc98ca2c08388bcd9017def Mon Sep 17 00:00:00 2001 From: beveloper Date: Mon, 12 Aug 2002 20:10:24 +0000 Subject: [PATCH] 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 --- headers/private/media/TMap.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/headers/private/media/TMap.h b/headers/private/media/TMap.h index 7b8798a644..20727392c5 100644 --- a/headers/private/media/TMap.h +++ b/headers/private/media/TMap.h @@ -1,3 +1,5 @@ +#ifndef _MEDIA_T_MAP_H +#define _MEDIA_T_MAP_H template 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