com.lti.utils.collections.Queue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fmj Show documentation
Show all versions of fmj Show documentation
Freedom for Media in Java
The newest version!
package com.lti.utils.collections;
import java.util.*;
/**
* Implementation of a FIFO.
*
* @author Ken Larson
*/
public class Queue
{
private List v = new ArrayList();
public T dequeue()
{
// if (v.size() == 0)
// throw new ArrayIndexOutOfBoundsException("Queue empty");
final T o = v.get(0);
v.remove(0);
return o;
}
public void enqueue(T o)
{
v.add(o);
}
public boolean isEmpty()
{
return v.size() == 0;
}
public T peek()
{
if (v.size() == 0)
return null;
return v.get(0);
}
public void removeAllElements()
{
v.clear();
}
public int size()
{
return v.size();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy