E - type of elements stored in the listpublic class KeyCollectionImpl<E>
extends java.lang.Object
implements java.util.Collection<E>, java.io.Serializable, java.lang.Cloneable
GapList,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
KeyCollectionImpl.BuilderImpl<E>
Implementation of builder.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E elem)
Ensures that this collection contains the specified element (optional
operation).
|
boolean |
addAll(java.util.Collection<? extends E> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
java.util.Set<E> |
asSet()
Returns a set view of the collection.
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
boolean |
contains(java.lang.Object o)
Returns true if this collection contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this collection contains all of the elements
in the specified collection.
|
KeyCollectionImpl |
copy()
Returns a copy of this collection with all its elements.
|
KeyCollectionImpl |
crop()
Returns a copy of this collection but without elements.
|
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one.
|
GapList<java.lang.Object> |
getKeyValues(int keyIndex) |
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this collection.
|
boolean |
remove(java.lang.Object elem)
Removes a single instance of the specified element from this
collection, if it is present (optional operation).
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.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.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
<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.
|
GapList<E> |
toList()
Returns all elements contained in this collection as list.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public boolean add(E elem)
java.util.CollectionCollections 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 java.util.Collection<E>elem - element whose presence in this collection is to be ensuredpublic boolean remove(java.lang.Object elem)
java.util.Collectionremove in interface java.util.Collection<E>elem - element to be removed from this collection, if presentpublic int size()
java.util.Collectionsize in interface java.util.Collection<E>public boolean isEmpty()
java.util.CollectionisEmpty in interface java.util.Collection<E>public boolean contains(java.lang.Object o)
java.util.Collectioncontains in interface java.util.Collection<E>o - element whose presence in this collection is to be testedpublic java.util.Iterator<E> iterator()
java.util.Collectionpublic boolean addAll(java.util.Collection<? extends E> c)
java.util.CollectionaddAll in interface java.util.Collection<E>c - collection containing elements to be added to this collectionCollection.add(Object)public GapList<java.lang.Object> getKeyValues(int keyIndex)
public GapList<E> toList()
public java.lang.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 java.util.Collection<E>public <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 java.util.Collection<E>a - 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 boolean containsAll(java.util.Collection<?> c)
java.util.CollectioncontainsAll in interface java.util.Collection<E>c - collection to be checked for containment in this collectionCollection.contains(Object)public boolean removeAll(java.util.Collection<?> c)
java.util.CollectionremoveAll in interface java.util.Collection<E>c - collection containing elements to be removed from this collectionCollection.remove(Object),
Collection.contains(Object)public boolean retainAll(java.util.Collection<?> c)
java.util.CollectionretainAll in interface java.util.Collection<E>c - collection containing elements to be retained in this collectionCollection.remove(Object),
Collection.contains(Object)public java.lang.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())
toString in class java.lang.Objectpublic KeyCollectionImpl copy()
public KeyCollectionImpl crop()
public java.util.Set<E> asSet()
public void clear()
java.util.Collectionclear in interface java.util.Collection<E>public boolean equals(java.lang.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 java.util.Collection<E>equals in class java.lang.Objecto - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
Hashtablepublic int hashCode()
java.lang.Objectjava.util.Hashtable.
The general contract of hashCode is:
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 hashtables.
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 JavaTM programming language.)
hashCode in interface java.util.Collection<E>hashCode in class java.lang.ObjectObject.equals(java.lang.Object),
Hashtable