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.
| Access | Abstract | Final | Extends | Implements |
|---|---|---|---|---|
| - | No | No | AbstractArrayListSorter | - |
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
- Return type: CNM_AbstractObject.CNM_ReturnTypes.CloneResult
This method is used to create a new instance…
instantSort
- Parameters:
size(UDINT): The size of the list to be sortedcontainer(POINTER TO CNM_CollectionInterfaces.CNM_AbstractObject.IObject): the container, that contains the list elementscomparator(CNM_CollectionInterfaces.CNM_AbstractObject.IComparator): the comparator that should be used for the sort. Must not be changed while sort is in processcurrentListVersion(__XWORD): the current version of the list, must change when the data in the list changes
- Return type: CNM_CollectionInterfaces.CNM_ReturnTypes.SingleExecutionResult
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 SUCCESSsize(UDINT): The size of the list to be sortedcontainer(POINTER TO CNM_AbstractObject.IObject): the container, that contains the list elementscomparator(CNM_AbstractObject.IComparator): the comparator that should be used for the sort. Must not be changed while sort is in processcurrentListVersion(__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