Added AddUninitialized(), appending the given number of uninitialized elements.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31628 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b5d6fc7173
commit
6de84d6d8d
@ -23,6 +23,7 @@ public:
|
||||
inline Element* Elements() const { return fElements; }
|
||||
|
||||
inline bool Add(const Element& element);
|
||||
inline bool AddUninitialized(int elementCount);
|
||||
inline bool Insert(const Element& element, int index);
|
||||
inline bool Remove(int index);
|
||||
|
||||
@ -92,6 +93,23 @@ Array<Element>::Add(const Element& element)
|
||||
}
|
||||
|
||||
|
||||
template<typename Element>
|
||||
bool
|
||||
Array<Element>::AddUninitialized(int elementCount)
|
||||
{
|
||||
if (elementCount < 0)
|
||||
return false;
|
||||
|
||||
if (fSize + elementCount > fCapacity) {
|
||||
if (!_Resize(fSize, elementCount))
|
||||
return false;
|
||||
}
|
||||
|
||||
fSize += elementCount;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<typename Element>
|
||||
bool
|
||||
Array<Element>::Insert(const Element& element, int index)
|
||||
|
Loading…
Reference in New Issue
Block a user