Chapter 8


Defining a New Collection Class

Every collection class must provide an implementation of the iteration protocol. A method on forward-iteration-protocol is required. A method on backward-iteration-protocol is optional.

Every collection must provide or inherit methods for element and key-test. If the collection is also a <mutable-collection>, it must provide or inherit a method for element-setter. A collection that is not a <mutable-collection> must provide an implementation of type-for-copy.

Individual collection classes may impose further requirements on their subclasses. For example, concrete subclasses of <table> must provide or inherit a method for table-protocol.

For efficiency, it may be desirable to provide specialized implementations for certain generic functions. Collections that can implement functions such as size or member? more efficiently should do so. Sequences that can reuse storage to implement functions such as reverse! and sort! should do so.