|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object
|
+--com.sosnoski.util.GrowableBase
|
+--com.sosnoski.util.array.ArrayBase
|
+--com.sosnoski.util.array.CharArray
|
+--com.sosnoski.util.CharBuffer
Growable char array with added StringBuffer-like
functionality. This implementation differs from StringBuffer in
that it is unsynchronized so as to provide the best possible performance for
typical usage scenarios. Explicit synchronization must be implemented by a
wrapper class or directly by the application in cases where instances are
modified in a multithreaded environment. See the base classes for other
details of the implementation.
This class defines a number of convenience methods for working with
character data (including simple arrays and Strings). Besides
allowing character data to be appended/inserted/replaced in the growable
array, other methods support comparisons between the several forms of
character sequences and calculations of hash codes independent of the form
of the sequence.
| Field Summary | |
protected static int |
KEY_MULTIPLIER
Hash value multiplier to scramble bits in accumulation. |
| Fields inherited from class com.sosnoski.util.array.CharArray |
m_baseArray |
| Fields inherited from class com.sosnoski.util.array.ArrayBase |
m_countPresent |
| Fields inherited from class com.sosnoski.util.GrowableBase |
DEFAULT_SIZE, m_countLimit, m_maximumGrowth |
| Constructor Summary | |
CharBuffer()
Default constructor. |
|
CharBuffer(char[] base)
Constructor from char[]. |
|
CharBuffer(CharArray base)
Copy (clone) constructor. |
|
CharBuffer(int size)
Constructor with initial size specified. |
|
CharBuffer(int size,
int growth)
Constructor with full specification. |
|
CharBuffer(java.lang.String base)
Constructor from String. |
|
| Method Summary | |
protected void |
adjust(int from,
int to,
int length)
Adjust the characters in the array to make room for an insertion or replacement. |
int |
append(char[] text)
Appends all the characters from an array to the current contents of the array. |
int |
append(char[] text,
int offset,
int length)
Appends the characters from an array range to the current contents of the array. |
int |
append(CharArray text)
Appends all the characters from another growable array to the current contents of the array. |
int |
append(java.lang.String text)
Appends the characters from a String to the current contents
of the array. |
java.lang.Object |
clone()
Duplicates the object with the generic call. |
boolean |
equals(char[] comp)
Compare the character sequence in the array with that in a simple array. |
static boolean |
equals(char[] a,
char[] b)
Compare the character sequences in a pair of arrays. |
boolean |
equals(char[] comp,
int offset,
int length)
Compare the character sequence in the array with the characters in a simple array range. |
static boolean |
equals(char[] a,
java.lang.String b)
Compare the character sequences in a simple array and a String. |
boolean |
equals(CharArray comp)
Compare the character sequence in the array with the sequence in another growable array. |
boolean |
equals(java.lang.String comp)
Compare the character sequence in the array with a String. |
boolean |
equalsNoCase(char[] comp)
Compare the character sequence in the array with that in a simple array without regard to case. |
static boolean |
equalsNoCase(char[] a,
char[] b)
Compare the character sequences in a pair of arrays without regard to case. |
boolean |
equalsNoCase(char[] comp,
int offset,
int length)
Compare the character sequence in the array with the characters in a simple array range without regard to case. |
static boolean |
equalsNoCase(char[] a,
java.lang.String b)
Compare the character sequences in a simple array and a String without regard to case. |
boolean |
equalsNoCase(CharArray comp)
Compare the character sequence in the array with the sequence in another growable array without regard to case. |
boolean |
equalsNoCase(java.lang.String comp)
Compare the character sequence in the array with a String
without regard to case. |
int |
hashCode()
Compute a compatible hash code value for this character sequence. |
static int |
hashCode(char[] text)
Compute the compatible hash code value for character sequence in a simple array. |
static int |
hashCode(java.lang.String text)
Compute the compatible hash code value for character sequence in a String. |
void |
insert(int offset,
char[] text)
Insert the characters from a char[] into the array. |
void |
insert(int offset,
java.lang.String text)
Insert the characters from a String into the array. |
void |
replace(int from,
int to,
char[] text)
Replace a character range in the array with the characters from a char[]. |
void |
replace(int from,
int to,
java.lang.String text)
Replace a character range in the array with the characters from a String. |
java.lang.String |
toString()
Construct a String from the character sequence present. |
java.lang.String |
toString(int offset,
int length)
Construct a String from a portion of the character sequence
present. |
| Methods inherited from class com.sosnoski.util.array.CharArray |
add, add, get, getArray, set, setArray, toArray, toArray |
| Methods inherited from class com.sosnoski.util.array.ArrayBase |
buildArray, clear, getAddIndex, getArray, makeInsertSpace, remove, remove, setSize, size |
| Methods inherited from class com.sosnoski.util.GrowableBase |
discardValues, ensureCapacity, growArray, resizeCopy |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static final int KEY_MULTIPLIER
| Constructor Detail |
public CharBuffer(int size,
int growth)
size - number of char values initially allowed in arraygrowth - maximum size increment for growing arraypublic CharBuffer(int size)
size - number of char values initially allowed in arraypublic CharBuffer()
public CharBuffer(java.lang.String base)
String.public CharBuffer(char[] base)
char[].public CharBuffer(CharArray base)
base - instance being copied| Method Detail |
public int append(java.lang.String text)
String to the current contents
of the array.text - String of characters to be appended
public int append(char[] text,
int offset,
int length)
text - array containing characters to be appendedoffset - starting offset in arraylength - length of character range in arraypublic int append(char[] text)
text - array containing characters to be appendedpublic int append(CharArray text)
text - growable array containing characters to be appended
protected void adjust(int from,
int to,
int length)
from - index number of first character to be replacedto - index number past last character to be replacedlength - length of character range being inserted
public void replace(int from,
int to,
java.lang.String text)
String.from - index number of first character to be replacedto - index number past last character to be replacedtext - replacement text
public void replace(int from,
int to,
char[] text)
char[].from - index number of first character to be replacedto - index number past last character to be replacedtext - replacement text
public void insert(int offset,
java.lang.String text)
String into the array.offset - insert position offset in arraytext - insertion text
public void insert(int offset,
char[] text)
char[] into the array.offset - insert position offset in arraytext - insertion textpublic boolean equals(java.lang.String comp)
String.comp - String value to be comparedtrue if the character sequences are identical,
false if they're different
public boolean equals(char[] comp,
int offset,
int length)
comp - array of characters to be comparedoffset - starting offset in arraylength - length of character range in arraytrue if the character sequences are identical,
false if they're differentpublic boolean equals(char[] comp)
comp - array of characters to be comparedtrue if the character sequences are identical,
false if they're differentpublic boolean equals(CharArray comp)
comp - array of characters to be comparedtrue if the character sequences are identical,
false if they're different
public static boolean equals(char[] a,
char[] b)
a - first character sequence array (non-null)b - second character sequence array (may be null)true if the character sequences are identical,
false if they're different
public static boolean equals(char[] a,
java.lang.String b)
String.a - simple array character sequence (non-null)b - String character sequence (may be
null)true if the character sequences are identical,
false if they're differentpublic boolean equalsNoCase(java.lang.String comp)
String
without regard to case.comp - String value to be comparedtrue if the character sequences are identical
except perhaps for case, false if they're different
public boolean equalsNoCase(char[] comp,
int offset,
int length)
comp - array of characters to be comparedoffset - starting offset in arraylength - length of character range in arraytrue if the character sequences are identical
except perhaps for case, false if they're differentpublic boolean equalsNoCase(char[] comp)
comp - array of characters to be comparedtrue if the character sequences are identical
except perhaps for case, false if they're differentpublic boolean equalsNoCase(CharArray comp)
comp - array of characters to be comparedtrue if the character sequences are identical
except perhaps for case, false if they're different
public static boolean equalsNoCase(char[] a,
char[] b)
a - first character sequence array (non-null)b - second character sequence array (may be null)true if the character sequences are identical
except perhaps for case, false if they're different
public static boolean equalsNoCase(char[] a,
java.lang.String b)
String without regard to case.a - simple array character sequence (non-null)b - String character sequence (may be
null)true if the character sequences are identical
except perhaps for case, false if they're differentpublic static int hashCode(char[] text)
text - text to be hashedpublic static int hashCode(java.lang.String text)
String.text - text to be hashedpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object clone()
clone in class CharArraypublic java.lang.String toString()
String from the character sequence present.toString in class java.lang.ObjectString
public java.lang.String toString(int offset,
int length)
String from a portion of the character sequence
present.offset - start offset in arraylength - number of characters to useString
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||