Write programs which implement the interface that is attached, according the following rule
- Compile and execute in Java 6 environment
- Use "UTF-8" for the encoding of your programs
-Use English only. (For all class names, identifiers, method names, comments, etc.)
-Package name should be "jp.co.worksap.intern" and class name must be "Sortable stack"
-Consider Execution speed. Implement all methods as fast as possible
- Suppose every method will be called in the same frequency, so every method should be similarly fast, not part of (or particular) methods.
package jp.co.worksap.intern;
/**
*The Stack class represents a last-in-first-out(LIFO) stack of objects
*And this class can look at the object which has the highest (lowest or so) value.
*So every object onto the stack must be comparable to each other.
*@param<E.
*/
public interface ISortableStack<E extends Comparable<E>>(
/**
*Pushes an item onto the top of this stack.
*If the Element e is null, throws NullPointerException.
*
*
@param e
*@throws NullPointerException
/*
public void push(E e);
/**
*Removes the object at the top of this stack and returns that object as the value of this function.
*If the stack is empty, throws EmptyStackException.
*@return
*@throws EmptyStackException
*/
public E pop();
/**
*Locks at the object which has the middle value among the all objects without removing it from the stack.
*Returns the object which has the value of following order <code>(size()/2)+1</code>
*<pre>
*e.g.
*When the stack has the following values (1, 2, 5, 4, 2, 6)
*this method returns 4 and doesn't remove the object.
*</pre>
*
*If the stack is empty, throws EmptyStackException.
*@return
*@throws EmptyStackException
*/
public E peekMidElement();
/**
*Looks at the object which has the highest value among the all objects without removing it from the stack.
*Returns the object which has the value of the following order <code>size()</code>
*<pre>
*e.g.
*When the stack has the following values (1,2,5,4,2,6)
*this method returns 6 and doesn't remove that object
*</pre>
*
*If the stack is empty, throws EmptyStackException.
*@return
*@throws EmptyStackException
*/
public E peekHighestElement();
/**
*Looks at the object which has the lowest value among the all objects without removing it from the stack.
*Returns the object which has the value of the following order <code>1</code>
*<pre>
*e.g.
*When the stack has the following values (1,2,5,4,2,6)
*this method returns 1 and doesn't remove the object.
*</pre>
*
*If the stack is empty, throws EmptyStackException.
*@return
*@throws EmptyStackException
*/
public E peekLowestElement();
/**
*Returns the number of objects in this stack.
*@return
*/
public int size();
}