Interface COM.odi.util.Collection
- public interface Collection
This is the COM.odi.util version of java.util.Collection,
which will be generally available in the JDK 1.2. At that
time, COM.odi.util.Collection will be obsoleted, in favor
of the interface in java.util.Collection.
Additional information about collections
is in the user guide.
-
add(Object)
- Ensures that this Collection contains the specified element
(optional operation).
-
addAll(Collection)
- Adds all of the elements in the specified Collection to this
Collection (optional operation).
-
clear()
- Removes all of the elements from this Collection (optional
operation).
-
contains(Object)
- Returns true if this Collection contains the specified element.
-
containsAll(Collection)
- Returns true if this Collection contains all of the elements in
the specified Collection.
-
equals(Object)
- Compares the specified Object with this Collection for
equality.
-
hashCode()
- Returns the hash code value for this Collection.
-
isEmpty()
- Returns true if this Collection contains no elements.
-
iterator()
- Returns an Iterator over the elements in this Collection.
-
remove(Object)
- Removes a single instance of the specified element from this
Collection, if it is present (optional operation).
-
removeAll(Collection)
- Removes from this Collection all of its elements that are
contained in the specified Collection (optional operation).
-
retainAll(Collection)
- Retains only the elements in this Collection that are contained
in the specified Collection (optional operation).
-
size()
- Returns the number of elements in this Collection.
-
toArray()
- Returns an array containing all of the elements in this
Collection.
size
public abstract int size()
- Returns the number of elements in this Collection.
isEmpty
public abstract boolean isEmpty()
- Returns true if this Collection contains no elements.
contains
public abstract boolean contains(Object o)
- Returns true if this Collection contains the specified element.
More formally, returns true if and only if this Collection
contains at least one element
e
such that
(o==null ? e==null : o.equals(e))
.
- Parameters:
- o - element whose presence in this Collection is to be tested.
iterator
public abstract Iterator iterator()
- Returns an Iterator over the elements in this Collection.
There are no guarantees concerning the order in which the
elements are returned (unless this Collection is an instance of
some class that provides a guarantee).
toArray
public abstract Object[] toArray()
- Returns an array containing all of the elements in this
Collection. If the 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. The returned array
will be "safe" in that no references to it are maintained by
the Collection. (In other words, this method must allocate a
new array even if the 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.
add
public abstract boolean add(Object o)
- Ensures that this Collection contains the specified element
(optional operation). Returns true if the Collection changed
as a result of the call. (Returns false if this Collection
does not permit duplicates and already contains the specified
element.) Collections that support this operation may place
limitations on what elements may be added to the 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.
- Parameters:
- o - element whose presence in this Collection is to be ensured.
- Returns:
- true if the Collection changed as a result of the call.
- Throws: UnsupportedOperationException
- add is not supported by this
Collection.
- Throws: ClassCastException
- class of the specified element
prevents it from being added to this Collection.
- Throws: IllegalArgumentException
- some aspect of this element prevents
it from being added to this Collection.
remove
public abstract boolean remove(Object o)
- Removes a single instance of the specified element from this
Collection, if it is present (optional operation). More
formally, removes an element
e
such that
(o==null ? e==null : o.equals(e))
, if the
Collection contains one or more such elements. Returns true if
the Collection contained the specified element (or
equivalently, if the Collection changed as a result of the
call).
- Parameters:
- o - element to be removed from this Collection, if present.
- Returns:
- true if the Collection changed as a result of the call.
- Throws: UnsupportedOperationException
- remove is not supported
by this Collection.
containsAll
public abstract boolean containsAll(Collection c)
- Returns true if this Collection contains all of the elements in
the specified Collection.
addAll
public abstract boolean addAll(Collection c)
- Adds all of the elements in the specified Collection to this
Collection (optional operation). The behavior of this
operation is undefined if the specified Collection is modified
while the operation is in progress. (This implies that the
behavior of this call is undefined if the the specified
Collection is this Collection, and this Collection is
nonempty.)
- Parameters:
- c - elements to be inserted into this Collection.
- Returns:
- true if this Collection changed as a result of the call.
- Throws: UnsupportedOperationException
- addAll is not supported
by this Collection.
- Throws: ClassCastException
- class of an element of the specified
Collection prevents it from being added to this Collection.
- Throws: IllegalArgumentException
- some aspect of an element of
the specified Collection prevents it from being added to
this Collection.
removeAll
public abstract boolean removeAll(Collection c)
- Removes from this Collection all of its elements that are
contained in the specified Collection (optional operation).
- Parameters:
- c - elements to be removed from this Collection.
- Returns:
- true if this Collection changed as a result of the call.
- Throws: UnsupportedOperationException
- removeAll is not supported
by this Collection.
retainAll
public abstract boolean retainAll(Collection c)
- Retains only the elements in this Collection that are contained
in the specified Collection (optional operation). In other
words, removes from this Collection all of its elements that
are not contained in the specified Collection.
- Parameters:
- c - elements to be retained in this Collection.
- Returns:
- true if this Collection changed as a result of the call.
- Throws: UnsupportedOperationException
- retainAll is not supported
by this Collection.
clear
public abstract void clear()
- Removes all of the elements from this Collection (optional
operation). The Collection will be empty after this call
returns (unless it throws an exception).
- Throws: UnsupportedOperationException
- clear is not supported
by this Collection.
equals
public abstract boolean equals(Object o)
- Compares the specified Object with this Collection for
equality. While Collection adds no stipulations to the general
contract for Object.equals, programmers who impelement
Collection "directly" (in other words, create a class that is a
Collection but is not a Set or a List) must exercise care if
they choose to override Object.equals. It is not necessary do
so, and the simplest course of action is to rely on Object's
implementation, but the implementer may wish to implement a
"value comparison" in place of the default "reference
comparison." (Lists and Sets mandate such value comparisons.)
The general contract for Object.equals states that equals must
be reflexive (in other words,
a.equals(b)
if and
only if b.equals(a)
). The contracts for
List.equals and Set.equals state that Lists are only equal to
other Lists, and Sets to other Sets. Thus, a custom equals
method for a Collection that is neither a List nor a Set must
return false when this Collection is compared to any List or
Set.
- Parameters:
- o - Object to be compared for equality with this Collection.
- Returns:
- true if the specified Object is equal to this Collection.
- Overrides:
- equals in class Object
hashCode
public abstract int hashCode()
- Returns the hash code value for this Collection. While
Collection adds no stipulations to the general contract for
Object.hashCode, programmers should take note that any class
that overrides Object.equals must also override
Object.hashCode, in order to satisfy the general contract for
Object.hashCode. In particular,
c1.equals(c2)
implies that c1.hashCode()==c2.hashCode()
.
- Overrides:
- hashCode in class Object
Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.