JX Application Framework
Loading...
Searching...
No Matches
Public Member Functions | List of all members
JHashRecord< V > Class Template Reference

#include <JHashRecord.h>

Public Member Functions

 JHashRecord ()
 
 JHashRecord (JHashValue hash, const V &value)
 
 ~JHashRecord ()
 
JHashRecordT::State GetState () const
 
bool IsEmpty () const
 
bool IsDeleted () const
 
bool IsFull () const
 
JHashValue GetHashValue () const
 
const V & GetValue () const
 
void Set (const JHashValue hash, const V &value)
 
void Set (const V &value)
 
void Remove ()
 
void MarkEmpty ()
 
void PrintLayout ()
 

Constructor & Destructor Documentation

◆ JHashRecord() [1/2]

template<class V >
JHashRecord< V >::JHashRecord ( )

JHashRecord encapsulates the per-entry information needed by JHashTable. JHashTable itself only requires the state information and treats the rest of the data (the template parameter) opaquely. Only client code need understand the properties of the data and provide hash values and key comparisons. Care must be taken to ensure that the hash value is the correct one for the given key.

It is perhaps unusual that the hash value would be stored in the table itself, which uses considerable extra space in a large table. For static tables it is unnecessary, since the location itself is the hash value. To implement dynamic resizing, however, the location is essentially only a partial hash value (for JHashTable, the hash value modulo the tablesize), and the complete hash value must be cached to determine the new location of a record in a larger table.

Base code generated by Codemill v0.1.0

◆ JHashRecord() [2/2]

template<class V >
JHashRecord< V >::JHashRecord ( JHashValue  hash,
const V &  value 
)

◆ ~JHashRecord()

template<class V >
JHashRecord< V >::~JHashRecord ( )

Member Function Documentation

◆ GetHashValue()

template<class V >
JHashValue JHashRecord< V >::GetHashValue ( ) const
inline

◆ GetState()

template<class V >
JHashRecordT::State JHashRecord< V >::GetState ( ) const
inline

◆ GetValue()

template<class V >
const V & JHashRecord< V >::GetValue ( ) const
inline

◆ IsDeleted()

template<class V >
bool JHashRecord< V >::IsDeleted ( ) const
inline

◆ IsEmpty()

template<class V >
bool JHashRecord< V >::IsEmpty ( ) const
inline

◆ IsFull()

template<class V >
bool JHashRecord< V >::IsFull ( ) const
inline

◆ MarkEmpty()

template<class V >
void JHashRecord< V >::MarkEmpty ( )
inline

DANGER! Extreme memory leak hazard!

Don't use this unless you know what you're doing–this is the single easiest way to rip a hash table to shreds, and likely leak memory too.

◆ PrintLayout()

template<class V >
void JHashRecord< V >::PrintLayout ( )

Prints the layout of a JHashRecord in memory. Useful for optimizing the memory usage on a particular architecture, which can be important considering how many records can potentially be stored.

This method ought to be static but isn't to accomodate how certain compilers implement sizeof() and/or offsetof(). It isn't very hard to use the default constructor to create a throwaway object anyway.

◆ Remove()

template<class V >
void JHashRecord< V >::Remove ( )
inline

If the state is kFull, sets it to kDeleted (in other words, won't mark a kEmpty record kDeleted).

◆ Set() [1/2]

template<class V >
void JHashRecord< V >::Set ( const JHashValue  hash,
const V &  value 
)

Some fields cannot be set individually to make it harder to set the value incorrectly (such as accidentally marking it empty or giving it a hash value which does not match the value).

◆ Set() [2/2]

template<class V >
void JHashRecord< V >::Set ( const V &  value)

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