All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class collections.InterleavingEnumeration

java.lang.Object
   |
   +----collections.InterleavingEnumeration

public class InterleavingEnumeration
extends Object
implements Enumeration
InterleavingEnumerations allow you to combine the elements of two different enumerations as if they were one enumeration before they are seen by their `consumers'. This sometimes allows you to avoid having to use a Collection object to temporarily combine two sets of Collection elements() that need to be collected together for common processing.

The elements are revealed (via nextElement()) in a purely interleaved fashion, alternating between the first and second enumerations unless one of them has been exhausted, in which case all remaining elements of the other are revealed until it too is exhausted.

InterleavingEnumerations work as wrappers around other Enumerations. To build one, you need two existing Enumerations. For example, if you want to process together the elements of two Collections a and b, you could write something of the form:

 Enumeration items = InterleavingEnumeration(a.elements(), b.elements());
 while (items.hasMoreElements()) 
  doSomethingWith(items.nextElement());
 


Constructor Index

 o InterleavingEnumeration(Enumeration, Enumeration)
Make an enumeration interleaving elements from fst and snd

Method Index

 o hasMoreElements()
Implements java.util.Enumeration.hasMoreElements
 o nextElement()
Implements java.util.Enumeration.nextElement.

Constructors

 o InterleavingEnumeration
 public InterleavingEnumeration(Enumeration fst,
                                Enumeration snd)
Make an enumeration interleaving elements from fst and snd

Methods

 o hasMoreElements
 public synchronized boolean hasMoreElements()
Implements java.util.Enumeration.hasMoreElements

 o nextElement
 public synchronized Object nextElement()
Implements java.util.Enumeration.nextElement.


All Packages  Class Hierarchy  This Package  Previous  Next  Index