home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / applets / collectn / collecti.jav < prev    next >
Encoding:
Text File  |  1995-10-14  |  2.0 KB  |  67 lines

  1. /*
  2.   File: CollectionEnumeration.java
  3.  
  4.   Originally written by Doug Lea and released into the public domain. 
  5.   Thanks for the assistance and support of Sun Microsystems Labs, Agorics 
  6.   Inc, Loral, and everyone contributing, testing, and using this code.
  7.  
  8.   History:
  9.   Date     Who                What
  10.   24Sep95  dl@cs.oswego.edu   Create from collections.java  working file
  11.  
  12. */
  13.   
  14. package collections;
  15.  
  16. import java.util.Enumeration;
  17. import java.util.NoSuchElementException;
  18.  
  19. /**
  20.  *
  21.  * CollectionEnumeration extends the standard java.util.Enumeration
  22.  * interface with two additional methods.
  23.  * @author Doug Lea
  24.  * @version 0.93
  25.  *
  26.  * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
  27.  *
  28. **/
  29.  
  30. public interface CollectionEnumeration extends Enumeration {
  31.  
  32. /**
  33.  * Return true if the collection that constructed this enumeration
  34.  * has been detectably modified since construction of this enumeration.
  35.  * Ability and precision of detection of this condition can vary
  36.  * across collection class implementations.
  37.  * hasMoreElements() is false whenever corrupted is true.
  38.  *
  39.  * @return true if detectably corrupted.
  40. **/
  41.  
  42.   public boolean corrupted();
  43.  
  44. /**
  45.  * Return the number of elements in the enumeration that have
  46.  * not yet been traversed. When corrupted() is true, this 
  47.  * number may (or may not) be greater than zero even if hasMoreElements() 
  48.  * is false. Exception recovery mechanics may be able to
  49.  * use this as an indication that recovery of some sort is
  50.  * warranted. However, it is not necessarily a foolproof indication.
  51.  * <P>
  52.  * You can also use it to pack enumerations into arrays. For example:
  53.  * <PRE>
  54.  * Object arr[] = new Object[e.numberOfRemainingElement()]
  55.  * int i = 0;
  56.  * while (e.hasMoreElements()) arr[i++] = e.nextElement();
  57.  * </PRE>
  58.  * <P>
  59.  * For the converse case, 
  60.  * @see ArrayEnumeration
  61.  * @return the number of untraversed elements
  62. **/
  63.     
  64.   public int numberOfRemainingElements();
  65. }
  66.  
  67.