MapI.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 template<class Key, class T, class Compare >
24 {
25  auto [iter, success] = this->insert( valueType(k,v));
26  return success;
27 }
28 
29 template<class Key, class T, class Compare >
31 {
32  auto [iter, success] = this->insert
33  (
34  std::move( valueType(k,v) )
35  );
36  return success;
37 }
38 
39 template<class Key, class T, class Compare >
41 {
42  auto [iter, found] = findIf(k);
43  return found;
44 }
45 
46 template<class Key, class T, class Compare >
47 std::pair<typename pFlow::Map<Key, T, Compare>::iterator, bool> pFlow::Map<Key, T, Compare>::findIf(const keyType& k)
48 {
49  if( auto iter = this->find(k); iter!= this->end() )
50  return {iter,true};
51  else
52  return {iter,false};
53 }
54 
55 template<class Key, class T, class Compare >
56 const std::pair<typename pFlow::Map<Key, T, Compare>::constIterator, bool> pFlow::Map<Key, T, Compare>::findIf(const keyType& k) const
57 {
58  if( auto iter = this->find(k); iter!= this->end() )
59  return {iter,true};
60  else
61  return {iter,false};
62 }
63 
64 
65 template<typename T>
66 inline iOstream& printKeys(iOstream& os, const wordMap<T> & m)
67 {
68  if (m.empty())
69  return os<<"wordMap is empty"<<endl;
70 
71  for(auto& iter : m)
72  {
73  os << iter.first<<endl;
74  }
75 
76  return os;
77 }
78 
79 
80 template<typename T>
81 inline iOstream& printKeys(iOstream& os, const uint32Map<T> & m)
82 {
83  if (m.empty())
84  return os<<"uint32Map is empty"<<endl;
85 
86  for(auto& iter : m)
87  {
88  os << iter.first<<endl;
89  }
90 
91  return os;
92 }
93 
94 template<typename T>
95 inline iOstream& printKeys(iOstream& os, const labelMap<T> & m)
96 {
97  if (m.empty())
98  return os<<"labelMap is empty"<<endl;
99 
100  for(auto& iter : m)
101  {
102  os << iter.first<<endl;
103  }
104 
105  return os;
106 }
107 
108 template<typename T>
109 inline iOstream& printKeys(iOstream& os, const int32Map<T> & m)
110 {
111  if (m.empty())
112  return os<<"int32Map is empty"<<endl;
113 
114  for(auto& iter : m )
115  {
116  os << iter.first<<endl;
117  }
118 
119  return os;
120 }
121 
122 template<typename T>
123 inline iOstream& printKeys(iOstream& os, const int64Map<T> & m)
124 {
125  if (m.empty())
126  return os<<"int64Map is empty"<<endl;
127 
128  for(auto& iter : m )
129  {
130  os << iter.first<<endl;
131  }
132 
133  return os;
134 }
pFlow::find
int64 find(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:69
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::Map< pFlow::repository * >::mappedType
typename mapType::mapped_type mappedType
Definition: Map.hpp:58
pFlow::Map< pFlow::repository * >::keyType
typename mapType::key_type keyType
Definition: Map.hpp:56
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::findIf
std::pair< iterator, bool > findIf(const keyType &k)
Definition: MapI.hpp:47
pFlow::Map::search
bool search(const keyType k) const
Definition: MapI.hpp:40
printKeys
iOstream & printKeys(iOstream &os, const wordMap< T > &m)
Definition: MapI.hpp:66
m
int32 m
Definition: NBSCrossLoop.hpp:22