home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / src / COM / objectspace / jgl / Sequence.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  4.6 KB  |  152 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package COM.objectspace.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 COM.objectspace.jgl.Array
  11.  * @see COM.objectspace.jgl.Deque
  12.  * @see COM.objectspace.jgl.DList
  13.  * @see COM.objectspace.jgl.SList
  14.  * @version 2.0.2
  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 at most a given number of elements that match a specified object and return the number of
  79.    * objects that were removed.
  80.    * @param object The object to remove.
  81.    * @param count The maximum number of objects to remove.
  82.    */
  83.   public int remove( Object object, int count );
  84.  
  85.   /**
  86.    * Remove all elements within a specified range that match a particular object
  87.    * and return the number of objects that were removed.
  88.    * @param first The index of the first object to remove.
  89.    * @param last The index of the last object to remove.
  90.    * @param object The object to remove.
  91.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  92.    */
  93.   public int remove( int first, int last, Object object );
  94.  
  95.   /**
  96.    * Return the number of objects that match a specified object.
  97.    * @param object The object to count.
  98.    */
  99.   public int count( Object object );
  100.  
  101.   /**
  102.    * Return the number of objects within a specified range of that match a
  103.    * particular value.
  104.    * @param first The index of the first object to consider.
  105.    * @param last The index of the last object to consider.
  106.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  107.    */
  108.   public int count( int first, int last, Object object );
  109.  
  110.   /**
  111.    * Replace all elements that match a particular object with a new value and return
  112.    * the number of objects that were replaced.
  113.    * @param oldValue The object to be replaced.
  114.    * @param newValue The value to substitute.
  115.    */
  116.   public int replace( Object oldValue, Object newValue );
  117.  
  118.   /**
  119.    * Replace all elements within a specified range that match a particular object
  120.    * with a new value and return the number of objects that were replaced.
  121.    * @param first The index of the first object to be considered.
  122.    * @param last The index of the last object to be considered.
  123.    * @param oldValue The object to be replaced.
  124.    * @param newValue The value to substitute.
  125.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  126.    */
  127.   public int replace( int first, int last, Object oldValue, Object newValue );
  128.  
  129.   /**
  130.    * Return true if I contain a particular object.
  131.    * @param object The object in question.
  132.    */
  133.   public boolean contains( Object object );
  134.  
  135.   /**
  136.    * Return the index of the first object that matches a particular value, or
  137.    * -1 if the object is not found.
  138.    * @param object The object to find.
  139.    */
  140.   public int indexOf( Object object );
  141.  
  142.   /**
  143.    * Return an iterator positioned at the first object within a specified range that
  144.    * matches a particular object, or -1 if the object is not found.
  145.    * @param first The index of the first object to consider.
  146.    * @param last The index of the last object to consider.
  147.    * @param object The object to find.
  148.    * @exception java.lang.IndexOutOfBoundsException If either index is invalid.
  149.    */
  150.   public int indexOf( int first, int last, Object object );
  151.   }
  152.