public static class ByteCollections.SynchronizedCollection extends Object implements ByteCollection, Serializable
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(byte k)
Ensures that this collection contains the specified element (optional
operation).
|
boolean |
add(Byte k)
Deprecated.
|
boolean |
addAll(ByteCollection c)
Adds all elements of the given type-specific collection to this
collection.
|
boolean |
addAll(Collection<? extends Byte> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
boolean |
contains(byte k)
Returns
true if this collection contains the specified element. |
boolean |
contains(Object k)
Deprecated.
|
boolean |
containsAll(ByteCollection c)
Checks whether this collection contains all elements from the given
type-specific collection.
|
boolean |
containsAll(Collection<?> c)
Returns true if this collection contains all of the elements
in the specified collection.
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
ByteIterator |
iterator()
Returns a type-specific iterator on the elements of this collection.
|
boolean |
rem(byte k)
Removes a single instance of the specified element from this collection,
if it is present (optional operation).
|
boolean |
remove(Object k)
Deprecated.
|
boolean |
removeAll(ByteCollection c)
Remove from this collection all elements in the given type-specific
collection.
|
boolean |
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
boolean |
retainAll(ByteCollection c)
Retains in this collection only elements from 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).
|
int |
size()
Returns the number of elements in this collection.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
byte[] |
toArray(byte[] a)
Returns an array containing all of the elements in this collection; the
runtime type of the returned array is that of the specified array.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this collection;
the runtime type of the returned array is that of the specified array.
|
byte[] |
toByteArray()
Returns a primitive type array containing the items of this collection.
|
byte[] |
toByteArray(byte[] a)
Deprecated.
|
String |
toString()
Returns a string representation of the object.
|
parallelStream, removeIf, spliterator, streamforEach, forEachpublic boolean add(byte k)
ByteCollectionadd in interface ByteCollectionCollection.add(Object)public boolean contains(byte k)
ByteCollectiontrue if this collection contains the specified element.contains in interface ByteCollectionCollection.contains(Object)public boolean rem(byte k)
ByteCollection
Note that this method should be called
remove(), but the clash with
the similarly named index-based method in the List
interface forces us to use a distinguished name. For simplicity, the set
interfaces reinstates remove().
rem in interface ByteCollectionCollection.remove(Object)public int size()
java.util.Collectionsize in interface Collection<Byte>public boolean isEmpty()
java.util.CollectionisEmpty in interface Collection<Byte>public byte[] toByteArray()
ByteCollectiontoByteArray in interface ByteCollectionCollection.toArray()public Object[] toArray()
java.util.CollectionThe 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.
toArray in interface Collection<Byte>@Deprecated public byte[] toByteArray(byte[] a)
ByteCollection
Note that, contrarily to Collection.toArray(Object[]), this
methods just writes all elements of this collection: no special value
will be added after the last one.
toByteArray in interface ByteCollectiona - if this array is big enough, it will be used to store this
collection.Collection.toArray(Object[])public byte[] toArray(byte[] a)
ByteCollection
Note that, contrarily to Collection.toArray(Object[]), this
methods just writes all elements of this collection: no special value
will be added after the last one.
toArray in interface ByteCollectiona - if this array is big enough, it will be used to store this
collection.Collection.toArray(Object[])public boolean addAll(ByteCollection c)
ByteCollectionaddAll in interface ByteCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)public boolean containsAll(ByteCollection c)
ByteCollectioncontainsAll in interface ByteCollectionc - a type-specific collection.true if this collection contains all elements of the
argument.Collection.containsAll(Collection)public boolean removeAll(ByteCollection c)
ByteCollectionremoveAll in interface ByteCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)public boolean retainAll(ByteCollection c)
ByteCollectionretainAll in interface ByteCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)@Deprecated public boolean add(Byte k)
ByteCollectionCollections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.
add in interface ByteCollectionadd in interface Collection<Byte>k - element whose presence in this collection is to be ensured@Deprecated public boolean contains(Object k)
ByteCollectioncontains in interface ByteCollectioncontains in interface Collection<Byte>k - element whose presence in this collection is to be tested@Deprecated public boolean remove(Object k)
ByteCollectionremove in interface ByteCollectionremove in interface Collection<Byte>k - element to be removed from this collection, if presentpublic <T> T[] toArray(T[] a)
java.util.CollectionIf this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the Collection.toArray() method, this method acts as bridge between
array-based and collection-based APIs. Further, this method allows
precise control over the runtime type of the output array, and may,
under certain circumstances, be used to save allocation costs.
Suppose x is a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array of String:
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().toArray in interface Collection<Byte>T - the runtime type of the array to contain the collectiona - the array into which the elements of this collection are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose.public ByteIterator iterator()
ByteCollection
Note that this specification strengthens the one given in
Iterable.iterator(), which was already strengthened in
the corresponding type-specific class, but was weakened by the fact that
this interface extends Collection.
iterator in interface ByteCollectioniterator in interface ByteIterableiterator in interface Iterable<Byte>iterator in interface Collection<Byte>Iterable.iterator()public boolean addAll(Collection<? extends Byte> c)
java.util.CollectionaddAll in interface Collection<Byte>c - collection containing elements to be added to this collectionCollection.add(Object)public boolean containsAll(Collection<?> c)
java.util.CollectioncontainsAll in interface Collection<Byte>c - collection to be checked for containment in this collectionCollection.contains(Object)public boolean removeAll(Collection<?> c)
java.util.CollectionremoveAll in interface Collection<Byte>c - collection containing elements to be removed from this collectionCollection.remove(Object),
Collection.contains(Object)public boolean retainAll(Collection<?> c)
java.util.CollectionretainAll in interface Collection<Byte>c - collection containing elements to be retained in this collectionCollection.remove(Object),
Collection.contains(Object)public void clear()
java.util.Collectionclear in interface Collection<Byte>public String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
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<Byte>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<Byte>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(),
HashMap