Alpha Release of the Collection Library for GNU Objective-C WARNING: This library has not been tested, and I would be surprised if it were usable at this point. I am making it public now in order to get feedback on design issues. ------------------------------------------------------------------ * Where can you get it? By anonymous ftp at iesd.auc.dk:pub/ObjC/libcoll-??????.tar.z, where ?????? is some string of numbers specifying its date. ------------------------------------------------------------------ * What is the Collection library? It's a library of Objective-C objects with similar functionality to Smalltalk's Collection objects. It includes: Set, Bag, Array, LinkedList, LinkList, CircularArray, Queue, Stack, SortedArray, MappedCollector, GapArray and DelegateList. Outside of its main heirarchy it also includes List, HashTable and Storage objects compatible with NeXT's objects of the same name. The library is built around several protocols: Here are some explanatory comments from the protocol .h files: The <Collecting> protocol is root of the collection protocol heirarchy. The <Collecting> protocol defines the most general interface to a collection of elements. Elements can be added, removed, and replaced. The contents can be tested, enumerated, and copied with various modifications. Elements may be objects, or any C type included in the "elt" union given below, but all elements of a collection must be of the same C type. [NOTE: for examples see Set and Bag.] The <KeyedCollecting> protocol inherits from the <Collecting> protocol. The <KeyedCollecting> protocol defines the interface to a collection of elements that are accessible by a key, where the key is some unique element. Pairs of (key element, content element) may be added, removed and replaced. The the key and value contents may be tested, enumerated and copied. [NOTE: for examples see Dictionary and MappedCollector.] The <IndexedCollecting> protocol inherits from the <KeyedCollecting> protocol. The <IndexedCollecting> protocol defines the interface to a collection of elements that are accessible by a key that is an index, where the indeces in a collection are a contiguous series of unsigned integers beginning at 0. This is the root of the protocol heirarchy for all collections that hold their elements in some order. Elements may be accessed, inserted, replaced and removed by their index. [NOTE: for examples see Array and LinkList.] The <ComparedCollecting> protocol inherits from the <IndexedCollecting> protocol. The <ComparedCollecting> protocol defines the interface to a collection of elements whose sequence is affected by some comparison operator. [NOTE: for an example see SortedArray.] The <ListLinking> protocol defines the interface to an object that may be an element in a LinkList. LinkList is a collection object based on a doubly linked list. [NOTE: for an example see ListLink.] Here is the object inheritance heirarchy. All collection abtract superclasses (classes which are not usable without subclassing) end with "Collection"; all protocols end with "ing"; all collection protocols end with "Collecting". Collection <Collecting> Set Bag KeyedCollection <KeyedCollecting> Dictionary MappedCollector IndexedCollection <IndexedCollecting> Array Stack GapArray CircularArray Queue SortedArray <ComparedCollecting> LinkList LinkedList ListLink <ListLinking> EltListLink DelegateList HashTable List Storage ------------------------------------------------------------------ * The design philosophy. Objective C is not Smalltalk. Differences that matter to the Collection heirarchy: - There can be only one set of argument types with each selector. (For instance in Objective C we can't have "-(double)data" and "-(char)data". I can't stand it when some library that I'm forced to load already defines a selector that I want to use with different types.) This isn't an issue in Smalltalk because everything is an object. * I make the Collection method names a little more descriptive, while keeping them close to Smalltalk. (For instance I think there is a good reason for using "-addObject:" instead of "-add:") - We will want collections of int's, float's, and other non-Objects. Using Objective C wrappers around these C primitive types (i.e. Integer and Float objects) is not an efficient enough option for all cases. * We could create two parallel heirarchies, one for Objects and one for elements passed as void*, but since so much of the functionality overlaps, I have merged them, and it doesn't actually look all that bad. - Objective C doesn't have Smalltalk Blocks. * Passing selectors and pointers to functions are both reasonable substitutes. I make both options available. They are distinguished as "-detectByCalling:" and "-detectByPerforming:", for example. - Smalltalk does automatic garbage collection; Objective C doesn't. * I think it should be made obvious which methods allocate a new object. Hence "-shallowCopyAs:[Bag class]" instead of "as:[Bag class]", and "-shallowCopySelect..." instead of "-select...". - We have usable Collection classes (Set, Bag, Array, etc) with functionality matching Smalltalk's objects, but there are good reasons for not having the abstract superclass structure match Smalltalk exactly. ------------------------------------------------------------------ * If you have any suggestions or bug reports, please contact: R. Andrew McCallum ARPA: mccallum@cs.rochester.edu Computer Science Department UUCP: uunet!cs.rochester.edu!mccallum University of Rochester VOX: (716) 275-2527 Rochester, NY 14627-0226 FEET: CSB Rm. 625
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.