Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Freenet.support
Class CyclicArray  view CyclicArray download CyclicArray.java

java.lang.Object
  extended byFreenet.support.CyclicArray
All Implemented Interfaces:
java.io.Serializable

public class CyclicArray
extends java.lang.Object
implements java.io.Serializable

This class represents an array which is of finite length and can have information added to it in such a way that if the array fills to capacity, the last information added will be deleted.

Version:
1.0

Field Summary
(package private)  java.lang.Object[] ar
          The array that contains the objects
(package private)  int ptr
          A pointer to the next item to be deleted, moves backwards through array
 
Constructor Summary
CyclicArray(int size)
           
 
Method Summary
 java.lang.Object get(int objectPos)
          Return the object at a given position in the CyclicArray
protected  int getPos(int objectPos)
          Return the position of the object in the internal array
 int length()
          Obtain the length of this CyclicArray
 java.lang.Object put(java.lang.Object newObj)
          Adds an object to the top of the cyclic array.
 void remove(int objectPos)
          Removes an object from the specified position in the CyclicArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ar

java.lang.Object[] ar
The array that contains the objects


ptr

int ptr
A pointer to the next item to be deleted, moves backwards through array

Constructor Detail

CyclicArray

public CyclicArray(int size)
Method Detail

length

public int length()
Obtain the length of this CyclicArray


get

public java.lang.Object get(int objectPos)
Return the object at a given position in the CyclicArray


getPos

protected int getPos(int objectPos)
Return the position of the object in the internal array


put

public java.lang.Object put(java.lang.Object newObj)
Adds an object to the top of the cyclic array. This may result in an old object being deleted from the array.


remove

public void remove(int objectPos)
Removes an object from the specified position in the CyclicArray