ClearList()

Syntax

ClearList(LinkedList())
Description
Clears all the elements in this list and releases their memory. After this call the list is still usable, but the list is empty (i.e. there are no elements in it).

Parameters

LinkedList() The name of your linked-list variable, created with the NewList function. You must include the brackets after the list name.

Return value

This function has no return value.

Remarks

PureBasic will only free the memory for the elements. If you have been using the linked-list for something such as storing handles of objects that you create directly with the OS, there is no way PureBasic (or any other language) can know what they are. Therefore, in cases such as that, you should go through the elements in the list and free the objects yourself.

Example

  NewList Numbers.w()

  ; A small loop to add many items to the list
  For i=1 To 100
    AddElement(Numbers())
    Numbers() = i
  Next

  ; Proof that items have been added to the list
  MessageRequester("Information", "There are "+Str(ListSize(Numbers()))+" elements in the list", #PB_MessageRequester_OK)
 
  ; Clear the list and show that the list really is empty
  ClearList(Numbers())
  MessageRequester("Information", "There are "+Str(ListSize(Numbers()))+" elements in the list", #PB_MessageRequester_OK)

See Also

DeleteElement(), FreeList()

Supported OS

All

<- ChangeCurrentElement() - LinkedList Index - CopyList() ->