Class DArray (unit SDL)

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.

Constructors


constructor create; override;

Creates this container using the default comparator (DObjectComparator).

constructor createSize(size : Integer);


constructor createWith(compare : Dcomparator); override;

Creates this container using the specified comparator for ordering elements.


Functions

function at(pos : Integer) : DObject; override;

Return the item at the specified position.

function backRef : PDObject; override;

Returns a reference to the last item in the array.

function blockFactor : Integer;

Returns the current blocking factor.

function capacity : Integer; override;

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; override;


procedure ensureCapacity(amount : Integer); override;

Ensure that a certain number of items can be held without expanding storage (which can be expensive).

function finish : DIterator; override;

Return an iterator positioned after the last item in the array.

function frontRef : PDObject; override;

Returns a reference to the first item in the array.

procedure insertRangeAt(index : Integer; _start, _finish : DIterator); override;

Inserts copies of the objects in a given range before the object at position index.

procedure insertRangeAtIter(iterator : DIterator; _start, _finish : DIterator); override;

Inserts copies of the objects in a given range before the object the iterator is over.

function maxSize : Integer; override;

Return the maximum number of items that may be placed in the array.

function popBack : DObject; override;

Removes and returns the last item in the array.

function popFront : DObject; override;

Removes and returns the first item in the array.

procedure removeAt(index : Integer); override;

Remove the object at the given index.

function removeAtIter(iter : DIterator; count : Integer) : DIterator; override;

Removes the number of items specified in count, starting with the given iterator.

procedure removeBetween(_begin, _end : Integer); override;

Remove all objects between two indicies.

procedure setBlockFactor(factor : Integer);

Sets the current blocking factor.

procedure setCapacity(amount : Integer); override;

Ensure that this vector can accomodate at least amount objects without expanding.

procedure setSize(newSize : Integer); virtual;

Directly set the number of items being held by this array.

function size : Integer; override;

Return the current number of items in the array.

function start : DIterator; override;

Return an iterator positioned on the first item in the array.

procedure trimToSize; override;

Minimize the storage required by this container.

procedure _add(const obj : DObject); override;

Add an object to the array.

procedure _insertAt(index : Integer; const obj : DObject); override;

Inserts an object before the object at position index.

procedure _insertAtIter(iterator : DIterator; const obj : DObject); override;

Inserts count copies of obj before the object iterator is positioned at.

procedure _insertMultipleAt(index : Integer; count : Integer; const obj : DObject); override;

Inserts count copies of obj before the object at position index.

procedure _insertMultipleAtIter(iterator : DIterator; count : Integer; const obj : DObject); override;

Inserts count copies of obj before the object iterator is positioned at.

procedure _pushBack(const obj : DObject); override;

Push an object to the back of the sequence.

procedure _pushFront(const obj : DObject); override;

Push an object to the front of the container.

procedure _putAt(index : Integer; const obj : DObject); override;

Put an object at a specific place.

procedure _remove(const obj : DObject); override;

Removes an object, by value, from this sequence.

procedure _removeWithin(_begin, _end : Integer; const obj : DObject); override;

Remove every occurrence of object between two indicies.

Properties

Events

Variables


Constructors


constructor create; override;

Creates this container using the default comparator (DObjectComparator).


constructor createSize(size : Integer);


constructor createWith(compare : Dcomparator); override;

Creates this container using the specified comparator for ordering elements.


Functions


function at(pos : Integer) : DObject; override;

ParameterDescription
posPosition of the item to retrieve.

Return the item at the specified position.


function backRef : PDObject; override;

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; override;

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; override;


procedure ensureCapacity(amount : Integer); override;

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; override;

Return an iterator positioned after the last item in the array.


function frontRef : PDObject; override;

Returns a reference to the first item in the array.


procedure insertRangeAt(index : Integer; _start, _finish : DIterator); override;

Inserts copies of the objects in a given range before the object at position index.


procedure insertRangeAtIter(iterator : DIterator; _start, _finish : DIterator); override;

Inserts copies of the objects in a given range before the object the iterator is over.


function maxSize : Integer; override;

Return the maximum number of items that may be placed in the array. This is a theoretical limit.


function popBack : DObject; override;

Removes and returns the last item in the array.


function popFront : DObject; override;

Removes and returns the first item in the array.


procedure removeAt(index : Integer); override;

Remove the object at the given index.


function removeAtIter(iter : DIterator; count : Integer) : DIterator; override;

Removes the number of items specified in count, starting with the given iterator.


procedure removeBetween(_begin, _end : Integer); override;

Remove all objects between two indicies.


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); override;

Ensure that this vector can accomodate at least amount objects without expanding.


procedure setSize(newSize : Integer); virtual;

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; override;

Return the current number of items in the array.


function start : DIterator; override;

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; override;

Minimize the storage required by this container. The storage used will shrink to the smallest possible amount.


procedure _add(const obj : DObject); override;

ParameterDescription
objThe object to add.

Add an object to the array.


procedure _insertAt(index : Integer; const obj : DObject); override;

Inserts an object before the object at position index. If the iterator is atEnd, the object will be added at the end.


procedure _insertAtIter(iterator : DIterator; const obj : DObject); override;

Inserts count copies of obj before the object iterator is positioned at.


procedure _insertMultipleAt(index : Integer; count : Integer; const obj : DObject); override;

Inserts count copies of obj before the object at position index.


procedure _insertMultipleAtIter(iterator : DIterator; count : Integer; const obj : DObject); override;

Inserts count copies of obj before the object iterator is positioned at.


procedure _pushBack(const obj : DObject); override;

Push an object to the back of the sequence. The object will be copied.


procedure _pushFront(const obj : DObject); override;

Push an object to the front of the container.


procedure _putAt(index : Integer; const obj : DObject); override;

ParameterDescription
indexPosition 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.
objThe object to put there.

Put an object at a specific place.


procedure _remove(const obj : DObject); override;

Removes an object, by value, from this sequence.


procedure _removeWithin(_begin, _end : Integer; const obj : DObject); override;

Remove every occurrence of object between two indicies.


Properties


Events


Variables