Inherits from
DVector
DArray is a classic vector of items. Arrays have very fast indexed
access to elements. Very fast addition to the end is possible if you
call the ensureCapacity method with the right number of elements before
adding. As additions are occurring, the DArray will adaptively resize
itself based on a blocking factor. DArrays will expand themselves by
30% or so each time they run out of capacity.
constructor create;
constructor createSize(size : Integer);
constructor createWith(compare : Dcomparator);
function at(pos : Integer) : DObject;
Return the item at the specified position.
function backRef : PDObject;
Returns a reference to the last item in the array.
function blockFactor : Integer;
Returns the current blocking factor.
function capacity : Integer;
Return the number of items the array is capable of holding without
expanding.
procedure copy(another : DArray);
Copy the contents of another array into this one.
procedure copyTo(another : DArray);
Copy the contents of this array into another one.
destructor destroy;
procedure ensureCapacity(amount : Integer);
Ensure that a certain number of items can be held without expanding
storage (which can be expensive).
function finish : DIterator;
Return an iterator positioned after the last item in the array.
function frontRef : PDObject;
Returns a reference to the first item in the array.
procedure insertRangeAt(index : Integer; _start, _finish : DIterator);
procedure insertRangeAtIter(iterator : DIterator; _start, _finish : DIterator);
function maxSize : Integer;
Return the maximum number of items that may be placed in the
array.
function popBack : DObject;
Removes and returns the last item in the array.
function popFront : DObject;
Removes and returns the first item in the array.
procedure removeAt(index : Integer);
function removeAtIter(iter : DIterator; count : Integer) : DIterator;
Removes the number of items specified in count, starting with the
given iterator.
procedure removeBetween(_begin, _end : Integer);
procedure setBlockFactor(factor : Integer);
Sets the current blocking factor.
procedure setCapacity(amount : Integer);
procedure setSize(newSize : Integer);
Directly set the number of items being held by this array.
function size : Integer;
Return the current number of items in the array.
function start : DIterator;
Return an iterator positioned on the first item in the array.
procedure trimToSize;
Minimize the storage required by this container.
procedure _add(const obj : DObject);
Add an object to the array.
procedure _insertAt(index : Integer; const obj : DObject);
procedure _insertAtIter(iterator : DIterator; const obj : DObject);
procedure _insertMultipleAt(index : Integer; count : Integer; const obj : DObject);
procedure _insertMultipleAtIter(iterator : DIterator; count : Integer; const obj : DObject);
procedure _pushBack(const obj : DObject);
procedure _pushFront(const obj : DObject);
procedure _putAt(index : Integer; const obj : DObject);
Put an object at a specific place.
procedure _remove(const obj : DObject);
procedure _removeWithin(_begin, _end : Integer; const obj : DObject);
constructor create;
constructor createSize(size : Integer);
constructor createWith(compare : Dcomparator);
function at(pos : Integer) : DObject;
Parameter | Description |
---|
pos | Position of the item to retrieve. |
Return the item at the specified position.
function backRef : PDObject;
Returns a reference to the last item in the array.
function blockFactor : Integer;
Returns the current blocking factor. When growing the array, the current array capacity is divided by
the block factor to determine how many new entries to add. Block factor
defaults to 4, so that capacity / 4 entries will be added each time the
array must be grown.
function capacity : Integer;
Return the number of items the array is capable of holding without
expanding.
procedure copy(another : DArray);
Copy the contents of another array into this one.
procedure copyTo(another : DArray);
Copy the contents of this array into another one.
destructor destroy;
procedure ensureCapacity(amount : Integer);
Ensure that a certain number of items can be held without expanding
storage (which can be expensive). It's a good idea to set this when
you're going to add a large number of items to a container.
function finish : DIterator;
Return an iterator positioned after the last item in the array.
function frontRef : PDObject;
Returns a reference to the first item in the array.
procedure insertRangeAt(index : Integer; _start, _finish : DIterator);
procedure insertRangeAtIter(iterator : DIterator; _start, _finish : DIterator);
function maxSize : Integer;
Return the maximum number of items that may be placed in the
array. This is a theoretical limit.
function popBack : DObject;
Removes and returns the last item in the array.
function popFront : DObject;
Removes and returns the first item in the array.
procedure removeAt(index : Integer);
function removeAtIter(iter : DIterator; count : Integer) : DIterator;
Removes the number of items specified in count, starting with the
given iterator.
procedure removeBetween(_begin, _end : Integer);
procedure setBlockFactor(factor : Integer);
Sets the current blocking factor. The current capacity will be divided
by this factor to determine the number of entries to add to the array, when
expansion is necessary. Block factor must be greater than zero.
procedure setCapacity(amount : Integer);
procedure setSize(newSize : Integer);
Directly set the number of items being held by this array. If the
size is smaller than the current size, the extra items will be cleared
and eliminated. If the size is larger, the newly created items will be
filled with an empty value.
function size : Integer;
Return the current number of items in the array.
function start : DIterator;
Return an iterator positioned on the first item in the array. If
there are no items in the array, the iterator is positioned atEnd.
procedure trimToSize;
Minimize the storage required by this container. The storage used
will shrink to the smallest possible amount.
procedure _add(const obj : DObject);
Parameter | Description |
---|
obj | The object to add.
|
Add an object to the array.
procedure _insertAt(index : Integer; const obj : DObject);
procedure _insertAtIter(iterator : DIterator; const obj : DObject);
procedure _insertMultipleAt(index : Integer; count : Integer; const obj : DObject);
procedure _insertMultipleAtIter(iterator : DIterator; count : Integer; const obj : DObject);
procedure _pushBack(const obj : DObject);
procedure _pushFront(const obj : DObject);
procedure _putAt(index : Integer; const obj : DObject);
Parameter | Description |
---|
index | Position to place the object. What happens when we have a
really long comment? What does it decide to do? We are curious
about the result of a long description.
|
obj | The object to put there. |
Put an object at a specific place.
procedure _remove(const obj : DObject);
procedure _removeWithin(_begin, _end : Integer; const obj : DObject);