Zippy-Egoboo Home EgoWiki > Documentation > MakingZippyObjects > ZippyLists EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }

Lists in Zippy

The Zippy engine exposes its linked list implementation to scripts. Lists may be instantiated as follows:

list = List([args, ...])

If arguments are passed to the List constructor, they are added to the list in the order they appear. Lists provide the following member functions:

first()
Returns an iterator to the first item in the list.
last()
Returns an iterator to the last item in the list. add_after(iter, data): Adds "data" to the list after the iterator "iter". Returns an iterator to the newly added item. If "iter" is nil, the new item is added at the beginning of the list.
remove_after(iter)
Removes the item after "iter" in the list, or the first item if "iter" is nil.
count()
Returns the number of items in the list. find(target, cmp_func): Calls cmp_func(item, target) on each item in the list, where "item" is the item at that position and "target" is the argument passed to the find() method. Returns an iterator to the first item for which cmp_func() returns non-nil, or nil if no such item exists in the list. find_before(target, cmp_func): Same as find(), but returns an iterator to the previous item. This means that the return value is nil if the first item matches.

Iterators

Iterators are created only by member functions of Lists. They have the following members:

valid()
Returns non-nil if the iterator points to a valid position in a list.
advance()
Advances the iterator to the next item in the list.
data
The data pointed to by the iterator.

-- ElminI - 03 Feb 2004

Topic ZippyLists . { Edit | Attach | Ref-By | Printable | Diffs | r1.1 | More }
Revision r1.1 - 03 Feb 2004 - 05:18 GMT - ElminI
Parents: WebHome > MakingZippyObjects
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.