Skip to main content

ArrayListShellSorter

Short summary​

This FB sorts the list using a shellsort, which has O(n^(4/3)) runtime. Slower than merge or timsort but doesn't need additional memory.

AccessAbstractFinalExtendsImplements
-NoNoAbstractArrayListSorter-

UML Diagram​

Parameters

none

Properties​

className​

Type: CNM_AbstractObject.ClassName

This abstract property returns the class name of the concrete object, …

Methods​

clearContents​

  • Return type: VOID

This method is called in the destruct method and is intended to zero all references and interfaces that should not be destructed. …

clone​

This method is used to create a new instance…

instantSort​

This method sorts the data structure instantly within one call. …

sort​

  • Parameters:
    • execute (BOOL): control bit to start or abort the sorting, needs to be active until the ExecutionState is SUCCESS
    • size (UDINT): The size of the list to be sorted
    • container (POINTER TO CNM_AbstractObject.IObject): the container, that contains the list elements
    • comparator (CNM_AbstractObject.IComparator): the comparator that should be used for the sort. Must not be changed while sort is in process
    • currentListVersion (__XWORD): the current version of the list, must change when the data in the list changes
  • Return type: CNM_ReturnTypes.SingleExecutionState

This method sorts the data structure. …

Code​

Declaration​

{attribute 'enable_dynamic_creation'}
FUNCTION_BLOCK ArrayListShellSorter EXTENDS AbstractArrayListSorter
VAR CONSTANT
MAX_COLUMNINDEX :UINT := 7;
//ciuras proposal for columns on shellsort
PREPARED_COLUMN_WIDTH :ARRAY[0..MAX_COLUMNINDEX] OF __XWORD := [1,4,10,23,57,132,301,701];
END_VAR