# list class Abstracts a double linked list of strings
Inherits
object
Description
This object class abstracts a double linked list of strings. You can insert/remove items by zero based position, at the end (tail) or at the beginning (head). The items can be sorted by using the $sort() function (quicksort algorithm). The list incorporates an efficient iteration method by using the $first(),$last(), $next(),$prev(), $current() and $canIterate() functions.
        %Nicknames = $new(list,0,mylist)
        %Nicknames->$append(Crocodile,Pragma,Number1,Kristoff,alch3m1st)
        %nick = %Nicknames->$first();
        while(%Nicknames->$canIterate())
        {
            msg %nick Hello!
            %nick = %Nicknames->$next()
        }
        delete %Nicknames;
Functions
`$count()`
Returns the number of strings stored in the list
`$isEmpty()`
Returns '1' if there are no items stored in the list , '0' otherwise.
`$insert(<index>,<string>)`
Inserts the <string> at (zero based) position <index> in the list.
`$at(<index>)`
Returns the string at (zero based) position <index>, or an empty string if there is no item at position <index>. Note: since empty strings are valid inside the list, there is no implicit method to know if the returned empty string is a valid one or it has been returned because <index> was out of range. You have to explicitly check <index> before.
`$remove(<index>)`
Removes the string at (zero based) position <index>. Does nothing if <index> is out of range.
`$append(<string_list>)`
Appends the items in the <string_list> to this list. <string_list> is expected to be a comma separated list of strings:
        %MyList->$append(Item1,Item2,Item3,%ListOfItems[])
`$prepend(<string_list>)`
Prepends the items in the <string_list> to this list. <string_list> is expected to be a comma separated list of strings:
        %MyList->$prepend(%LastNick,Pragma,%Nicknames[],[Pragma])
`$removeFirst()`
Removes the first item in the list. Does nothing if the list is empty.
`$removeLast()`
Removes the last item in the list. Does nothing if the list is empty.
`$first()`
Returns the first item in the list or an empty string if the list is empty. Moves the "current item" to the first item in the list.
`$last()`
Returns the last item in the list or an empty string if the list is empty. Moves the "current item" to the last item in the list.
`$prev()`
Moves the "current item" to the previous item and returns it. If the "current item" is no longer valid (if you've ran past the head of the list) the returned string is empty.
`$next()`
Moves the "current item" to the next item and returns it. If the "current item" is no longer valid (if you've ran past the tail of the list) the returned string is empty.
`$current()`
Returns the "current item". The returned string is empty if the current item is not valid (eg. poiting past the tail or head of the list).
`$canIterate()`
Returns '1' if the "current item" is valid (eg. points to an item in the list).
`$clear()`
Removes all the strings from the list.
`$sort()`
Sorts the list in case insensitive alphabetic order.
`$find(<string>)`
Returns the zero-based index of the first occurente of <string> in the list or -1 if the <string> is not in the list at all.

Index, Object Classes

KVIrc 3.2.0 Documentation
Generated by root at Tue Dec 4 07:16:18 2007