Opus5
Class OrderedListAsArray

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractSearchableContainer
                    |
                    +--Opus5.OrderedListAsArray
All Implemented Interfaces:
Comparable, Container, OrderedList, SearchableContainer
Direct Known Subclasses:
SortedListAsArray

public class OrderedListAsArray
extends AbstractSearchableContainer
implements OrderedList

An ordered list implemented using an array.

Version:
$Id: OrderedListAsArray.java,v 3.7 1998/09/20 18:20:57 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Inner Class Summary
protected  class OrderedListAsArray.MyCursor
          A position in this ordered list.
 
Field Summary
protected  Comparable[] array
          The array.
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.OrderedList
copyright
 
Constructor Summary
OrderedListAsArray(int size)
          Constructs an OrderedListAsArray with the specified array length
 
Method Summary
 void accept(Visitor visitor)
          Accepts the specified visitor and makes it visit the objects in this ordered list in order.
protected  int compareTo(Comparable arg)
          Compares this ordered list with the specified comparable object.
 Comparable find(Comparable arg)
          Finds an object in this ordered list that matches the specified object.
 Cursor findPosition(Comparable object)
          Returns the position of an object in this ordered list that matches the specified object.
 Comparable get(int offset)
          Returns the object in this ordered lists found at the specified offset.
 Enumeration getEnumeration()
          Returns an enumeration that enumerates the objects in this ordered list in order.
 void insert(Comparable object)
          Inserts the specified object into this ordered list.
 boolean isFull()
          Tests whether this ordered list is full.
 boolean isMember(Comparable object)
          Tests whether the specified object is in this ordered list.
 void purge()
          Purges this ordered list, making it empty.
 void withdraw(Comparable object)
          Withdraws the specified object from this ordered list.
 
Methods inherited from class Opus5.AbstractContainer
getCount, hashCode, isEmpty, toString
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Container
getCount, isEmpty
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

array

protected Comparable[] array
The array.
Constructor Detail

OrderedListAsArray

public OrderedListAsArray(int size)
Constructs an OrderedListAsArray with the specified array length
Parameters:
size - The desired array length.
Method Detail

insert

public void insert(Comparable object)
Inserts the specified object into this ordered list.
Specified by:
insert in interface SearchableContainer
Parameters:
object - The object to insert.
Throws:
ContainerFullException - If this ordered list is full.

purge

public void purge()
Purges this ordered list, making it empty.
Specified by:
purge in interface Container

isFull

public boolean isFull()
Tests whether this ordered list is full.
Specified by:
isFull in interface Container
Overrides:
isFull in class AbstractContainer
Returns:
True if this ordered list if full; false otherwise.

accept

public void accept(Visitor visitor)
Accepts the specified visitor and makes it visit the objects in this ordered list in order.
Specified by:
accept in interface Container
Overrides:
accept in class AbstractContainer
Parameters:
visitor - The visitor to accept.

isMember

public boolean isMember(Comparable object)
Tests whether the specified object is in this ordered list.
Specified by:
isMember in interface SearchableContainer
Parameters:
object - The object for which to look.
Returns:
True if the specified object is in this list; false otherwise.

find

public Comparable find(Comparable arg)
Finds an object in this ordered list that matches the specified object.
Specified by:
find in interface SearchableContainer
Parameters:
arg - The object to match.
Returns:
The object in this list that matches the specified object; null if no match is found.

withdraw

public void withdraw(Comparable object)
Withdraws the specified object from this ordered list.
Specified by:
withdraw in interface SearchableContainer
Parameters:
objet - The object to be withdrawn.
Throws:
ContainerEmptyException - If this ordered list is empty.
java.lang.IllegalArgumentException - If object is not in this list.

findPosition

public Cursor findPosition(Comparable object)
Returns the position of an object in this ordered list that matches the specified object.
Specified by:
findPosition in interface OrderedList
Parameters:
object - The object to match.
Returns:
The position in this list of the matching object.

get

public Comparable get(int offset)
Returns the object in this ordered lists found at the specified offset.
Specified by:
get in interface OrderedList
Parameters:
offset - The offset of the desired object.
Returns:
The object at the specified offset.

getEnumeration

public Enumeration getEnumeration()
Returns an enumeration that enumerates the objects in this ordered list in order.
Specified by:
getEnumeration in interface Container
Returns:
An enumeration that enumerates the objects in this list.

compareTo

protected int compareTo(Comparable arg)
Compares this ordered list with the specified comparable object. This method is not impemented.
Overrides:
compareTo in class AbstractObject
Parameters:
arg - The comparable object with which to compare this ordered list.
Throws:
MethodNotImplemented - Always.