package runEnv; import java.util.*; public class Multiple { /* Represents an array, or fields, methods, classes for an instance or class. */ private Vector< RunValue > vector = new Vector< RunValue >(); public int size() { return vector.size(); } public Multiple( int size ) { for ( int i = 0; i < size; i++ ) vector.addElement( new RunData() ); } public String toString() { String result = ""; if ( size() == 0 ) return "{}"; for ( int i = 0; i < size(); i++ ) { if ( i > 0 ) result += ", "; result += getValue( i ); } return "{ " + result + " }"; } public void addData( int size ) { for ( int i = 0; i < size; i++ ) vector.addElement( new RunData() ); } public RunValue getValue( int i ) { return getData( i ).getValue(); } public RunData getData( int i ) { return ( RunData ) vector.elementAt( i ); } public void setValue( int i, RunValue value ) { getData( i ).setValue( value ); } public void setReference( int i, RunData data ) { vector.setElementAt( data, i ); } public Multiple subMultiple( int low, int high ) { if ( low < 0 || low > high + 1 || high > size() ) throw new Error( "Subarray bounds invalid" ); Multiple result = new Multiple( high - low + 1 ); for ( int i = low; i <= high; i++ ) result.setReference( i - low, getData( i ) ); return result; } }