|
|
6.73 HashedCollection
- Defined in namespace Smalltalk
- Category: Collections-Unordered
- I am an hashed collection that can store objects uniquely and
give fast responses on their presence in the collection.
6.73.1 HashedCollection class: instance creation
- new
- Answer a new instance of the receiver with a default size
- new: anInteger
- Answer a new instance of the receiver with the given size
6.73.2 HashedCollection: accessing
- add: newObject
- Add newObject to the set, if and only if the set doesn't already contain an occurrence of it. Don't fail if a duplicate is found. Answer anObject
- at: index
- This method should not be called for instances of this class.
- at: index put: value
- This method should not be called for instances of this class.
6.73.3 HashedCollection: builtins
- primAt: anIndex
- Private - Answer the anIndex-th item of the hash table for the receiver. Using this instead of basicAt: allows for easier changes in the representation
- primAt: anIndex put: value
- Private - Store value in the anIndex-th item of the hash table for the receiver. Using this instead of basicAt:put: allows for easier changes in the representation
- primSize
- Private - Answer the size of the hash table for the receiver. Using this instead of basicSize allows for easier changes in the representation
6.73.4 HashedCollection: copying
- deepCopy
- Returns a deep copy of the receiver (the instance variables are copies of the receiver's instance variables)
- shallowCopy
- Returns a shallow copy of the receiver (the instance variables are not copied)
6.73.5 HashedCollection: enumerating the elements of a collection
- do: aBlock
- Enumerate all the non-nil members of the set
6.73.6 HashedCollection: rehashing
- rehash
- Rehash the receiver
6.73.7 HashedCollection: Removing from a collection
- remove: oldObject ifAbsent: anExceptionBlock
- Remove oldObject to the set. If it is found, answer oldObject. Otherwise, evaluate anExceptionBlock and return its value.
6.73.8 HashedCollection: saving and loading
- postLoad
- Called after loading an object; rehash the collection because identity objects will most likely mutate their hashes.
- postStore
- Called after an object is dumped. Do nothing -- necessary because by default this calls #postLoad by default
6.73.9 HashedCollection: storing
- storeOn: aStream
- Store on aStream some Smalltalk code which compiles to the receiver
6.73.10 HashedCollection: testing collections
- = aHashedCollection
- Returns true if the two sets have the same membership, false if not
- capacity
- Answer how many elements the receiver can hold before having to grow.
- hash
- Return the hash code for the members of the set. Since order is unimportant, we use a commutative operator to compute the hash value.
- includes: anObject
- Answer whether the receiver contains an instance of anObject.
- isEmpty
- Answer whether the receiver is empty.
- occurrencesOf: anObject
- Return the number of occurrences of anObject. Since we're a set, this is either 0 or 1. Nil is never directly in the set, so we special case it (the result is always 1).
- size
- Answer the receiver's size
|