From 4bbad05e9d9291d2cedba38924d817f7c5f4a83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 27 Jan 2014 22:01:51 +0100 Subject: [PATCH] List.h: Make Remove() methods return bool. The methods can't fail, but they return false for out-of-bounds index or when the item was not contained in the list, which is sometimes helpful. --- src/apps/haiku-depot/List.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/apps/haiku-depot/List.h b/src/apps/haiku-depot/List.h index 92d3adf0c4..804d7769e3 100644 --- a/src/apps/haiku-depot/List.h +++ b/src/apps/haiku-depot/List.h @@ -141,16 +141,19 @@ public: return true; } - inline void Remove() + inline bool Remove() { - if (fCount > 0) + if (fCount > 0) { _Resize(fCount - 1); + return true; + } + return false; } - inline void Remove(int32 index) + inline bool Remove(int32 index) { if (index < 0 || index >= (int32)fCount) - return; + return false; if (!PlainOldData) { ItemType* object = fItems + index; @@ -164,12 +167,12 @@ public: } fCount--; + return true; } - inline void Remove(const ItemType& item) + inline bool Remove(const ItemType& item) { - Remove(IndexOf(item)); - + return Remove(IndexOf(item)); } inline bool Replace(int32 index, const ItemType& copyFrom)