mpicbg.util
Class RingBuffer<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by mpicbg.util.RingBuffer<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>

public class RingBuffer<T>
extends AbstractList<T>

Version:
0.1b
Author:
Stephan Saalfeld

Nested Class Summary
protected  class RingBuffer.RingBufferIterator
           
protected  class RingBuffer.RingBufferListIterator
           
 
Field Summary
protected  T[] buffer
           
protected static IllegalStateException illegalStateException
           
protected static IndexOutOfBoundsException indexOutOfBoundsException
           
protected  int nextBufferIndex
           
protected  int nextRealIndex
           
protected static NoSuchElementException noSuchElementException
           
protected  int size
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
RingBuffer(int capacity)
           
 
Method Summary
 void add(int index, T element)
           Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.
 boolean add(T element)
           
 void clear()
           
 boolean containsIndex(int index)
           
 T get(int index)
           Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.
protected  boolean indexOutOfBounds(int index)
           
 Iterator<T> iterator()
           
 int lastIndex()
           
 ListIterator<T> listIterator()
           
 ListIterator<T> listIterator(int index)
           
 int nextIndex()
           
 T remove(int index)
           Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.
protected  T removeUnsafe(int index)
           
 int size()
           
 T[] toArray()
           
 
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, indexOf, lastIndexOf, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray
 

Field Detail

indexOutOfBoundsException

protected static final IndexOutOfBoundsException indexOutOfBoundsException

noSuchElementException

protected static final NoSuchElementException noSuchElementException

illegalStateException

protected static final IllegalStateException illegalStateException

buffer

protected final T[] buffer

nextRealIndex

protected int nextRealIndex

size

protected int size

nextBufferIndex

protected int nextBufferIndex
Constructor Detail

RingBuffer

public RingBuffer(int capacity)
Method Detail

containsIndex

public boolean containsIndex(int index)

indexOutOfBounds

protected boolean indexOutOfBounds(int index)

get

public T get(int index)
      throws IndexOutOfBoundsException
Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.

Specified by:
get in interface List<T>
Specified by:
get in class AbstractList<T>
Throws:
IndexOutOfBoundsException

add

public boolean add(T element)
Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>

add

public void add(int index,
                T element)
         throws IndexOutOfBoundsException
Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.

Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>
Throws:
IndexOutOfBoundsException

removeUnsafe

protected T removeUnsafe(int index)

remove

public T remove(int index)
         throws IndexOutOfBoundsException
Doesn not check for index < 0 for efficiency resons, so be sure not to pass negative indices.

Specified by:
remove in interface List<T>
Overrides:
remove in class AbstractList<T>
Throws:
IndexOutOfBoundsException

clear

public void clear()
Specified by:
clear in interface Collection<T>
Specified by:
clear in interface List<T>
Overrides:
clear in class AbstractList<T>

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface List<T>
Overrides:
iterator in class AbstractList<T>

listIterator

public ListIterator<T> listIterator()
Specified by:
listIterator in interface List<T>
Overrides:
listIterator in class AbstractList<T>

listIterator

public ListIterator<T> listIterator(int index)
Specified by:
listIterator in interface List<T>
Overrides:
listIterator in class AbstractList<T>

toArray

public T[] toArray()
Specified by:
toArray in interface Collection<T>
Specified by:
toArray in interface List<T>
Overrides:
toArray in class AbstractCollection<T>

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>

nextIndex

public int nextIndex()

lastIndex

public int lastIndex()


Copyright © 2007-2016 Fiji. All Rights Reserved.