HaikuDepot: List.h: added IndexOf(), Contains() and Remove()

* All of those take const ItemType& as argument.
This commit is contained in:
Stephan Aßmus
2013-08-10 20:37:09 +02:00
parent 42479955ae
commit 2c3e4eaa41
+20
View File
@@ -142,6 +142,12 @@ public:
fCount--;
}
inline void Remove(const ItemType& item)
{
Remove(IndexOf(item));
}
inline const ItemType& ItemAt(int32 index) const
{
if (index >= (int32)fCount)
@@ -159,6 +165,20 @@ public:
return ItemAt((int32)fCount - 1);
}
inline int32 IndexOf(const ItemType& item) const
{
for (uint32 i = 0; i < fCount; i++) {
if (ItemAtFast(i) == item)
return i;
}
return -1;
}
inline bool Contains(const ItemType& item) const
{
return IndexOf(item) >= 0;
}
private:
inline bool _Resize(uint32 count)
{