© 1998-2002 McGraw-Hill

structure
Interface Linear

All Superinterfaces:
Structure
All Known Subinterfaces:
Queue, Stack
All Known Implementing Classes:
AbstractLinear

public interface Linear
extends Structure

An interface describing the behavior of linear data structures, structures that that have completely determined add and remove methods. Linear structures are often used to store the the state of a recursively solved problem and stacks and queues are classic examples of such structures. The structure package provides several implementations of the Linear interface, each of which has its particular strengths and weaknesses.

See Also:
Stack, Queue

Method Summary
 void add(Object value)
          Add a value to the structure.
 boolean empty()
          Returns true iff the structure is empty.
 Object get()
          Preview the object to be removed.
 Object remove()
          Remove a value from the structure.
 int size()
          Returns the number of elements in the linear structure.
 
Methods inherited from interface structure.Structure
clear, contains, elements, isEmpty, iterator, remove, values
 

Method Detail

add

public void add(Object value)
Add a value to the structure. The type of structure determines the location of the value added.
Specified by:
add in interface Structure
Parameters:
value - The value to be added to the structure.
Precondition:
value is non-null
Postcondition:
the value is added to the collection, the consistent replacement policy is not specified

get

public Object get()
Preview the object to be removed.
Precondition:
structure is not empty
Postcondition:
returns reference to next object to be removed
Returns:
A reference to the next object to be removed.

remove

public Object remove()
Remove a value from the structure. The particular value to be removed is determined by the structure.
Precondition:
structure is not empty
Postcondition:
removes an object from store
Returns:
Value removed from structure.

size

public int size()
Returns the number of elements in the linear structure.
Specified by:
size in interface Structure
Postcondition:
returns the number of elements in the structure
Returns:
number of elements in structure.

empty

public boolean empty()
Returns true iff the structure is empty.
Postcondition:
returns true if and only if the linear structure is empty
Returns:
True iff the linear structure is empty.

© 1998-2002 McGraw-Hill