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.
Integer CacheTreeType
Used to test the type of a Dynamic value.
AddBoolean 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.
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. |
CacheTree Create()
Creates an empty CacheTree object.
Dynamic Get( CacheTree tree, Integer key )
Returns the data value associated with the specified key.
tree | - | The CacheTree to manipulate. |
key | - | The key of the entry whose associated data value will be returned. |
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.
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 TRUE if the test child key is an ancestor of the specified key.
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.
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. |
Integer Parent( CacheTree tree, Integer key )
Returns the Parent Key for the specified entry.
tree | - | The CacheTree. |
key | - | The child key whose parent key will be returned. |
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.
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. |