Implementing the Iterator Design Pattern in Lisp: Specification

Internal Iterators

(map-over f collection) -> collection

Maps function over collection. Returns collection.

External Iterators

(make-cursor-for collection) -> cursor

Creates a cursor for collection; a cursor is a function which returns an element from a collection each time it is called, until there are no elements left.

(cursor-next cursor) -> element, finishedp

Returns the next element in cursor's collection. finishedp will be t if the cursor is finished. If the cursor was already finished before cursor-next was called, the value of element will be nil.

(cursor-finished-p cursor) -> boolean

Returns t if cursor is finished, nil otherwise.

Simple Childed collections

simple-childed-mixin

Class representing simple collections, where the elements of the collection are called "children" of the collection. Children are accessible only using the functions provided for manipulating the set of children. Any given element can appear only once within a given collection; in order to establish that a new child is unique, it will be compared with existing children using eql.

(add-child cursor) -> boolean

Returns t if cursor is finished, nil otherwise.

(delete-child cursor) -> boolean

Returns t if cursor is finished, nil otherwise.

(delete-child-if cursor) -> boolean

Returns t if cursor is finished, nil otherwise.

Authors: Gail Anderson (ga@cley.com), Tim Bradshaw(tfb@cley.com), Cley Limited.
Copyright 1999–2003 Cley Ltd. & Franz Inc.