home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / manifvector.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.8 KB  |  85 lines

  1. // ManifVector.java
  2. // 27.02.96
  3. // 
  4. // Puts a lot of typecasting in one place
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.util.Vector;
  9. import java.util.Enumeration;
  10.  
  11.  
  12. /**
  13.  * A Vector of Manif objects.  See the comments for the
  14.  * Vector class, they all apply.  The only difference is that it
  15.  * only takes and returns Manif's.  Note: I didn't implement
  16.  * the entire set of Vector methods, just the one's I use.  I would
  17.  * have extended the Vector class, but most of its methods are final.
  18.  *
  19.  * @see Vector;
  20.  * @see Manif;
  21.  */
  22. public class ManifVector {
  23.  
  24.   /* the real Vector behind the scenes */
  25.   private Vector objects;
  26.  
  27.   public ManifVector () {
  28.     objects = new Vector ();
  29.   }
  30.  
  31.   public ManifVector (int initCapacity) {
  32.     objects = new Vector (initCapacity);
  33.   }
  34.  
  35.   /**
  36.    * Converts a Vector into a ManifVector.
  37.    */
  38.   public ManifVector (Vector oldVector) {
  39.     objects = oldVector;
  40.   }
  41.  
  42.   public synchronized void addElement (Manif newElement) {
  43.     objects.addElement (newElement);
  44.   }
  45.  
  46.   public synchronized Manif elementAt (int index) {
  47.     return (Manif)objects.elementAt (index);
  48.   }
  49.  
  50.   public synchronized Manif firstElement () {
  51.     return (Manif)objects.firstElement ();
  52.   }
  53.  
  54.   public synchronized Manif lastElement () {
  55.     return (Manif)objects.lastElement ();
  56.   }
  57.  
  58.   /**
  59.    * Ok, so the Manif type info is lost in the Enumeration. 
  60.    */
  61.   public synchronized Enumeration elements () {
  62.     return objects.elements ();
  63.   }
  64.  
  65.   public int size () {
  66.     return objects.size ();
  67.   }
  68.  
  69.   public boolean isEmpty () {
  70.     return objects.isEmpty ();
  71.   }
  72.  
  73.   public synchronized void removeElementAt (int index) {
  74.     objects.removeElementAt (index);
  75.   }
  76.  
  77.   public synchronized String toString () {
  78.     return objects.toString ();
  79.   }
  80.  
  81.   public synchronized Vector toVector () {
  82.     return objects;
  83.   }
  84. }
  85.