Copyright (c) 1998 Ross Judson
All rights reserved. Unauthorized duplication or use prohibited.
You may not create derived works from this material.
For licensing information, contact that author at the address or email
address listed below.
Standard Delphi Library 1.0
Author: Ross Judson
2103 Patty Lane
Vienna, VA, 22182
USA
rossj@soletta.com
Stepanov's Standard Template Library for C++ demonstrated the power of
generic programming. I purchased ObjectSpace's implementation of STL and,
after climbing the learning curve, came to appreciate the leverage it
gave me when tackling tough problems.
Java lacked the same capabilities until ObjectSpace released JGL, the
Java Generic Library, which is modelled on STL. The hierarchies and
methods that Stepanov designed were extended into Java, with the
peculiarities and powers of that language well taken into account. No
serious Java developer should be without JGL, and no serious C++ developer
should be without STL.
Delphi programmers have lacked similar generic algorithms and containers.
The container classes provided with Delphi are, at best, primitive. They
are, though, easy to use, which is their saving grace. Serious Delphi
applications usually try to bend the existing data structures to their
needs, with varying degrees of success.
There also exist one or two simple data structures libraries. One of these,
Julian Bucknall's EZStruct, implements a number of useful structures. I have
used EZStruct very successfully in the past, but had difficulty with its
inability to store atomic types and use generic algorithms.
What previous solutions were lacking was the strong theoretical foundation
that the STL model provides for generic programming, and the large number
of generic algorithms that come along with it.
SDL brings this power to Delphi developers. I hope you enjoy using it, and
I hope that it saves you time and effort.
Learn the algorithms, and what they do! The secret to effectively using
STL, JGL, and SDL is developing an implementation vocabulary that
frequently makes use of the generic algorithms.
SDL is packaged into a single unit to make it easy to include in your
programs. Some of the names are rather common -- just use sdl.xxxxxx to
call a function if there's a conflict.
By definining the compilation symbol GC, you can enable a garbage-collected
build of SDL. All SDL internal objects will be allocated as collectable
objects. This option makes use of the Boehm collector, and an interface
unit by vladimir A. Merzlaikov.
I wish to express my appreciation to the following authors, whose work has
helped me own.
Martin Waldenburg
Julian Bucknall
Vladimir Merzlaikov
Kurt Westerfeld
DAdapter - A container adapter is used to give a container a certain kind of
interface.
DAdapterClass -
DArray - DArray is a classic vector of items.
DAssociative -
DAssociativeClass -
DBinaryFunction -
DContainer - DContainer is the base class of all containers.
DContainerClass -
DHashMap -
DHashSet -
DInternalHash -
DInternalMap - Internal class.
DIterAdapter - DIterAdapter is an abstract base class for other classes that can
modify the iterator manipulation behavior of a container.
DIterFilter -
DIterHandler -
This class is defined separately so that we can create special types
of iterators that aren't actually containers.
DIterSkipper -
DList - Double linked list.
DListNode - Node element for DList class.
DMap - Maps associate a key with a value.
DMultiHashMap -
DMultiHashSet -
DMultiMap - Multi maps permit a key to appear more than once.
DMultiSet -
DQueue -
DRedBlackTree - Internal class.
DSequence - DSequence is an abstract base class for containers that hold their
items in a defined order.
DSequenceClass -
DSet -
DStack -
DTList -
DTreeNode - RBTrees are collections of nodes.
DTStrings -
DUnaryFunction -
DVector - DVector is an abstract base class for containers that hold their items
in an integer-addressable sequence.
SDLEmpty - Exception upon acting on an empty container.
SDLException - SDLException is the base of all exceptions thrown by SDL.
SDLNeedBidirectional - Exception, upon needing a bidirectional iterator.
SDLNeedRandom - Exception upon needing a random access iterator.
SDLNotImplemented - An exception indicating that the function has not yet been implemented.
adjacentFind - Locates the first pair of consecutive equal items in the container.
adjacentFindIn - Locates the first pair of consecutive equal items in the range.
adjacentFindInWith - Locates the first pair of consecutive equal items in the range, using the compare specified.
adjacentFindWith - Locates the first pair of consecutive equal items in the container, using the compare specified.
advance - Moves the iterator to the next object in the container.
advanceBy - Moves the iterator forward by count objects.
advanceByF - Returns a new iterator at the next position in the container.
advanceF - Returns a new iterator at the next position in the container.
ApplyPrint - A simple printing function -- each obj is printed to the console.
ApplyPrintLN -
asBoolean - Converts the DObject to a Boolean.
asChar - Converts the DObject to a Char.
asClass - Converts the DObject to a class reference (TClass).
asCurrency - Converts the DObject to a currency value.
asExtended - Converts the DObject to an extended floating point value.
asInteger - Converts the DObject to an integer.
asInterface - Converts the DObject to an interface pointer.
asObject - Converts the DObject to an object reference.
asPChar - Converts the DObject to a PChar.
asPointer - Converts the DObject to an untyped pointer.
asPWideChar - Converts the DObject to a pointer to a WideChar.
asShortString - Converts the DObject to a short string.
asString - Converts the DObject to a String (AnsiString).
asVariant - Converts the DObject to a variant.
asWideChar - Converts the DObject to a WideChar.
asWideString - Converts the DObject to a WideString.
atEnd - Tests to see if the iterator is at the end of the container.
atStart - Tests to see if the iterator is at the start of the container.
binarySearch - Locates an object in a sorted container using a binary search.
binarySearchIn - Locates an object in a sorted range using a binary search.
binarySearchInWith - Locates an object in a sorted range using a binary search and a specified comparator.
binarySearchWith - Locates an object in a sorted container using a binary search and a specified comparator.
ClearDObject - Clears an existing DObject, freeing memory if need be.
collect - Collect applies the unary function to each object in the container,
storing the results in a new container (that is constructed by the function)
that is of the same type as the existing one.
collectIn - CollectIn applies the unary function to each object in the given range,
storing the results in a new container (that is constructed by this function)
that is of the same type as the starting iterator's associated container.
copyBackward - Copies a reversed range of values to the given iterator.
copyContainer - Copies the contents of source to dest.
CopyDObject - Creates a copy of the DObject.
copyInTo - Copies a range of values to the given iterator.
copyTo - Copies the contents of con1 to the given iterator.
count - Counts the number of times items matching objs exist in the container.
countIf - Counts the number of times the test returns true.
countIfIn - Counts the number of times the test returns true.
countIn - Counts the number of times items matching objs exist in the given range.
detectInWith - Determines the first item in the range for which the compare returns true.
detectWith - Determines the first item for which compare returns true.
distance - Determines the number of positions between iter1 and iter2.
equal - Tests to see if two containers are equal, testing each object with
their comparators.
equalIn - Tests to see if two ranges contain equal objects, according to the
comparators associated with the containers associated with the iterators.
equals - Determines if two iterators are equal -- that is, they are pointing at
the same container and at the same object.
every - Determines if the test returns true for every element in the container.
everyIn - Determines if the test returns true for every element in the range.
fill - Fill the container with a given value.
fillIn - Fill the range with a value.
fillN - Fill a container with values, expanding if necessary.
Filter - Copy values for which test returns true to the destination.
FilterInTo - Copy values for which test returns true to the destination.
FilterTo - Copy values for which test returns true to the destination.
find - Locates an item in a container.
findIf - Find the first item in a container for which test returns true.
findIfIn - Find the first item in a range for which test returns true.
findIn - Locates an item in a range.
forEach - Apply the unary function to each object in the container.
forEachIf - Apply a unary function to each object in a container if it
passes a test.
forEachIn - Apply the unary function to a range of objects.
forEachInIf - Apply a unary function to a range of objects if the object passes
a test.
FreeAll -
generate - Fill a container using a generator.
generateIn - Fills a range using a generator.
generateTo - Outputs count objects from a generator to the destination iterator,
which is called by output.
get - Retrieve the object an iterator is positioned at.
getAt - Return the object at the given offset from the iterator.
getBoolean - Retrieve the object at the iterator as a boolean.
getChar - Retrieve the object at the iterator as a character.
getClass - Retrieve the object at the iterator as a class reference (TClass).
getContainer - Retrieves the container associated with an iterator.
getCurrency - Retrieve the object at the iterator as a currency value.
getExtended - Retrieve the object at the iterator as an extended floating point value.
getInteger - Retrieve the object at the iterator as an integer.
getInterface - Retrieve the object at the iterator as an interface pointer.
getObject - Retrieve the object at the iterator as an object reference.
getPChar - Retrieve the object at the iterator as a PChar.
getPointer - Retrieve the object at the iterator as an untyped pointer.
getPWideChar - Retrieve the object at the iterator as a pointer to a wide character.
getRef - Retrieve a pointer to the object the iterator is positioned at.
getShortString - Retrieve the object at the iterator as a short string (old style string).
getString - Retrieve the object at the iterator as a String (AnsiString).
getVariant - Retrieve the object at the iterator as a variant.
getWideChar - Retrieve the object at the iterator as a wide character.
getWideString - Retrieve the object at the iterator as a WideString.
hashCode -
includes - Determine if master contains all the items in subset.
includesIn - Determine if the master range contains all the items in subset range.
includesInWith - Determines if master range contains all the items in subset range, comparing
items with the supplied comparator.
includesWith - Determines if master contains all the items in subset, comparing
items with the supplied comparator.
index - Determine the index (position within the container) for the given iterator.
InitDObject - Make sure a DObject is empty.
inject - Call binary with obj as the first parameter and the first item in the
container as the next parameter.
injectIn - Call binary with obj as the first parameter and the items in the range
as the second parameter.
IterateOver - IterateOver initiates and moves an iterator from its position until the end.
iterSwap - Swaps the items the two iterators are positioned at.
JenkinsHashBuffer -
JenkinsHashDouble -
JenkinsHashInteger -
JenkinsHashSingle -
JenkinsHashString -
less - Determine if iter1 comes before iter2.
lexicographicalCompare - LexicographicalCompare compares two sequences by comparing their items,
in order, one by one.
lexicographicalCompareIn - Lexicographically compare (item by item compare) within the specified
range.
lexicographicalCompareInWith - Lexicographically compare (item by item compare) within the specified
range, using the specified comparator.
lexicographicalCompareWith - Lexicographically compare (item by item compare) using a supplied
comparator.
make - Create a DObject from an atomic type.
MakeApply - Turn a procedure into a closure, suitable for use as a DApply.
MakeApplyEx - Turn a procedure into a closure, suitable for use as a DApply.
MakeBinary - Turn a procedure into a closure, suitable for use as a DBinary.
MakeBinaryEx - Turn a procedure into a closure, suitable for use as a DBinary.
MakeComparator - Turn a procedure into a closure, suitable for use as a comparator.
MakeComparatorEx - Turn a procedure into a closure, suitable for use as a comparator.
MakeEquals - Turn a procedure into a closure, suitable for use as a DEquals.
MakeEqualsEx - Turn a procedure into a closure, suitable for use as a DEquals.
MakeGenerator - Turn a procedure into a closure, suitable for use as a DGenerator.
MakeGeneratorEx - Turn a procedure into a closure, suitable for use as a DGenerator.
MakeHash - Turn a procedure into a closure, suitable for use as a DHash.
MakeHashEx - Turn a procedure into a closure, suitable for use as a DHash.
MakePair -
MakeRange -
MakeTest - Turn a procedure into a closure, suitable for use as a DTest.
MakeTestEx - Turn a procedure into a closure, suitable for use as a DTest.
MakeUnary - Turn a procedure into a closure, suitable for use as a DUnary.
MakeUnaryEx - Turn a procedure into a closure, suitable for use as a DUnary.
median -
mismatch - Determines the point at which con1 and con2 begin to differ.
mismatchIn - Tests two ranges to determine at which point they begin to
differ.
mismatchInWith - Determines the point at which the two ranges differ, using bt
as a test.
mismatchWith - Determines the point at which con1 and con2 differ, using bt as
a binary test.
MoveDObject - Moves a DObject; the original is left empty.
nextPermutation - Not implemented.
nextPermutationIn - Not implemented.
objDispose - Calls FreeMem on all the items in the container.
objDisposeIn - Calls FreeMem on all the items in the range.
objFree - Calls TObject.
objFreeIn - Calls TObject.
objFreeKeys - Calls TObject.
orderedHash - Hashes all the items in the container.
orderedHashIn - Hashes all the items in the range.
output -
prevPermutation - Not implemented.
prevPermutationIn - Not implemented.
PrintString - Convert a DObject into a printable string representation.
put - Stores an array of objects at the current iterator location, if possible.
putAt - Put an object at the given offset from the iterator.
putBoolean - Store a boolean at the current iterator location.
putChar - Store a character at the current iterator location.
putClass - Store a class reference at the current iterator location.
putCurrency - Store a currency value at the current iterator location.
putExtended - Store an extended floating point value at the current iterator location.
putInteger - Store an integer at the current iterator location.
putInterface - Store an interface pointer at the current iterator location.
putObject - Store an object reference at the current iterator location.
putPChar - Store a PChar at the current iterator location.
putPointer - Store an untyped pointer at the current iterator location.
putPWideChar - Store a pointer to a wide character at the current iterator location.
putRef - Store an object directly to a location.
putShortString - Store a short string at the current iterator location.
putString - Store a string (AnsiString) at the current iterator location.
putVariant - Store a variant at the current iterator location.
putWideChar - Store a wide character at the current iterator location.
putWideString - Store a wide string at the current iterator location.
randomShuffle - Shuffles the items in the container, just like shuffling a deck
of cards.
randomShuffleIn - Shuffles the items in the range, just like shuffling a deck
of cards.
RegisterSDLPrinter - Register printable string converters for your own classes.
remove - Removes all instances of each item in objs from the container.
removeCopy - Copies the source container to the destination, except for the items
matching objs.
removeCopyIf - Copies the source container to the destination, except for those items
for which test returns true.
removeCopyIfIn - Copies the source range to the destination, except for those items
for which test returns true.
removeCopyIfTo - Copies the source container to the destination, except for those items
for which test returns true.
removeCopyIn - Copies the source range to the destination, except for the items
matching objs.
removeCopyTo - Copies the source container to a destination iterator, except for the items
matching objs.
removeIf - Removes items from the container for which test returns true.
removeIfIn - Removes items from the range for which test returns true.
removeIfInTo - Removes items from the range, where that item returns true from test.
removeIfTo - Removes items from the container, where that item returns true from test.
removeIn - Removes all instances of each item in objs in the range.
removeInTo - Removes all instances of each item in objs from the range, copying
the removed items to dest.
removeTo - Removes all instances of each item in objs from the container, copying
the removed items to dest.
replace - For each pair of items objs1[N] and objs2[N], replace all instances of
objs1[N] with objs2[N] in the given container.
replaceCopy - For each pair of items objs1[N] and objs2[N], copies each item in con1 to con2,
except if the item equals objs1[N], where objs2[N] is copied.
replaceCopyIf - Copies the items in con1 to con2, except for those items in con1 who
return true from the test.
replaceCopyIfInTo - Copies the items in the range to the destination, except for those items in con1 who
return true from the test.
replaceCopyIfTo - Copies the items in con1 to the destination, except for those items in con1 who
return true from the test.
replaceCopyInTo - For each pair of items objs1[N] and objs2[N], copies each item in the range to the destination,
except if the item equals objs1[N], where objs2[N] is copied.
replaceCopyTo - For each pair of items objs1[N] and objs2[N], copies each item in con1 to the destination,
except if the item equals objs1[N], where objs2[N] is copied.
replaceIf - For each objs[N], replace all items in the container for which test returns
true with objs[N].
replaceIfIn - For each objs[N], replace all items in the range for which test returns
true with objs[N].
replaceIn - For each pair of items objs1[N] and objs2[N], replace all instances of
objs1[N] with objs2[N] in the given range.
retreat - Move an iterator backwards one position.
retreatBy - Move an iterator backwards by count positions.
retreatByF - Move an iterator backwards by count positions.
retreatF - Move an iterator backwards one position.
reverse - Reverse the order of the items in the container.
reverseCopy - Copy the items in con1 to con2, in reverse order.
reverseCopyInTo - Copy the items in the range to the output iterator, in reverse
order.
reverseCopyTo - Copy the items in container to the output iterator, in reverse
order.
reverseIn - Reverse the order of the items in the range.
rotate - Rotate the items between the iterators such that the item at the
first iterator moves to the middle iterator.
rotateCopy - Rotate the items between the iterators such that the item at the
first iterator moves to the middle iterator.
setBoolean - Set a boolean to a DObject.
setChar - Set a character to a DObject.
setClass - Set a class reference to a DObject.
setCurrency - Set a currency value to a DObject.
setDifference - Finds the set of items that are in con1 but not in con2, and writes
that set to the destination iterator.
setDifferenceIn - Finds the set of items that are in range 1 but not in range 2, and writes
that set to the destination iterator.
setDifferenceInWith - Finds the set of items that are in range 1 but not in range 2, using comparator to test them, and writes
that set to the destination iterator.
setDifferenceWith - Finds the set of items that are in con1 but not in con2, using comparator to compare items, and writes
that set to the destination iterator.
SetDObject - Sets an arbitrary value to a DObject.
setExtended - Set an extended floating point value to a DObject.
setInteger - Set an integer to a DObject.
setInterface - Set an interface pointer to a DObject.
setIntersection - Finds the set of items that are in both con1 and con2, and writes
that set to the destination iterator.
setIntersectionIn - Finds the set of items that are in both range 1 and in range 2, and writes
that set to the destination iterator.
setIntersectionInWith - Finds the set of items that are in both range 1 and range 2, using comparator to test them, and writes
that set to the destination iterator.
setIntersectionWith - Finds the set of items that are in both con1 and con2, using comparator to compare items, and writes
that set to the destination iterator.
setObject - Set an object reference to a DObject.
setPChar - Set a PChar to a DObject.
setPointer - Set an untyped pointer to a DObject.
setPWideChar - Set a pointer to a wide character to a DObject.
setShortString - Set a short string to a DObject.
setString - Set a string (AnsiString) to a DObject.
setSymmetricDifference - Finds the set of items that are NOT in both sets.
setSymmetricDifferenceIn - Finds the set of items that are NOT in both sets.
setSymmetricDifferenceInWith - Finds the set of items that are NOT in both sets, using the specified comparator.
setSymmetricDifferenceWith - Finds the set of items that are NOT in both sets, using the specified comparator.
SetToKey - Toggle the iterator to retrieve keys.
SetToValue - Toggle the iterator to retrieve values.
setUnion - Finds the set of items that are in both con1 and con2.
setUnionIn - Finds the set of items that are in both range 1 and range 2.
setUnionInWith - Finds the set of items that are in both range 1 and range 2, using the specified comparator.
setUnionWith - Finds the set of items that are in both con1 and con2, using the specified comparator.
setVariant - Set a variant to a DObject.
setWideChar - Set a wide character to a DObject.
setWideString - Set a wide string to a DObject.
some - Determines if any of the items in the container return true, when passed
to test.
someIn - Determines if any of the items in the range cause test to return true.
sort - Sorts the items in the sequence with QuickSort.
sortIn - Sorts the items in the range with QuickSort.
sortInWith - Sorts the items in the range with QuickSort, using the specified
comparator to control sorting.
sortWith - Sorts the items in the sequence with QuickSort, using the specified
comparator to control sorting.
stablesort - Sorts the items in the sequence with MergeSort.
stablesortIn - Sorts the items in the range with MergeSort.
stablesortInWith - Sorts the items in the range with MergeSort, using the specified
comparator to control sorting.
stablesortWith - Sorts the items in the sequence with MergeSort, using the specified
comparator to control sorting.
Swap - Swap two dobjects.
swapRanges - Swaps the items in the two containers.
swaprangesInTo - Swaps the items in two ranges.
toBoolean - Retrieves at an index as a Boolean.
toChar - Retrieves at an index as a Char.
toClass - Retrieves at an index as a class reference (TClass).
toCurrency - Retrieves at an index as a currency value.
toExtended - Retrieves at an index as an extended floating point value.
toInteger - Retrieves at an index as an integer.
toInterface - Retrieves at an index as an interface pointer.
toObject - Retrieves at an index as an object reference.
toPChar - Retrieves at an index as a PChar.
toPointer - Retrieves at an index as an untyped pointer.
toPWideChar - Retrieves at an index as a pointer to a WideChar.
toShortString - Retrieves at an index as a short string.
toString - Retrieves at an index as a String (AnsiString).
toVariant - Retrieves at an index as a variant.
toWideChar - Retrieves at an index as a WideChar.
toWideString - Retrieves at an index as a WideString.
transformBinary - TransformBinary applies a binary function to pairs of objects from
con1 and con2, and stores the result into the output container.
transformBinaryInTo - TransformBinaryInTo applies a binary function to pairs of objects.
transformBinaryTo - TransformBinaryTo applies a binary function to pairs of objects from
con1 and con2, and stores the result at the output iterator.
transformUnary - TransformUnary applies a function to each object in a container, storing
the results in an output container.
transformunaryInTo - TransformUnaryInTo applies a unary function to each object in a range,
storing the results at another iterator.
transformUnaryTo - TransformUnary applies a function to each object in a container, storing
the results at an output iterator.
unique - Removes duplicate values from a container, replacing them with a
single instance.
uniqueIn - Removes duplicate values from the range, replacing them with a
single instance.
uniqueInTo - Copies a range to a destination, removing duplicates.
uniqueInWith - Removes duplicate values in a range, as defined by comparator returning true.
uniqueInWithTo - Copy all values to a destination, removing duplicates.
uniqueTo - Copies a container to a destination, removing duplicates.
uniqueWith - Removes duplicate values, as defined by the given comparator return true.
unorderedHash - Hashes all the items in the container.
unorderedHashIn - Hashes all the items in the range.
_binarySearch -
_binarySearchIn -
_binarySearchInWith -
_binarySearchWith -
_count - Counts the number of times items matching the given obj appear in the
container.
_countIn - Counts the number of times items matching the given obj appear in a given
range.
_fill - Fill the given container with the specified value.
_fillIn - Fill the specified range with a value.
_fillN - Fill a container with N copies of a value.
_find - Locates the given object in the container, returning an iterator positioned
at it.
_findIn - Locate the object in the given range, returning an iterator positioned
at it.
_inject - Call binary with obj as the first parameter and the first item in the
container as the next parameter.
_injectIn - Call binary with obj as the first parameter and the items in the range
as the second parameter.
_median - Finds the median of three objects using the given comparator.
_output - Stores an object at the current iterator location, if possible.
_outputRef -
_put - Stores an object at the current iterator location, if possible.
_putAt - Use the array of const form to store atomic values at the given offset from
iter.
_remove -
_removeCopy -
_removeCopyIn -
_removeCopyTo -
_removeIn -
_removeInTo -
_removeTo -
_replace -
_replaceCopy -
_replaceCopyIf -
_replaceCopyIfInTo -
_replaceCopyIfTo -
_replaceCopyInTo -
_replaceCopyTo -
_replaceIf -
_replaceIfIn -
_replaceIn -
_SetDObject - Sets an arbitrary dobject to another, clearing the destination's value
first.
DApply
DApplyProc
DBinary
DBinaryProc
DBinaryTest
DBinaryTestProc
DComparator
DComparatorProc
DEquals
DEqualsProc
DGenerator
DGeneratorProc
DHash
DHashProc
DIterator
DIteratorFlag
DIteratorFlags
DIteratorPair
DIteratorStucture
DObject
DObjectArray
DPair
DPrinterProc
DRange
DTest
DTestProc
DTreeNodeColor
DUnary
DUnaryProc
PDIterator
PDObject
PDObjectArray
SDLBaseClass
DefaultArraySize
DefaultBucketCount
function adjacentFind(container : DContainer) : DIterator;
Locates the first pair of consecutive equal items in the container.
Returns an iterator posisitioned on the first item. Returns atEnd if
no such pair is found.
function adjacentFindIn(_start, _end : DIterator) : DIterator;
Locates the first pair of consecutive equal items in the range.
Returns an iterator posisitioned on the first item. Returns _end if
no such pair is found.
function adjacentFindInWith(_start, _end : DIterator; compare : DBinaryTest) : DIterator;
Locates the first pair of consecutive equal items in the range, using the compare specified.
Returns an iterator posisitioned on the first item. Returns _end if
no such pair is found.
function adjacentFindWith(container : DContainer; compare : DBinaryTest) : DIterator;
Locates the first pair of consecutive equal items in the container, using the compare specified.
Returns an iterator posisitioned on the first item. Returns atEnd if
no such pair is found.
procedure advance(var iterator : DIterator);
Parameter | Description |
---|
iterator | The iterator to advance. |
Moves the iterator to the next object in the container.
procedure advanceBy(var iterator : DIterator; count : Integer);
Parameter | Description |
---|
iterator | The iterator to advance.
|
count | The number of positions to advance. |
Moves the iterator forward by count objects.
function advanceByF(const iterator : DIterator; count : Integer) : DIterator;
Returns a new iterator at the next position in the container. This is
a functional version of advanceBy, returning a new iterator.
function advanceF(const iterator : DIterator) : DIterator;
Returns a new iterator at the next position in the container.
procedure ApplyPrint(ptr : Pointer; const obj : DObject);
A simple printing function -- each obj is printed to the console. Nice
for debugging container contents. Suitable for passing to ForEach.
procedure ApplyPrintLN(ptr : Pointer; const obj : DObject);
function asBoolean(const obj : DObject) : Boolean;
Converts the DObject to a Boolean. Asserts if the type is not correct.
function asChar(const obj : DObject) : Char;
Converts the DObject to a Char. Asserts if the type is not correct.
function asClass(const obj : DObject) : TClass;
Converts the DObject to a class reference (TClass). Asserts if the type is not correct.
function asCurrency(const obj : DObject) : Currency;
Converts the DObject to a currency value. Asserts if the type is not correct.
function asExtended(const obj : DObject) : Extended;
Converts the DObject to an extended floating point value. Asserts if the type is not correct.
function asInteger(const obj : DObject) : Integer;
Converts the DObject to an integer. Asserts if the type is not correct.
function asInterface(const obj : DObject) : Pointer;
Converts the DObject to an interface pointer. Asserts if the type is not correct.
function asObject(const obj : DObject) : TObject;
Converts the DObject to an object reference. Asserts if the type is not correct.
function asPChar(const obj : DObject) : PChar;
Converts the DObject to a PChar. Asserts if the type is not correct.
function asPointer(const obj : DObject) : Pointer;
Converts the DObject to an untyped pointer.Asserts if the type is not correct.
function asPWideChar(const obj : DObject) : PWideChar;
Converts the DObject to a pointer to a WideChar. Asserts if the type is not correct.
function asShortString(const obj : DObject) : ShortString;
Converts the DObject to a short string.Asserts if the type is not correct.
function asString(const obj : DObject) : String;
Converts the DObject to a String (AnsiString). Asserts if the type is not correct.
function asVariant(const obj : DObject) : Variant;
Converts the DObject to a variant. Asserts if the type is not correct.
function asWideChar(const obj : DObject) : WideChar;
Converts the DObject to a WideChar. Asserts if the type is not correct.
function asWideString(const obj : DObject) : WideString;
Converts the DObject to a WideString. Asserts if the type is not correct.
function atEnd(const iterator : DIterator) : Boolean;
Parameter | Description |
---|
iterator | The iterator to test. |
Tests to see if the iterator is at the end of the container. This is
extremely common during loops. Containers should make a real effort to
ensure that this is processed quickly.
function atStart(const iterator : DIterator) : Boolean;
Parameter | Description |
---|
iterator | The iterator to test. |
Tests to see if the iterator is at the start of the container.
function binarySearch(con : DContainer; obj : array of const) : DIterator;
Locates an object in a sorted container using a binary search. Returns
an iterator positioned at the item if found. Returns atEnd if not found.
function binarySearchIn(_start, _end : DIterator; obj : array of const) : DIterator;
Locates an object in a sorted range using a binary search. Returns
an iterator positioned at the item if found. Returns atEnd if not found.
function binarySearchInWith(_start, _end : DIterator; compare : DComparator; obj : array of const) : DIterator;
Locates an object in a sorted range using a binary search and a specified comparator. Returns
an iterator positioned at the item if found. Returns atEnd if not found.
function binarySearchWith(con : DContainer; compare : DComparator; obj : array of const) : DIterator;
Locates an object in a sorted container using a binary search and a specified comparator. Returns
an iterator positioned at the item if found. Returns atEnd if not found.
procedure ClearDObject(var obj : DObject);
Clears an existing DObject, freeing memory if need be. Do not call
this on uninitialized memory -- prepare that kind of memory with InitDObject.
function collect(container : DContainer; unary : DUnary) : DContainer;
Parameter | Description |
---|
container | The container to operator on.
|
unary | The function to apply |
Collect applies the unary function to each object in the container,
storing the results in a new container (that is constructed by the function)
that is of the same type as the existing one.
function collectIn(_start, _end : DIterator; unary : DUnary) : DContainer;
Parameter | Description |
---|
_start | The beginning of the range to collect in.
|
_end | The end of the range.
|
unary | The function to apply. |
CollectIn applies the unary function to each object in the given range,
storing the results in a new container (that is constructed by this function)
that is of the same type as the starting iterator's associated container.
function copyBackward(_start, _end, dest : DIterator) : DIterator;
Copies a reversed range of values to the given iterator.
function copyContainer(source, dest : DContainer) : DIterator;
Copies the contents of source to dest.
procedure CopyDObject(const source : DObject; var dest : DObject);
Creates a copy of the DObject.
function copyInTo(_start, _end, dest : DIterator) : DIterator;
Copies a range of values to the given iterator.
function copyTo(source : DContainer; dest : DIterator) : DIterator;
Copies the contents of con1 to the given iterator.
function count(con1 : DContainer; objs : array of const) : Integer;
Parameter | Description |
---|
con1 | The counter to count in.
|
objs | An open array of objects to count (counts for all will be summed |
Counts the number of times items matching objs exist in the container.
If more than one object is passed in, count sums for all objects.
function countIf(con1 : DContainer; test : DTest) : Integer;
Parameter | Description |
---|
con1 | The container to test in
|
test | The DTest to apply to each object in the container |
Counts the number of times the test returns true. Each item in the
container is passed to the test.
function countIfIn(_start, _end : DIterator; test : DTest) : Integer;
Parameter | Description |
---|
_start | The start of the range
|
_end | The end of the range
|
test | The test to apply. |
Counts the number of times the test returns true. Each item in the
specified range is passed to the test.
function countIn(_start, _end : DIterator; objs : array of const) : Integer;
Parameter | Description |
---|
_start | The start of the range
|
_end | The end of the range
|
objs | An open array of objects to count (counts will be summed |
Counts the number of times items matching objs exist in the given range.
If more than one object is passed in, count sums for all objects.
function detectInWith(_start, _end : DIterator; compare : DTest) : DIterator;
Determines the first item in the range for which the compare returns true.
function detectWith(container : DContainer; compare : DTest) : DIterator;
Parameter | Description |
---|
container | The container whose items should be tested.
|
compare | The test to try. |
Determines the first item for which compare returns true.
function distance(const iter1, iter2 : DIterator) : Integer;
Determines the number of positions between iter1 and iter2. The two
iterators must point to the same container.
function equal(con1, con2 : DContainer) : Boolean;
Tests to see if two containers are equal, testing each object with
their comparators.
function equalIn(start1, end1, start2 : DIterator) : Boolean;
Tests to see if two ranges contain equal objects, according to the
comparators associated with the containers associated with the iterators.
function equals(const iter1, iter2 : DIterator) : Boolean;
Parameter | Description |
---|
iter1 | The first iterator.
|
iter2 | The second iterator. |
Determines if two iterators are equal -- that is, they are pointing at
the same container and at the same object.
function every(container : DContainer; test : DTest) : Boolean;
Determines if the test returns true for every element in the container.
function everyIn(_start, _end : DIterator; test : DTest) : Boolean;
Determines if the test returns true for every element in the range.
procedure fill(con : DContainer; obj : array of const);
Fill the container with a given value.
procedure fillIn(_start, _end : DIterator; obj : array of const);
Fill the range with a value.
procedure fillN(con : DContainer; count : Integer; obj : array of const);
Fill a container with values, expanding if necessary.
procedure Filter(fromCon, toCon : DContainer; test : DTest);
Copy values for which test returns true to the destination.
function FilterInTo(_start, _end, dest : DIterator; test : DTest) : DIterator;
Copy values for which test returns true to the destination.
function FilterTo(con : DContainer; dest : DIterator; test : DTest) : DIterator;
Copy values for which test returns true to the destination.
function find(container : DContainer; objs : array of const) : DIterator;
Locates an item in a container. Returns atEnd if the item is not found.
function findIf(container : DContainer; test : DTest) : DIterator;
Find the first item in a container for which test returns true. Returns
atEnd if no such item is found.
function findIfIn(_start, _end : DIterator; test : DTest) : DIterator;
Find the first item in a range for which test returns true. Returns
_end if no such item is found.
function findIn(_start, _end : DIterator; objs : array of const) : DIterator;
Locates an item in a range. Returns _end if the item is not found.
procedure forEach(container : DContainer; unary : DApply);
Parameter | Description |
---|
container | The container to iterator over.
|
unary | The function to apply. |
Apply the unary function to each object in the container.
procedure forEachIf(container : DContainer; unary : DApply; test : DTest);
Parameter | Description |
---|
container | The container to iterate over.
|
unary | The function to apply.
|
test | The test that must be passed before the function will be applied. |
Apply a unary function to each object in a container if it
passes a test.
procedure forEachIn(_start, _end : DIterator; unary : DApply);
Parameter | Description |
---|
_start | An iterator set to the start of the range.
|
_end | An iterator set to the end of the range.
|
unary | The function to apply. |
Apply the unary function to a range of objects.
procedure forEachInIf(_start, _end : DIterator; unary : DApply; test : DTest);
Parameter | Description |
---|
_start | An iterator set to the start of the range.
|
_end | An iterator set to the end of the range.
|
unary | The function to apply.
|
test | The test that must be passed before unary will be applied. |
Apply a unary function to a range of objects if the object passes
a test.
procedure FreeAll(objs : array of TObject);
procedure generate(con : DContainer; count : Integer; gen : DGenerator);
Fill a container using a generator. Executes count times. The objects
generated are added to the container with Add.
procedure generateIn(_start, _end : DIterator; gen : DGenerator);
Fills a range using a generator.
procedure generateTo(dest : DIterator; count : Integer; gen : DGenerator);
Outputs count objects from a generator to the destination iterator,
which is called by output.
function get(const iterator : DIterator) : DObject;
Parameter | Description |
---|
iterator | The iterator to get the object from. |
Retrieve the object an iterator is positioned at. This object is
returned in DObject form, which is a generic type that can hold any
object. Use one of the conversion functions (asObject, etc.) to
turn it into something useful. Or, use one of the getXXX functions,
which are slightly more efficient.
function getAt(const iter : DIterator; offset : Integer) : DObject;
Parameter | Description |
---|
iter | The iterator that gives the starting position.
|
offset | The number of positions to move (positive or negative). |
Return the object at the given offset from the iterator.
function getBoolean(const iterator : DIterator) : Boolean;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a boolean.
function getChar(const iterator : DIterator) : Char;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a character.
function getClass(const iterator : DIterator) : TClass;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a class reference (TClass).
function getContainer(const iterator : DIterator) : DContainer;
Parameter | Description |
---|
iterator | The iterator to retrieve a container for. |
Retrieves the container associated with an iterator. You can cast the
reference returned into the real container type, or just use it as a
generic container.
function getCurrency(const iterator : DIterator) : Currency;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a currency value.
function getExtended(const iterator : DIterator) : Extended;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as an extended floating point value.
function getInteger(const iterator : DIterator) : Integer;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as an integer.
function getInterface(const iterator : DIterator) : Pointer;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as an interface pointer.
function getObject(const iterator : DIterator) : TObject;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as an object reference.
It's a good idea to do a typecast with this using the AS operator.
function getPChar(const iterator : DIterator) : PChar;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a PChar.
function getPointer(const iterator : DIterator) : Pointer;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as an untyped pointer.
function getPWideChar(const iterator : DIterator) : PWideChar;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a pointer to a wide character.
function getRef(const iterator : DIterator) : PDObject;
Parameter | Description |
---|
iterator | The iterator to get the object from. |
Retrieve a pointer to the object the iterator is positioned at.
This is somewhat more efficient than getting the object directly,
which involves copying. Many of the internal functions use this to
avoid copying DObjects around.
function getShortString(const iterator : DIterator) : ShortString;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a short string (old style string).
function getString(const iterator : DIterator) : String;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a String (AnsiString).
function getVariant(const iterator : DIterator) : Variant;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a variant.
function getWideChar(const iterator : DIterator) : WideChar;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a wide character.
function getWideString(const iterator : DIterator) : WideString;
Parameter | Description |
---|
iterator | The iterator to get from. |
Retrieve the object at the iterator as a WideString.
function hashCode(const obj : DObject) : Integer;
function includes(master, subset : DContainer) : Boolean;
Determine if master contains all the items in subset. Requires that
both containers be sorted.
function includesIn(startMaster, finishMaster, startSubset, finishSubset : DIterator) : Boolean;
Determine if the master range contains all the items in subset range. Requires that
both containers be sorted.
function includesInWith(startMaster, finishMaster, startSubset, finishSubset : DIterator; comparator : DComparator) : Boolean;
Determines if master range contains all the items in subset range, comparing
items with the supplied comparator. Requires that both containers
be sorted.
function includesWith(master, subset : DContainer; comparator : DComparator) : Boolean;
Determines if master contains all the items in subset, comparing
items with the supplied comparator. Requires that both containers
be sorted.
function index(const iter : DIterator) : Integer;
Determine the index (position within the container) for the given iterator.
procedure InitDObject(var obj : DObject);
Make sure a DObject is empty. Does not clear out the previous contents.
Call this when you're creating a DObject (like on the stack) and you're not
sure if the memory is clear or not.
function inject(container : DContainer; obj : array of const; binary : DBinary) : DObject;
Call binary with obj as the first parameter and the first item in the
container as the next parameter. Then call binary with the result of the
first call to binary as the first parameter, and the second object in the
container as the second parameter. Keep going. Return the last return value
of binary. If no items are in the container, return obj.
function injectIn(_start, _end : DIterator; obj : array of const; binary : DBinary) : DObject;
Call binary with obj as the first parameter and the items in the range
as the second parameter. Pass the result of each call to binary to the next
call to binary (as the first parameter).
function IterateOver(var iter : DIterator) : Boolean;
IterateOver initiates and moves an iterator from its position until the end.
It returns true as long as there are elements to process. The best way to
use this is with a while loop: iter := container.start; while IterateOver(iter) do ...
Note that you don't need to call an advance on the iterator...the IterateOver
function does that for you.
procedure iterSwap(iter1, iter2 : DIterator);
Swaps the items the two iterators are positioned at.
function JenkinsHashBuffer(const buffer; length : Integer; initVal : Integer) : Integer;
function JenkinsHashDouble(d : Double) : Integer;
function JenkinsHashInteger(value : Integer) : Integer;
function JenkinsHashSingle(s : Single) : Integer;
function JenkinsHashString(const s : String) : Integer;
function less(const iter1, iter2 : DIterator) : Boolean;
Determine if iter1 comes before iter2.
function lexicographicalCompare(con1, con2 : DContainer) : Integer;
Parameter | Description |
---|
con1 | The first container to use for comparison.
|
con2 | The second container to use for comparison. |
LexicographicalCompare compares two sequences by comparing their items,
in order, one by one. If an item in con1 is found that is different from
that in con2, the result of the comparison is returned.
function lexicographicalCompareIn(start1, end1, start2, end2 : DIterator) : Integer;
Lexicographically compare (item by item compare) within the specified
range.
function lexicographicalCompareInWith(start1, end1, start2, end2 : DIterator; compare : DCOmparator) : Integer;
Lexicographically compare (item by item compare) within the specified
range, using the specified comparator.
function lexicographicalCompareWith(con1, con2 : DContainer; compare : DComparator) : Integer;
Parameter | Description |
---|
con1 | The first container.
|
con2 | The second container.
|
compare | The comparator to use. |
Lexicographically compare (item by item compare) using a supplied
comparator.
function make(obj : array of const) : DObject;
Parameter | Description |
---|
obj | The object to create a DObject from. |
Create a DObject from an atomic type. This function is intended to
make a single DObject only. It uses the array of const syntax to permit
the construction of a DObject from any atomic type. The DObject created
contains a copy of the object.
function MakeApply(proc : DApplyProc) : DApply;
Turn a procedure into a closure, suitable for use as a DApply.
function MakeApplyEx(proc : DApplyProc; ptr : Pointer) : DApply;
Turn a procedure into a closure, suitable for use as a DApply.
function MakeBinary(proc : DBinaryProc) : DBinary;
Turn a procedure into a closure, suitable for use as a DBinary.
function MakeBinaryEx(proc : DBinaryProc; ptr : Pointer) : DBinary;
Turn a procedure into a closure, suitable for use as a DBinary.
function MakeComparator(proc : DComparatorProc) : DComparator;
Turn a procedure into a closure, suitable for use as a comparator.
function MakeComparatorEx(proc : DComparatorProc; ptr : Pointer) : DComparator;
Turn a procedure into a closure, suitable for use as a comparator.
function MakeEquals(proc : DEqualsProc) : DEquals;
Turn a procedure into a closure, suitable for use as a DEquals.
function MakeEqualsEx(proc : DEqualsProc; ptr : Pointer) : DEquals;
Turn a procedure into a closure, suitable for use as a DEquals.
function MakeGenerator(proc : DGeneratorProc) : DGenerator;
Turn a procedure into a closure, suitable for use as a DGenerator.
function MakeGeneratorEx(proc : DGeneratorProc; ptr : Pointer) : DGenerator;
Turn a procedure into a closure, suitable for use as a DGenerator.
function MakeHash(proc : DHashProc) : DHash;
Turn a procedure into a closure, suitable for use as a DHash.
function MakeHashEx(proc : DHashProc; ptr : Pointer) : DHash;
Turn a procedure into a closure, suitable for use as a DHash.
function MakePair(const ob1, ob2 : DObject) : DPair;
function MakeRange(s,f : DIterator) : DRange;
function MakeTest(proc : DTestProc) : DTest;
Turn a procedure into a closure, suitable for use as a DTest.
function MakeTestEx(proc : DTestProc; ptr : Pointer) : DTest;
Turn a procedure into a closure, suitable for use as a DTest.
function MakeUnary(proc : DUnaryProc) : DUnary;
Turn a procedure into a closure, suitable for use as a DUnary.
function MakeUnaryEx(proc : DUnaryProc; ptr : Pointer) : DUnary;
Turn a procedure into a closure, suitable for use as a DUnary.
function median(objs : array of const; compare : DComparator) : DObject;
function mismatch(con1, con2 : DContainer) : DIteratorPair;
Determines the point at which con1 and con2 begin to differ. It
returns a pair of iterators positioned at the appropriate place in
both containers. If no mismatch is found, both iterators will be at
the end.
function mismatchIn(start1, end1, start2 : DIterator) : DIteratorPair;
Tests two ranges to determine at which point they begin to
differ. The comparators associated with the iterators will be
used for the test.
function mismatchInWith(start1, end1, start2 : DIterator; bt : DBinaryTest) : DIteratorPair;
Determines the point at which the two ranges differ, using bt
as a test. The function will stop when bt returns false. An iterator
pair will be returned, positioned at the first mismatched element.
If no mismatch is found, both iterators will be positioned at the end.
function mismatchWith(con1, con2 : DContainer; bt : DBinaryTest) : DIteratorPair;
Determines the point at which con1 and con2 differ, using bt as
a binary test. The function will halt when bt returns false.
procedure MoveDObject(var source, dest : DObject);
Moves a DObject; the original is left empty.
function nextPermutation(container : DContainer; comparator : DComparator) : Boolean;
Not implemented.
function nextPermutationIn(_start, _end : DIterator; comparator : DComparator) : Boolean;
Not implemented.
procedure objDispose(container : DContainer);
Calls FreeMem on all the items in the container. Assumes the items
are pointers to memory allocated with GetMem.
procedure objDisposeIn(_start, _end : DIterator);
Calls FreeMem on all the items in the range. Assumes the items
are pointers to memory allocated with GetMem.
procedure objFree(container : DContainer);
Calls TObject.Free on all the objects in the container. Asserts if
the type of an item is not TObject.
procedure objFreeIn(_start, _end : DIterator);
Calls TObject.Free on all the items in the range.
procedure objFreeKeys(assoc : DAssociative);
Calls TObject.Free on all the items in the container. Since maps
store pairs, this calls free on the KEY part of the pair.
function orderedHash(container : DContainer) : Integer;
Hashes all the items in the container. The order or the items
is significant.
function orderedHashIn(_start, _end : DIterator) : Integer;
Hashes all the items in the range. The order or the items
is significant.
procedure output(var iterator : DIterator; objs : array of const);
function prevPermutation(container : DContainer; comparator : DComparator) : Boolean;
Not implemented.
function prevPermutationIn(_start, _end : DIterator; comparator : DComparator) : Boolean;
Not implemented.
function PrintString(const obj : DObject) : String;
Convert a DObject into a printable string representation.
procedure put(const iterator : DIterator; objs : array of const);
Parameter | Description |
---|
iterator | The location to store at.
|
obj | The object to store. |
Stores an array of objects at the current iterator location, if possible. Some
containers don't permit arbitrary insertions (like trees). The put operation
erases whatever was in the location before; it is destructive.
This form of put is very useful for storing atomic types into a container.
array._put(array.start, [1,2,3])
procedure putAt(const iter : DIterator; offset : Integer; const obj : DObject);
Put an object at the given offset from the iterator.
procedure putBoolean(const iterator : DIterator; value : Boolean);
Store a boolean at the current iterator location.
procedure putChar(const iterator : DIterator; value : Char);
Store a character at the current iterator location.
procedure putClass(const iterator : DIterator; value : TClass);
Store a class reference at the current iterator location.
procedure putCurrency(const iterator : DIterator; value : Currency);
Store a currency value at the current iterator location.
procedure putExtended(const iterator : DIterator; const value : Extended);
Store an extended floating point value at the current iterator location.
procedure putInteger(const iterator : DIterator; value : Integer);
Store an integer at the current iterator location.
procedure putInterface(const iterator : DIterator; value : Pointer);
Store an interface pointer at the current iterator location.
procedure putObject(const iterator : DIterator; value : TObject);
Store an object reference at the current iterator location.
procedure putPChar(const iterator : DIterator; value : PChar);
Store a PChar at the current iterator location.
procedure putPointer(const iterator : DIterator; value : Pointer);
Store an untyped pointer at the current iterator location.
procedure putPWideChar(const iterator : DIterator; value : PWideChar);
Store a pointer to a wide character at the current iterator location.
procedure putRef(const iterator : DIterator; const obj : DObject);
Store an object directly to a location. This routine ensures the
target location is clean, then makes a direct copy of the object. Note
that you should NOT clear the source DObject -- it is now residing
at the iterator position.
procedure putShortString(const iterator : DIterator; const value : ShortString);
Store a short string at the current iterator location.
procedure putString(const iterator : DIterator; const value : String);
Store a string (AnsiString) at the current iterator location.
procedure putVariant(const iterator : DIterator; const value : Variant);
Store a variant at the current iterator location.
procedure putWideChar(const iterator : DIterator; value : WideChar);
Store a wide character at the current iterator location.
procedure putWideString(const iterator : DIterator; const value : WideString);
Store a wide string at the current iterator location.
procedure randomShuffle(container : DContainer);
Shuffles the items in the container, just like shuffling a deck
of cards.
procedure randomShuffleIn(_start, _end : DIterator);
Shuffles the items in the range, just like shuffling a deck
of cards.
procedure RegisterSDLPrinter(cls : TClass; prt : DPrinterProc);
Register printable string converters for your own classes.
function remove(container : DContainer; objs : array of const) : DIterator;
Removes all instances of each item in objs from the container.
function removeCopy(source, destination : DContainer; objs : array of const) : DIterator;
Copies the source container to the destination, except for the items
matching objs.
function removeCopyIf(source, destination : DContainer; test : DTest) : DIterator;
Copies the source container to the destination, except for those items
for which test returns true.
function removeCopyIfIn(_start, _end, dest : DIterator; test : DTest) : DIterator;
Copies the source range to the destination, except for those items
for which test returns true.
function removeCopyIfTo(source : DContainer; dest : DIterator; test : DTest) : DIterator;
Copies the source container to the destination, except for those items
for which test returns true.
function removeCopyIn(_start, _end, dest : DIterator; objs : array of const) : DIterator;
Copies the source range to the destination, except for the items
matching objs.
function removeCopyTo(source : DContainer; dest : DIterator; objs : array of const) : DIterator;
Copies the source container to a destination iterator, except for the items
matching objs.
function removeIf(container : DContainer; test : DTest) : DIterator;
Removes items from the container for which test returns true.
function removeIfIn(_start, _end : DIterator; test : DTest) : DIterator;
Removes items from the range for which test returns true. The extra elements
left after removal will have undefined values.
function removeIfInTo(_start, _end, dest : DIterator; test : DTest) : DIteratorPair;
Removes items from the range, where that item returns true from test.
The removed items are sent to the destination. A pair of iterators is
returned. The first is positioned at the last element remaining in the
_start, _end range. The second is positioned after the last element
written to dest.
function removeIfTo(container : DContainer; dest : DIterator; test : DTest) : DIteratorPair;
Removes items from the container, where that item returns true from test.
The removed items are sent to the destination. A pair of iterators is
returned: the first is positioned after the last element remaining in the
container. The second is positioned after the last element written to dest.
function removeIn(_start, _end : DIterator; objs : array of const) : DIterator;
Removes all instances of each item in objs in the range.
function removeInTo(_start, _end, dest : DIterator; objs : array of const) : DIterator;
Removes all instances of each item in objs from the range, copying
the removed items to dest.
function removeTo(container : DContainer; dest : DIterator; objs : array of const) : DIterator;
Removes all instances of each item in objs from the container, copying
the removed items to dest.
function replace(container : DContainer; objs1, objs2 : array of const) : Integer;
For each pair of items objs1[N] and objs2[N], replace all instances of
objs1[N] with objs2[N] in the given container. Returns the number of
replacements performed.
function replaceCopy(con1, con2 : DContainer; objs1, objs2 : array of const) : Integer;
For each pair of items objs1[N] and objs2[N], copies each item in con1 to con2,
except if the item equals objs1[N], where objs2[N] is copied. Returns the number of
replacements performed.
function replaceCopyIf(con1, con2 : DContainer; test : DTest; objs : array of const) : Integer;
Copies the items in con1 to con2, except for those items in con1 who
return true from the test. In that case objs[N] will be subsituted. The
operation is repeated for each objs[N].
function replaceCopyIfInTo(_start, _end, dest : DIterator; test : DTest; objs : array of const) : Integer;
Copies the items in the range to the destination, except for those items in con1 who
return true from the test. In that case objs[N] will be subsituted. The
operation is repeated for each objs[N].
function replaceCopyIfTo(container : DContainer; dest : DIterator; test : DTest; objs : array of const) : Integer;
Copies the items in con1 to the destination, except for those items in con1 who
return true from the test. In that case objs[N] will be subsituted. The
operation is repeated for each objs[N].
function replaceCopyInTo(_start, _end, dest : DIterator; objs1, objs2 : array of const) : Integer;
For each pair of items objs1[N] and objs2[N], copies each item in the range to the destination,
except if the item equals objs1[N], where objs2[N] is copied. Returns the number of
replacements performed.
function replaceCopyTo(container : DContainer; dest : DIterator; objs1, objs2 : array of const) : Integer;
For each pair of items objs1[N] and objs2[N], copies each item in con1 to the destination,
except if the item equals objs1[N], where objs2[N] is copied. Returns the number of
replacements performed.
function replaceIf(container : DContainer; test : DTest; objs : array of const) : Integer;
For each objs[N], replace all items in the container for which test returns
true with objs[N].
function replaceIfIn(_start, _end : DIterator; test : DTest; objs : array of const) : Integer;
For each objs[N], replace all items in the range for which test returns
true with objs[N].
function replaceIn(_start, _end : DIterator; objs1, objs2 : array of const) : Integer;
For each pair of items objs1[N] and objs2[N], replace all instances of
objs1[N] with objs2[N] in the given range. Returns the number of
replacements performed.
procedure retreat(var iterator : DIterator);
Move an iterator backwards one position.
procedure retreatBy(var iterator : DIterator; count : Integer);
Move an iterator backwards by count positions.
function retreatByF(const iterator : DIterator; count : Integer) : DIterator;
Move an iterator backwards by count positions.
function retreatF(const iterator : DIterator) : DIterator;
Move an iterator backwards one position.
procedure reverse(container : DContainer);
Reverse the order of the items in the container.
procedure reverseCopy(con1, con2 : DContainer);
Copy the items in con1 to con2, in reverse order.
procedure reverseCopyInTo(_start, _end, dest : DIterator);
Copy the items in the range to the output iterator, in reverse
order.
procedure reverseCopyTo(container : DContainer; dest : DIterator);
Copy the items in container to the output iterator, in reverse
order.
procedure reverseIn(_start, _end : DIterator);
Reverse the order of the items in the range.
procedure rotate(first, middle, last : DIterator);
Rotate the items between the iterators such that the item at the
first iterator moves to the middle iterator. Items pushed off the
end will move to the beginning of the range. This is a right rotation.
function rotateCopy(first, middle, last, dest : DIterator) : DIterator;
Rotate the items between the iterators such that the item at the
first iterator moves to the middle iterator. Items pushed off the
end will move to the beginning of the range. This is a right rotation.
The items at the original iterators are not altered. The results of
this operation are copied to the output iterator.
procedure setBoolean(var obj : DObject; value : Boolean);
Set a boolean to a DObject.
procedure setChar(var obj : DObject; value : Char);
Set a character to a DObject.
procedure setClass(var obj : DObject; value : TClass);
Set a class reference to a DObject.
procedure setCurrency(var obj : DObject; value : Currency);
Set a currency value to a DObject.
function setDifference(con1, con2 : DContainer; dest : DIterator) : DIterator;
Finds the set of items that are in con1 but not in con2, and writes
that set to the destination iterator. Assumes that both containers are
sorted. An iterator positioned just after
the last written item is returned.
function setDifferenceIn(start1, finish1, start2, finish2, dest : DIterator) : DIterator;
Finds the set of items that are in range 1 but not in range 2, and writes
that set to the destination iterator. Assumes that both ranges are
sorted. An iterator positioned just after
the last written item is returned.
function setDifferenceInWith(start1, finish1, start2, finish2, dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in range 1 but not in range 2, using comparator to test them, and writes
that set to the destination iterator. Assumes that both ranges are
sorted. An iterator positioned just after
the last written item is returned.
function setDifferenceWith(con1, con2 : DContainer; dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in con1 but not in con2, using comparator to compare items, and writes
that set to the destination iterator. Assumes that both containers are
sorted. An iterator positioned just after
the last written item is returned.
procedure SetDObject(var obj : DObject; value : array of const);
Sets an arbitrary value to a DObject. The destination is assumed to be
an already-initialized DObject. It is cleared before the new value is
written.
procedure setExtended(var obj : DObject; const value : Extended);
Set an extended floating point value to a DObject.
procedure setInteger(var obj : DObject; value : Integer);
Set an integer to a DObject.
procedure setInterface(var obj : DObject; value : Pointer);
Set an interface pointer to a DObject.
function setIntersection(con1, con2 : DContainer; dest : DIterator) : DIterator;
Finds the set of items that are in both con1 and con2, and writes
that set to the destination iterator. Assumes that both containers are
sorted. An iterator positioned just after
the last written item is returned.
function setIntersectionIn(start1, finish1, start2, finish2, dest : DIterator) : DIterator;
Finds the set of items that are in both range 1 and in range 2, and writes
that set to the destination iterator. Assumes that both ranges are
sorted. An iterator positioned just after
the last written item is returned.
function setIntersectionInWith(start1, finish1, start2, finish2, dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in both range 1 and range 2, using comparator to test them, and writes
that set to the destination iterator. Assumes that both ranges are
sorted. An iterator positioned just after
the last written item is returned.
function setIntersectionWith(con1, con2 : DContainer; dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in both con1 and con2, using comparator to compare items, and writes
that set to the destination iterator. Assumes that both containers are
sorted. An iterator positioned just after
the last written item is returned.
procedure setObject(var obj : DObject; value : TObject);
Set an object reference to a DObject.
procedure setPChar(var obj : DObject; value : PChar);
Set a PChar to a DObject.
procedure setPointer(var obj : DObject; value : Pointer);
Set an untyped pointer to a DObject.
procedure setPWideChar(var obj : DObject; value : PWideChar);
Set a pointer to a wide character to a DObject.
procedure setShortString(var obj : DObject; const value : ShortString);
Set a short string to a DObject.
procedure setString(var obj : DObject; const value : String);
Set a string (AnsiString) to a DObject.
function setSymmetricDifference(con1, con2 : DContainer; dest : DIterator) : DIterator;
Finds the set of items that are NOT in both sets. That is, it finds the items
that are only in con1, or only in con2. It writes these items to the
destination iterator. Assumes that both containers are sorted. An iterator positioned just after
the last written item is returned.
function setSymmetricDifferenceIn(start1, finish1, start2, finish2, dest : DIterator) : DIterator;
Finds the set of items that are NOT in both sets. That is, it finds the items
that are only in range 1, or only in range 2. It writes these items to the
destination iterator. Assumes that both ranges are sorted. An iterator positioned just after
the last written item is returned.
function setSymmetricDifferenceInWith(start1, finish1, start2, finish2, dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are NOT in both sets, using the specified comparator. That is, it finds the items
that are only in range 1, or only in range 2. It writes these items to the
destination iterator. Assumes that both ranges are sorted. An iterator positioned just after
the last written item is returned.
function setSymmetricDifferenceWith(con1, con2 : DContainer; dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are NOT in both sets, using the specified comparator. That is, it finds the items
that are only in con1, or only in con2. It writes these items to the
destination iterator. Assumes that both containers are sorted. An iterator positioned just after
the last written item is returned.
procedure SetToKey(var iter : DIterator);
Toggle the iterator to retrieve keys. Only useful with map containers.
procedure SetToValue(var iter : DIterator);
Toggle the iterator to retrieve values. Only useful with map containers.
function setUnion(con1, con2 : DContainer; dest : DIterator) : DIterator;
Finds the set of items that are in both con1 and con2. Note that only
one copy of each item will show up (a unique operation). The results are
written to the destination iterator. An iterator positioned just after
the last written item is returned.
function setUnionIn(start1, finish1, start2, finish2, dest : DIterator) : DIterator;
Finds the set of items that are in both range 1 and range 2. Note that only
one copy of each item will show up (a unique operation). The results are
written to the destination iterator. An iterator positioned just after
the last written item is returned.
function setUnionInWith(start1, finish1, start2, finish2, dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in both range 1 and range 2, using the specified comparator. Note that only
one copy of each item will show up (a unique operation). The results are
written to the destination iterator. An iterator positioned just after
the last written item is returned.
function setUnionWith(con1, con2 : DContainer; dest : DIterator; comparator : DComparator) : DIterator;
Finds the set of items that are in both con1 and con2, using the specified comparator. Note that only
one copy of each item will show up (a unique operation). The results are
written to the destination iterator. An iterator positioned just after
the last written item is returned.
procedure setVariant(var obj : DObject; const value : Variant);
Set a variant to a DObject.
procedure setWideChar(var obj : DObject; value : WideChar);
Set a wide character to a DObject.
procedure setWideString(var obj : DObject; const value : WideString);
Set a wide string to a DObject.
function some(container : DContainer; test : DTest) : Boolean;
Determines if any of the items in the container return true, when passed
to test.
function someIn(_start, _end : DIterator; test : DTest) : Boolean;
Determines if any of the items in the range cause test to return true.
procedure sort(sequence : DSequence);
Sorts the items in the sequence with QuickSort.
procedure sortIn(_start, _end : DIterator);
Sorts the items in the range with QuickSort.
procedure sortInWith(_start, _end : DIterator; comparator : DComparator);
Sorts the items in the range with QuickSort, using the specified
comparator to control sorting.
procedure sortWith(sequence : DSequence; comparator : DComparator);
Sorts the items in the sequence with QuickSort, using the specified
comparator to control sorting.
procedure stablesort(sequence : DSequence);
Sorts the items in the sequence with MergeSort.
procedure stablesortIn(_start, _end : DIterator);
Sorts the items in the range with MergeSort.
procedure stablesortInWith(_start, _end : DIterator; comparator : DComparator);
Sorts the items in the range with MergeSort, using the specified
comparator to control sorting.
procedure stablesortWith(sequence : DSequence; comparator : DComparator);
Sorts the items in the sequence with MergeSort, using the specified
comparator to control sorting.
procedure Swap(var obj1, obj2 : DObject);
Swap two dobjects.
procedure swapRanges(con1, con2 : DContainer);
Swaps the items in the two containers.
procedure swaprangesInTo(start1, end1, start2 : DIterator);
Swaps the items in two ranges.
function toBoolean(const obj : DObject) : Boolean;
Retrieves at an index as a Boolean. Asserts if the type is not correct. Clears the source DObject.
function toChar(const obj : DObject) : Char;
Retrieves at an index as a Char. Asserts if the type is not correct. Clears the source DObject.
function toClass(const obj : DObject) : TClass;
Retrieves at an index as a class reference (TClass). Asserts if the type is not correct. Clears the source DObject.
function toCurrency(const obj : DObject) : Currency;
Retrieves at an index as a currency value. Asserts if the type is not correct. Clears the source DObject.
function toExtended(const obj : DObject) : Extended;
Retrieves at an index as an extended floating point value. Asserts if the type is not correct. Clears the source DObject.
function toInteger(const obj : DObject) : Integer;
Retrieves at an index as an integer. Asserts if the type is not correct. Clears the source DObject.
function toInterface(const obj : DObject) : Pointer;
Retrieves at an index as an interface pointer. Asserts if the type is not correct. Clears the source DObject.
function toObject(const obj : DObject) : TObject;
Retrieves at an index as an object reference. Asserts if the type is not correct. Clears the source DObject.
function toPChar(const obj : DObject) : PChar;
Retrieves at an index as a PChar. Asserts if the type is not correct. Clears the source DObject.
function toPointer(const obj : DObject) : Pointer;
Retrieves at an index as an untyped pointer.Asserts if the type is not correct. Clears the source DObject.
function toPWideChar(const obj : DObject) : PWideChar;
Retrieves at an index as a pointer to a WideChar. Asserts if the type is not correct. Clears the source DObject.
function toShortString(const obj : DObject) : ShortString;
Retrieves at an index as a short string.Asserts if the type is not correct. Clears the source DObject.
function toString(const obj : DObject) : String;
Retrieves at an index as a String (AnsiString). Asserts if the type is not correct. Clears the source DObject.
function toVariant(const obj : DObject) : Variant;
Retrieves at an index as a variant. Asserts if the type is not correct. Clears the source DObject.
function toWideChar(const obj : DObject) : WideChar;
Retrieves at an index as a WideChar. Asserts if the type is not correct. Clears the source DObject.
function toWideString(const obj : DObject) : WideString;
Retrieves at an index as a WideString. Asserts if the type is not correct. Clears the source DObject.
procedure transformBinary(con1, con2, output : DContainer; binary : DBinary);
Parameter | Description |
---|
con1 | The container of objects that will be passed as the first parameter to the binary function.
|
con2 | The container of objects that will be passed as the second parameter.
|
output | The container where the results will go.
|
binary | The binary function to be applied. |
TransformBinary applies a binary function to pairs of objects from
con1 and con2, and stores the result into the output container. con1 and
con2 need to have the same number of objects in them.
function transformBinaryInTo(start1, finish1, start2, output : DIterator; binary : DBinary) : DIterator;
Parameter | Description |
---|
start1 | The start of the range for the first object.
|
finish1 | The end of the range for the first object. Note that this
parameter dictates how many objects will be processed.
|
output | The container where the results will go.
|
binary | The binary function to be applied. |
TransformBinaryInTo applies a binary function to pairs of objects. The first
object is taken from the range starting at start1 and ending at finish1. The
second object is taken from the range starting at start2. The results of the
applied function are put at output.
function transformBinaryTo(con1, con2 : DContainer; output : DIterator; binary : DBinary) : DIterator;
Parameter | Description |
---|
con1 | The container of objects that will be passed as the first parameter to the binary function.
|
con2 | The container of objects that will be passed as the second parameter.
|
output | The iterator where the results will go.
|
binary | The binary function to be applied. |
TransformBinaryTo applies a binary function to pairs of objects from
con1 and con2, and stores the result at the output iterator. con1 and
con2 need to have the same number of objects in them.
procedure transformUnary(container, output : DContainer; unary : DUnary);
Parameter | Description |
---|
container | The container of objects to apply the function to.
|
output | The container where the results of the function will go.
|
unary | The function to apply. |
TransformUnary applies a function to each object in a container, storing
the results in an output container.
function transformunaryInTo(_start, _finish, output : DIterator; unary : DUnary) : DIterator;
Parameter | Description |
---|
_start | The start of the range of objects.
|
_finish | The end of the range of objects.
|
output | Where the results of the function will go.
|
unary | The function to apply. |
TransformUnaryInTo applies a unary function to each object in a range,
storing the results at another iterator.
function transformUnaryTo(container : DContainer; output : DIterator; unary : DUnary) : DIterator;
Parameter | Description |
---|
container | The container of objects to apply the function to.
|
output | The iterator where the results of the function will go.
|
unary | The function to apply. |
TransformUnary applies a function to each object in a container, storing
the results at an output iterator.
function unique(con : DContainer) : DIterator;
Removes duplicate values from a container, replacing them with a
single instance. Empty items will have undefined values.
function uniqueIn(_start, _end : DIterator) : DIterator;
Removes duplicate values from the range, replacing them with a
single instance. The empty items will have undefined values.
function uniqueInTo(_start, _end, dest : DIterator) : DIterator;
Copies a range to a destination, removing duplicates.
function uniqueInWith(_start, _end : DIterator; compare : DBinaryTest) : DIterator;
Removes duplicate values in a range, as defined by comparator returning true.
function uniqueInWithTo(_start, _end, dest : DIterator; compare : DBinaryTest) : DIterator;
Copy all values to a destination, removing duplicates.
function uniqueTo(con : DContainer; dest : DIterator) : DIterator;
Copies a container to a destination, removing duplicates.
function uniqueWith(con : DContainer; compare : DBinaryTest) : DIterator;
Removes duplicate values, as defined by the given comparator return true.
function unorderedHash(container : DContainer) : Integer;
Hashes all the items in the container. The order or the items
is not significant.
function unorderedHashIn(_start, _end : DIterator) : Integer;
Hashes all the items in the range. The order or the items
is not significant.
function _binarySearch(con : DContainer; const obj : DObject) : DIterator;
function _binarySearchIn(_start, _end : DIterator; const obj : DObject) : DIterator;
function _binarySearchInWith(_start, _end : DIterator; compare : DComparator; const obj : DObject) : DIterator;
function _binarySearchWith(con : DContainer; compare : DComparator; const obj : DObject) : DIterator;
function _count(con1 : DContainer; const obj : DObject) : Integer;
Parameter | Description |
---|
con1 | The container to count in.
|
obj | The object to count. |
Counts the number of times items matching the given obj appear in the
container. You may often use the count version instead of this version.
function _countIn(_start, _end : DIterator; const obj : DObject) : Integer;
Parameter | Description |
---|
_start | The start of the range
|
_end | The end of the range
|
obj | The object to count |
Counts the number of times items matching the given obj appear in a given
range. You may often use the countIn version instead of this version.
procedure _fill(con : DContainer; const obj : DObject);
Fill the given container with the specified value.
procedure _fillIn(_start, _end : DIterator; const obj : DObject);
Fill the specified range with a value.
procedure _fillN(con : DContainer; count : Integer; const obj : DObject);
Fill a container with N copies of a value. This will expand
the container if necessary.
function _find(container : DContainer; const obj : DObject) : DIterator;
Locates the given object in the container, returning an iterator positioned
at it. If the object is not found, the iterator is atEnd.
function _findIn(_start, _end : DIterator; const obj : DObject) : DIterator;
Locate the object in the given range, returning an iterator positioned
at it. If not found, the iterator equals _end.
function _inject(container : DContainer; const obj : DObject; binary : DBinary) : DObject;
Call binary with obj as the first parameter and the first item in the
container as the next parameter. Then call binary with the result of the
first call to binary as the first parameter, and the second object in the
container as the second parameter. Keep going. Return the last return value
of binary. If no items are in the container, return obj.
function _injectIn(_start, _end : DIterator; const obj : DObject; binary : DBinary) : DObject;
Call binary with obj as the first parameter and the items in the range
as the second parameter. Pass the result of each call to binary to the next
call to binary (as the first parameter).
function _median(const obj1, obj2, obj3 : DObject; compare : DComparator) : DObject;
Finds the median of three objects using the given comparator.
procedure _output(var iterator : DIterator; const obj : DObject);
Parameter | Description |
---|
iterator | The location to store at.
|
obj | The object to store. |
Stores an object at the current iterator location, if possible. Following
the put operation, the iterator is advanced. This is very convenient for
adding objects to a finish-iterator.
procedure _outputRef(var iterator : DIterator; const obj : DObject);
procedure _put(const iterator : DIterator; const obj : DObject);
Parameter | Description |
---|
iterator | The location to store at.
|
obj | The object to store. |
Stores an object at the current iterator location, if possible. Some
containers don't permit arbitrary insertions (like trees). The put operation
erases whatever was in the location before; it is destructive.
procedure _putAt(const iter : DIterator; offset : Integer; objs : array of const);
Parameter | Description |
---|
iter | The iterator to use as the starting position.
|
offset | The number of positions to move.
|
objs | An array of const (array of atomic values). |
Use the array of const form to store atomic values at the given offset from
iter.
function _remove(container : DContainer; const obj : DObject) : DIterator;
function _removeCopy(source, destination : DContainer; const obj : DObject) : DIterator;
function _removeCopyIn(_start, _end, dest : DIterator; const obj : DObject) : DIterator;
function _removeCopyTo(source : DContainer; dest : DIterator; const obj : DObject) : DIterator;
function _removeIn(_start, _end : DIterator; const obj : DObject) : DIterator;
function _removeInTo(_start, _end, dest : DIterator; const obj : DObject) : DIterator;
function _removeTo(container : DContainer; dest : DIterator; const obj : DObject) : DIterator;
function _replace(container : DContainer; const obj1, obj2 : DObject) : Integer;
function _replaceCopy(con1, con2 : DContainer; const obj1, obj2 : DObject) : Integer;
function _replaceCopyIf(con1, con2 : DContainer; test : DTest; const obj : DObject) : Integer;
function _replaceCopyIfInTo(_start, _end, dest : DIterator; test : DTest; const obj : DObject) : Integer;
function _replaceCopyIfTo(container : DContainer; dest : DIterator; test : DTest; const obj : DObject) : Integer;
function _replaceCopyInTo(_start, _end, dest : DIterator; const obj1, obj2 : DObject) : Integer;
function _replaceCopyTo(container : DContainer; dest : DIterator; const obj1, obj2 : DObject) : Integer;
function _replaceIf(container : DContainer; test : DTest; const obj : DObject) : Integer;
function _replaceIfIn(_start, _end : DIterator; test : DTest; const obj : DObject) : Integer;
function _replaceIn(_start, _end : DIterator; const obj1, obj2 : DObject) : Integer;
procedure _SetDObject(var destination : DObject; const src : DObject);
Sets an arbitrary dobject to another, clearing the destination's value
first.
DApply = procedure(const obj : DObject) of object
Apply a function to an object. Usually used in apply functions.
DApplyProc = procedure(ptr : Pointer; const obj : DObject)
Procedural equivalent to DApply.
DBinary = function(const obj1, obj2 : DObject) : DObject of object
Apply a function to two objects. Usually used in transform functions.
DBinaryProc = function(ptr : Pointer; const obj1, obj2 : DObject) : DObject
Procedural equivalent to DBinary.
DBinaryTest = function(const obj1, obj2 : DObject) : Boolean of object
Apply a test to two objects.
DBinaryTestProc = function(ptr : Pointer; const obj1, obj2 : DObject) : Boolean
Procedural equivalent to DBinaryTest.
DComparator = function (const obj1, obj2 : DObject) : Integer of object
A closure that can compare two objects and returns less than zero if
obj1 is less than obj2, 0 if obj1 equals obj2, and greater than zero if
obj1 is greater than obj2;
@param obj1 The first object (left hand side).
@param obj2 The second object (right hand side).
DComparatorProc = function(ptr : Pointer; const obj1, obj2 : DObject) : Integer
A procedural equivalent to the DComparator closure. Use these when you
want your comparator to be a procedure instead of a closure. They can be
converted to DComparator with the MakeComparator function.
DEquals = function(const obj1, obj2 : DObject) : Boolean of object
Test to see if the two objects are the same.
DEqualsProc = function(ptr : Pointer; const obj1, obj2 : DObject) : Boolean
Procedural equivalent to DEquals.
DGenerator = function : DObject of object
A generator creates DObjects.
DGeneratorProc = function(ptr : Pointer) : DObject
Procedural equivalent to DGenerator.
DHash = function(const buffer; byteCount : Integer) : Integer of object
DHashProc = function(ptr : Pointer; const buffer; byteCount : Integer) : Integer
DIterator = record
flags : DIteratorFlags;
Handler : DIterHandler;
end;
DIteratorFlag = (diSimple, diForward, diBidirectional, diRandom, diMarkStart, diMarkFinish, diKey, diIteration);
Flags that can exist on iterators.
-
diSimple
-
Indicates that the iterator is of the most basic type.
-
diForward
-
An iterator that can move forward only (like for single-
linked lists).
-
diBidirectional
-
An iterator that can move forward and backward.
-
diRandom
- An iterator that can move forward and backward, or to
a particular element quickly (indexed access).
DIteratorFlags = set of DIteratorFlag
DIteratorPair = record
first : DIterator;
second : DIterator;
end;
Contains a pair of iterators. Not the same as a range -- ranges
will have two iterators that are from the same container. DIteratorPairs
usually have iterators from two different containers.
DIteratorStucture = (dsArray, dsList, dsMap, dsSet, dsDeque, dsHash);
Different underlying containers for an iterator.
DObject = TVarRec
DObject are TVarRecs, and can store any kind of atomic value.
DObjectArray = array[0..MaxInt div sizeof(DObject) - 1] of DObject;
DArrays keep arrays of DObjects. We declare them using the MaxInt
notation so that they can be of any length.
DPair = record
first : DObject;
second : DObject;
end;
DPairs store two complete DObjects. They are frequently used by maps
to contain key, value pairs.
DPrinterProc = function (obj : TObject) : String
Signature for conversion functions that change objects into printable
strings. Create a function with this signature and pass it to
RegisterSDLPrinter.
DRange = record
start : DIterator;
finish : DIterator;
end;
A DRange stores the beginning and ending to a range within a container.
DTest = function(const obj : DObject) : Boolean of object
Apply a generic test to an object. Usually used to select objects from
a container.
DTestProc = function(ptr : Pointer; const obj : DObject) : Boolean
Procedural equivalent to DTest.
DTreeNodeColor = (tnfBlack, tnfRed);
Red black tree nodes get colored either red or black. Surprised?
DUnary = function(const obj : DObject) : DObject of object
Apply a function to an object. Usually used in collect functions.
DUnaryProc = function(ptr : Pointer; const obj : DObject) : DObject
Procedural equivalent to DUnary.
PDIterator = ^DIterator
DIterators store positional information within a container.
I'm using a record structure here because records are assignable in Delphi.
We want to be able to pass these iterators around freely, and not have to worry
about continually constructing them and destroying them. That precludes using
the object model.
PDObject = ^DObject
A pointer to an individual DObject.
PDObjectArray = ^DObjectArray
A pointer to an arbitrarily sized array of DObjects.
SDLBaseClass = TObject
SDLBase class is used as the ultimate base for all SDL objects. We do
this so we can potentially garbage collect them.
DefaultArraySize = 16
DefaultBucketCount = 128