public static class ShortSets.Singleton extends AbstractShortSet implements Serializable, Cloneable
This class may be useful to implement your own in case you subclass a type-specific set.
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAll(Collection<? extends Short> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
boolean |
addAll(ShortCollection c)
Adds all elements of the given type-specific collection to this
collection.
|
Object |
clone()
Creates and returns a copy of this object.
|
boolean |
contains(short k)
Returns
true if this collection contains the specified element. |
ShortListIterator |
iterator()
Returns an iterator over the elements contained in this collection.
|
boolean |
remove(short k)
Removes an element from this set.
|
boolean |
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
boolean |
removeAll(ShortCollection c)
Remove from this collection all elements in the given type-specific
collection.
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(ShortCollection c)
Retains in this collection only elements from the given type-specific
collection.
|
int |
size()
Returns the number of elements in this collection.
|
equals, hashCode, remadd, add, contains, containsAll, remove, toArray, toShortArray, toShortArray, toStringclear, containsAll, isEmpty, toArray, toArrayadd, containsAll, toArray, toShortArray, toShortArrayforEach, forEachclear, containsAll, isEmpty, spliterator, toArray, toArrayparallelStream, removeIf, streampublic boolean contains(short k)
AbstractShortCollectiontrue if this collection contains the specified element.
This implementation iterates over the elements in the collection, looking for the specified element.
contains in interface ShortCollectioncontains in class AbstractShortCollectionCollection.contains(Object)public boolean remove(short k)
AbstractShortSet
Note that the corresponding method of a type-specific collection is
rem(). This unfortunate situation is caused by the clash with the
similarly named index-based method in the List
interface. Delegates to the type-specific rem() method
implemented by type-specific abstract Collection
superclass.
remove in interface ShortSetremove in class AbstractShortSetCollection.remove(Object)public ShortListIterator iterator()
java.util.AbstractCollectioniterator in interface ShortCollectioniterator in interface ShortIterableiterator in interface ShortSetiterator in interface Iterable<Short>iterator in interface Collection<Short>iterator in interface Set<Short>iterator in class AbstractShortSetIterable.iterator()public int size()
java.util.Collectionsize in interface Collection<Short>size in interface Set<Short>size in class AbstractCollection<Short>public boolean addAll(Collection<? extends Short> c)
java.util.AbstractCollectionThis implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).
addAll in interface Collection<Short>addAll in interface Set<Short>addAll in class AbstractCollection<Short>c - collection containing elements to be added to this collectionAbstractCollection.add(Object)public boolean removeAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.
removeAll in interface Collection<Short>removeAll in interface Set<Short>removeAll in class AbstractCollection<Short>c - collection containing elements to be removed from this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean retainAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll in interface Collection<Short>retainAll in interface Set<Short>retainAll in class AbstractCollection<Short>c - collection containing elements to be retained in this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean addAll(ShortCollection c)
ShortCollectionaddAll in interface ShortCollectionaddAll in class AbstractShortCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)public boolean removeAll(ShortCollection c)
ShortCollectionremoveAll in interface ShortCollectionremoveAll in class AbstractShortCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)public boolean retainAll(ShortCollection c)
ShortCollectionretainAll in interface ShortCollectionretainAll in class AbstractShortCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)public Object clone()
java.lang.Objectx, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except
Object) obey this convention, it will be the case that
x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone for class Object performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable, then a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable and that
the return type of the clone method of an array type T[]
is T[] where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time.