# PhasicFlow: src/phasicFlow/containers/Map/hashMap/hashMap.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

hashMap.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __hashMap_hpp__
#define __hashMap_hpp__
#include <unordered_map>
#include "types.hpp"
#include "typeInfo.hpp"
#include "iOstream.hpp"
namespace pFlow
{
template<class Key, class T, class Hash = std::hash<Key> >
class hashMap
:
public std::unordered_map<Key, T, Hash>
{
public:
using hashMapType = hashMap<Key, T, Hash>;
using hashmapType = std::unordered_map<Key, T, Hash>;
using hasher = typename hashmapType::hasher;
using iterator = typename hashmapType::iterator;
using constIterator = typename hashmapType::const_iterator;
using reference = typename hashmapType::reference;
using constReference= typename hashmapType::const_reference ;
using initList = typename std::initializer_list<T>;
using keyType = typename hashmapType::key_type;
using mappedType = typename hashmapType::mapped_type;
using valueType = typename hashmapType::value_type;
TypeInfoTemplateNV11("hashMap", Key);
// Empty hashMap
hashMap()
{}
// - with initList
hashMap(initList lst)
:
hashmapType(lst)
{}
// - Copy construct
hashMap(const hashMapType & src) = default;
// - Move construct
hashMap( hashMapType&& src) = default;
// - Copy assignment
hashMapType& operator=(const hashMapType& rhs) = default;
// - Move assignment
hashMapType& operator=(hashMapType&& rhs) = default;
uniquePtr<hashMapType> clone()const
{
return makeUnique<hashMapType>(*this);
}
~hashMap() = default;
// Insert an item with copy operation
bool insertIf(const keyType& k, const mappedType & v);
// insert an item with move operation
bool insertIf( keyType&& k, mappedType && v);
// search for a key
bool search(const keyType k) const;
std::pair<iterator, bool> findIf(const keyType& k);
const std::pair<constIterator, bool> findIf(const keyType& k) const;
};
template<typename T>
using wordHashMap = hashMap<word,T>;
template<typename T>
using uint64HashMap = hashMap<uint64,T>;
template<typename T>
using uint32HashMap = hashMap<uint32,T>;
template<typename T>
using int64HashMap = hashMap<int64,T>;
template<typename T>
using int32HashMap = hashMap<int32,T>;
template<typename T>
inline iOstream& printKeys(iOstream& os, const wordHashMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const uint64HashMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const uint32HashMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const int64HashMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const int32HashMap<T> & m);
#include "hashMapI.hpp"
} // pFlow
#endif
pFlow::hashMap< void * >::valueType
typename hashmapType::value_type valueType
Definition: hashMap.hpp:62
pFlow::hashMap< void * >::mappedType
typename hashmapType::mapped_type mappedType
Definition: hashMap.hpp:60
pFlow::hashMap::hashMap
hashMap()
Definition: hashMap.hpp:70
types.hpp
pFlow::hashMap
Definition: hashMap.hpp:36
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pFlow::hashMap< void * >::hasher
typename hashmapType::hasher hasher
Definition: hashMap.hpp:46
pFlow::hashMap::TypeInfoTemplateNV11
TypeInfoTemplateNV11("hashMap", Key)
pFlow::hashMap::~hashMap
~hashMap()=default
pFlow
Definition: demGeometry.hpp:27
pFlow::hashMap::findIf
std::pair< iterator, bool > findIf(const keyType &k)
Definition: hashMapI.hpp:48
pFlow::hashMap< void * >::iterator
typename hashmapType::iterator iterator
Definition: hashMap.hpp:48
pFlow::hashMap::clone
uniquePtr< hashMapType > clone() const
Definition: hashMap.hpp:91
pFlow::hashMap::search
bool search(const keyType k) const
Definition: hashMapI.hpp:40
pFlow::hashMap< void * >::reference
typename hashmapType::reference reference
Definition: hashMap.hpp:52
pFlow::hashMap< void * >::hashmapType
std::unordered_map< void *, T, std::hash< void * > > hashmapType
Definition: hashMap.hpp:44
pFlow::hashMap< void * >::constReference
typename hashmapType::const_reference constReference
Definition: hashMap.hpp:54
pFlow::hashMap::hashMap
hashMap(initList lst)
Definition: hashMap.hpp:74
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::hashMap::hashMapType
hashMap< Key, T, Hash > hashMapType
Definition: hashMap.hpp:42
typeInfo.hpp
iOstream.hpp
pFlow::hashMap::operator=
hashMapType & operator=(const hashMapType &rhs)=default
pFlow::hashMap< void * >::initList
typename std::initializer_list< T > initList
Definition: hashMap.hpp:56
m
uint32 m
Definition: NBSLoop.hpp:22
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
hashMapI.hpp
pFlow::hashMap< void * >::keyType
typename hashmapType::key_type keyType
Definition: hashMap.hpp:58
pFlow::hashMap< void * >::constIterator
typename hashmapType::const_iterator constIterator
Definition: hashMap.hpp:50
pFlow::hashMap::insertIf
bool insertIf(const keyType &k, const mappedType &v)
Definition: hashMapI.hpp:23