Structure

 

Structure Overview

A Structure is a table with two columns. The left column contains symbolic keys, and the right column contains the value associated with its respective symbolic key.

A Structure has a variable number of rows; however, a Structure always has exactly two columns (the symbolic keys and the values associated with those symbolic keys). Both the keys and values are available at run time, and the Structure can be sorted by keys or values, can have keys added, altered, or deleted dynamically.

Structure Illustration

A Structure 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 Structure binding of a Key/Value pair.

Name John Doe
Salary $55000
Address 184 Anywhere St.
City Los Angeles
State California

We can sort the structure by key in descending order. Using the Structure above, the resulting sorted structure is:

State California
Salary $55000
Name John Doe
City Los Angeles
Address 184 Anywhere St.

When to Use

Structures are convenient for storing Key/ Value pairs in unsorted order. They have a relatively small overhead compared to Dictionaries or Directories which sorts these key value pairs automatically.

Visual Basic Comparison

An Analytic Information Server Structures are 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, 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 Structure data type supports a simple constant form. The whole Structure constant is enclosed in braces and preceded by the sharp symbol and a left-brace (#{ ... }) and terminated with a right-brace. Some Structure constant examples:

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

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

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

#{Date: #Jan,1 ,1972 Manager: #{Name: "Joe Smith" Age: "45"} Employee: #{Name: Jan Brown Address: "28"}}

The Structure data type also supports a strongly-typed declarative form. The declarative Structure constant is enclosed in braces and preceded by the sharp symbol, a left-brace, and the decl notation (#{decl| ... }), and terminated with a right-brace. Some declarative Structure constant examples:

#{decl| (String:Name "John Doe") Number:Salary}

Note: The declarative constant form, shown above, supports the same variable declaration and initialization syntax as in the args:(), vars:(), svars:(), pvars:(), and cvars:() sections of the lambda special form. See the lambda special form for additional information on variable declaration.

Object Data Types

The Structure 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.

NOTE: The Structure is a special type in AIS Lisp. Structures are used to store the strongly-typed templates for all class variables, persistant variables, constant variables, and temporary variables. In addition, strongly-typed user-defined Structure templates can be declared using the declarative constant form of the Structure.

 

Data Type Examples

The Structure object can be demonstrated by the following examples.

Example_Structure_addMethod_003 Example_Structure_addMethod_004 Example_Structure_append_004 Example_Structure_append_005
Example_Structure_apply_001 Example_Structure_apply_002 Example_Structure_binaryInsert_001 Example_Structure_binarySearch_001
Example_Structure_cdr_001 Example_Structure_cdr_002 Example_Structure_compareEQ_003 Example_Structure_compareGE_003
Example_Structure_compareGT_003 Example_Structure_compareLE_003 Example_Structure_compareLT_003 Example_Structure_compareNE_003
Example_Structure_compare_003 Example_Structure_comparison_003 Example_Structure_copy_001 Example_Structure_count_001
Example_Structure_defMethod_004 Example_Structure_defMethod_005 Example_Structure_defineStructure_001 Example_Structure_defineStructure_002
Example_Structure_defineStructure_003 Example_Structure_defstruct_001 Example_Structure_defstruct_002 Example_Structure_delete_001
Example_Structure_delete_002 Example_Structure_fieldsOf_001 Example_Structure_insert_001 Example_Structure_inside_001
Example_Structure_isAtom_001 Example_Structure_isBound_001 Example_Structure_isEqual_001 Example_Structure_isIdentical_001
Example_Structure_isInside_001 Example_Structure_isMember_001 Example_Structure_isObject_003 Example_Structure_isStructure_001
Example_Structure_isType_005 Example_Structure_length_004 Example_Structure_makeStructure_001 Example_Structure_makeStructure_002
Example_Structure_map_001 Example_Structure_mapc_001 Example_Structure_member_001 Example_Structure_methodsOf_005
Example_Structure_methodsOf_006 Example_Structure_new_003 Example_Structure_objectToStructure_001 Example_Structure_objectToStructure_002
Example_Structure_objectToStructure_003 Example_Structure_objectToStructure_004 Example_Structure_refAttributes_001 Example_Structure_refValues_001
Example_Structure_ref_004 Example_Structure_ref_005 Example_Structure_ref_006 Example_Structure_remove_001
Example_Structure_resize_001 Example_Structure_send_003 Example_Structure_setAttributes_001 Example_Structure_setCdr_001
Example_Structure_setCdr_002 Example_Structure_setLastCdr_001 Example_Structure_setq_003 Example_Structure_setq_004
Example_Structure_setq_005 Example_Structure_setq_006 Example_Structure_sizeof_003 Example_Structure_sort_001
Example_Structure_sort_002 Example_Structure_sort_003 Example_Structure_type_003 Example_Structure_type_004
Example_Structure_type_006 Example_Structure_uniqueInsert_001 Example_Structure_uniqueInsert_002