Class DList (unit SDL)

Inherits from

DSequence

Double linked list. The classic data structure -- fast insertion, fast deletion, slow searching.

Constructors


constructor Create;

Construct a new DList.

constructor CreateWith(compare : DComparator);

Construct a new DList, that uses the specified comparator for operations that require comparators.


Functions

function backRef : PDObject;

Returns a pointer to the last object in the list.

procedure cut(_start, _finish : DIterator);

Removes all objects between two iterators.

destructor Destroy;


function finish : DIterator;

Returns an iterator positioned at the end of this list.

function frontRef : PDObject;

Returns a pointer to the first object in the list.

procedure insertAtIter(iterator : DIterator; objs : array of const);

Insert objects at the given iterator.

function maxSize : Integer;

Returns the maximum number of elements that can be placed in the list.

procedure mergeSort;

Sort this DList, very efficiently.

procedure mergeSortWith(compare : DComparator);

Sort this DList, using the specified comparator.

function popBack : DObject;

Returns the last object in this list, and removes it from the list.

function popFront : DObject;

Returns the first object in this list, and removes it from the list.

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

Removes count objects beginning at the given iterator.

function Size : Integer;

Returns the number of items in this list.

function start : DIterator;

Returns an iterator positioned at the beginning of this list, on the first item.

procedure _add(const obj : DObject);

Override of DContainer's _add; usually called internally.

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

Insert an object at the given iterator.

procedure _pushBack(const obj : DObject);

Adds an object to the end of the list.

procedure _pushFront(const obj : DObject);

Adds an object to the front of the list.

procedure _remove(const obj : DObject);


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

Removes all objects in the list between the two integer positions for that are equal to obj.

Properties

Events

Variables


Constructors


constructor Create;

Construct a new DList.


constructor CreateWith(compare : DComparator);

Construct a new DList, that uses the specified comparator for operations that require comparators.


Functions


function backRef : PDObject;

Returns a pointer to the last object in the list. Does not copy the object. The pointer can be derefences to examine its value.


procedure cut(_start, _finish : DIterator);

Removes all objects between two iterators. Does not remove under the _finish iterator (removes all objects up to but NOT including the _finish object.


destructor Destroy;


function finish : DIterator;

Returns an iterator positioned at the end of this list. Inserting at the iterator will add to the list.


function frontRef : PDObject;

Returns a pointer to the first object in the list. Does not copy the object. The pointer can be derefences to examine its value.


procedure insertAtIter(iterator : DIterator; objs : array of const);

Insert objects at the given iterator. The item the iterator is currently positioned at is pushed back. If an atEnd iterator is passed as the location, the object is added to the end (back) of the list.


function maxSize : Integer;

Returns the maximum number of elements that can be placed in the list.


procedure mergeSort;

Sort this DList, very efficiently.


procedure mergeSortWith(compare : DComparator);

Sort this DList, using the specified comparator.


function popBack : DObject;

Returns the last object in this list, and removes it from the list. Note that this is returning a DObject, and as such, the value returned must be cleared with ClearDObject if it is not stored in an appropriate place.


function popFront : DObject;

Returns the first object in this list, and removes it from the list. Note that this is returning a DObject, and as such, the value returned must be cleared with ClearDObject if it is not stored in an appropriate place.


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

Removes count objects beginning at the given iterator.


function Size : Integer;

Returns the number of items in this list.


function start : DIterator;

Returns an iterator positioned at the beginning of this list, on the first item. If the iterator has no items in it, it returns an iterator with atEnd being true.


procedure _add(const obj : DObject);

Override of DContainer's _add; usually called internally. Adds the specified DObject to the list. Copies the DObject.


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

Insert an object at the given iterator. The item the iterator is currently positioned at is pushed back. If an atEnd iterator is passed as the location, the object is added to the end (back) of the list.


procedure _pushBack(const obj : DObject);

Adds an object to the end of the list. Copies the object given.


procedure _pushFront(const obj : DObject);

Adds an object to the front of the list. Copies the object given.


procedure _remove(const obj : DObject);


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

Removes all objects in the list between the two integer positions for that are equal to obj.


Properties


Events


Variables