FB_List (Function Block)

A doubly linked list with iterator hint optimisation. Essentially the linked list keeps track of the node it last accessed. Iteration starts from the closest node (head, tail or last accessed) to the access/mutation index. This should result in sequential access times of O(1) and similar times for access/mutation on the same index.

Extends: FB_Collection

Implements: I_List, I_Iterable

Properties

_Begin

Type: T_Position

Index of the first element.

_End

Type: T_Position

Index of the last element.

Methods

Append

Adds an item to the end of the list.

Inputs

Name

Type

Description

Item

ANY

Value to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Clear

Empties/Clears/Deletes every item in the list.

Closest_Node_Iterator

Iteration helper method that finds the closest node to an index and iterates from there to the node at the specified index.

Inputs

Name

Type

Description

Index

T_Position

Contains

Checks if item is contained in list.

Inputs

Name

Type

Description

Item

ANY

Item to find in list

FB_exit

Inputs

Name

Type

Description

bInCopyCode

BOOL

if TRUE, the exit method is called for exiting an instance that is copied afterwards (online change).

Get

Gets item from list at specified location without removing it

Inputs

Name

Type

Description

Index

T_Position

Location of item

Item

ANY

Variable to store returned item

Outputs

Name

Type

Description

bSuccess

BOOL

Get_As_String

Returns item as a string, if type to string conversion is supported

Inputs

Name

Type

Description

Index

T_Position

Location of item

sItem

REFERENCE TO STRING

Variable to store returned item.

Outputs

Name

Type

Description

bSuccess

BOOL

Get_Generic

Gets a value from a list in it’s generic form. Use carefully as this contains the pointer of the actual value in the collection. If you wish to use this it is recommeded you create a copy of the returned value using MEMMOVE or MEMCPY

Inputs

Name

Type

Description

Index

T_Position

Location of item

Outputs

Name

Type

Description

Item

T_Generic

bSuccess

BOOL

Get_Type_At

Gets the type of the item at specified location.

Inputs

Name

Type

Description

Index

T_Position

Outputs

Name

Type

Description

Item_Type

T_Type

bSuccess

BOOL

Insert

Adds new item to list at specified location, if index = 0, item will be added at the front, if index = count, item will be added at the back

Inputs

Name

Type

Description

Index

T_Position

Location of item

Item

ANY

Item to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Insert_Generic

Adds new item to list at specified location using the generic form. If index = 0, item will be added at the front, if index = count, item will be added at the back

Inputs

Name

Type

Description

Index

T_Position

Location of item

Item

T_Generic

Item to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Iterate

Iteration helper method to iterate from a given node in a specific direction for a specified count.

Inputs

Name

Type

Description

pStart

POINTER TO T_List_Node

Count

T_Capacity

bIterateUp

BOOL

Prepend

Adds an item at the front of the list.

Inputs

Name

Type

Description

Item

ANY

Value to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Remove

Removes item from the list.

Inputs

Name

Type

Description

Item

ANY

Item to remove from in list

Outputs

Name

Type

Description

bSuccess

BOOL

Remove_At

Remove item at specified location

Inputs

Name

Type

Description

Index

T_Position

Location of item

Outputs

Name

Type

Description

bSuccess

BOOL

Remove_Last

Removes item at the back of the list.

Outputs

Name

Type

Description

bSuccess

BOOL

Resize

Manually resize list. If list becomes smaller, item on higher locations will be deleted.

Inputs

Name

Type

Description

Size

T_Capacity

New size of list.

Outputs

Name

Type

Description

bSuccess

BOOL

Reverse

Reverses the order of items in the list

Outputs

Name

Type

Description

bSuccess

BOOL

Set

Changes the item at the specified location in the list.

Inputs

Name

Type

Description

Index

T_Position

Location of item

Item

ANY

Item to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Set_Generic

Changes the item at the specified location in the list in it’s generic form.

Inputs

Name

Type

Description

Index

T_Position

Location of item

Item

T_Generic

Item to store in list

Outputs

Name

Type

Description

bSuccess

BOOL

Swap

Swaps item at index A with item at index B.

Inputs

Name

Type

Description

Index_A, Index_B

T_Position

Outputs

Name

Type

Description

bSuccess

BOOL