An identity set implemented as a hash set stored in an Array of singly linked lists. The hash code of an element is defined by identityHash(). Note that an IdentitySet is not a Set, since it does not obey the semantics of a Set. In particular, it may contain multiple elements which are equal, as determined by the == operator.

By: Gavin King

no subtypes hierarchy

IdentitySet(Hashtable hashtable = ..., {Element*} elements = ...)
  • hashtable = Hashtable()

    Performance-related settings for the backing array.

  • elements = {}

    The initial elements of the set.

hashSource Codeshared actual Integer hash

The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that:

  • if x==y then x.hash==y.hash.

Therefore, a class which refines equals must also refine hash.

Refines Identifiable.hash ultimately refines Object.hash
sizeSource Codeshared actual Integer size

The number of elements returned by the iterator of this stream, if the iterator terminates. In the case of an infinite stream, this operation never terminates.

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Collection<Element>
Attributes inherited from: Iterable<Element,Absent>
addSource Codeshared Boolean add(Element element)
addAllSource Codeshared Boolean addAll({Element*} elements)
clearSource Codeshared void clear()

Removes every element

cloneSource Codeshared actual IdentitySet<Element> clone()

A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned.

complementSource Codeshared IdentitySet<Element> complement<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
containsSource Codeshared actual Boolean contains(Object element)

Returns true if the given value belongs to this Category, that is, if it is an element of this Category, or false otherwise.

For most Categorys the following relationship is satisfied by every pair of elements x and y:

  • if x==y, then x in category == y in category

However, it is possible to form a useful Category consistent with some other equivalence relation, for example ===. Therefore implementations of contains() which do not satisfy this relationship are tolerated.

Refines Iterable.contains ultimately refines Category.contains
countSource Codeshared actual Integer count(Boolean selecting(Element element))

Produces the number of elements in this stream that satisfy the given predicate function (selecting). For an infinite stream, this method never terminates.

equalsSource Codeshared actual Boolean equals(Object that)

Determine if two values are equal. Implementations should respect the constraints that:

  • if x===y then x==y (reflexivity),
  • if x==y then y==x (symmetry),
  • if x==y and y==z then x==z (transitivity).

Furthermore it is recommended that implementations ensure that if x==y then x and y have the same concrete class.

A class which explicitly refines equals() is said to support value equality, and the equality operator == is considered much more meaningful for such classes than for a class which simply inherits the default implementation of identity equality from Identifiable.

Refines Identifiable.equals ultimately refines Object.equals
exclusiveUnionSource Codeshared IdentitySet<Element|Other> exclusiveUnion<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
intersectionSource Codeshared IdentitySet<Element&Other> intersection<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
iteratorSource Codeshared actual Iterator<Element> iterator()

An iterator for the elements belonging to this stream.

removeSource Codeshared Boolean remove(Element element)
removeAllSource Codeshared Boolean removeAll({Element*} elements)
subsetSource Codeshared default Boolean subset<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
supersetSource Codeshared default Boolean superset<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
unionSource Codeshared IdentitySet<Element|Other> union<Other>(IdentitySet<Other> set)
given Other satisfies Identifiable
Inherited Methods
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Iterable<Element,Absent>