FB_Hash_Set (Function Block)
A collection that contains no duplicate items. Implemented using hash table with closed addressing.
Extends: FB_Collection
Implements: I_Hash_Set
Properties
_Bucket_Count
Type: T_Capacity
Number of buckets in the hash set.
Methods
Clear
Empties/Clears/Deletes every item in the set.
Contains
Checks if item is contained in set.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
Item to find. |
Create_Buckets
Creates buckets and initialises them since user defined types can’t be created as arrays dynamically using __NEW(…).
Inputs
Name |
Type |
Description |
|---|---|---|
|
Outputs
Name |
Type |
Description |
|---|---|---|
|
|
|
|
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). |
FB_init
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
if TRUE, the retain variables are initialized (warm start / cold start) |
|
|
if TRUE, the instance afterwards gets moved into the copy code (online change) |
|
Number of buckets you want to initialise the hash set with. Use 0 if you don’t know. |
Get_Values
Gets an immutable list of the values in the set.
Hash
Wrapper for murmur3 hash function that generates a value that fits in the upperage of DINT to avoid negative values due to integer overflow.
Inputs
Name |
Type |
Description |
|---|---|---|
|
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 |
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 |
Resize
Sets the number of buckets in the hash set. Existing items are rehashed and redistributed into the new buckets. Note that of the count is 0 the hashtable is cleared.
Inputs
Name |
Type |
Description |
|---|---|---|
|
Outputs
Name |
Type |
Description |
|---|---|---|
|
|