@DATABASE Linked List V1.10
$VER: Pure Basic - Linked List library V1.10 (30.11.1999) © Fantaisie Software
@NODE MAIN "Linked List"

  @{b}Pure Basic - Linked List library V1.10@{ub}

    The Linked Lists are object which are dynamically allocated
    depending of your need. This is a list of elements and each
    elements is fully independant of the other. You can add any
    elements you want, inserting elements at the position you need
    deleting some other and more... These kind of datamanagement is
    very used in the AmigaOS as it's the best way to handle data
    when you don't know how many there are.

  @{b}Commands summary in alphabetical order:@{ub}

    @{" AddElement           " LINK AddElement}
    @{" ChangeCurrentElement " LINK ChangeCurrentElement}
    @{" ClearList            " LINK ClearList}
    @{" CountList            " LINK CountList}
    @{" FirstElement         " LINK FirstElement}
    @{" InsertElement        " LINK InsertElement}
    @{" KillElement          " LINK KillElement}
    @{" LastElement          " LINK LastElement}
    @{" ListBase             " LINK ListBase}
    @{" ListIndex            " LINK ListIndex}
    @{" NextElement          " LINK NextElement}
    @{" PreviousElement      " LINK PreviousElement}


  @{b}Example:@{ub}

    @{" Linked List demo " LINK "PureBasic:Examples/Sources/LinkedList.pb/Main"}

@ENDNODE


@NODE AddElement

    @{b}SYNTAX@{ub}
  AddElement(linkedlist())

    @{b}COMMAND@{ub}
  Add a new empty element after the actual position. This new element become
  the current element of the list.

@ENDNODE


@NODE ChangeCurrentElement

    @{b}SYNTAX@{ub}
  ChangeCurrentElement(linkedlist(), *NewElement)

    @{b}COMMAND@{ub}
  Change the current element of the specified list to the given *NewElement.
  The *NewElement must be a pointer to another element which exists in this
  list. This function is very useful to remember an element, and calling it
  back after doing other processing.


  Example:

    *Old_Element = @mylist()      ; Get the address of the actual element

    ResetList(mylist())           ; Doing a search loop to all elements named
    While(NextItem(mylist())      ; "John" and change them to "J"
        If mylist()\name = "John" ;
            mylist()\name = "J"   ;
        EndIf                     ;
    Wend                          ;

    ChangeCurrentElement(mylist(), *Old_Element) ; Restore our element before the search

@ENDNODE


@NODE ClearList

    @{b}SYNTAX@{ub}
  ClearList(linkedlist())

    @{b}COMMAND@{ub}
  Kill all the elements in this list and release their memory. After this
  call the list is still usable, but no more elements are in the list.

@ENDNODE


@NODE CountList

    @{b}SYNTAX@{ub}
  CountList(linkedlist())

    @{b}COMMAND@{ub}
  Count how many elements there is in the linked list. It doesn't change the
  actual current element.

@ENDNODE


@NODE FirstElement

    @{b}SYNTAX@{ub}
  FirstElement(linkedlist())

    @{b}FUNCTION@{ub}
  Change the current list element to the first list element.

@ENDNODE


@NODE InsertElement

    @{b}SYNTAX@{ub}
  InsertElement(linkedlist())

    @{b}COMMAND@{ub}
  Add a new empty element before the actual position. This new element become
  the current element of the list.

@ENDNODE


@NODE KillElement

    @{b}SYNTAX@{ub}
  KillElement(linkedlist())

    @{b}FUNCTION@{ub}
  Remove the current element from the list. After this call, the new current
  element is the element which follow or null if you've kill the last element.

@ENDNODE


@NODE LastElement

    @{b}SYNTAX@{ub}
  LastElement(linkedlist())

    @{b}FUNCTION@{ub}
  Change the current list element to the last list element.

@ENDNODE


@NODE ListBase

    @{b}SYNTAX@{ub}
  *ListBase = ListBase(linkedlist())

    @{b}FUNCTION@{ub}
  It returns the address of the list base structure ('List' on the AmigaOS)

@ENDNODE


@NODE ListIndex

    @{b}SYNTAX@{ub}
  Index = ListIndex(linkedlist())

    @{b}STATEMENT@{ub}
  Return the current list element position, considering that the first element
  is at the position 1.

@ENDNODE


@NODE NextElement

    @{b}SYNTAX@{ub}
  Result = NextElement(linkedlist())

    @{b}STATEMENT@{ub}
  Change the current list element with the next element and return its
  address or return NULL if there is no more elements.

@ENDNODE


@NODE PreviousElement

    @{b}SYNTAX@{ub}
  Result = PreviousElement(linkedlist())

    @{b}STATEMENT@{ub}
  Change the current list element with the previous element and return its
  address or return NULL if the current element was the first element.

@ENDNODE

