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.
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. |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly get |
(int) |
size() Property should get the number of elements stored in the set as an |
public readonly get |
(long) |
sizeLong() Property should get the number of elements stored in the set as a |
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.
element
- element to add
true
if element was not already present in the set
public clear() => (Set<E>)
Removes all elements from the set. This operation should run in constant time.
set after being cleared
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.
element
- element to search for
true
if element is found
public readonly isEmpty() => (boolean)
Method should check whether or not the set map is empty.
true
if the set is empty
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.
element
- element to remove
true
if element was present in the set and has been successfully removed