public abstract static class ShortCollections.EmptyCollection extends AbstractShortCollection
This class may be useful to implement your own in case you subclass a type-specific collection.
| 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.
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
boolean |
contains(short k)
Returns
true if this collection contains the specified element. |
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
int |
hashCode()
Returns a hash code value for the object.
|
ShortBidirectionalIterator |
iterator()
Returns an iterator over the elements contained in this collection.
|
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.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
add, add, contains, containsAll, rem, remove, toArray, toShortArray, toShortArray, toStringcontainsAll, isEmpty, toArraycontainsAll, isEmpty, parallelStream, removeIf, spliterator, stream, toArrayforEach, forEachpublic 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 Object[] toArray()
java.util.AbstractCollectionThe returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
This implementation returns an array containing all the elements
returned by this collection's iterator, in the same order, stored in
consecutive elements of the array, starting with index 0.
The length of the returned array is equal to the number of elements
returned by the iterator, even if the size of this collection changes
during iteration, as might happen if the collection permits
concurrent modification during iteration. The size method is
called only as an optimization hint; the correct result is returned
even if the iterator returns a different number of elements.
This method is equivalent to:
List<E> list = new ArrayList<E>(size());
for (E e : this)
list.add(e);
return list.toArray();
toArray in interface Collection<Short>toArray in class AbstractCollection<Short>public ShortBidirectionalIterator iterator()
java.util.AbstractCollectioniterator in interface ShortCollectioniterator in interface ShortIterableiterator in interface Iterable<Short>iterator in interface Collection<Short>iterator in class AbstractShortCollectionIterable.iterator()public int size()
java.util.Collectionsize in interface Collection<Short>size in class AbstractCollection<Short>public void clear()
java.util.AbstractCollectionThis implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.
clear in interface Collection<Short>clear in class AbstractCollection<Short>public int hashCode()
java.lang.ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode in interface Collection<Short>hashCode in class ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public boolean equals(Object o)
java.lang.Object
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
equals in interface Collection<Short>equals in class Objecto - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic 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 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 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 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)