/* * InputChannelVector.java * * Developed for the "Rethinking CS101" project. See http://www.cs101.org, the * CS101 homepage or email las@olin.edu. * * Please do not redistribute without obtaining permission. */ package nodenet; import nodenet.Node; import java.util.Vector; import java.util.Enumeration; import java.io.Serializable; /** * InputChannelVector is something which acts like a Vector * of InputChannels instead of Objects.

The methods of * this class were previously synchronized, but Sun's Vector class uses * synchronized methods. Since our only data field is the already * synchronized Vector, locking on this object is redundant.

* * @author Todd C. Parnell, tparnell@ai.mit.edu * @author Patrick G. Heck, gus.heck@olin.edu * @version $Id: InputChannelVector.java,v 1.7 2004/01/14 20:23:21 gus Exp $ */ public class InputChannelVector implements Serializable { private Vector myVector; private Node owner; /** * Constructs a new InputChannelVector. */ public InputChannelVector(Node owner) { this.owner = owner; this.myVector = new Vector( ); } /** * Find out who the owner of this object is. * * @return a reference to the owning Node */ public Node getOwner() { return owner; } /** * Adds an object to the InputChannelVector. */ public final void addElement( InputChannel obj ) { this.myVector.addElement( obj ); } /** * Checks to see if it contains an element. */ public final boolean contains( Object elem ) { return this.myVector.contains( elem ); } /** * Returns the InputChannel at a certain index. * * @param index index of the InputChannel being looked up */ public final InputChannel elementAt( int index ) { return (InputChannel)this.myVector.elementAt( index ); } /** * Transforms InputChannelVector into yet another type * of collection of objects, called an Enumeration. */ public final Enumeration elements( ) { return this.myVector.elements( ); } /** * Returns the first InputChannel in the InputChannelVector. */ public final InputChannel firstElement( ) { return (InputChannel)this.myVector.firstElement( ); } /** * Returns true if the InputChannelVector is empty. */ public final boolean isEmpty( ) { return this.myVector.isEmpty( ); } /** * Returns the last InputChannel in the InputChannelVector. */ public final InputChannel lastElement( ) { return (InputChannel)this.myVector.lastElement( ); } /** * Removes all elements from the InputChannelVector. */ public final void removeAllElements( ) { this.myVector.removeAllElements( ); } /** * Removes a specific element from the InputChannelVector. * * @param obj the object being removed */ public final boolean removeElement( InputChannel obj ) { return this.myVector.removeElement( obj ); } /** * Returns the size of the InputChannelVector. */ public final int size( ) { return this.myVector.size( ); } } /* * $Log: InputChannelVector.java,v $ * Revision 1.7 2004/01/14 20:23:21 gus * Javadoc and comment cleanup * * Revision 1.6 2003/02/24 16:04:15 gus * Make input and output channel vectors aware of their owners, and able to report * who their owner is. * * Revision 1.5 2003/02/21 17:50:54 gus * fixed log comment * */