Class ADictionary
Unit
classwork
Declaration
type ADictionary = class(AMapping)
Description
This class represents a dictionary, which is a list of items that are indexed by a string key. The overall functionality of the dictionary is similar to that provided by Python and other languages that implement such objects; however, the dictionary is implemented as a binary tree rather than a table of hashed objects.
As with instances of ABinaryTree, the dictionary is capable of looking up entries and streaming those entries to and from arbitrary streams. The dictionary also supports condensing itself into a delimited string and iterating over its keys and values.
Hierarchy
Overview
Methods
Description
Methods
|
function init: boolean; override; |
Initializer
|
|
function Values: AVariantList; virtual; |
Construct a list of all entry values in the dictionary.
This method proceeds sequentially through all entries in the dictionary, obtaining the value of each. The values are inserted into an instance of AVariantList which is constructed for this purpose.
Returns
An instance of AVariantList that contains the values of all dictionary entries. This list should be freed by the caller when it is no longer required. If there are no entries in the dictionary, an empty variant list is returned. |
|
function add(const thisKey: string; const thisValue: Variant): ADictionaryEntry; reintroduce; virtual; |
Add the specified key and value to the dictionary.
As with other instances of ABinaryTree, ADictionary does not allow duplicate entries; consequently, if thisKey already exists in the dictionary, its value will be updated with thisValue . Otherwise, a new entry is created.
Returns
A reference to the dictionary entry that has been created and inserted or, if the entry already existed, the existing entry. The caller should NOT attempt to free this reference; that will be done when the dictionary is destroyed. |
|
function valueOf(const key: string): Variant; virtual; |
Retrieve the value of the named item.
This method retrieves the instance of ADictionaryEntry that has the specified key ; it then returns the value obtained by calling ADictionaryEntry.value on that entry.
If no entry that matches key is found in the dictionary, this routine returns Variants.null .
|
|
function valueOf(const key: string; const defaultValue: Variant): Variant; virtual; |
Retrieve the value of the named item.
This method retrieves the instance of ADictionaryEntry that has the specified key ; it then returns the value obtained by calling ADictionaryEntry.value on that entry.
If no entry that matches key is found in the dictionary, this routine returns defaultValue .
|
|
function setValueOf(const key: string; const thisValue: Variant): Variant; virtual; |
Set the value of the named item.
This method retrieves the instance of ADictionaryEntry that has the specified key ; it then sets the value by calling ADictionaryEntry.setValue on that entry.
If no entry that matches key is found in the dictionary, then this method will add a new item.
Returns
The previous value of the specified item, if it was found; Variants.null otherwise. |
|
function valueAt(const thisIndex: TNodeAbsoluteIndex): Variant; virtual; |
Retrieves the value at the specified index in the dictionary.
Internally, this method calls ABinaryTree.LeafAtIndex on itself; if that method returns a node, then ADictionaryEntry.value is called on it.
Returns
The value of the node at the specified index , if found; Variants.null otherwise. |
|
function setValueAt(const thisIndex: TNodeAbsoluteIndex; const newValue: Variant): Variant; virtual; |
Set the value of the entry at the specified index in the dictionary.
Internally, this method calls ABinaryTree.LeafAtIndex on itself; if that method returns a node, then ADictionaryEntry.setValue is called on it.
Returns
The previous value of the node at the specified index , if found; Variants.null otherwise. |
Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18
|