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.
This commit is contained in:
Stephan Aßmus 2014-01-27 22:01:51 +01:00
parent b42302c5d3
commit 4bbad05e9d

View File

@ -141,16 +141,19 @@ public:
return true; return true;
} }
inline void Remove() inline bool Remove()
{ {
if (fCount > 0) if (fCount > 0) {
_Resize(fCount - 1); _Resize(fCount - 1);
return true;
}
return false;
} }
inline void Remove(int32 index) inline bool Remove(int32 index)
{ {
if (index < 0 || index >= (int32)fCount) if (index < 0 || index >= (int32)fCount)
return; return false;
if (!PlainOldData) { if (!PlainOldData) {
ItemType* object = fItems + index; ItemType* object = fItems + index;
@ -164,12 +167,12 @@ public:
} }
fCount--; 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) inline bool Replace(int32 index, const ItemType& copyFrom)