Dictionary Overview

A Dictionary is an Object containing an arbitrary number of bindings. A binding consists of a key and value pair. A Dictionary key can only be can any Object type such as Symbol (Unquoted or Quoted), List, Pair (Unquoted or Quoted), all Vector types, Structure, Dictionary, Repository, or Lambda.

Analytic Information Server Structure Objects and Dictionary objects share common properties: they both contain an arbitrary number of bindings, values can be referenced by key or index, or two indices, keys can only be objects. However, Dictionary Object keys are always maintained in ascending sort order. There are no sort functions for sorting keys in a Dictionary, nor can Dictionaries be sorted by value.

Dictionary Illustration

A Dictionary Object is analogous to a table containing exactly two columns and an arbitrary number of rows. The left column contains a key (must be an Object type: Symbol, List, Pair , any Vector type, Structure, Dictionary, Repository, or Lambda ) , and the right column contains the value associated with its key. Any given row in a table is analogous to a Dictionary binding: Key/Value pair.

Aardvark "Animal with long snout"
Armadillo "Animal with a protective shell"
Baboon "A simian found in the jungle"
Cheetah "A fast running animal"
Platypus "A mammal with a bill"

Or delete the key, Baboon:

Aardvark "Animal with long snout"
Armadillo "Animal with a protective shell"
Cheetah "A fast running animal"
Platypus "A mammal with a bill"

When to Use

Dictionaries are like Structures, in that they are convenient for storing Key/ Value pairs. However, they have a maintenance overhead keeping the keys in sorted order. An application that requires sorted keys would best be served by using a Dictionary.

Visual Basic Comparison

An Analytic Information Server Dictionary is similar to the user-defined type of Visual Basic. The Visual Basic user defined type is created at compile time, whereas the Analytic Information Server structure is created, expanded, or contracted dynamically at run time. The main difference is that the Visual Basic user defined type is static and the Analytic Information Server structure is dynamic, has its object keys and values available maintained in sorted order, and the object keys offer a wider range of values.

Type Employee

Name As Variant

' Name of the employee.

Salary As Variant

' Salary of the employee.

Address As Variant

' Address of the employee.

City As Variant

' City of the employee.

State As Variant

' State of the employee.

End Type

Constant Form

The Dictionary native data type supports a constant form. The whole Dictionary constant is enclosed in braces and preceded by the sharp symbol, brace, and the dic| symbol (#{dic|). Some Dictionary constant examples:

#{dic| Name: "John Doe" Address: "184 Anywhere Street" City: "Los Angeles" State: "California"}

The constant form for dictionaries allows using the constant prefix, #{dic|| with two bars, to specify creating "as is" in unsorted order as follows:

#{dic|| Z: 5 Y: #{Mike: "father" Sally: "mother"} X: "Hello"}

The constant form for dictionaries allows embedded Analytic Information Server objects for the values or keys as follows:

#{dic| X: 5 Y: #{Mike: "father" Sally: "mother"} Z: "Hello"}

#{dic| #Jan,1 ,1972 {Name: Joe Eyes: Blue} #Sept, 3 ,1969 {Name: Jan Eyes: Brown}}

Object Data Types

The Dictionary is a Heap Object or an Object Data Type. The Analytic Information Server Object Types are stored in the Heap and are managed by the Heap manager. The Analytic Information Server Heap manager supports object resizing, garbage collection, and anti-fragmentation algorithms so that the user may concentrate on the analysis and modeling of data rather than on memory management. Without exception, all of the Object types are identified by an object id. The object id identifies a block of memory, managed by the Lambda Information Server memory manager, in which the Object's data is stored.

The Analytic Information Server Heap Object and Native Data types can be saved and loaded to and from persistent (disk file) storage at any time. Containers with immediate data are saved on disk in fixed length records equal to the size of the container. Containers with Heap object references are saved in fixed length records, which are automatically expanded to include the contents of the Heap object, and any objects referenced by the Heap object, etc. This feature is called Object Closure Management and is automatic with every Analytic Information Server container database save.

Analytic Information Server containers may be loaded from any database repository record at any time. If the data in the record is immediate, the database load fills the container with the immediate data. If the data in the record is an object closure, the database load fills the container with a Heap object reference, and all of the objects in the record are loaded back into the Heap with the same referential relationships they had when they were saved in the repository.


Data Type Examples

The Dictionary object can be demonstrated by the following examples.

Example_Dictionary_addMethod_005 Example_Dictionary_binarySearch_002 Example_Dictionary_cdr_003 Example_Dictionary_compareEQ_004
Example_Dictionary_compareGE_004 Example_Dictionary_compareGT_004 Example_Dictionary_compareLE_004 Example_Dictionary_compareLT_004
Example_Dictionary_compareNE_004 Example_Dictionary_compare_003 Example_Dictionary_compare_004 Example_Dictionary_comparison_004
Example_Dictionary_copy_002 Example_Dictionary_count_002 Example_Dictionary_defmethod_006 Example_Dictionary_delete_003
Example_Dictionary_delete_004 Example_Dictionary_insert_002 Example_Dictionary_inside_002 Example_Dictionary_isAtom_002
Example_Dictionary_isBound_002 Example_Dictionary_isDictionary_001 Example_Dictionary_isDictionary_002 Example_Dictionary_isEqual_002
Example_Dictionary_isIdentical_002 Example_Dictionary_isInside_002 Example_Dictionary_isMember_002 Example_Dictionary_isObject_004
Example_Dictionary_isType_006 Example_Dictionary_length_005 Example_Dictionary_makeDictionary_001 Example_Dictionary_map_002
Example_Dictionary_mapc_002 Example_Dictionary_member_002 Example_Dictionary_methodsOf_007 Example_Dictionary_new_004
Example_Dictionary_objectToDictionary_001 Example_Dictionary_objectToDictionary_002 Example_Dictionary_objectToDictionary_003 Example_Dictionary_objectToDictionary_004
Example_Dictionary_refAttributes_002 Example_Dictionary_refValues_002 Example_Dictionary_ref_007 Example_Dictionary_ref_008
Example_Dictionary_ref_009 Example_Dictionary_remove_002 Example_Dictionary_resize_002 Example_Dictionary_send_004
Example_Dictionary_setAttributes_002 Example_Dictionary_setCdr_002 Example_Dictionary_setCdr_003 Example_Dictionary_setq_007
Example_Dictionary_setq_008 Example_Dictionary_setq_009 Example_Dictionary_sizeof_004 Example_Dictionary_sort_004
Example_Dictionary_sort_005 Example_Dictionary_sort_006 Example_Dictionary_type_007