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 TypeMethodDescriptioncharcharAt(int index) voiddequeue()voidenqueue(char character) voidforceEnqueue(char character) This is the same as: if (buffer.length() * == buffer.getCapacity()) buffer.dequeue(); buffer.enqueue(character);intprivate booleanisEmpty()private booleanisFull()intlength()subSequence(int start, int end) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
isEmpty
private boolean isEmpty() -
isFull
private boolean isFull()
-