    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());

##

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

##

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

##

InterleavingEnumeration

     public InterleavingEnumeration(Enumeration fst,
                                    Enumeration snd)

  Make an enumeration interleaving elements from fst and snd

##

hasMoreElements

     public synchronized boolean hasMoreElements()

  Implements java.util.Enumeration.hasMoreElements

nextElement

     public synchronized Object nextElement()

  Implements java.util.Enumeration.nextElement.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index