public final class CharArrayPool
extends java.lang.Object
CharArrayPool
is a utility class used by for
pooling common char[] to reduce overall memory footprint.Modifier and Type | Field and Description |
---|---|
static java.util.Comparator |
CHAR_ARRAY_COMPARATOR
Our char[] comparator instance.
|
Constructor and Description |
---|
CharArrayPool(int initialSize)
Construct a new CharArrayPool of given initial size.
|
Modifier and Type | Method and Description |
---|---|
char[] |
add(char[] keyword)
Utility routine which adds the char[] keyword to the pool, ensuring
that the instance of the keyword of the pool is returned if
it already exists.
|
char[] |
add(javax.swing.text.Segment keywordSegment)
Utility routine which adds the keyword to the pool, ensuring
that the instance of the keyword of the pool is returned if
it already exists.
|
char[] |
add(java.lang.String keyword)
Utility routine which adds the keyword to the pool, ensuring
that the instance of the keyword of the pool is returned if
it already exists.
|
boolean |
contains(char[] keyword)
Check whether the pool contains the given keyword
|
java.util.Iterator |
iterator()
Fetch an iterator to get the keywords for this pool.
|
int |
size()
Fetch the size of this keyword pool.
|
void |
trimToSize()
Trims size of keyword pool to reduce wasted space.
|
public static final java.util.Comparator CHAR_ARRAY_COMPARATOR
public CharArrayPool(int initialSize)
initialSize
- the initial size to use for the char[] poolpublic char[] add(char[] keyword)
keyword
- the char[] keyword to internpublic char[] add(java.lang.String keyword)
keyword
- the keyword to internpublic char[] add(javax.swing.text.Segment keywordSegment)
keyword
- the keyword to internpublic int size()
public boolean contains(char[] keyword)
keyword
- the keyword to checkpublic java.util.Iterator iterator()
public void trimToSize()