|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
The minimum requirements of the collection class implementation is as follow:
This makes iterator methods such as
filter to work.
In order to make the constructive methods (e.g.
create your collection), you have to implement
method as well. Note that
call-with-builder method must work
a sort of class method, dispatched by class, rather than normal method
dispatched by instance. In Gauche, you can implement it by using a
metaclass. Then the minimal code will look like this:
(define-class <your-collection-meta> (<class>) ()) (define-class <your-collection> (<collection>) (...) ;; slots :metaclass <your-collection-meta>) (define-method call-with-iterator ((coll <your-collection>) proc . options) ... ) (define-method call-with-builder ((coll <your-collection-meta>) proc . options) ... )
Optionally, you can overload other generic functions to optimize performance.