From 2c3e4eaa41cfd0d79ddd41d115f6f2f4febc0518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 10 Aug 2013 19:29:17 +0200 Subject: [PATCH] HaikuDepot: List.h: added IndexOf(), Contains() and Remove() * All of those take const ItemType& as argument. --- src/apps/haiku-depot/List.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/apps/haiku-depot/List.h b/src/apps/haiku-depot/List.h index be46c2a4d8..d60bfaf0e4 100644 --- a/src/apps/haiku-depot/List.h +++ b/src/apps/haiku-depot/List.h @@ -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) {