|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.util.CircularCharArrayBuffer
public class CircularCharArrayBuffer
A circular char buffer, that can be used to implement a sliding
window over a text. The buffer has a maximum size, fixed at construction time. As new characters
are added, the oldest ones are discarded if necessary. At all
times, the number of available characters present in the buffer is size()
(it will never be larger
than the buffer size). The characters present in the buffer are provided through the toCharArray(char[], int, int)
method and alike.
Constructor Summary | |
---|---|
CircularCharArrayBuffer(int maxChar)
Creates a new circular buffer. |
Method Summary | |
---|---|
void |
add(char[] b,
int offset,
int length)
Adds the characters b[offset] , … b[offset+length-1] to the
buffer (possibly just the last ones, and possibly discarding the oldest characters in the buffer). |
void |
clear()
Clears the buffer content, before reuse. |
int |
size()
The number of characters present in the buffer. |
char[] |
toCharArray()
Returns a new array containing a copy of the buffer content. |
void |
toCharArray(char[] b)
Copies the content of the buffer to an array. |
void |
toCharArray(char[] b,
int offset,
int length)
Copies the content of the buffer to an array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CircularCharArrayBuffer(int maxChar)
maxChar
- the buffer size.Method Detail |
---|
public void add(char[] b, int offset, int length)
b[offset]
, … b[offset+length-1]
to the
buffer (possibly just the last ones, and possibly discarding the oldest characters in the buffer).
b
- the array whence characters are copied.offset
- the starting point.length
- the (maximum) number of characters to be copied.public void toCharArray(char[] b, int offset, int length)
b
- the buffer where the content is to be copied.offset
- the starting index where copy should start from.length
- the maximum number of characters to be copied.public void toCharArray(char[] b)
b
- the buffer where the content is to be copied.public char[] toCharArray()
public int size()
public void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |