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:
Ingo Weinhold 2009-07-18 23:03:01 +00:00
parent b5d6fc7173
commit 6de84d6d8d
1 changed files with 18 additions and 0 deletions

View File

@ -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)