Category: Collections-Unordered
Superclass: Collection
I am an hashed collection that can store objects uniquely and give fast responses on their presence in the collection.

Method category index

instance creation (class)
accessing (instance)
builtins (instance)
copying (instance)
enumerating the elements of a collection (instance)
rehashing (instance)
removing (instance)
saving and loading (instance)
storing (instance)
testing collections (instance)

instance creation (class)

new
Answer a new instance of the receiver with a default size

new: anInteger

Answer a new instance of the receiver with the given capacity

withAll: aCollection

Answer a collection whose elements are all those in aCollection

top


accessing (instance)

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.

top


builtins (instance)

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

top


copying (instance)

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)

top


enumerating the elements of a collection (instance)

do: aBlock
Enumerate all the non-nil members of the set

top


rehashing (instance)

rehash
Rehash the receiver

top


removing (instance)

remove: oldObject ifAbsent: anExceptionBlock
Remove oldObject from the set. If it is found, answer oldObject. Otherwise, evaluate anExceptionBlock and answer its value.

top


saving and loading (instance)

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

top


storing (instance)

storeOn: aStream
Store on aStream some Smalltalk code which compiles to the receiver

top


testing collections (instance)

= 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

top