at.molindo.utils.collections
Class CircularQueue<T>

java.lang.Object
  extended by java.util.AbstractCollection<T>
      extended by at.molindo.utils.collections.CircularQueue<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, Queue<T>

public class CircularQueue<T>
extends AbstractCollection<T>
implements Queue<T>

Queue implementation that uses a single, fixed-size buffer as if it were connected end-to-end. This structure lends itself easily to buffering data streams.


Constructor Summary
CircularQueue(int capacity)
          create a new queue with the given capacity
 
Method Summary
 boolean add(T e)
          overrides first element in queue if queue is full
 void clear()
           
 T element()
           
 boolean isEmpty()
           
 boolean isFull()
           
 Iterator<T> iterator()
           
 boolean offer(T e)
           
protected  void onOverflow()
           
 T peek()
           
 T poll()
           
 T remove()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, contains, containsAll, equals, hashCode, toArray, toArray
 

Constructor Detail

CircularQueue

public CircularQueue(int capacity)
create a new queue with the given capacity

Method Detail

offer

public boolean offer(T e)
Specified by:
offer in interface Queue<T>

add

public boolean add(T e)
overrides first element in queue if queue is full

Specified by:
add in interface Collection<T>
Specified by:
add in interface Queue<T>
Overrides:
add in class AbstractCollection<T>
See Also:
Queue.add(Object)

onOverflow

protected void onOverflow()

remove

public T remove()
Specified by:
remove in interface Queue<T>

poll

public T poll()
Specified by:
poll in interface Queue<T>

element

public T element()
Specified by:
element in interface Queue<T>

peek

public T peek()
Specified by:
peek in interface Queue<T>

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in class AbstractCollection<T>

isFull

public boolean isFull()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<T>
Overrides:
isEmpty in class AbstractCollection<T>

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in class AbstractCollection<T>

clear

public void clear()
Specified by:
clear in interface Collection<T>
Overrides:
clear in class AbstractCollection<T>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<T>
Overrides:
remove in class AbstractCollection<T>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<T>
Overrides:
removeAll in class AbstractCollection<T>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<T>
Overrides:
retainAll in class AbstractCollection<T>


Copyright © 2013 Molindo GmbH. All Rights Reserved.