Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


com.tangosol.util
Class SimpleEnumerator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.SimpleEnumerator

All Implemented Interfaces:
Enumeration, Iterator
Direct Known Subclasses:
SortedEnumerator

public class SimpleEnumerator
extends Base
implements Enumeration, Iterator

Provide a generic implementation of an array enumerator.

Version:
0.50, 09/05/97, 1.00, 08/07/98
Author:
Cameron Purdy

Field Summary
protected  Object[] m_aoItem
          Array of items to enumerate.
protected  boolean m_fForward
          Iterator direction.
protected  int m_iItem
          Iterator position: next item to return.
protected  int m_ofLimit
          Iterator end position (beyond last).

 

Constructor Summary
SimpleEnumerator(Collection col)
          Construct a simple enumerator based on a collection.
SimpleEnumerator(Enumeration enmr)
          Construct a simple enumerator based on another Enumeration.
SimpleEnumerator(Iterator iter)
          Construct a simple enumerator based on another Iterator.
SimpleEnumerator(Object[] aoItem)
          Construct the simple enumerator based on an array of objects.
SimpleEnumerator(Object[] aoItem, int ofStart, int cItems)
          Construct the simple enumerator based on an array of objects.
SimpleEnumerator(Object[] aoItem, int ofStart, int cItems, boolean fForward, boolean fCopy)
          Construct the simple enumerator based on an array of objects, making a copy of the array if specified.

 

Method Summary
 boolean hasMoreElements()
          Tests if this enumeration contains more elements.
 boolean hasNext()
          Tests if this Iterator contains more elements.
 Object next()
          Returns the next element of this Iterator.
 Object nextElement()
          Returns the next element of this enumeration.
 void remove()
          Remove the last-returned element that was returned by the Iterator.
 Object[] toArray()
          Return the remaining contents of this SimpleEnumerator as an array.
static Object[] toArray(Enumeration enmr)
          Turns an enumeration into an array.
static Object[] toArray(Enumeration enmr, Object[] ao)
          Turns an enumeration into an array.
static Object[] toArray(Iterator iter)
          Turns an Iterator into an array.
static Object[] toArray(Iterator iter, Object[] ao)
          Turns an Iterator into an array.
 Object[] toArray(Object[] ao)
          Return the remaining contents of this SimpleEnumerator as an array of the type specified by the passed array, and use that passed array to store the values if it is big enough, putting a null in the first unused element if the size of the passed array is bigger than the number of remaining elements in this enumerator, as per the contract of the Collection.toArray(Object[]) method.

 

Field Detail

m_aoItem

protected Object[] m_aoItem
Array of items to enumerate.

m_iItem

protected int m_iItem
Iterator position: next item to return.

m_ofLimit

protected int m_ofLimit
Iterator end position (beyond last).

m_fForward

protected boolean m_fForward
Iterator direction.

Constructor Detail

SimpleEnumerator

public SimpleEnumerator(Object[] aoItem)
Construct the simple enumerator based on an array of objects.
Parameters:
aoItem - array of objects to enumerate

SimpleEnumerator

public SimpleEnumerator(Object[] aoItem,
                        int ofStart,
                        int cItems)
Construct the simple enumerator based on an array of objects.
Parameters:
aoItem - array of objects to enumerate
ofStart - the first object position
cItems - the number of objects to enumerate

SimpleEnumerator

public SimpleEnumerator(Object[] aoItem,
                        int ofStart,
                        int cItems,
                        boolean fForward,
                        boolean fCopy)
Construct the simple enumerator based on an array of objects, making a copy of the array if specified.
Parameters:
aoItem - array of objects to enumerate
ofStart - the first object position
cItems - the number of objects to enumerate
fForward - true to iterate forwards, false to iterate from the end backwards to the beginning
fCopy - pass true to make a copy of the array or false if the array's contents will not change

SimpleEnumerator

public SimpleEnumerator(Enumeration enmr)
Construct a simple enumerator based on another Enumeration. This forces an initial pass through the elements of the passed enumerator, making a copy of that data, thus capturing a "point in time" view of an Enumeration which may be backed by mutable data. In other words, this constructs a "safe enumerator" based on a "not-safe enumerator".
Parameters:
enmr - the java.util.Enumeration to enumerate

SimpleEnumerator

public SimpleEnumerator(Iterator iter)
Construct a simple enumerator based on another Iterator. This forces an initial pass through the elements of the passed enumerator, making a copy of that data, thus capturing a "point in time" view of an Iterator which may be backed by mutable data. In other words, this constructs a "safe enumerator" based on a "not-safe enumerator".
Parameters:
iter - the java.util.Iterator to enumerate

SimpleEnumerator

public SimpleEnumerator(Collection col)
Construct a simple enumerator based on a collection.
Parameters:
col - the java.util.Collection to enumerate

Method Detail

hasMoreElements

public boolean hasMoreElements()
Tests if this enumeration contains more elements.
Specified by:
hasMoreElements in interface Enumeration
Returns:
true if the enumeration contains more elements, false otherwise

nextElement

public Object nextElement()
Returns the next element of this enumeration.
Specified by:
nextElement in interface Enumeration
Returns:
the next element in the enumeration

hasNext

public boolean hasNext()
Tests if this Iterator contains more elements.
Specified by:
hasNext in interface Iterator
Returns:
true if the Iterator contains more elements, false otherwise

next

public Object next()
Returns the next element of this Iterator.
Specified by:
next in interface Iterator
Returns:
the next element in the Iterator

remove

public void remove()
Remove the last-returned element that was returned by the Iterator. This method always throws UnsupportedOperationException because the Iterator is immutable.
Specified by:
remove in interface Iterator

toArray

public static Object[] toArray(Enumeration enmr)
Turns an enumeration into an array.
Parameters:
enmr - the enumerator
Returns:
an array of the objects from the enumerator

toArray

public static Object[] toArray(Enumeration enmr,
                               Object[] ao)
Turns an enumeration into an array. The behavior of this method differs from the simple toArray(Enumeration) method in the same way that the Collection.toArray(Object[]) method differs from the Collection.toArray() method.
Parameters:
enmr - the enumerator
ao - the array into which the elements of the Enumeration are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
Returns:
an array of the objects from the enumerator

toArray

public static Object[] toArray(Iterator iter)
Turns an Iterator into an array.
Parameters:
iter - the Iterator
Returns:
an array of the objects

toArray

public static Object[] toArray(Iterator iter,
                               Object[] ao)
Turns an Iterator into an array. The behavior of this method differs from the simple toArray(Iterator) method in the same way that the Collection.toArray(Object[]) method differs from the Collection.toArray() method.
Parameters:
iter - the Iterator
ao - the array into which the elements of the Iterator are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
Returns:
an array of the objects from the Iterator

toArray

public Object[] toArray()
Return the remaining contents of this SimpleEnumerator as an array.
Returns:
an array containing all of the elements in this enumerator

toArray

public Object[] toArray(Object[] ao)
Return the remaining contents of this SimpleEnumerator as an array of the type specified by the passed array, and use that passed array to store the values if it is big enough, putting a null in the first unused element if the size of the passed array is bigger than the number of remaining elements in this enumerator, as per the contract of the Collection.toArray(Object[]) method.
Parameters:
ao - the array into which the elements of the Enumeration are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
Returns:
an array containing the elements of the collection
Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this collection

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.