Class AMapping

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AMapping = class(ABinaryTree)

Description

This class represents a mapping, which is a list of items that are indexed by a string key. The overall functionality of the mapping is similar to that provided by Python and other languages that implement such objects; however, the maping is implemented as a binary tree rather than a table of hashed objects and buckets.

Hierarchy

Overview

Methods

Public function init: boolean; override;
Public function implode(pairsDelimiter: string = ''; keyValueDelimiter: string = ''): AnsiString; virtual;
Public function Keys: AStringList; virtual;
Public function ValuesAsStrings: AStringList; virtual;
Public function implodeKeys(delimiter: string = ''): AnsiString; virtual;
Public function implodeValues(delimiter: string = ''): AnsiString; virtual;
Public function Entry(const key: string): AMappingEntry; virtual;
Public function keyAt(const thisIndex: TIndexAbsolute): string; virtual;

Description

Methods

Public function init: boolean; override;

Initializer

Public function implode(pairsDelimiter: string = ''; keyValueDelimiter: string = ''): AnsiString; virtual;

Condense the mapping and its entries into a doubly-delimited string.

This method iterates through the items in the mapping, calling AMappingEntry.implode on each one. The resulting string will consist of key/value pairs, in which the keys and values are separated by keyValueDelimiter and the key/value pairs are separated from each other by pairsDelimiter.

If keyValueDelimiter is not specified by the caller, or if it is an empty string, then the value of mapDefaultDelimiter is used. If pairsDelimiter is not specified by the caller, or if it is an empty string, then value of llstDefaultDelimiter is used.

Returns

A doubly-delimited string that contains representations of all dictionary entries.

Public function Keys: AStringList; virtual;

Construct a list of all string keys in the mapping.

This method proceeds sequentially through all entries in the mapping, obtaining the name of each. The names are inserted into an instance of AStringList which is constructed for this purpose.

Returns

An instance of AStringList that contains the names of all mapping entries. This list should be freed by the caller when it is no longer required. If there are no entries in the mapping, an empty string list is returned.

Public function ValuesAsStrings: AStringList; virtual;

Construct a list of all values in the mapping, represented as strings.

This method iterates sequentially through all entries in the mapping, calling AMappingEntry.valueAsString on each. The values are inserted into an instance of AStringList which is constructed for this purpose.

Returns

An instance of AStringList that contains the values of all mapping entries, represented as strings. This list should be freed by the caller when it is no longer required. If there are no entries in the mapping, an empty string list is returned.

Public function implodeKeys(delimiter: string = ''): AnsiString; virtual;

Construct a delimited string that contains the names of all entries in the mapping. The names are separated from each other by the string specified in delimiter. If delimiter is not provided by the caller, or if it is an empty string, then the value of llstDefaultDelimiter is used.

Public function implodeValues(delimiter: string = ''): AnsiString; virtual;

Construct a delimited string that contains the values of all entries in the dictionary. The values are separated from each other by the string specified in delimiter. If delimiter is not provided by the caller, or if it is an empty string, then the value of llstDefaultDelimiter is used.

Public function Entry(const key: string): AMappingEntry; virtual;

Retrieve the entry associated with the specified string key. This method is synonymous to a call to ABinaryTree.fetchLeaf, except that it returns an instance of AMappingEntry.

Public function keyAt(const thisIndex: TIndexAbsolute): string; virtual;

Retrieve the key at the specified index in the mapping.

Internally, this method calls ABinaryTree.LeafAtIndex on itself; if that method returns a node, then AMappingEntry.name is called on it.

Returns

The name of the node at the specified index, if found; an empty string otherwise.


Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11