Package org.carrot2.util
Class MutableCharArray
- java.lang.Object
-
- org.carrot2.util.MutableCharArray
-
- All Implemented Interfaces:
CharSequence,Cloneable
public final class MutableCharArray extends Object implements CharSequence, Cloneable
ImplementsCharSequenceover a mutablechar[]buffer.This class implements proper content-based
hashCode()andequals(Object)against otherMutableCharArrayobjects, assuming the underlying character buffers does not change. In case the buffers is changed, the resulting behavior is unpredictable.
-
-
Constructor Summary
Constructors Constructor Description MutableCharArray()Creates 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.MutableCharArray(CharSequence seq)Creates aMutableCharArrayfrom anotherCharSequence, creates a new buffer to store characters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)MutableCharArrayclone()booleanequals(Object other)See comments in the header of this class.char[]getBuffer()intgetStart()inthashCode()See comments in the header of this class.static inthashCode(char[] buffer, int start, int length)Calculates a hash code for a given portion of the character buffer.intlength()voidreset(char[] buffer)Resets internal buffers in this object to point to another character buffer.voidreset(char[] buffer, int start, int length)Resets internal buffers in this object to point to another character buffer.voidreset(CharSequence seq)Resets internal buffers in this object to represent another character sequence.MutableCharArraysubSequence(int start, int end)char[]toArray()StringtoString()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Constructor Detail
-
MutableCharArray
public MutableCharArray()
Creates an emptyMutableCharArray.
-
MutableCharArray
public MutableCharArray(CharSequence seq)
Creates aMutableCharArrayfrom anotherCharSequence, creates a new buffer to store characters.
-
MutableCharArray
public MutableCharArray(char[] buffer)
Resets the internal buffer to use the provided argument.- See Also:
reset(char[])
-
MutableCharArray
public MutableCharArray(char[] buffer, int start, int length)Resets the internal buffer to use the provided argument.- See Also:
reset(char[])
-
-
Method Detail
-
reset
public void reset(CharSequence seq)
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().
-
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:
getBuffer(),length
-
charAt
public final char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
length
public int length()
- Specified by:
lengthin interfaceCharSequence
-
subSequence
public MutableCharArray subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
hashCode
public int hashCode()
See comments in the header of this class.
-
equals
public boolean equals(Object other)
See comments in the header of this class.
-
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 wrapperMutableCharArraywere created.
-
clone
public MutableCharArray clone()
-
toArray
public char[] toArray()
-
-