org.amino.ds.lockfree
Class LockFreePriorityQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by org.amino.ds.lockfree.LockFreePriorityQueue<E>
Type Parameters:
E - type of element in the priority queue
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Queue<E>

public class LockFreePriorityQueue<E>
extends java.util.AbstractQueue<E>

It is a thread-safe and lock-free queue. This lock free priority queue implementation, which based on the algorithm defined in the follwoing paper: Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems By Hakan Sundell and Philippas Tsigas

Author:
raja

Constructor Summary
LockFreePriorityQueue()
          default constructor.
LockFreePriorityQueue(java.util.Comparator<? super E> cmp)
           
 
Method Summary
 boolean add(E d)
          
 boolean contains(java.lang.Object o)
          
 boolean isEmpty()
          
 java.util.Iterator<E> iterator()
          
 boolean offer(E e)
          
 E peek()
          
 E peekFirst()
           
 E poll()
          
 int size()
          
 
Methods inherited from class java.util.AbstractQueue
addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, 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
containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

LockFreePriorityQueue

public LockFreePriorityQueue()
default constructor.


LockFreePriorityQueue

public LockFreePriorityQueue(java.util.Comparator<? super E> cmp)
Parameters:
cmp - customized comparator
Method Detail

size

public int size()

Specified by:
size in interface java.util.Collection<E>
Specified by:
size in class java.util.AbstractCollection<E>

peek

public E peek()


offer

public boolean offer(E e)


peekFirst

public E peekFirst()
Returns:
first element

poll

public E poll()


contains

public boolean contains(java.lang.Object o)

Specified by:
contains in interface java.util.Collection<E>
Overrides:
contains in class java.util.AbstractCollection<E>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Collection<E>
Overrides:
isEmpty in class java.util.AbstractCollection<E>

iterator

public java.util.Iterator<E> iterator()

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in class java.util.AbstractCollection<E>

add

public boolean add(E d)

Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.Queue<E>
Overrides:
add in class java.util.AbstractQueue<E>


Copyright © 2008. All Rights Reserved.