# PhasicFlow: src/phasicFlow/containers/Map/Map/Map.hpp Source File

Map.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 __Map_hpp__
#define __Map_hpp__
#include <map>
#include "types.hpp"
#include "iOstream.hpp"
namespace pFlow
{
template<class Key, class T, class Compare = std::less<Key> >
class Map
:
public std::map<Key, T, Compare>
{
public:
using MapType = Map<Key, T, Compare>;
using mapType = std::map<Key, T, Compare>;
using iterator = typename mapType::iterator;
using constIterator = typename mapType::const_iterator;
using reference = typename mapType::reference;
using constReference= typename mapType::const_reference;
using initList = typename std::initializer_list<T>;
using keyType = typename mapType::key_type;
using mappedType = typename mapType::mapped_type;
using valueType = typename mapType::value_type;
// - type info
TypeInfoTemplateNV("Map", Key);
// Empty Map
Map()
{}
// - with initList
Map(initList lst)
:
mapType(lst)
{}
// - Copy construct
Map(const MapType & src)
:
mapType(src)
{}
// - Move construct
Map( MapType&& src)
:
mapType(std::move(src))
{}
// - Copy assignment
MapType& operator=(const MapType& rhs)
{
mapType::operator=(rhs);
return *this;
}
// - Move assignment
MapType& operator=(MapType&& rhs)
{
mapType::operator=( std::move(rhs));
return *this;
}
uniquePtr<MapType> clone()const
{
return makeUnique<MapType>(*this);
}
MapType* clonePtr()const
{
return new MapType(*this);
}
~Map()
{
this->clear();
}
// 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 wordMap = Map<word,T>;
template<typename T>
using labelMap = Map<label,T>;
template<typename T>
using uint32Map = Map<uint32,T>;
template<typename T>
using int32Map = Map<int32,T>;
template<typename T>
using int64Map = Map<int64,T>;
template<typename T>
inline iOstream& printKeys(iOstream& os, const wordMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const labelMap<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const uint32Map<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const int32Map<T> & m);
template<typename T>
inline iOstream& printKeys(iOstream& os, const int64Map<T> & m);
#include "MapI.hpp"
} // pFlow
#endif
pFlow::Map::Map
Map(const MapType &src)
Definition: Map.hpp:78
pFlow::Map< pFlow::repository * >::constReference
typename mapType::const_reference constReference
Definition: Map.hpp:52
pFlow::Map< pFlow::repository * >::iterator
typename mapType::iterator iterator
Definition: Map.hpp:46
pFlow::Map::~Map
~Map()
Definition: Map.hpp:113
pFlow::Map< pFlow::repository * >::mapType
std::map< pFlow::repository *, T, std::less< pFlow::repository * > > mapType
Definition: Map.hpp:44
pFlow::Map::Map
Map(initList lst)
Definition: Map.hpp:72
types.hpp
pFlow::Map::operator=
MapType & operator=(const MapType &rhs)
Definition: Map.hpp:90
pFlow::Map< pFlow::repository * >::initList
typename std::initializer_list< T > initList
Definition: Map.hpp:54
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pFlow::Map::clone
uniquePtr< MapType > clone() const
Definition: Map.hpp:103
pFlow::Map< pFlow::repository * >::mappedType
typename mapType::mapped_type mappedType
Definition: Map.hpp:58
pFlow
Definition: demComponent.hpp:28
pFlow::Map::Map
Map(MapType &&src)
Definition: Map.hpp:84
pFlow::Map< pFlow::repository * >::keyType
typename mapType::key_type keyType
Definition: Map.hpp:56
pFlow::Map::Map
Map()
Definition: Map.hpp:68
pFlow::Map< pFlow::repository * >::reference
typename mapType::reference reference
Definition: Map.hpp:50
pFlow::Map< pFlow::repository * >::constIterator
typename mapType::const_iterator constIterator
Definition: Map.hpp:48
pFlow::Map::insertIf
bool insertIf(const keyType &k, const mappedType &v)
Definition: MapI.hpp:23
pFlow::Map< pFlow::repository * >::valueType
typename mapType::value_type valueType
Definition: Map.hpp:60
pFlow::Map::TypeInfoTemplateNV
TypeInfoTemplateNV("Map", Key)
pFlow::Map::findIf
std::pair< iterator, bool > findIf(const keyType &k)
Definition: MapI.hpp:47
pFlow::Map::MapType
Map< Key, T, Compare > MapType
Definition: Map.hpp:42
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::Map
Definition: Map.hpp:36
pFlow::Map::clonePtr
MapType * clonePtr() const
Definition: Map.hpp:108
pFlow::Map::search
bool search(const keyType k) const
Definition: MapI.hpp:40
iOstream.hpp
MapI.hpp
pFlow::iOstream
Definition: iOstream.hpp:53
m
int32 m
Definition: NBSCrossLoop.hpp:22
pFlow::Map::operator=
MapType & operator=(MapType &&rhs)
Definition: Map.hpp:97