classwork.ppIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers Classes hierarchy graph
|
Class AVariantList
Unit
classwork
Declaration
type AVariantList = class(ALinkedList)
Description
This class represents a list of one or more variant values. It extends ALinkedList to allow variant values to be stored within the list. As with ALinkedList , AVariantList may be accessed as though it was an indexed array or used like a stack.
Hierarchy
Overview
Methods
|
constructor withValues(const values: array of const); virtual; |
|
constructor from(const thisList: string; const thisDelimiter: string = ''); virtual; |
|
function init: boolean; override; |
|
function add(const thisValue: Variant): TIndexAbsolute; virtual; |
|
function addSeveral(const values: array of const): TCensus; virtual; |
|
function explode(thisList: AnsiString; delimiter: string = ''): TCensus; override; |
|
procedure push(const thisValue: Variant); virtual; |
|
procedure pushSeveral(const values: array of const); virtual; |
|
function pop: Variant; virtual; |
|
procedure insertAt(const index: TIndexRelative; const thisValue: Variant); virtual; |
|
function hasValue(const thisValue: Variant): boolean; virtual; |
|
function indexOf(const thisValue: Variant; const afterIndex: TIndexRelative = 0): longint; virtual; |
|
function item(const thisIndex: TIndexRelative): Variant; virtual; |
|
function setItem(const thisIndex: TIndexRelative; const thisValue: Variant): Variant; virtual; |
Description
Methods
|
constructor withValues(const values: array of const); virtual; |
Construct a new variant list that contains the specified values.
This method calls AVariantList.pushSeveral to insert the values in values into the list after the new instance has been constructed and initialized. If values is empty, then an empty list is created by this routine.
|
|
constructor from(const thisList: string; const thisDelimiter: string = ''); virtual; |
Construct a new variant list by expanding the values provided in thisList .
If thisDelimiter is provided by the caller, then it is used to split the values provided in thisList ; otherwise, the delimiter specified by llstDefaultDelimiter is used. See AVariantList.explode for more information.
If thisList is an empty string, then an empty list is created by this routine.
|
|
function init: boolean; override; |
Initializer
|
|
function add(const thisValue: Variant): TIndexAbsolute; virtual; |
Adds thisValue to the end of the list.
This method constructs a new instance of AVariantListItem and then calls ALinkedList.addItem to add the item to the list.
Returns
The index of the new item. This index is not guaranteed to remain the same for this item if other items are added or removed at locations PRIOR to the index returned. |
|
function addSeveral(const values: array of const): TCensus; virtual; |
Add several values to the end of the list.
This method calls TVarRecToVariant in order to convert each of the values specified in values to a Variant value. It then calls AVariantList.add to add the value to the list.
Returns
The total number of items added to the list. |
|
function explode(thisList: AnsiString; delimiter: string = ''): TCensus; override; |
Add the items specified in thisList to the list.
This method assumes that thisList contains one or more values that are separated by a delimiter of some kind (e.g., a comma). It uses the value of delimiter to split the string into its component values; these values are then added as individual items to the list. If delimiter is not supplied by the caller, or if it is an empty string, then the value of llstDefaultDelimiter is used.
Returns
The total number of items added to the list. |
|
procedure push(const thisValue: Variant); virtual; |
Pushes the specified variant value onto the list, as the last item in the list. Calling AVariantList.pop immediately after this routine will return thisValue .
This method constructs a new instance of AVariantListItem and then calls ALinkedList.pushItem to push the item onto the list.
|
|
procedure pushSeveral(const values: array of const); virtual; |
Push several values onto the list.
This method calls TVarRecToVariant in order to convert each of the values specified in values to a Variant value. It then calls AVariantList.push to add the value to the list.
|
|
function pop: Variant; virtual; |
Pops the last item from the list. This will be the value most recently added to the list by a call to AVariantList.add or AVariantList.push.
If the list is empty, this routine returns an empty string.
|
|
procedure insertAt(const index: TIndexRelative; const thisValue: Variant); virtual; |
Inserts the specified variant value at the given index . If an item already exists at that index, it is "bumped aside" in favor of the new item.
This method constructs a new instance of AVariantListItem and then calls ALinkedList.insertItemAt to insert the item into the list.
The first item in the list is always at index zero (0). The last item in the list is always at index (ALinkedList.census - 1 ). If index specifies a value that is greater than the number of items in the list, then thisString is inserted at the end of the list.
|
|
function hasValue(const thisValue: Variant): boolean; virtual; |
Performs a recursive search to determine whether or not the specified value exists within the list. For very large lists, this search can be inefficient (and can cause stack overflows, due to the recursive nature of the search).
This method calls AVariantListItem.find on the last item in the list, which causes the entire list to be searched recursively.
Returns
True if thisValue is found in the list; False if not.
|
|
function indexOf(const thisValue: Variant; const afterIndex: TIndexRelative = 0): longint; virtual; |
Performs a linear search to find the index of the specified value. The search will begin at afterIndex .
Because this method performs a linear search, it can be inefficient on very large lists.
Returns
The index of the specified value, if found; -1 otherwise. The index returned by this routine will always be an offset relative to the beginning of the list (i.e., a positive integer) if the string is found. |
|
function item(const thisIndex: TIndexRelative): Variant; virtual; |
Retrieve the value of the item at the specified index.
This method calls ALinkedList.itemAt to retrieve the AVariantListItem instance at the specified index; it then returns the value of AVariantListItem.value.
Index zero (0) represents the first node in the list, while index (ALinkedList.census - 1 ) represents the last node in the list. If index specifies a value that is greater than the number of nodes in the list, then this routine will remove the last item in the list.
If an invalid index is passed to this routine, it will return an empty string.
|
|
function setItem(const thisIndex: TIndexRelative; const thisValue: Variant): Variant; virtual; |
Set the value of the item at the specified index.
This method calls ALinkedList.itemAt to retrieve the AVariantListItem instance at the specified index; it then calls AVariantListItem.setValue on that instance.
If index specifies an index that is greater than or equal to the value of Self.census, then this method will insert a new item that contains thisValue into the list.
Returns
The previous value of the string stored at the specified index, if any. An empty string will be returned if an invalid index is passed to this routine. |
Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11
|