|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.util.StringCache
public class StringCache
Caches strings and provides lookup methods by raw character data to avoid string construction. It is intended to be used in various parsers to reduce memory footprint and garbage.
The StringCache is a N-way set associative cache which distributes all strings into buckets based on hash function and then uses LRU algorithm within each bucket. The StringCache is a thread-safe, asynchronous, wait-free data structure.
Constructor Summary | |
---|---|
StringCache()
Creates a StringCache with default parameters. |
|
StringCache(int size)
Creates a StringCache with the specified number of elements and default bucket size. |
|
StringCache(int bucketNumber,
int bucketSize)
Creates a StringCache with the specified number of buckets and their size. |
Method Summary | |
---|---|
String |
get(char[] c)
Returns string from the cache that matches specified character sequence. |
String |
get(char[] c,
int offset,
int length)
Returns string from the cache that matches specified character sequence. |
String |
get(CharSequence cs)
Returns string from the cache that matches specified character sequence. |
String |
get(String s)
Returns string from the cache that matches specified string. |
String |
get(String s,
boolean copy)
Returns string from the cache that matches specified string. |
String |
getASCII(byte[] b)
Returns string from the cache that matches specified character sequence. |
String |
getASCII(byte[] b,
int offset,
int length)
Returns string from the cache that matches specified character sequence. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StringCache()
public StringCache(int size)
size
- the number of elements
IllegalArgumentException
- if size is not positive or result in too large cachepublic StringCache(int bucketNumber, int bucketSize)
NOTE: cache uses linear search within each bucket, so do not use very large bucket sizes.
bucketNumber
- the number of bucketsbucketSize
- the size of each bucket
IllegalArgumentException
- if parameters are not positive or result in too large cacheMethod Detail |
---|
public String get(String s)
public String get(String s, boolean copy)
public String get(CharSequence cs)
public String get(char[] c)
public String get(char[] c, int offset, int length)
public String getASCII(byte[] b)
public String getASCII(byte[] b, int offset, int length)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |