Welcome to Pauls PureProject
 Home Online Reference Guide duplicated from http://cvs.purebasic.com  
 Online Resources
   · Reference

 Libraries
     2DDrawing
     Billboard
     Camera
     CDAudio
     Cipher
     Clipboard
     Console
     Database
     Date
     Desktop
     Engine3D
     Entity
     File
     FileSystem
     Font
     Gadget
     Help
     Image
     ImagePlugin
     Joystick
     Keyboard
     Library
     Light
     LinkedList
     Material
     Math
     Memory
     Menu
     Mesh
     Misc
     Module
     Mouse
     Movie
     Network
     OnError
     Packer
     Palette
     Particle
     Preference
     Printer
     Requester
     Sort
     Sound
     SoundPlugin
     Sprite
     Sprite3D
     StatusBar
     String
     SysTray
     Terrain
     Texture
     Thread
     Toolbar
     Window

 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



Hosted by Reel Media Productions Copyright©2001-2004 All Rights Reserved