Xalan-C++ API Reference  1.12.0
Public Types | Public Member Functions | List of all members
xalanc::XalanDOMStringHashTable Class Reference

#include <xalanc/PlatformSupport/XalanDOMStringHashTable.hpp>

Public Types

enum  { eDefaultBucketCount = 101, eDefaultBucketSize = 15 }
 
typedef XalanVector< const XalanDOMString * > BucketType
 
typedef BucketType::size_type bucket_size_type
 
typedef XalanVector< bucket_size_typeBucketCountsType
 
typedef ExplicitMemoryManagedConstructionTraits< BucketTypeConstructionTraits
 
typedef XalanVector< BucketType, ConstructionTraitsBucketVectorType
 

Public Member Functions

 XalanDOMStringHashTable (MemoryManager &theManager, size_t theBucketCount=eDefaultBucketCount, bucket_size_type theBucketSize=eDefaultBucketSize)
 Create a hash table. More...
 
 ~XalanDOMStringHashTable ()
 
void clear ()
 Clear the hash table. More...
 
size_t size () const
 Get the number of strings in the table. More...
 
size_t bucketCount () const
 Get the number of buckets in the table. More...
 
void getBucketCounts (BucketCountsType &theVector) const
 Get the size of each of the buckets in the table. More...
 
size_t collisions () const
 Get the collision count. More...
 
const XalanDOMStringfind (const XalanDOMString &theString, size_t *theBucketIndex=0) const
 Find a string. More...
 
const XalanDOMStringfind (const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos, size_t *theBucketIndex=0) const
 Find a string. More...
 
void insert (const XalanDOMString &theString)
 Insert a pointer to a string into the table. More...
 
void insert (const XalanDOMString &theString, size_t theBucketIndex)
 Insert a pointer to a string into the table. More...
 
MemoryManager & getMemoryManager ()
 
const MemoryManager & getMemoryManager () const
 

Detailed Description

Definition at line 40 of file XalanDOMStringHashTable.hpp.

Member Typedef Documentation

◆ bucket_size_type

Definition at line 45 of file XalanDOMStringHashTable.hpp.

◆ BucketCountsType

Definition at line 46 of file XalanDOMStringHashTable.hpp.

◆ BucketType

Definition at line 44 of file XalanDOMStringHashTable.hpp.

◆ BucketVectorType

Definition at line 48 of file XalanDOMStringHashTable.hpp.

◆ ConstructionTraits

Definition at line 47 of file XalanDOMStringHashTable.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
eDefaultBucketCount 
eDefaultBucketSize 

Definition at line 50 of file XalanDOMStringHashTable.hpp.

Constructor & Destructor Documentation

◆ XalanDOMStringHashTable()

xalanc::XalanDOMStringHashTable::XalanDOMStringHashTable ( MemoryManager &  theManager,
size_t  theBucketCount = eDefaultBucketCount,
bucket_size_type  theBucketSize = eDefaultBucketSize 
)
explicit

Create a hash table.

Parameters
theBucketCountThe number of buckets to use for the hash table. This should be a prime number for best results.
theBucketSizeThe initial size of each bucket in the hash table.

◆ ~XalanDOMStringHashTable()

xalanc::XalanDOMStringHashTable::~XalanDOMStringHashTable ( )
inline

Definition at line 65 of file XalanDOMStringHashTable.hpp.

Member Function Documentation

◆ bucketCount()

size_t xalanc::XalanDOMStringHashTable::bucketCount ( ) const
inline

Get the number of buckets in the table.

Returns
The number of buckets in the table

Definition at line 90 of file XalanDOMStringHashTable.hpp.

◆ clear()

void xalanc::XalanDOMStringHashTable::clear ( )

Clear the hash table.

◆ collisions()

size_t xalanc::XalanDOMStringHashTable::collisions ( ) const
inline

Get the collision count.

Release builds will always return 0.

Returns
The number of collisions. Valid only for non-release builds.

Definition at line 110 of file XalanDOMStringHashTable.hpp.

◆ find() [1/2]

const XalanDOMString* xalanc::XalanDOMStringHashTable::find ( const XalanDOMChar *  theString,
XalanDOMString::size_type  theLength = XalanDOMString::npos,
size_t *  theBucketIndex = 0 
) const

Find a string.

If the string is not found, return null. If theBucketIndex is not null, the variable pointed to will be updated with the bucket index that was calculated for the string. This index can be used in a later call to insert() to avoid recalculating the index.

Parameters
theStringThe string to find.
theLengthThe number of characters in the string.
theBucketIndexA pointer to a parameter to get the bucket index
Returns
a pointer to the string, or null if not found.

◆ find() [2/2]

const XalanDOMString* xalanc::XalanDOMStringHashTable::find ( const XalanDOMString theString,
size_t *  theBucketIndex = 0 
) const

Find a string.

If the string is not found, return null.

Parameters
theStringThe string to find.
theBucketIndexThe index of the bucket for the string.
Returns
a pointer to the string, or null if not found.

◆ getBucketCounts()

void xalanc::XalanDOMStringHashTable::getBucketCounts ( BucketCountsType theVector) const

Get the size of each of the buckets in the table.

Parameters
Avector to return the bucket counts.

◆ getMemoryManager() [1/2]

MemoryManager& xalanc::XalanDOMStringHashTable::getMemoryManager ( )
inline

Definition at line 181 of file XalanDOMStringHashTable.hpp.

◆ getMemoryManager() [2/2]

const MemoryManager& xalanc::XalanDOMStringHashTable::getMemoryManager ( ) const
inline

Definition at line 187 of file XalanDOMStringHashTable.hpp.

◆ insert() [1/2]

void xalanc::XalanDOMStringHashTable::insert ( const XalanDOMString theString)

Insert a pointer to a string into the table.

If the string is already present, the string will still be added, but it will never be found, since it will be placed after the identical string.

Note that this class only stores a pointer to a XalanDOMString. It's expected that the string will be allocated and managed outside of the hash table.

Parameters
theStringThe string to insert.

◆ insert() [2/2]

void xalanc::XalanDOMStringHashTable::insert ( const XalanDOMString theString,
size_t  theBucketIndex 
)

Insert a pointer to a string into the table.

If the string is already present, the string will still be added, but it will never be found, since it will be placed after the identical string. theBucketIndex must be the index returned from a previous call to find. If not, then the behavior is undefined. This is meant as an optimization to avoid re-hashing the string.

Note that this class only stores a pointer to a XalanDOMString. It's expected that the string will be allocated and managed outside of the hash table.

Parameters
theStringThe string to insert.
theBucketIndexThe index of the bucket for the string.

◆ size()

size_t xalanc::XalanDOMStringHashTable::size ( ) const
inline

Get the number of strings in the table.

Returns
The number of strings in the table

Definition at line 79 of file XalanDOMStringHashTable.hpp.


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