Category: Collections-Keyed
Superclass: Collection
I 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 must be an instance of a subclass of SequenceableCollection, and the map must be an instance of Dictionary, or of a subclass of SequenceableCollection. As an example of using me, consider implenting a Dictionary whose elements are indexed. The domain would be a SequenceableCollection with n elements, the map a Dictionary associating each key to an index in the domain. To access by key, to perform enumeration, etc. you would ask an instance of me; to access by index, you would access the domain directly. Another idea could be to implement row access or column access to a matrix implemented as a single n*m Array: the Array would be the domain, while the map would be an Interval.

Method category index

instance creation (class)
basic (instance)

instance creation (class)

collection: aCollection map: aMap
Answer a new MappedCollection using the given domain (aCollection) and map

new

This method should not be used; instead, use #collection:map: to create MappedCollection.

top


basic (instance)

add: anObject
This method should not be called for instances of this class.

at: key

Answer the object at the given key

at: key put: value

Store value at the given key

atAll: keyCollection

Answer a new MappedCollection that only includes the given keys. The new MappedCollection might use keyCollection or consecutive integers for the keys, depending on the map's type. Fail if any of them is not found in the map.

collect: aBlock

Answer a Collection with the same keys as the map, where accessing a key yields the value obtained by passing through aBlock the value accessible from the key in the receiver. The result need not be another MappedCollection

contents

Answer a bag with the receiver's values

copyFrom: a to: b

Answer a new collection containing all the items in the receiver from the a-th to the b-th.

do: aBlock

Evaluate aBlock for each object

domain

Answer the receiver's domain

keys

Answer the keys that can be used to access this collection.

keysAndValuesDo: aBlock

Evaluate aBlock passing two arguments, one being a key that can be used to access this collection, and the other one being the value.

keysDo: aBlock

Evaluate aBlock on the keys that can be used to access this collection.

map

Answer the receiver's map

reject: aBlock

Answer the objects in the domain for which aBlock returns false

select: aBlock

Answer the objects in the domain for which aBlock returns true

size

Answer the receiver's size

top