shadow:utility

Interface Set<E>

Interfaces

shadow:standard@CanIterate<E>, shadow:standard@CanIndex<E,boolean>, shadow:standard@CanIndexStore<E,boolean>

interface Set<E>

Interface Set<E> defines the operations that a class must implement to be a set, a collection of elements. A set is used to store elements of type E. It should be possible to find elements quickly, allowing for efficient addition and retrieval. Set<E> differs from OrderedSet<E> in that an ordering of elements is not required.

See Also

Method Summary

Modifiers Return Types Method and Description
public (boolean) add(E element)

Method should add an element to the set.

public (Set<E>) clear()

Removes all elements from the set.

public readonly (boolean) contains(E element)

Method should check whether the set contains a matching element.

public readonly (boolean) isEmpty()

Method should check whether or not the set map is empty.

public (boolean) remove(E element)

Method should remove an element from the set.

Property Summary

Modifiers Return Types Method and Description
public readonly get (int) size()

Property should get the number of elements stored in the set as an int.

public readonly get (long) sizeLong()

Property should get the number of elements stored in the set as a long.

Method Detail

add

public add(E element) => (boolean)

Method should add an element to the set. Since sets are usually organized by elements, this operation should be efficient, running in either constant or logarithmic time, depending on the implementation.

Parameters

element - element to add

Returns

true if element was not already present in the set

clear

public clear() => (Set<E>)

Removes all elements from the set. This operation should run in constant time.

Returns

set after being cleared

contains

public readonly contains(E element) => (boolean)

Method should check whether the set contains a matching element. Since sets are usually organized by elements, this operation should be efficient, running in either constant or logarithmic time, depending on the implementation.

Parameters

element - element to search for

Returns

true if element is found

isEmpty

public readonly isEmpty() => (boolean)

Method should check whether or not the set map is empty.

Returns

true if the set is empty

remove

public remove(E element) => (boolean)

Method should remove an element from the set. Since sets are usually organized by elements, this operation should be efficient, running in either constant or logarithmic time, depending on the implementation.

Parameters

element - element to remove

Returns

true if element was present in the set and has been successfully removed

Property Detail

size

public readonly get size() => (int)

Property should get the number of elements stored in the set as an int.

Returns

size of the set

sizeLong

public readonly get sizeLong() => (long)

Property should get the number of elements stored in the set as a long.

Returns

size of the set