Package org.carrot2.util
Class MutableCharArray
java.lang.Object
org.carrot2.util.MutableCharArray
- All Implemented Interfaces:
CharSequence
,Cloneable
Implements
CharSequence
over a mutable char[]
buffer.
This class implements proper content-based hashCode()
and equals(Object)
against other MutableCharArray
objects, assuming the underlying character buffers does
not change. In case the buffers is changed, the resulting behavior is unpredictable.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyMutableCharArray
.MutableCharArray
(char[] buffer) Resets the internal buffer to use the provided argument.MutableCharArray
(char[] buffer, int start, int length) Resets the internal buffer to use the provided argument.Creates aMutableCharArray
from anotherCharSequence
, creates a new buffer to store characters. -
Method Summary
Modifier and TypeMethodDescriptionfinal char
charAt
(int index) clone()
boolean
final boolean
equals
(MutableCharArray other) char[]
int
getStart()
int
hashCode()
See comments in the header of this class.static final int
hashCode
(char[] buffer, int start, int length) Calculates a hash code for a given portion of the character buffer.int
length()
void
reset()
Resets internal buffers to an empty string.void
reset
(char[] buffer) Resets internal buffers in this object to point to another character buffer.void
reset
(char[] buffer, int start, int length) Resets internal buffers in this object to point to another character buffer.void
reset
(CharSequence seq) Resets internal buffers in this object to represent another character sequence.subSequence
(int start, int end) char[]
toArray()
toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
MutableCharArray
public MutableCharArray()Creates an emptyMutableCharArray
. -
MutableCharArray
Creates aMutableCharArray
from anotherCharSequence
, creates a new buffer to store characters. -
MutableCharArray
public MutableCharArray(char[] buffer) Resets the internal buffer to use the provided argument.- See Also:
-
MutableCharArray
public MutableCharArray(char[] buffer, int start, int length) Resets the internal buffer to use the provided argument.- See Also:
-
-
Method Details
-
reset
Resets internal buffers in this object to represent another character sequence. See class header notes for side-effects onequals(Object)
andhashCode()
. -
reset
public void reset(char[] buffer) Resets internal buffers in this object to point to another character buffer. See class header notes for side-effects onequals(Object)
andhashCode()
. -
reset
public void reset(char[] buffer, int start, int length) Resets internal buffers in this object to point to another character buffer. See class header notes for side-effects onequals(Object)
andhashCode()
. -
reset
public void reset()Resets internal buffers to an empty string. -
getBuffer
public char[] getBuffer()- Returns:
- Returns the internal buffer currently used to store the content of this char sequence.
-
getStart
public int getStart()- Returns:
- the offset at which the data currently starts in the buffer.
- See Also:
-
charAt
public final char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
hashCode
-
equals
-
equals
-
hashCode
public static final int hashCode(char[] buffer, int start, int length) Calculates a hash code for a given portion of the character buffer. The returned value is identical to what be returned fromhashCode()
if a wrapperMutableCharArray
were created. -
clone
-
toArray
public char[] toArray()
-