Package net.loomchild.segment.srx.legacy
Class Buffer
java.lang.Object
net.loomchild.segment.srx.legacy.Buffer
- All Implemented Interfaces:
CharSequence
Represents character buffer with fixed capacity.
Implements
CharSequence
methods and in addition queue methods.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) void
dequeue()
void
enqueue
(char character) void
forceEnqueue
(char character) This is the same as: if (buffer.length() * == buffer.getCapacity()) buffer.dequeue(); buffer.enqueue(character);int
private boolean
isEmpty()
private boolean
isFull()
int
length()
subSequence
(int start, int end) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Field Details
-
buffer
private char[] buffer -
head
private int head -
size
private int size
-
-
Constructor Details
-
Buffer
private Buffer(char[] buffer, int head, int size) -
Buffer
public Buffer(int capacity)
-
-
Method Details
-
getCapacity
public int getCapacity() -
enqueue
public void enqueue(char character) -
dequeue
public void dequeue() -
forceEnqueue
public void forceEnqueue(char character) This is the same as: if (buffer.length() * == buffer.getCapacity()) buffer.dequeue(); buffer.enqueue(character);- Parameters:
character
-
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
isEmpty
private boolean isEmpty() -
isFull
private boolean isFull()
-