jclass
Class RoundRobin

java.lang.Object
  |
  +--jclass.RoundRobin

public class RoundRobin
extends java.lang.Object

A synchronized class used in reprezenting a circular list of Objects optimized for round robin parsing.

Written: Radu Sion
Version: 0.24x
Source: RoundRobin.java

Visit Smart Software 


Field Summary
static int MAX_ENTRIES
          The maximum number of entries allowed out of internal reasons
 
Constructor Summary
RoundRobin(int max_entries)
           
 
Method Summary
 int applyAll(java.lang.Object ooo)
          Powerfull mechanism of applying some function on all the Objects in the structure.
 java.lang.Object getCurrent()
          Gets the current Object.
 int getMaxSize()
          Gets the maximum entries allowed in this structure.
 java.lang.Object getNext()
          Gets the next Object in the structure.
 void Insert(java.lang.Object ooo)
          Inserts new Object AFTER the current one.
 boolean isEmpty()
          Tests if structure is empty.
 boolean isFull()
          Tests if structure is full.
 void Remove()
          Removes CURRENT Object.
 void Remove(java.lang.Object ooo)
          Removes the specified Object.
 int HREF="../jclass/RoundRobin.html#Size()">Size()
          The number of Objects in the structure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_ENTRIES

public static final int MAX_ENTRIES
The maximum number of entries allowed out of internal reasons
Constructor Detail

RoundRobin

public RoundRobin(int max_entries)
Parameters:
max_entries - Maximum entries in the structure
Method Detail

isEmpty

public boolean isEmpty()
Tests if structure is empty.

isFull

public boolean isFull()
Tests if structure is full.

Size

public int Size()
The number of Objects in the structure
Returns:
The current number of entries in the structure

getMaxSize

public int getMaxSize()
Gets the maximum entries allowed in this structure. This value is the value passed to the constructor or MAX_ENTRIES .

getCurrent

public java.lang.Object getCurrent()
                            throws EmptyException
Gets the current Object.
Returns:
The current Object
Throws:
EmptyException - If the structure is empty

getNext

public java.lang.Object getNext()
                         throws EmptyException
Gets the next Object in the structure. (round robin parsing)
Returns:
The next Object
Throws:
EmptyException - If the structure is empty

Remove

public void Remove()
            throws EmptyException
Removes CURRENT Object. After removing, the PREVIOUS becomes current.
Throws:
EmptyException - If the structure is empty

Remove

public void Remove(java.lang.Object ooo)
            throws EmptyException
Removes the specified Object. After removing, if the Object was the current one then the PREVIOUS becomes current, otherwise the current remains unchanged. The Objects are compared via == comparision. Only the first occurence is removed !!!
Parameters:
ooo - The objetc to remove.
Throws:
EmptyException - If the structure is empty

Insert

public void Insert(java.lang.Object ooo)
            throws FullException
Inserts new Object AFTER the current one. After inserting, the current will remain THE SAME. Does NOT Insert null objects.
Parameters:
ooo - Object to insert
Throws:
FullException - If the structure is full

applyAll

public int applyAll(java.lang.Object ooo)
Powerfull mechanism of applying some function on all the Objects in the structure. (not implemented yet) This method is NOT FOR GENERAL USE (because it's synchronized and blocks the whole structure)
Parameters:
ooo - Object that gives the function to apply (but how ?)
Returns:
A indicator that shows how many objects were processed