parth doshi

Greenhorn
+ Follow
since Aug 31, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by parth doshi

I am trying to do exactly the same but for queue

my interface looks like this:

public interface ExamPeekableQueue<E extends Comparable<E>>
{
public void enqueue(E e);

public E dequeue();

public int size();

}


I now want to create a class. Here is what I tried but I need some help to complete the code. Please help me. I need to code this asap

public class ExamPeekableQueueImpl implements ExamPeekableQueue
{

@Override
public void enqueue(Comparable e)
{
// TODO Auto-generated method stub

}

@Override
public Comparable dequeue()
{
// TODO Auto-generated method stub
return null;
}


@Override
public int size()
{
// TODO Auto-generated method stub
return 0;
}

public static void main(String args[])
{
ExamPeekableQueueImpl e=new ExamPeekableQueueImpl();
List<Integer> list=new ArrayList();
list.add(1);
list.add(2);
list.add(3);

for(int i=0;i<list.size();i++)
e.enqueue(new Integer(5));

System.out.println(e.size());
}


How do i write the code for enqueue, deque functions...please just point me to a solution and i'll try to code the same
11 years ago