All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface collections.CollectionEnumeration

public interface interface CollectionEnumeration
extends Enumeration, Serializable
CollectionEnumeration extends the standard java.util.Enumeration interface with two additional methods.


Method Index

 o corrupted()
Return true if the collection that constructed this enumeration has been detectably modified since construction of this enumeration.
 o numberOfRemainingElements()
Return the number of elements in the enumeration that have not yet been traversed.

Methods

 o corrupted
 public abstract boolean corrupted()
Return true if the collection that constructed this enumeration has been detectably modified since construction of this enumeration. Ability and precision of detection of this condition can vary across collection class implementations. hasMoreElements() is false whenever corrupted is true.

Returns:
true if detectably corrupted.
 o numberOfRemainingElements
 public abstract int numberOfRemainingElements()
Return the number of elements in the enumeration that have not yet been traversed. When corrupted() is true, this number may (or may not) be greater than zero even if hasMoreElements() is false. Exception recovery mechanics may be able to use this as an indication that recovery of some sort is warranted. However, it is not necessarily a foolproof indication.

You can also use it to pack enumerations into arrays. For example:

 Object arr[] = new Object[e.numberOfRemainingElement()]
 int i = 0;
 while (e.hasMoreElements()) arr[i++] = e.nextElement();
 

For the converse case,

Returns:
the number of untraversed elements
See Also:
ArrayEnumeration

All Packages  Class Hierarchy  This Package  Previous  Next  Index