II. Collections Library

1. Dependencies

Following are the other header files imported by <collections.h>:

#import <defobj.h>

The collections library follows the library interface conventions of the defobj library. It also depends on standard supertypes and classes defined by this library. Initialization of the collections library automatically initializes the defobj library as well. Since defobj also requires the collections library, both must always be linked into an application together.

2. Compatibility

No explicit incompatibilites for particular versions of Swarm

3. Usage Guide

This section of documentation is not yet available. In the meantime, see the GridTurtle test programs for the most complete examples of collections library usage. If you can't find an example there that exercises a message or option that you want to use, chances are it's not implemented.

5. Subclassing Reference

Until the collections library has been fully implemented, subclassing conventions from collections implementation classes are still in flux. In general, these classes will be among the most complex uses of multiple classes selected to implement an independent object type. (See library definition conventions for a summary of the distinction between types and classes.) New methods are being developed to simplify subclassing from such implementations. In the meantime, if you need to use to a collection within the implementation of your own class, just put an instance variable in your class and put the collection in that, and pass through the messages of the collection you want to have available on your class to this variable. In many if not most cases, this is better design anyway, because you control all use of the underlying structure.

6. Interface Design Notes

A collections library is one of the most important foundation services for object-oriented programming. Most object-oriented systems provide at least the start of a general-purpose collections library. The GNUSTEP, project, for example, provides the libobject library (currently in alpha test at ftp://alpha.prep.ai.mit.edu/) which includes a collections library along with other services intended to parallel those of the OpenStep framework developed by Next.

Swarm has implemented its own collection library to meet the specialized needs of its agent simulation framework.

Table of Contents
ArchiverArray --  Array encapsulation for serialization.
ArchiverKeyword --  Keyword encapsulation for serialization.
ArchiverList --  Archiver list encapsulation for serialization.
ArchiverPair --  List pair encapsulation for serialization.
ArchiverQuoted --  Archiver serialization object for (quote x) or 'x
ArchiverValue --  Value encapsulation for serialization.
Array --  Collection supporting access only by relative position.
Collection --  A generic collection interface.
CompareFunction --  Interface for defining the compare function to use when comparing to members in a collection.
DefaultMember --  Methods for setting and getting the default member in a collection.
ForEach --  Messages for performing the same message on objects in a collection.
ForEachKey --  Exactly the same as the ForEach protocol, but only for KeyedCollections.
Index --  Reference into the enumeration sequence for a collection.
InputStream --  Stream of input data.
KeyedCollection --  Member identity definition shared by Set and Map types.
KeyedCollectionIndex --  Index behavior shared by Set and Map types.
List --  Collection of members in an externally assigned linear sequence.
ListIndex --  Index with insertion capability at any point in list.
ListShuffler --  A class to randomize the order of a given Swarm List
Map --  Collection of associations from key objects to member objects.
MapIndex --  The index behavior for a Map.
MemberBlock --  A way to wrap an existing C array for access as an object collection.
MemberSlot --  Allocation in member/key for fast setMember:/setKey:
Offsets --  Methods for accessing collection members by position.
OrderedSet --  A set of members in an externally assigned linear sequence.
OutputStream --  Stream of output bytes.
Permutation --  A class that represents a permutation of elements of a collection
PermutationItem --  An element of a Permutation
PermutedIndex --  General PermutedIndex class.
Set --  Collection of members each having a defined identity.
String --  Character string object (later to support collection behavior).
General --  Standard collection types

Documentation and Implementation Status

The collections library has an almost complete set of Interface Reference documents, and the design of the interface is almost entirely final. The implementation of the collections library, however, doesn't yet implement many of the more advanced features of this interface.

Collections library development has concentrated on the specific features needed by the activity library. This library uses collections for its underlying support of actions to be executed in schedules. The collections library itself is still being completed for use as a general-purpose library.

The Array and List types have all basic capability fully implemented. Set and Map have basic messages defined, but currently rely on a crude implementation based on sorted lists. (This implementation is more than adequate for the usually small and relatively static schedule structures in the activity library, and is the most forgiving when change does take place within members being traversed.) Much more efficient implementations based on both balanced trees and hash tables are in the works.

OrderedSet is currently supported only with the low-level option for an internal member slot, and the implemented messages do not match the ones documented in the Interface Reference. Support for groups of duplicate members is missing from both Set and Map.

None of the special options for restricted usage modes on any type of collection (e.g., read-only restriction) has been implemented. Stack and Queue are not implemented, but are nothing more than restricted uses of a List. There is no support for any member type except id or smaller (other member types will depend on a data type facility to be supplied by defobj).

Even though incomplete, the portion of capability that is implemented has been exercised very heavily. The interfaces to Set and Map structures will remain the same even as their underlying implementations improve, so there is no harm in using them. See the GridTurtle test programs for the most complete examples of collections usage.

The collections library follows the documentation structure suggested by the library interface conventions of the defobj library. There are placeholders at least for each section of documentation (some of which merely indicate that the section is not available yet) so that all links should at least link up with something, whether or not there's anything there.

Throughout the documentation, a parenthesized comment that starts with (.. indicates an editorial comment on the current status of implementation or documentation.

The documentation priority for all libraries is to complete at least their interface reference documents, so that there is the equivalent of Unix "man pages" that summarize all basic capability. A second priority is to complete the complementary "Usage Guide" documents. Unlike the reference documents, the Usage Guide will have a task-oriented organization, and will lead the initial user through actual code examples in the rough order a typical user is likely to need them. It will serve the role of a tutorial on each library.

The Usage Guide code examples have not yet been developed. For the time being, a directory of test programs (GridTurtle test programs, contained within the documentation release directory) provides code examples of many of the basic features of the defobj, collections, and activity libraries. These code examples also help indicate the portions of the libraries which are fully implemented and working, since they are run on each new release of these libraries.

Revision History (collections)

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.