|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstructure5.StructCollection<E>
public class StructCollection<E>
This utility class converts a Structure to a Collection.
Users are advised to make use of the values
method
that is part of every Structure
that returns a Collection
.
This class is necessary because there are certain basic differences in the interfaces of the two classes.
This class works provides a facade: methods of the Collection interface are directly referred to the base Structure, or simple code supports the interface.
Example Usage:
public static void main(String[] argv){
Structure struct = new Vector();
for(int i = 0; i < argv.length; i++) struct.add(argv[i]);
Collection collect = new StructCollection(struct)
;
}
Constructor Summary | |
---|---|
StructCollection(Structure<E> s)
Constructs a Collection, based on the contents of the subordinate Structure object. |
Method Summary | ||
---|---|---|
boolean |
add(E o)
Add an object to the subordinate Structure, and return boolean indicating success. |
|
boolean |
addAll(Collection<? extends E> c)
Adds all the elements of another collection (c) into this Structure. |
|
void |
clear()
Remove all elements from the Structure. |
|
boolean |
contains(Object o)
Returns true iff object o is contained within the subordinate structure. |
|
boolean |
containsAll(Collection<?> c)
Returns true if all of the elements of c are contained within the subordinate structure. |
|
boolean |
equals(Object o)
Compare one StructCollection with another. |
|
int |
hashCode()
Return hash code. |
|
boolean |
isEmpty()
Detect an empty structure. |
|
Iterator<E> |
iterator()
Return an iterator to traverse the subordinate structure. |
|
boolean |
remove(Object o)
Removes an instance of object o, if it appears within structure. |
|
boolean |
removeAll(Collection<?> c)
Removes all objects found within collection c from this collection. |
|
boolean |
retainAll(Collection<?> c)
Retains elements of this Collection that are also in c. |
|
int |
size()
Determine the number of elements in this collection. |
|
Object[] |
toArray()
Construct an array of values found in the subordinate Structure. |
|
|
toArray(T[] target)
Copy elements of this structure into target array. |
|
String |
toString()
Construct a string representation of this class. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StructCollection(Structure<E> s)
Method Detail |
---|
public boolean add(E o)
add
in interface Collection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
public void clear()
clear
in interface Collection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
public boolean equals(Object o)
equals
in interface Collection<E>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in class Object
public boolean isEmpty()
isEmpty
in interface Collection<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
public boolean remove(Object o)
remove
in interface Collection<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
public int size()
size
in interface Collection<E>
public Object[] toArray()
toArray
in interface Collection<E>
public <T> T[] toArray(T[] target)
toArray
in interface Collection<E>
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |