FB_Tree_Set (Function Block)
A collection that contains no duplicate items implemented using an iterative AVL Tree. This data structure was implemented with the help of Max Goren’s iterative AVL tree in C++. See Function Block’s body for more details.
Extends: FB_Collection
Implements: I_Tree_Set
Properties
_Traversal
Type: T_BST_Traversal
Traversal method for retrieving values in the tree set.
Methods
Balance
Performs rotation and updates heights until tree is balanced.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Clear
Empties/Clears/Deletes every item in the set.
Clear_Node
Deletes the node and its tree/sub-trees.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Contains
Checks if item is contained in set.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Item to find. |
Create_Node
Creates a new node in dynamic memory with a clone of the generic item as it data.
Inputs
Name |
Type |
Description |
|---|---|---|
|
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
|
|
Delete_Node
Safety deletes node. If the node and/or it’s value/data is in dynamic memory it/they will be deleted.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
FB_exit
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
if TRUE, the exit method is called for exiting an instance that is copied afterwards (online change). |
Find_Minimum_Node
Finds the node with the smallest item in a tree or sub-tree.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Get_Balance
Gets the difference between the left and right sub-trees.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Get_Height
Safely gets the height of a sub-tree.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Get_Values
Gets an immutable list of the values in the set.
Insert
Insert item into set.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Data to insert |
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
Indicates whether operation was successful. Success = TRUE, Failure = FALSE |
Insert_Generic
Adds new generic item at into set. The set will store a copy of the generic item so as to not modify the original value outside it’s scope.
Inputs
Name |
Type |
Description |
|---|---|---|
|
Item to store |
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
Indicates whether operation was successful. Success = TRUE, Failure = FALSE |
Move_Node
Moves from node at source into the position of the destination.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Remove
Removes item from the set.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Data to remove |
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
Indicates whether operation was successful. Success = TRUE, Failure = FALSE |
Remove_Generic
Removes generic item from the set.
Inputs
Name |
Type |
Description |
|---|---|---|
|
Data to remove |
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
Indicates whether operation was successful. Success = TRUE, Failure = FALSE |
Remove_Node
Finds and removes a node from a tree/sub-tree and returns the new root of the tree/subtree.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Rotate_Left
Rotates a tree/sub-tree left.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Rotate_Right
Rotates a tree/sub-tree right.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Search_Node
Checks if an item is in a tree/ sub-tree.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
|
|
Update_Height
Inputs
Name |
Type |
Description |
|---|---|---|
|
|