www.cemf.ir
hashMapI.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::hashMap<Key, T, Compare>::iterator, bool>
49 {
50  if( auto iter = this->find(k); iter!= this->end() )
51  return {iter,true};
52  else
53  return {iter,false};
54 }
55 
56 template<class Key, class T, class Compare >
57 const std::pair<typename pFlow::hashMap<Key, T, Compare>::constIterator, bool>
59 {
60  if( auto iter = this->find(k); iter!= this->end() )
61  return {iter,true};
62  else
63  return {iter,false};
64 }
65 
66 
67 template<typename T>
68 inline iOstream& printKeys(iOstream& os, const wordHashMap<T> & m)
69 {
70  if (m.empty())
71  return os<<"wordHashMap is empty"<<endl;
72 
73  for(auto iter = m.cbegin(); iter != m.cend(); iter++ )
74  {
75  os << iter->first<<endl;
76  }
77 
78  return os;
79 }
80 
81 
82 template<typename T>
83 inline iOstream& printKeys(iOstream& os, const uint64HashMap<T> & m)
84 {
85  if (m.empty())
86  return os<<"labelHashMap is empty"<<endl;
87 
88  for(auto iter : m )
89  {
90  os << iter->first<<endl;
91  }
92 
93  return os;
94 }
95 
96 template<typename T>
97 inline iOstream& printKeys(iOstream& os, const uint32HashMap<T> & m)
98 {
99  if (m.empty())
100  return os<<"uint32HashMap is empty"<<endl;
101 
102  for(auto iter : m )
103  {
104  os << iter->first<<endl;
105  }
106 
107  return os;
108 }
109 
110 template<typename T>
111 inline iOstream& printKeys(iOstream& os, const int64HashMap<T> & m)
112 {
113  if (m.empty())
114  return os<<"int64HashMap is empty"<<endl;
115 
116  for(auto iter : m )
117  {
118  os << iter->first<<endl;
119  }
120 
121  return os;
122 }
123 
124 
125 template<typename T>
126 inline iOstream& printKeys(iOstream& os, const int32HashMap<T> & m)
127 {
128  if (m.empty())
129  return os<<"int32HashMap is empty"<<endl;
130 
131  for(auto iter : m )
132  {
133  os << iter->first<<endl;
134  }
135 
136  return os;
137 }
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::find
int64 find(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:69
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::hashMap::findIf
std::pair< iterator, bool > findIf(const keyType &k)
Definition: hashMapI.hpp:48
printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
Definition: hashMapI.hpp:68
pFlow::hashMap::search
bool search(const keyType k) const
Definition: hashMapI.hpp:40
m
uint32 m
Definition: NBSLoop.hpp:22
pFlow::hashMap< void * >::keyType
typename hashmapType::key_type keyType
Definition: hashMap.hpp:58
pFlow::hashMap::insertIf
bool insertIf(const keyType &k, const mappedType &v)
Definition: hashMapI.hpp:23