OScript API/Built-in Package Index

Class: CacheTree

The CacheTree class is used to maintain a tree of parent-child relationships with a data value attached to each relationship. The keys for the parent and child objects are Integer values. A single data value, of any type, can be associated with each key. The CacheTree can be queried regarding parent-child relations, such as whether a given key is a descendant or ancestor of some specified key.

Class Attributes

Used to test the type of a Dynamic value.

Class Methods

Add( CacheTree tree, Integer childKey, Integer parentKey, Dynamic childData )

Creates a new parent-child relationship.

Create( )

Creates an empty CacheTree object.

Get( CacheTree tree, Integer key )

Returns the data value associated with the specified key.

IsAncestor( Dynamic tree, Integer key, Integer testParentKey, Integer testChildKey )

Returns TRUE if the test child key is an ancestor of the specified key.

IsDescendant( Dynamic tree, Integer key, Integer testParentKey, Integer testChildKey )

Returns TRUE if the test child key is a descendant of the specified key.

Parent( CacheTree tree, Integer key )

Returns the parent key for the specified key.

Set( CacheTree tree, Integer key, Dynamic data )

Resets the data value maintained for the specified key.

Class Attributes

Used to test the type of a Dynamic value.

Class Methods

Add

Boolean Add( CacheTree tree,
             Integer childKey,
             Integer parentKey,
             Dynamic childData )

Creates a new parent-child relationship. Adds the parent key, parentKey, to the CacheTree if it is not already present, adds the child Key, childKey, to the CacheTree if is not already present, and makes sure the child key references the specified parent key. The specified child data value, childData, is saved along with the child key.

Parameters

tree

The CacheTree to manipulate.

childKey

The Integer key of the child.

parentKey

The Integer key of the parent.

childData

A value of any type to be attached to the child.

Returns:

Returns FALSE.

Create

CacheTree Create()

Creates an empty CacheTree object.

Returns:

An empty CacheTree object.

Get

Dynamic Get( CacheTree tree,
             Integer key )

Returns the data value associated with the specified key.

Parameters

tree

The CacheTree to manipulate.

key

The key of the entry whose associated data value will be returned.

Returns:

The data value associated with the specified key, if the specified key is not in the CacheTree Undefined will be returned.

IsAncestor

Boolean IsAncestor( Dynamic tree,
                    Integer key,
                    Integer testParentKey,
                    Integer testChildKey )

Returns TRUE if the test child key is an ancestor of the specified key. The parent key of the child key, testChildKey, must be specified as testParentKey.

Returns TRUE if the test child key is an ancestor of the specified key.

Parameters

tree

The CacheTree.

key

The Key for which the testChildKey's ancestry is tested.

testParentKey

The Parent Key for testChildKey.

testChildKey

The child key that is tested to determine if it is an ancestor of the specified Key.

Returns:

Returns TRUE if the test child key is an ancestor of the specified key.

IsDescendant

Boolean IsDescendant( Dynamic tree,
                      Integer key,
                      Integer testParentKey,
                      Integer testChildKey )

Returns TRUE if the test child key is a descendant of the specified key. The parent key of the child key, testChildKey, must be specified as testParentKey.

Parameters

tree

The CacheTree.

key

The key for which testChildKey may be a descendant.

testParentKey

The parent key of testChildKey.

testChildKey

The key which may be a descendant of key.

Returns:

Returns TRUE if the test child key is a descendant of the specified key.

Parent

Integer Parent( CacheTree tree,
                Integer key )

Returns the Parent Key for the specified entry.

Parameters

tree

The CacheTree.

key

The child key whose parent key will be returned.

Returns:

The parent key of the specified key.

Set

Boolean Set( CacheTree tree,
             Integer key,
             Dynamic data )

Reset the data value maintained for the specified key. No action is performed if the specified key does not exist.

Parameters

tree

The CacheTree to manipulate.

key

The key to which the data value is associated.

data

The new data value to be associated with the specified key.

Returns:

TRUE if the specified key was in the CacheTree, otherwise FALSE.

 Copyright © 2021 OpenText Corporation. All rights reserved.