dxFeed .Net API  5.13.0
dxFeed .Net API library intended to provide market data access for DX clients
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
com.dxfeed.util.StringCache Class Reference

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. More...

Public Member Functions

 StringCache ()
 Creates a StringCache with default parameters. More...
 
 StringCache (int size)
 Creates a StringCache with the specified number of elements and default bucket size. More...
 
 StringCache (int bucketNumber, int bucketSize)
 Creates a StringCache with the specified number of buckets and their size. NOTE: cache uses linear search within each bucket, so do not use very large bucket sizes. More...
 
string Get (string s)
 Returns string from the cache that matches specified string. More...
 
string Get (string s, bool copy)
 Returns string from the cache that matches specified string. If copy parameter is true then specified string will be copied before being put to cache. More...
 
string Get (string s, int offset, int length)
 Returns string from the cache that matches specified character sequence. More...
 
string Get (object charSequence)
 Returns string from the cache that matches specified character sequence. More...
 
string Get (char[] c)
 Returns string from the cache that matches specified character sequence. More...
 
string Get (char[] c, int offset, int length)
 Returns string from the cache that matches specified character sequence. More...
 
override string ToString ()
 

Private Member Functions

string Finish (string cached, int n, int k)
 

Static Private Member Functions

static bool Eq (string cached, string s, int hash)
 
static bool Eq (string cached, string s, int offset, int length, int hash)
 
static bool Eq (string cached, char[] cs, int hash)
 
static bool Eq (string cached, char[] c, int offset, int length, int hash)
 

Private Attributes

int bucketNumber
 
int bucketSize
 
string [] cache
 
long requestCount
 
long compareCount
 
long missCount
 

Detailed Description

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 & Destructor Documentation

◆ StringCache() [1/3]

com.dxfeed.util.StringCache.StringCache ( )
inline

Creates a StringCache with default parameters.

◆ StringCache() [2/3]

com.dxfeed.util.StringCache.StringCache ( int  size)
inline

Creates a StringCache with the specified number of elements and default bucket size.

Parameters
sizeThe number of elements.
Exceptions
System.ArgumentExceptionIf parameters are not positive or result in too large cache.

◆ StringCache() [3/3]

com.dxfeed.util.StringCache.StringCache ( int  bucketNumber,
int  bucketSize 
)
inline

Creates a StringCache with the specified number of buckets and their size. NOTE: cache uses linear search within each bucket, so do not use very large bucket sizes.

Parameters
bucketNumberThe number of buckets.
bucketSizeThe size of each bucket.
Exceptions
System.ArgumentExceptionIf parameters are not positive or result in too large cache.

Member Function Documentation

◆ Eq() [1/4]

static bool com.dxfeed.util.StringCache.Eq ( string  cached,
string  s,
int  hash 
)
inlinestaticprivate

◆ Eq() [2/4]

static bool com.dxfeed.util.StringCache.Eq ( string  cached,
string  s,
int  offset,
int  length,
int  hash 
)
inlinestaticprivate

◆ Eq() [3/4]

static bool com.dxfeed.util.StringCache.Eq ( string  cached,
char []  cs,
int  hash 
)
inlinestaticprivate

◆ Eq() [4/4]

static bool com.dxfeed.util.StringCache.Eq ( string  cached,
char []  c,
int  offset,
int  length,
int  hash 
)
inlinestaticprivate

◆ Finish()

string com.dxfeed.util.StringCache.Finish ( string  cached,
int  n,
int  k 
)
inlineprivate

◆ Get() [1/6]

string com.dxfeed.util.StringCache.Get ( string  s)
inline

Returns string from the cache that matches specified string.

Parameters
s
Returns

◆ Get() [2/6]

string com.dxfeed.util.StringCache.Get ( string  s,
bool  copy 
)
inline

Returns string from the cache that matches specified string. If copy parameter is true then specified string will be copied before being put to cache.

Parameters
s
copy
Returns

◆ Get() [3/6]

string com.dxfeed.util.StringCache.Get ( string  s,
int  offset,
int  length 
)
inline

Returns string from the cache that matches specified character sequence.

Parameters
s
offset
length
Returns

◆ Get() [4/6]

string com.dxfeed.util.StringCache.Get ( object  charSequence)
inline

Returns string from the cache that matches specified character sequence.

Parameters
charSequence
Returns

◆ Get() [5/6]

string com.dxfeed.util.StringCache.Get ( char []  c)
inline

Returns string from the cache that matches specified character sequence.

Parameters
c
Returns

◆ Get() [6/6]

string com.dxfeed.util.StringCache.Get ( char []  c,
int  offset,
int  length 
)
inline

Returns string from the cache that matches specified character sequence.

Parameters
c
offset
length
Returns

◆ ToString()

override string com.dxfeed.util.StringCache.ToString ( )
inline

Field Documentation

◆ bucketNumber

int com.dxfeed.util.StringCache.bucketNumber
private

◆ bucketSize

int com.dxfeed.util.StringCache.bucketSize
private

◆ cache

string [] com.dxfeed.util.StringCache.cache
private

◆ compareCount

long com.dxfeed.util.StringCache.compareCount
private

◆ missCount

long com.dxfeed.util.StringCache.missCount
private

◆ requestCount

long com.dxfeed.util.StringCache.requestCount
private

The documentation for this class was generated from the following file: