home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / src / Range.java < prev    next >
Encoding:
Java Source  |  1996-09-13  |  1.3 KB  |  65 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * An Range is an object that contains two forward iterators. 
  8.  * It is most commonly used for conveniently storing and passing pairs
  9.  * of iterators.
  10.  * <p>
  11.  * @version 1.1
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public class Range
  16.   {
  17.   /**
  18.    * The begin iterator
  19.    */
  20.   public ForwardIterator begin;
  21.  
  22.   /**
  23.    * The end iterator
  24.    */
  25.   public ForwardIterator end;
  26.  
  27.   /**
  28.    * Construct myself to hold a pair of iterators.
  29.    * @param x The first object.
  30.    * @param y The second object.
  31.    */
  32.   public Range( ForwardIterator begin, ForwardIterator end )
  33.     {
  34.     this.begin = begin;
  35.     this.end = end;
  36.     }
  37.  
  38.   /**
  39.    * Construct myself to hold a pair of iterators initially null.
  40.    */
  41.   public Range()
  42.     {
  43.     this.begin = null;
  44.     this.end = null;
  45.     }
  46.                 
  47.   /**
  48.    * Return a string that describes me.
  49.    */
  50.   public String toString()
  51.     {
  52.     return "Range( " + begin + ", " + end + " )";
  53.     }
  54.  
  55.   public boolean equals( Object object )
  56.     {
  57.     return object instanceof Range && equals( (Range) object );
  58.     }
  59.  
  60.   public boolean equals( Range range )
  61.     {
  62.     return begin.equals( range.begin ) && end.equals( range.end );
  63.     }
  64.   }
  65.