|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectau.com.zip.cs.IteratorUtil
public class IteratorUtil
Assorted static methods to do things with Iterators.
| Method Summary | |
|---|---|
static Object |
byIndex(Iterator iter,
int index)
Return the specified Object by doing a seqeuntial search through an Iterator. |
static boolean |
equals(Iterator i1,
Iterator i2)
Compare two Iterators for equality. |
static Object |
getIteration(Iterator iter,
int n)
Return the nth next Object from an Iterator. |
static int |
indexOf(Iterator iter,
Object o)
Return the index of the specified Object in the Iterator. |
static int |
indexOf(List list,
Object o)
Returns the index in this List
of the first occurrence of the specified element,
or -1 if this list does not contain this element. |
static int |
indexOfComparable(Iterator iter,
Comparable c)
Return the index of a comparable Object in the Iterator. |
static int |
indexOfEquivalent(Iterator iter,
Object o)
Return the index of an equivalent Object in the Iterator. |
static int |
lastIndexOfEquivalent(Iterator iter,
Object o)
Return the last index of an equivalent Object in the Iterator. |
static boolean |
skip(Iterator iter,
int count)
Skip forward count elements of the Iterator. |
static Object[] |
toArray(Iterator iter,
int size)
Create and fill an Object[] with the elements from an Iterator. |
static Object[] |
toArray(Iterator iter,
Object[] ary)
Fill an Object[] with the elements from an Iterator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Object[] toArray(Iterator iter,
int size)
Iterator.
iter - the Iteratorsize - the size of the array to create
public static Object[] toArray(Iterator iter,
Object[] ary)
Iterator.
iter - the Iteratorary - the array to fill
public static Object byIndex(Iterator iter,
int index)
Iterator.
iter - the Iterator to searchindex - the Object to seek, counting from 0
IllegalArgumentException - if the index is negative
public static int indexOf(Iterator iter,
Object o)
Iterator.
This does a sequential search for the Object.
Since this uses up the Iterator,
a new one, identically constructed, will be required to
make use of the index returned.
iter - the Iterator to searcho - the Object to seek
public static int indexOf(List list,
Object o)
List
of the first occurrence of the specified element,
or -1 if this list does not contain this element.
Implemented by indexOf(Iterator,Object).
list - the List to search
List.indexOf(Object)
public static int indexOfEquivalent(Iterator iter,
Object o)
Iterator.
This does a sequential search for an Object whose Object.equals(Object)
method returns true.
iter - the Iterator to searcho - the Object whose equivalent is sought
public static int lastIndexOfEquivalent(Iterator iter,
Object o)
Iterator.
This does a sequential search for an Object whose Object.equals(Object)
method returns true.
iter - the Iterator to searcho - the Object whose last equivalent is sought
public static int indexOfComparable(Iterator iter,
Comparable c)
Iterator.
This does a sequential search for an Object
which returns 0 from the supplied Comparable's Comparable.compareTo(Object) method.
Objects returned by the Iterator which cannot be compared
are counted but not matched.
iter - the Iterator to searchc - the reference Comparable
public static boolean equals(Iterator i1,
Iterator i2)
Iterators for equality.
Compares each element from the first Iterator
with the corresponding element from the other Iterator.
i1 - the first Iteratori2 - the second Iterator
Object.equals(Object) and the Iterators are the same length
public static boolean skip(Iterator iter,
int count)
count elements of the Iterator.
iter - the Iteratorcount - the number of elements to skip
public static final Object getIteration(Iterator iter,
int n)
Iterator.
n counts from 0,
so getIteration(iter,0)
is equivalent to iter.next().
iter - the Iteratorn - the number of items to skip
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||