IdentitySet:
Filter:
Classes | Collections > Unordered

IdentitySet : Set : Collection : Object

a set according to identity
Source: Set.sc
Subclasses: OrderedIdentitySet

Description

An IdentitySet is a collection of objects, no two of which are the same object (aka. "identical"). Most of its methods are inherited (see Collection and Set classes). The contents of an IdentitySet are unordered. You must not depend on the order of items in an IdentitySet. For an ordered set, see OrderedIdentitySet.

IdentitySets are faster than Sets because testing for identity is much faster than testing for equality. Different classes may implement equality in different ways, but identity can be determined just by comparing the object addresses. This allows some methods of IdentitySet to be implemented by fast primitives.

Class Methods

Inherited class methods

Instance Methods

Adding and Removing

.add(item)

From superclass: Set

Add anObject to the IdentitySet. An object which is equal to an object already in the IdentitySet will not be added.

.remove(item)

From superclass: Set

Remove anObject from the IdentitySet.

Iteration

.do(function)

From superclass: Set

Evaluates function for each item in the IdentitySet. You must not depend on the order of items. The function is passed two arguments, the item and an integer index.

Finding an element

.findMatch(item)

From superclass: Set

Returns item if it is in the collection, otherwise returns nil.

Inherited instance methods

Undocumented instance methods

.scanFor(argKey)

Examples