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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * Sequence is the interface that is implemented by all Java toolkit
  8.  * containers that are sequences of objects.
  9.  * <p>
  10.  * @see jgl.Array
  11.  * @see jgl.Deque
  12.  * @see jgl.DList
  13.  * @see jgl.SList
  14.  * @version 1.1
  15.  * @author ObjectSpace, Inc.
  16.  */
  17.  
  18. public interface Sequence extends Container
  19.   {
  20.   /**
  21.    *
  22.    */
  23.   public Object clone();
  24.  
  25.   /**
  26.    * Return the object at the specified index.
  27.    * @param index The index.
  28.    */
  29.   public Object at( int index );
  30.  
  31.   /**
  32.    * Set the object at a specified index.
  33.    * @param index The index.
  34.    * @param object The object to place at the specified index.
  35.    */
  36.   public void put( int index, Object object );
  37.  
  38.   /**
  39.    * Return my last element.
  40.    */
  41.   public Object back();
  42.  
  43.   /**
  44.    * Return my first element.
  45.    */
  46.   public Object front();
  47.  
  48.   /**
  49.    * Insert an object in front of my first element.
  50.    * @param object The object to insert.
  51.    */
  52.   public void pushFront( Object object );
  53.  
  54.   /**
  55.    * Remove and return my first element.
  56.    */
  57.   public Object popFront();
  58.  
  59.   /**
  60.    * Add an object at my end.
  61.    * @param object The object to add.
  62.    */
  63.   public void pushBack( Object object );
  64.  
  65.   /**
  66.    * Remove and return my last element.
  67.    */
  68.   public Object popBack();
  69.  
  70.   /**
  71.    * Remove all elements that match a specified object and return the number of
  72.    * objects that were removed.
  73.    * @param object The object to remove.
  74.    */
  75.   public int remove( Object object );
  76.  
  77.   /**
  78.    * Remove all elements within a specified range that match a particular object
  79.    * and return the number of objects that were removed.
  80.    * @param first The index of the first object to remove.
  81.    * @param last The index of the last object to remove.
  82.    * @param object The object to remove.
  83.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  84.    */
  85.   public int remove( int first, int last, Object object );
  86.  
  87.   /**
  88.    * Return the number of objects that match a specified object.
  89.    * @param object The object to count.
  90.    */
  91.   public int count( Object object );
  92.  
  93.   /**
  94.    * Return the number of objects within a specified range of that match a
  95.    * particular value.
  96.    * @param first The index of the first object to consider.
  97.    * @param last The index of the last object to consider.
  98.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  99.    */
  100.   public int count( int first, int last, Object object );
  101.  
  102.   /**
  103.    * Replace all elements that match a particular object with a new value and return
  104.    * the number of objects that were replaced.
  105.    * @param oldValue The object to be replaced.
  106.    * @param newValue The value to substitute.
  107.    */
  108.   public int replace( Object oldValue, Object newValue );
  109.  
  110.   /**
  111.    * Replace all elements within a specified range that match a particular object
  112.    * with a new value and return the number of objects that were replaced.
  113.    * @param first The index of the first object to be considered.
  114.    * @param last The index of the last object to be considered.
  115.    * @param oldValue The object to be replaced.
  116.    * @param newValue The value to substitute.
  117.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  118.    */
  119.   public int replace( int first, int last, Object oldValue, Object newValue );
  120.  
  121.   /**
  122.    * Return true if I contain a particular object.
  123.    * @param object The object in question.
  124.    */
  125.   public boolean contains( Object object );
  126.  
  127.   /**
  128.    * Return the index of the first object that matches a particular value, or 
  129.    * -1 if the object is not found.
  130.    * @param object The object to find.
  131.    */
  132.   public int indexOf( Object object );
  133.  
  134.   /**
  135.    * Return an iterator positioned at the first object within a specified range that 
  136.    * matches a particular object, or -1 if the object is not found.
  137.    * @param first The index of the first object to consider.
  138.    * @param last The index of the last object to consider.
  139.    * @param object The object to find.
  140.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  141.    */
  142.   public int indexOf( int first, int last, Object object );
  143.   }
  144.  
  145.