HaikuDepot: List.h: added IndexOf(), Contains() and Remove()
* All of those take const ItemType& as argument.
This commit is contained in:
@@ -142,6 +142,12 @@ public:
|
|||||||
fCount--;
|
fCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Remove(const ItemType& item)
|
||||||
|
{
|
||||||
|
Remove(IndexOf(item));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
inline const ItemType& ItemAt(int32 index) const
|
inline const ItemType& ItemAt(int32 index) const
|
||||||
{
|
{
|
||||||
if (index >= (int32)fCount)
|
if (index >= (int32)fCount)
|
||||||
@@ -159,6 +165,20 @@ public:
|
|||||||
return ItemAt((int32)fCount - 1);
|
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:
|
private:
|
||||||
inline bool _Resize(uint32 count)
|
inline bool _Resize(uint32 count)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user