|
 |
Online Resources |
 |
 |
Libraries |
 |
|
 |
 |
SwapElements |
 |
 |
Syntax
SwapElements(linkedlist(), *FirstElement, *SecondElement)
Description
Swaps 2 elements of the specified list. The '*FirstElement' and '*SecondElement'
parameters must be pointers to valid list elements.
This function is very useful if you want to sort or reorganize quickly a list.
It should be used with care and only by advanced users.
Parameters:
linkedlist() - The name of your linked list variable, created with the NewList command.
You must specify the brackets after the list name.
*FirstElement - Address of the first element to swap. You should get this address by using the @ operator on the list name and not through
any other method.
*SecondElement - Address of the second element to swap. You should get this address by using the @ operator on the list name and not through
any other method.
Return value:
This command does not return anything.
Example:
NewList Numbers()
For k=0 To 10
AddElement(Numbers())
Numbers() = k
Next
SelectElement(Numbers(), 3) ; Get the 3th element
*FirstElement = @Numbers()
SelectElement(Numbers(), 9) ; Get the 9th element
*SecondElement = @Numbers()
; Swap the 3 with the 9
;
SwapElements(Numbers(), *FirstElement, *SecondElement)
; Prove it
;
ForEach Numbers()
Debug Numbers()
Next
Supported OS Windows, Linux <- SelectElement() - LinkedList Index
|
|
 |
|
|