HaikuDepot: Fixed some inconsistencies in List.h
This commit is contained in:
@@ -120,10 +120,8 @@ public:
|
|||||||
|
|
||||||
inline bool Add(const ItemType& copyFrom, int32 index)
|
inline bool Add(const ItemType& copyFrom, int32 index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0 || index >= (int32)fCount)
|
||||||
index = 0;
|
return false;
|
||||||
if (index > (int32)fCount)
|
|
||||||
index = fCount;
|
|
||||||
|
|
||||||
if (!_Resize(fCount + 1))
|
if (!_Resize(fCount + 1))
|
||||||
return false;
|
return false;
|
||||||
@@ -190,7 +188,7 @@ public:
|
|||||||
|
|
||||||
inline const ItemType& ItemAt(int32 index) const
|
inline const ItemType& ItemAt(int32 index) const
|
||||||
{
|
{
|
||||||
if (index >= (int32)fCount)
|
if (index < 0 || index >= (int32)fCount)
|
||||||
return fNullItem;
|
return fNullItem;
|
||||||
return ItemAtFast(index);
|
return ItemAtFast(index);
|
||||||
}
|
}
|
||||||
@@ -202,6 +200,8 @@ public:
|
|||||||
|
|
||||||
inline const ItemType& LastItem() const
|
inline const ItemType& LastItem() const
|
||||||
{
|
{
|
||||||
|
if (fCount == 0)
|
||||||
|
return fNullItem;
|
||||||
return ItemAt((int32)fCount - 1);
|
return ItemAt((int32)fCount - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user