Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Public Types | Public Member Functions | List of all members
XalanDOMStringHashTable Class Reference

Public Types

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

Public Member Functions

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

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator:
eDefaultBucketCount 
eDefaultBucketSize 

Constructor & Destructor Documentation

XalanDOMStringHashTable::XalanDOMStringHashTable ( MemoryManagerType 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::~XalanDOMStringHashTable ( )

Member Function Documentation

size_t XalanDOMStringHashTable::bucketCount ( ) const

Get the number of buckets in the table.

Returns
The number of buckets in the table
void XalanDOMStringHashTable::clear ( )

Clear the hash table.

size_t XalanDOMStringHashTable::collisions ( ) const

Get the collision count.

Release builds will always return 0.

Returns
The number of collisions. Valid only for non-release builds.
const XalanDOMString* 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.
const XalanDOMString* 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 an unsigned int to get the bucket index
Returns
a pointer to the string, or null if not found.
void XalanDOMStringHashTable::getBucketCounts ( BucketCountsType theVector) const

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

Parameters
Avector to return the bucket counts.
MemoryManagerType& XalanDOMStringHashTable::getMemoryManager ( )
const MemoryManagerType& XalanDOMStringHashTable::getMemoryManager ( ) const
void 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.
void 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_t XalanDOMStringHashTable::size ( ) const

Get the number of strings in the table.

Returns
The number of strings in the table

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

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo