/** * Collections of elements not supporting iteration. */ public interface Linear { // +-----------+----------------------------------------------- // | Accessors | // +-----------+ /** * Determine if the collection is full (in which case no more * elements can be added). * Precondition: The collection is initialized. * Postcondition: Returns true if the collection is full, and * false otherwise. */ public boolean isFull(); /** * Determine if the collection is empty (in which case no elements * can be deleted). * Precondition: The collection is initialized. * Postcondition: Returns true if the collection is empty, and * false otherwise. */ public boolean isEmpty(); /** * Get the next element to be returned in the collection * Precondition: The collection is initialized and nonempty. * Postcondition: An element is returned. The particular element * returned is determined by the policies of the linear structure. */ public Object next(); // +-----------+----------------------------------------------- // | Modifiers | // +-----------+ /** * Add an element to the collection. * Precondition: The collection is intialized and is not full. * Postcondition: The element is added to the collection. * Postcondition: The collection grows by one element. */ public void add(Object elt); /** * Delete an element from the collection. * Precondition: The collection is initialized and nonempty. * Postcondition: An element is deleted from the collection. The * particular element deleted is determined by the policies of * the linear structure. * Postcondition: Returns the element deleted. * Postcondition: The collection shrinks by one element. */ public Object delete(); } // interface Linear