Lolly 1.4.27
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
hashfunc_rep< T, U > Class Template Reference

A concrete implementation of a hash function for a given type. More...

#include <hashfunc.hpp>

Inheritance diagram for hashfunc_rep< T, U >:
Inheritance graph
[legend]
Collaboration diagram for hashfunc_rep< T, U >:
Collaboration graph
[legend]

Public Member Functions

 hashfunc_rep (U(*func2)(T), U init)
 Constructor for hashfunc_rep.
 
apply (T x)
 Applies the hash function to the given input.
 
- Public Member Functions inherited from concrete_struct
 concrete_struct ()
 Default constructor for the concrete object. Increments the reference count.
 
virtual ~concrete_struct ()
 Virtual destructor for the concrete object. Decrements the reference count.
 

Private Attributes

U(* func )(T)
 
hashmap< T, U > remember
 

Additional Inherited Members

- Public Attributes inherited from concrete_struct
int ref_count
 The reference count for the concrete object.
 

Detailed Description

template<class T, class U>
class hashfunc_rep< T, U >

A concrete implementation of a hash function for a given type.

Template Parameters
TThe input type of the hash function.
UThe output type of the hash function.

Definition at line 18 of file hashfunc.hpp.

Constructor & Destructor Documentation

◆ hashfunc_rep()

template<class T , class U >
hashfunc_rep< T, U >::hashfunc_rep ( U(*)(T) func2,
U init )
inline

Constructor for hashfunc_rep.

Parameters
func2A pointer to the hash function to be used.
initThe initial value for the hash map.

Definition at line 27 of file hashfunc.hpp.

28 : func (func2), remember (init) {}
U(* func)(T)
Definition hashfunc.hpp:19
hashmap< T, U > remember
Definition hashfunc.hpp:20
The list class represents a linked list.
Definition list.hpp:48

Member Function Documentation

◆ apply()

template<class T , class U >
U hashfunc_rep< T, U >::apply ( T x)

Applies the hash function to the given input.

Parameters
xThe input value to be hashed.
Returns
The output of the hash function for the given input.

Definition at line 18 of file hashfunc.ipp.

18 {
19 if (remember->contains (x)) return remember[x];
20 U y = func (x);
21 remember (x)= y;
22 return y;
23}

Member Data Documentation

◆ func

template<class T , class U >
U(* hashfunc_rep< T, U >::func) (T)
private

A pointer to the hash function.

Definition at line 19 of file hashfunc.hpp.

◆ remember

template<class T , class U >
hashmap<T, U> hashfunc_rep< T, U >::remember
private

A hash map to store remembered values.

Definition at line 20 of file hashfunc.hpp.


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