fr.inria.opengve.tools.dataStructures
Class Stack<E>

java.lang.Object
  extended by fr.inria.opengve.tools.dataStructures.Stack<E>
All Implemented Interfaces:
Accumulator<E>

public class Stack<E>
extends java.lang.Object
implements Accumulator<E>

This class implement the concept of stack.

Author:
fabrice.peix@sophia.inria.fr

Constructor Summary
Stack()
          Constructor.
 
Method Summary
 void clear()
          Removes all the element of this stack.
 E get()
          Return the first element of this stack and remove it.
 boolean isEmpty()
          Tell if the stack is empty.
 E look()
          Return the first element of this stack.
 void put(E o)
          Add an element to this stack.
 int size()
          Give the size of this stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Constructor.

Method Detail

get

public E get()
Return the first element of this stack and remove it.

Specified by:
get in interface Accumulator<E>
Returns:
The element at the top of the stack.
Throws:
java.util.NoSuchElementException - If the stack is empty.

look

public E look()
Return the first element of this stack.

Specified by:
look in interface Accumulator<E>
Returns:
The element at the top of the stack.
Throws:
java.util.NoSuchElementException - If the stack is empty.

put

public void put(E o)
Add an element to this stack.

Specified by:
put in interface Accumulator<E>
Parameters:
o - The object to add to the top of the stack.

isEmpty

public boolean isEmpty()
Tell if the stack is empty.

Specified by:
isEmpty in interface Accumulator<E>
Returns:
true if the stack is empty and false otherwise.

size

public int size()
Give the size of this stack.

Specified by:
size in interface Accumulator<E>
Returns:
The number of element in this stack.

clear

public void clear()
Removes all the element of this stack.

Specified by:
clear in interface Accumulator<E>


Copyright © 2009 INRIA (Projet Mascotte). All Rights Reserved.