LimeWire Collection Component API

org.limewire.collection
Class RoundRobinQueue<T>

java.lang.Object
  extended by org.limewire.collection.RoundRobinQueue<T>
Direct Known Subclasses:
RoundRobinSetQueue

public class RoundRobinQueue<T>
extends Object

A round-robin queue. next() returns an item on the queue and then puts that item to the end of the queue.

    
    RoundRobinQueue<Integer> rrq = new RoundRobinQueue<Integer>();  
    rrq.enqueue(1); 
    rrq.enqueue(2);  

    for(Integer i = rrq.size() + 1; i > 0; i--)
        System.out.println(rrq.next());

    Output:    
        1
        2
        1

 


Constructor Summary
RoundRobinQueue()
          do not create the terminating elements
 
Method Summary
 void clear()
           
 void enqueue(T value)
          enqueues the specified object in the round-robin queue.
 T next()
           
 void remove(T o)
          Removes the next occurrence of the specified object
 void removeAllOccurences(T o)
          Removes all occurrences of the given object in the list.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoundRobinQueue

public RoundRobinQueue()
do not create the terminating elements

Method Detail

enqueue

public void enqueue(T value)
enqueues the specified object in the round-robin queue.

Parameters:
value - the object to add to the queue

next

public T next()
Returns:
the next object in the round robin queue

remove

public void remove(T o)
Removes the next occurrence of the specified object

Parameters:
o - the object to remove from the queue.

removeAllOccurences

public void removeAllOccurences(T o)
Removes all occurrences of the given object in the list.

Parameters:
o - the object to remove.

size

public int size()

clear

public void clear()

LimeWire Collection Component API

Copyright © 2008 Lime Wire LLC. All Rights Reserved.