public class IdentifiableSet<X extends Identifiable> extends AbstractSet<X> implements Set<X>, Cloneable
The reason for this class is that in the future it might be needed to unregister an AddOn and with this class it is easy to introduce this feature.
Constructor and Description |
---|
IdentifiableSet() |
IdentifiableSet(Set<X> set) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(X x)
Adds an Element to the Set
|
void |
clear() |
Object |
clone()
Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
|
boolean |
contains(Object o)
Returns true if this set contains the specified element.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
Iterator<X> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(Object o) |
int |
size()
Returns the number of elements in this set (its cardinality).
|
equals, hashCode, removeAll
addAll, containsAll, retainAll, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, equals, hashCode, removeAll, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public IdentifiableSet(Set<X> set)
public IdentifiableSet()
public int size()
size
in interface Collection<X extends Identifiable>
size
in interface Set<X extends Identifiable>
size
in class AbstractCollection<X extends Identifiable>
public boolean isEmpty()
isEmpty
in interface Collection<X extends Identifiable>
isEmpty
in interface Set<X extends Identifiable>
isEmpty
in class AbstractCollection<X extends Identifiable>
public boolean contains(Object o)
contains
in interface Collection<X extends Identifiable>
contains
in interface Set<X extends Identifiable>
contains
in class AbstractCollection<X extends Identifiable>
o
- element whose presence in this set is to be testedClassCastException
- if the type of the specified element
is incompatible with this set
(optional)NullPointerException
- if the specified element is null and this
set does not permit null elements
(optional)public Iterator<X> iterator()
iterator
in interface Iterable<X extends Identifiable>
iterator
in interface Collection<X extends Identifiable>
iterator
in interface Set<X extends Identifiable>
iterator
in class AbstractCollection<X extends Identifiable>
public boolean add(X x)
add
in interface Collection<X extends Identifiable>
add
in interface Set<X extends Identifiable>
add
in class AbstractCollection<X extends Identifiable>
x
- the ElementIllegalArgumentException
- if it is not allowed to put Elements without Identification in this
Setpublic boolean remove(Object o)
This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.
remove
in interface Collection<X extends Identifiable>
remove
in interface Set<X extends Identifiable>
remove
in class AbstractCollection<X extends Identifiable>
o
- the object to removeClassCastException
NullPointerException
public void clear()
This implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.
clear
in interface Collection<X extends Identifiable>
clear
in interface Set<X extends Identifiable>
clear
in class AbstractCollection<X extends Identifiable>
Copyright © 2016. All rights reserved.