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:
@@ -23,6 +23,7 @@ public:
|
|||||||
inline Element* Elements() const { return fElements; }
|
inline Element* Elements() const { return fElements; }
|
||||||
|
|
||||||
inline bool Add(const Element& element);
|
inline bool Add(const Element& element);
|
||||||
|
inline bool AddUninitialized(int elementCount);
|
||||||
inline bool Insert(const Element& element, int index);
|
inline bool Insert(const Element& element, int index);
|
||||||
inline bool Remove(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>
|
template<typename Element>
|
||||||
bool
|
bool
|
||||||
Array<Element>::Insert(const Element& element, int index)
|
Array<Element>::Insert(const Element& element, int index)
|
||||||
|
|||||||
Reference in New Issue
Block a user