Squeak Class Documentation category index | class index  
 
Set
  category: Collections-Unordered
  superclass: Collection
  subclasses: Dictionary IdentitySet PluggableSet WeakSet

No comment. Sorry.

instance methods
  accessing
  atRandom:
capacity
like:
size
someElement

  adding
  add:
add:withOccurrences:

  converting
  asSet

  copying
  copy

  enumerating
  collect:
do:
doWithIndex:

  objects from disk
  comeFullyUpOnReload:

  private
  array
atNewIndex:put:
findElementOrNil:
fixCollisionsFrom:
fullCheck
grow
growSize
init:
keyAt:
noCheckAdd:
rehash
scanFor:
swap:with:
withArray:

  removing
  copyWithout:
remove:ifAbsent:

  testing
  =
hasContentsInExplorer
includes:
occurrencesOf:

class methods
  initialization
  quickRehashAllSets
rehashAllSets

  instance creation
  new
new:
newFrom:
sizeFor:

instance methods
  accessing top  
 

atRandom:

Answer a random element of the receiver. Uses aGenerator which
should be kept by the user in a variable and used every time. Use
this instead of #atRandom for better uniformity of random numbers
because only you use the generator. Causes an error if self has no
elements.


 

capacity

Answer the current capacity of the receiver.


 

like:

Answer an object in the receiver that is equal to anObject,
nil if no such object is found. Relies heavily on hash properties


 

size

Answer how many elements the receiver contains.


 

someElement

Deprecated. Use anyOne.


  adding top  
 

add:

Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.


 

add:withOccurrences:

Add newObject anInteger times to the receiver. Answer newObject.


  converting top  
 

asSet

Answer a Set whose elements are the unique elements of the receiver.


  copying top  
 

copy

Answer another instance just like the receiver. Subclasses typically
override this method; they typically do not override shallowCopy.


  enumerating top  
 

collect:

Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.


 

do:

Evaluate aBlock with each of the receiver's elements as the argument.


 

doWithIndex:

Support Set enumeration with a counter, even though not ordered


  objects from disk top  
 

comeFullyUpOnReload:

Symbols have new hashes in this image.


  private top  
 

array


 

atNewIndex:put:


 

findElementOrNil:

Answer the index of a first slot containing either a nil (indicating an empty slot) or an element that matches the given object. Answer the index of that slot or zero. Fail if neither a match nor an empty slot is found.


 

fixCollisionsFrom:

The element at index has been removed and replaced by nil.
This method moves forward from there, relocating any entries
that had been placed below due to collisions with this one


 

fullCheck

Keep array at least 1/4 free for decent hash behavior


 

grow

Grow the elements array and reinsert the old elements


 

growSize


 

init:

Initialize array to an array size of n


 

keyAt:

May be overridden by subclasses so that fixCollisions will work


 

noCheckAdd:


 

rehash

Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:


 

scanFor:

Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.


 

swap:with:

May be overridden by subclasses so that fixCollisions will work


 

withArray:

private -- for use only in copy


  removing top  
 

copyWithout:

Answer a copy of the receiver that does not contain any
elements equal to oldElement.


 

remove:ifAbsent:

Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.


  testing top  
 

=

Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.


 

hasContentsInExplorer


 

includes:

Answer whether anObject is one of the receiver's elements.


 

occurrencesOf:

Answer how many of the receiver's elements are equal to anObject.


class methods
  initialization top  
 

quickRehashAllSets

Set rehashAllSets


 

rehashAllSets

Set rehashAllSets


  instance creation top  
 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


 

new:

Create a Set large enough to hold nElements without growing


 

newFrom:

Answer an instance of me containing the same elements as aCollection.


 

sizeFor:

Large enough size to hold nElements with some slop (see fullCheck)