structure
Class OrderedVector

java.lang.Object
  extended by structure.AbstractStructure
      extended by structure.OrderedVector
All Implemented Interfaces:
OrderedStructure, Structure

public class OrderedVector
extends AbstractStructure
implements OrderedStructure

Implementation of an ordered structure implemented using a vector

See Also:
Vector

Field Summary
protected  Vector data
          The vector of values.
 
Constructor Summary
OrderedVector()
          Construct an empty ordered vector
 
Method Summary
 void add(java.lang.Object value)
          Add a comparable value to an ordered vector
 void clear()
          Removes all the values from a an ordered vector
 boolean contains(java.lang.Object value)
          Determine if a comparable value is a member of the ordered vector
 boolean isEmpty()
          Determine if the ordered vector is empty.
 java.util.Iterator iterator()
          Construct an iterator to traverse the ordered vector in ascending order
protected  int locate(java.lang.Comparable target)
           
 java.lang.Object remove(java.lang.Object value)
          Remove a comparable value from an ordered vector At most one value is removed
 int size()
          Determine the number of elements within the ordered vector
 java.lang.String toString()
          Construct a string representation of an ordered vector
 
Methods inherited from class structure.AbstractStructure
elements, hashCode, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface structure.Structure
elements, values
 

Field Detail

data

protected Vector data
The vector of values. Values are stored in increasing order

Constructor Detail

OrderedVector

public OrderedVector()
Construct an empty ordered vector

Postcondition:
constructs an empty, ordered vector
Method Detail

add

public void add(java.lang.Object value)
Add a comparable value to an ordered vector

Specified by:
add in interface Structure
Parameters:
value - The comparable value to be added to the ordered vector
Precondition:
value is non-null
Postcondition:
inserts value, leaves vector in order

contains

public boolean contains(java.lang.Object value)
Determine if a comparable value is a member of the ordered vector

Specified by:
contains in interface Structure
Overrides:
contains in class AbstractStructure
Parameters:
value - The comparable value sought
Returns:
True if the value is found within the ordered vector
Precondition:
value is non-null
Postcondition:
returns true if the value is in the vector

remove

public java.lang.Object remove(java.lang.Object value)
Remove a comparable value from an ordered vector At most one value is removed

Specified by:
remove in interface Structure
Parameters:
value - The comparable value to be removed
Returns:
The actual comparable removed
Precondition:
value is non-null
Postcondition:
removes one instance of value, if found in vector

isEmpty

public boolean isEmpty()
Determine if the ordered vector is empty.

Specified by:
isEmpty in interface Structure
Overrides:
isEmpty in class AbstractStructure
Returns:
True iff the ordered vector is empty
Postcondition:
returns true if the OrderedVector is empty

clear

public void clear()
Removes all the values from a an ordered vector

Specified by:
clear in interface Structure
Postcondition:
vector is emptied

size

public int size()
Determine the number of elements within the ordered vector

Specified by:
size in interface Structure
Returns:
The number of elements within the ordered vector
Postcondition:
returns the number of elements in vector

iterator

public java.util.Iterator iterator()
Construct an iterator to traverse the ordered vector in ascending order

Specified by:
iterator in interface Structure
Returns:
An iterator to traverse the ordered vector
See Also:
AbstractIterator, Iterator, Enumeration, Structure.elements()
Postcondition:
returns an iterator for traversing vector

locate

protected int locate(java.lang.Comparable target)

toString

public java.lang.String toString()
Construct a string representation of an ordered vector

Overrides:
toString in class java.lang.Object
Returns:
The string representing the ordered vector
Precondition:
returns string representation of ordered vector