|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.farafin.snEADy.communication.RingVector
public final class RingVector
this class is a implemention of a ring buffer. it is based on a array that contains the data. if the size of the array is too small, it will be automatically resized. (my first intention was to extend from java.util.Vector, but because i can not ovewride the resize methode, so it was not possible to implement a ring vector)
Vector| Field Summary | |
|---|---|
private java.lang.Object[] |
dataArray
the array that conatins the data |
private int |
definedLength
the length of this part of the array that contains data. |
private int |
headIndex
the index of the head of the data |
| Constructor Summary | |
|---|---|
RingVector()
default constructor creats a new, empty RingVector with a capacity of 10 |
|
RingVector(int size)
creats a new, empty RingVector with a capacity of size |
|
| Method Summary | |
|---|---|
void |
addFirst(java.lang.Object obj)
adds a element at the end |
void |
addLast(java.lang.Object obj)
adds a element at the end |
void |
clear()
sets all Elements to null and clear the RingVector so that there is no data defined any more. |
java.lang.Object |
clone()
|
private void |
doubleSize()
doubles the size of the array |
java.lang.Object |
getElementAt(int i)
|
java.lang.Object |
getFirst()
|
java.lang.Object |
getLast()
|
java.lang.Object |
moveFirstToLast()
move the last Element and put it to the front. |
java.lang.Object |
moveLastToFirst()
move the last Element and put it to the front. |
java.lang.Object |
remFirst()
remove the first Object. sets the reference to null. |
java.lang.Object |
remLast()
remove the last Object. sets the reference to null. |
java.lang.Object |
replaceAt(int i,
java.lang.Object obj)
replaces the i'th element with obj |
int |
size()
|
java.lang.Object[] |
toArray()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private int headIndex
private int definedLength
private java.lang.Object[] dataArray
| Constructor Detail |
|---|
public RingVector()
public RingVector(int size)
size
size - the size of the RingVector| Method Detail |
|---|
private void doubleSize()
public void addLast(java.lang.Object obj)
obj - public void addFirst(java.lang.Object obj)
obj - public java.lang.Object remLast()
public java.lang.Object remFirst()
public java.lang.Object replaceAt(int i,
java.lang.Object obj)
i'th element with obj
i - the index of the element that should be replacedobj - the new object
ipublic java.lang.Object moveLastToFirst()
public java.lang.Object moveFirstToLast()
public java.lang.Object getElementAt(int i)
i - index of the element
public java.lang.Object getFirst()
public java.lang.Object getLast()
public int size()
public void clear()
public java.lang.Object[] toArray()
public java.lang.Object clone()
clone in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||