home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / applets / collectn / updatabl.jav < prev   
Encoding:
Text File  |  1995-12-14  |  1.8 KB  |  75 lines

  1. /*
  2.   File: UpdatableSetImpl.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.   13Oct95  dl                 Create
  11.   22Oct95  dl                 add includeElements
  12.  
  13. */
  14.   
  15. package collections;
  16.  
  17. import java.util.Enumeration;
  18. import java.util.NoSuchElementException;
  19.  
  20. /**
  21.  *
  22.  * UpdatableSetImpl extends UpdatableImpl to provide
  23.  * default implementations of some Set operations. 
  24.  * @author Doug Lea
  25.  * @version 0.93
  26.  *
  27.  * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
  28.  *
  29. **/
  30.  
  31. abstract class UpdatableSetImpl extends UpdatableImpl implements UpdatableSet { 
  32.  
  33.  
  34. /**
  35.  * Initialize at version 0, an empty count, and null screener
  36. **/
  37.  
  38.   protected UpdatableSetImpl() { super(); }
  39.  
  40. /**
  41.  * Initialize at version 0, an empty count, and supplied screener
  42. **/
  43.   protected UpdatableSetImpl(Predicate screener) { super(screener); }
  44.  
  45.  
  46. // Default implementations of Set methods
  47.  
  48. /**
  49.  * Implements collections.Set.including
  50.  * @see collections.Set#including
  51. **/
  52.   public synchronized  Set including(Object element) 
  53.   throws IllegalElementException {
  54.     UpdatableSet c = null;
  55.     try {
  56.       c = ((UpdatableSet)clone());
  57.       c.include(element);
  58.     } catch (CloneNotSupportedException ex) {}      
  59.     return c;
  60.   }
  61.  
  62. /**
  63.  * Implements collections.UpdatableSet.includeElements
  64.  * @see collections.UpdatableSet#includeElements
  65. **/
  66.  
  67.   public synchronized  void includeElements(Enumeration e) 
  68.    throws IllegalElementException, CorruptedEnumerationException {
  69.     while (e.hasMoreElements()) include(e.nextElement());
  70.   }
  71.  
  72. }
  73.  
  74.  
  75.