org.vostok.io
Class CharBuffer

java.lang.Object
  extended by org.vostok.io.CharBuffer

public class CharBuffer
extends java.lang.Object

CharBuffer is an array of char than can grow

Author:
levreau.jerome@vostoksystem.eu

Field Summary
static int HUGE
           
static int INSANE
           
static int MEDIUM
           
static int TINY
           
 
Constructor Summary
CharBuffer()
          create a new GrowablecharBuffer with a default growby of 1024
CharBuffer(int growby)
          create a new GrowablecharBuffer with a specific growing policy. use constant ou specify your own size (char). bigger growby is, faster the buffer is but bigger the memory use is too.
 
Method Summary
 char[] copy()
          return a newly allocated copy of the available data
 char[] get()
          return a pointer on the current buffer.
 int getMaxSize()
          return the maximum data this buffer can (currently) hold without resizing
 char[] getNew()
          return a newly allocated array, reflecting the data of the buffer getNew().length==getSize()
 int getSize()
          return the data length.
 void push(char b)
          push a char on top of the buffer, increase buffer size if require
 void push(char[] b)
          push chars on top of the buffer, increase buffer size if require
 void push(char[] b, int length)
          push chars - up to length - on top of the buffer, increase buffer size if require
 void truncate(int length)
          truncate data to length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TINY

public static final int TINY
See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
See Also:
Constant Field Values

HUGE

public static final int HUGE
See Also:
Constant Field Values

INSANE

public static final int INSANE
See Also:
Constant Field Values
Constructor Detail

CharBuffer

public CharBuffer()
create a new GrowablecharBuffer with a default growby of 1024


CharBuffer

public CharBuffer(int growby)
create a new GrowablecharBuffer with a specific growing policy. use constant ou specify your own size (char). bigger growby is, faster the buffer is but bigger the memory use is too.

Parameters:
growby -
Method Detail

push

public void push(char b)
push a char on top of the buffer, increase buffer size if require

Parameters:
b -

push

public void push(char[] b)
push chars on top of the buffer, increase buffer size if require

Parameters:
b -

push

public void push(char[] b,
                 int length)
push chars - up to length - on top of the buffer, increase buffer size if require

Parameters:
b -

copy

public char[] copy()
return a newly allocated copy of the available data

Returns:

get

public char[] get()
return a pointer on the current buffer. keep in mind that get().length != getSize()

Returns:

getNew

public char[] getNew()
return a newly allocated array, reflecting the data of the buffer getNew().length==getSize()

Returns:

truncate

public void truncate(int length)
truncate data to length. This only alter the used data, NOT the actual size of the internal buffer, therefore still get().length != getSize()


getSize

public int getSize()
return the data length. this is the actual length, keep in mind that get().length != getSize()

Returns:

getMaxSize

public int getMaxSize()
return the maximum data this buffer can (currently) hold without resizing

Returns: