28 #ifndef CASA_HASHMAP_H
29 #define CASA_HASHMAP_H
31 #ifndef AIPS_USE_DEPRECATED
32 #error "HashMap.h is deprecated; use -DBUILD_DEPRECATED=ON to use it"
36 #include <casacore/casa/aips.h>
37 #include <casacore/casa/Containers/Block.h>
38 #include <casacore/casa/Containers/List.h>
39 #include <casacore/casa/Containers/OrderedPair.h>
40 #include <casacore/casa/Exceptions/Error.h>
45 template<
class key,
class val>
class ConstHashMapIter;
84 const Int &defaultHashValue(
const Int *);
301 template<
class key,
class val>
class HashMap {
330 HashMap(
const val &dflt = defaultHashValue((
const val*)(0)),
528 #ifndef CASACORE_NO_AUTO_TEMPLATES
529 #include <casacore/casa/Containers/HashMap.tcc>
Hash function with state.
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.
Associative Array with a hash table implementation.
uInt allocBuckets() const
Number of buckets which have been allocated, i.e.
uInt used_
Slots Being Used.
uInt hash(const key &k) const
Call the hash function.
void setMaxLoad(float new_max)
PtrBlock< List< OrderedPair< key, val > > * > blk
void freeTable()
delete the contents of the hash table
const val & defaultVal() const
Retrieve the default value.
uInt totalBuckets() const
Total number of buckets, i.e.
uInt(* Func)(const key &)
Signature of the hash functions.
HashMap(const val &dflt, Func newfunc, float maxlf=float(defaultMaxLoad_))
Constructor which allows for specifying:
uInt defs_
Number of Defined Mappings.
uInt availableBuckets() const
Number of buckets available, i.e.
HashClass< key > * hashClass
uInt enlarge()
enlarge the hash table.
static uInt defaultSize()
HashMap(const val &dflt, const HashClass< key > &newfunc, float maxlf=float(defaultMaxLoad_))
uInt totalSize() const
Total size of this HashMap minus dynamically allocated memory for key or val.
void remove(const key &k)
Remove a user defined mapping from k to a value.
static float defaultMaxLoad()
Bool empty() const
Have any mappings been defined by the user.
Block< uInt > distribution() const
This returns a Block which has the number of elements in each bucket of the table.
HashMap(const val &dflt, uInt size, const HashClass< key > &newfunc, float maxlf=float(defaultMaxLoad_))
uInt ndefined() const
Number of mappings which have been defined by the user.
Bool isDefined(const key &k) const
Check to see if a user defined mapping exists for k.
float maxLoad() const
Get or set the maximum load factor.
HashMap< key, val > & operator=(const HashMap< key, val > &)
This copies the right hand side of the assignment.
float loading() const
Current hash table loading factor.
uInt usedBuckets() const
Number of buckets currently populated by a bucket list.
HashMap(const val &dflt=defaultHashValue((const val *)(0)), uInt size=uInt(defaultSize_), Func newfunc=hashFunc, float maxlf=float(defaultMaxLoad_))
Default constructor (and variation) which allows for specifying:
HashMap(const HashMap &)
Copy constructor with copy semantics.
uInt populate(uInt to)
populate bucket "to".
const val & operator()(const key &ky) const
Retrieve values from the map, possibly for later assignment.
float maxLoad_
Maximum load.
val & define(const key &k, const val &v)
Define a complete mapping.
uInt filled_
Slots with At Least One Value in the Bucket.
void clear()
Remove all user defined mapping.
A drop-in replacement for Block<T*>.
String: the storage and methods of handling collections of characters.
this file contains all the compiler specific defines
void throw_invalid_hashmapiter_error()
uInt hashFunc(const ObjectID &)
void throw_hashmapiter_init_error()
bool Bool
Define the standard types used by Casacore.
const uLong & defaultHashValue(const uLong *)
const Float & defaultHashValue(const Float *)
const Int & defaultHashValue(const Int *)
const Long & defaultHashValue(const Long *)
const uInt & defaultHashValue(const uInt *)
const Double & defaultHashValue(const Double *)
uInt hashFunc(const int &)
uInt hashFunc(const double &)
uInt hashFunc(const String &)
uInt hashFunc(const float &)