Kernel Prolog with Fluent based Builtins

tarau.jinni
Class Queue

java.lang.Object
  |
  +--tarau.jinni.Queue

public class Queue
extends java.lang.Object
implements java.lang.Cloneable

Generic dynamic Queeue with (amortized) O(1) enq/deq (add and remove) operations


Field Summary
private  boolean busy
           
private  int head
           
(package private) static int MAX_QUEUE
           
(package private) static int MIN_QUEUE
           
private  java.lang.Object[] queue
           
private  int tail
           
 
Constructor Summary
Queue()
           
Queue(int size)
           
Queue(java.util.Vector V)
           
 
Method Summary
private  int count()
           
 java.lang.Object deq()
          Removes the first element of the queue
 boolean enq(java.lang.Object V)
          Adds an element to the end of the queue
private  void enterCritical()
           
private  void exitCritical()
           
private  int inc(int val)
           
 boolean isEmpty()
           
private  void makeIt(int size)
           
private  boolean requeue(java.lang.String Mes)
          Dynamically resizes the queue
 java.util.Enumeration toEnumeration()
           
 java.lang.String toString()
           
 java.util.Vector toVector()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

MIN_QUEUE

static final int MIN_QUEUE

MAX_QUEUE

static final int MAX_QUEUE

head

private int head

tail

private int tail

busy

private boolean busy

queue

private java.lang.Object[] queue
Constructor Detail

Queue

public Queue(int size)

Queue

public Queue()

Queue

public Queue(java.util.Vector V)
Method Detail

makeIt

private final void makeIt(int size)

count

private final int count()

requeue

private final boolean requeue(java.lang.String Mes)
Dynamically resizes the queue

enterCritical

private final void enterCritical()

exitCritical

private final void exitCritical()

enq

public final boolean enq(java.lang.Object V)
Adds an element to the end of the queue

deq

public final java.lang.Object deq()
Removes the first element of the queue

inc

private final int inc(int val)

isEmpty

public final boolean isEmpty()

toVector

public java.util.Vector toVector()

toEnumeration

public java.util.Enumeration toEnumeration()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Kernel Prolog with Fluent based Builtins