Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
ย
Posfix
1. 1
Stack.java
importjava.util.*;
/**
* A LIFOstack of generic<CODE>Object</CODE>s.
*
* @author JimGlenn
* @version0.1 12/05/2005
*/
publicclassStack
{
/**
* The listthatholdsthe elementsonthisstack. The endof the
* lististhe topof the stack.
*/
private Listelements;
/**
* Createsan emptystack.
*/
publicStack()
{
elements=newArrayList();
}
/**
* Addsan itemto the top of thisstack.
*
* @param toAddthe itemto add
*/
publicvoidpush(ObjecttoAdd)
{
elements.add(toAdd);
}
/**
* Removesthe itematthe top of thisstack.
*
* @return the itemat the top of thisstack
*/
publicObjectpop()
{
returnelements.remove(elements.size() - 1);
}
2. 2
/**
* Returnsthe itemat the top of thisstack. That itemisnot
* removed.
*
* @return the itemat the top of thisstack
*/
publicObjectpeek()
{
returnelements.get(elements.size()- 1);
}
/**
* Returnsthe numberof elementsonthisstack.
*
* @return the size of thisstack
*/
publicintsize()
{
returnelements.size();
}
}
3. 3
Queue.java
importjava.util.*;
/**
* A FIFOqueue of generic<CODE>Object</CODE>s.
*
* @author JimGlenn
* @version0.1 12/05/2005
*/
publicclassQueue
{
/**
* The listthatholdsthe elementsonthisqueue. The frontof the
* lististhe frontof the queue.
*/
private Listelements;
/**
* Createsan emptyqueue.
*/
publicQueue()
{
elements=newLinkedList();
}
/**
* Addsan itemto the endof thisqueue.
*
* @param toAddthe itemto add
*/
publicvoidenqueue(ObjecttoAdd)
{
elements.add(toAdd);
}
/**
* Removesthe itematthe front of thisqueue.
*
* @return the itemat the frontof thisqueue
*/
publicObjectdequeue()
{
returnelements.remove(0);
}
4. 4
/**
* Returnsthe itemat the front of thisqueue. Thatitemisnot
* removed.
*
* @return the itemat the frontof thisqueue
*/
publicObjectfirst()
{
returnelements.get(0);
}
/**
* Returnsthe numberof elementsonthisqueue.
*
* @return the size of thisqueue
*/
publicintsize()
{
returnelements.size();
}
}