Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.farafin.snEADy.communication
Class RingVector

    java.lang.Object
      de.farafin.snEADy.communication.RingVector

    public final class RingVector

extends java.lang.Object

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)

Author:
  lars, roland
See Also:
  `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

### headIndex

    private int headIndex

  the index of the head of the data

### definedLength

    private int definedLength

  the length of this part of the array that contains data.

### dataArray

    private java.lang.Object[] dataArray

  the array that conatins the data

Constructor Detail

### RingVector

    public RingVector()

  default constructor creats a new, empty RingVector with a capacity of 10

### RingVector

    public RingVector(int size)

  creats a new, empty RingVector with a capacity of `size`

  Parameters:
    `size` - the size of the RingVector

Method Detail

### doubleSize

    private void doubleSize()

  doubles the size of the array

### addLast

    public void addLast(java.lang.Object obj)

  adds a element at the end

  Parameters:
    `obj` -

### addFirst

    public void addFirst(java.lang.Object obj)

  adds a element at the end

  Parameters:
    `obj` -

### remLast

    public java.lang.Object remLast()

  remove the last Object. sets the reference to null.

  Returns:
    the removed Object

### remFirst

    public java.lang.Object remFirst()

  remove the first Object. sets the reference to null.

  Returns:
    the removed Object

### replaceAt

    public java.lang.Object replaceAt(int i,
                                      java.lang.Object obj)

  replaces the `i`'th element with `obj`

  Parameters:
    `i` - the index of the element that should be replaced
    `obj` - the new object
  Returns:
    the old object at the place of `i`

### moveLastToFirst

    public java.lang.Object moveLastToFirst()

  move the last Element and put it to the front.

  Returns:
    the moved element

### moveFirstToLast

    public java.lang.Object moveFirstToLast()

  move the last Element and put it to the front.

  Returns:
    the moved element

### getElementAt

    public java.lang.Object getElementAt(int i)

  Parameters:
    `i` - index of the element
  Returns:
    returns the element at i or if there is no element or the index is out of range, it returns 0

### getFirst

    public java.lang.Object getFirst()

  Returns:
    the first object of the array

### getLast

    public java.lang.Object getLast()

  Returns:
    the first object of the array

### size

    public int size()

  Returns:
    Returns the length of the with data defined part.

### clear

    public void clear()

  sets all Elements to null and clear the RingVector so that there is no data defined any more.

### toArray

    public java.lang.Object[] toArray()

  Returns:
    the ringVector as array

### clone

    public java.lang.Object clone()

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD