date: 2019/08/12 08:48:19
- user: cg
- file: MappedCollection.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Claus Gittinger
MappedCollections represent collections of objects that are indirectly indexed by names.
There are really two collections involved: domain and a map.
The map maps between external names and indices into domain,
which contains the real association.
In order to work properly, the domain and map objects must
be instances of a subclass of SequenceableCollection or Dictionary.
The valueDomain of the map must be the keyDomain of the domain collection.
mappedCollection at:k ==> domain at:(map at:k)
collection: domainCollection map: mapCollection
return a new MappedCollection
report an error; mappedCollections may not be created using new
adding & removing
retrieve an element
at: key put: anObject
store an element
return the contents as a bag
report an error; mappedCollections cannot add elements (without a key)
evaluate the argument, aBlock for each element
setCollection: domainCollection map: mapCollection
return true if the receiver cannot grow
return the number of elements in the receiver
return the type of collection to be returned by collect, select etc.
like species, but redefined for collections which cannot grow easily.
Used by functions which create a growing collection
(see collect:with:, for example)
keyMapping := Dictionary new
mapped := MappedCollection
collection:#(one two three four)
mapped select:[:each| each ~= 'two']