casacore
Public Member Functions | List of all members
casacore::HashClass< key > Class Template Referenceabstract

Hash function with state. More...

#include <HashMap.h>

Public Member Functions

virtual uInt hash (const key &)=0
 This function maps elements of key type to any integer. More...
 
virtual HashClass< key > * clone () const =0
 This function is used to make a deep copy. More...
 
 HashClass ()
 
virtual ~HashClass ()
 

Detailed Description

template<class key>
class casacore::HashClass< key >

Hash function with state.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Etymology

This is basically a way of specifying a hash function, but it is implemented as a class. Thus it is called HashClass, similar to "hash function".

Synopsis

This class is used to specify a hash function. Sometimes a hash function may require state, it may be useful to create a hierarchy of hash functions, or it may be useful to create a class which provides for hashing as well as other functionality. This class can be used as a base class for any of these purposed. This class is intended for parameterization of HashMap.

The hash function maps the key type to any integer. This integer is then used by HashMap to select a bucket in the hash table.

Example

If one wished to make a HashClass for integers, something like the following might be done:

class IntHash : public HashClass<Int> {
public:
uInt hash(const Int &v) const { return (uInt) v; }
uInt hash(const Int &v) { return (uInt) v; }
HashClass<Int> *clone() const { return new IntHash; }
IntHash() : HashClass<Int>() { }
};
virtual uInt hash(const key &)=0
This function maps elements of key type to any integer.
virtual HashClass< key > * clone() const =0
This function is used to make a deep copy.
unsigned int uInt
Definition: aipstype.h:51
int Int
Definition: aipstype.h:50

Motivation

There may be occasions when it is more convenient to use a class instead of a single function. This base class provides a starting point plus, and HashMap<k,v> has the necessary hooks to make use of classes derived from this class.

Definition at line 140 of file HashMap.h.

Constructor & Destructor Documentation

◆ HashClass()

template<class key >
casacore::HashClass< key >::HashClass ( )

◆ ~HashClass()

template<class key >
virtual casacore::HashClass< key >::~HashClass ( )
virtual

Member Function Documentation

◆ clone()

template<class key >
virtual HashClass<key>* casacore::HashClass< key >::clone ( ) const
pure virtual

This function is used to make a deep copy.

This means that the copy, which this function returns, contains all derived information.

◆ hash()

template<class key >
virtual uInt casacore::HashClass< key >::hash ( const key &  )
pure virtual

This function maps elements of key type to any integer.

This integer is then used by HashMap to select a bucket in the hash table.


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