it.lilik.capturemjpeg
Class CircularBuffer

java.lang.Object
  extended by it.lilik.capturemjpeg.CircularBuffer

 class CircularBuffer
extends Object

A circular buffer of ByteArrayInputStream

Author:
Alessio Caiazza, Cosimo Cecchi

Field Summary
(package private) static int DEFAULT_SIZE
          default size
 
Constructor Summary
CircularBuffer()
          Creates a CircularBuffer with internel buffer of DEFAULT_SIZE
CircularBuffer(int size)
          Creates a new CircularBuffer with the specified size.
 
Method Summary
 void clear()
          Clears the contents of the buffer.
 int getLength()
          Returns the number of elements into the buffer
 int getSize()
          Returns the size of the buffer.
 boolean isEmpty()
          Returns the status of the buffer.
 ByteArrayInputStream pop()
          Gets the first available element.
 void push(ByteArrayInputStream data)
          Adds a an element to the CircularBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

static final int DEFAULT_SIZE
default size

See Also:
Constant Field Values
Constructor Detail

CircularBuffer

public CircularBuffer(int size)
Creates a new CircularBuffer with the specified size.

Parameters:
size - the size of the buffer.

CircularBuffer

public CircularBuffer()
Creates a CircularBuffer with internel buffer of DEFAULT_SIZE

Method Detail

push

public void push(ByteArrayInputStream data)
Adds a an element to the CircularBuffer

Parameters:
data - the new element

getLength

public int getLength()
Returns the number of elements into the buffer

Returns:
the number of valid elements

pop

public ByteArrayInputStream pop()
Gets the first available element.

Returns:
the first element
Throws:
IndexOutOfBoundsExceptions

isEmpty

public boolean isEmpty()
Returns the status of the buffer.

Returns:
true if empty, otherwise false

clear

public void clear()
Clears the contents of the buffer.


getSize

public int getSize()
Returns the size of the buffer.

Returns:
the size of the buffer.


Copyright © 2008-09 Alessio Caiazza, Cosimo Cecchi All Rights Reserved.