OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
ids.hpp
1/*
2 * ids.hpp
3 *
4 * Created on: Mar 1, 2016
5 * Author: i-bird
6 */
7
8#ifndef SRC_GRAPH_IDS_HPP_
9#define SRC_GRAPH_IDS_HPP_
10
18struct rid
19{
21 idx_t id;
22
28 rid(size_t id)
29 :id(id)
30 {}
31
34 :id(0)
35 {}
36
44 inline bool operator<=(const rid & r) const
45 {
46 return id <= r.id;
47 }
48
56 inline bool operator<(const rid & r) const
57 {
58 return id < r.id;
59 }
60
68 inline rid operator-(int i) const
69 {
70 struct rid tmp;
71 tmp.id = id - i;
72 return tmp;
73 }
74
82 inline rid operator-(struct rid i) const
83 {
84 struct rid tmp;
85 tmp.id = id - i.id;
86 return tmp;
87 }
88
96 inline rid operator+(int i) const
97 {
98 struct rid tmp;
99 tmp.id = id + i;
100 return tmp;
101 }
102
110 inline rid & operator+=(const rid & i)
111 {
112 id += i.id;
113 return *this;
114 }
115
121 inline rid & operator++()
122 {
123 id++;
124
125 return *this;
126 }
127
135 inline bool operator==(const rid & r) const
136 {
137 return id == r.id;
138 }
139};
140
148struct gid
149{
150 size_t id;
151
153 gid(){};
154
156 gid(size_t id)
157 :id(id)
158 {}
159};
160
168struct lid
169{
170 size_t id;
171};
172
173// define hash map for gid rid and lid
174
175namespace std
176{
177 template <>
178 struct hash<rid>
179 {
180 inline std::size_t operator()(const rid& k) const
181 {
182 return k.id;
183 }
184 };
185
186 template <>
187 struct hash<gid>
188 {
189 inline std::size_t operator()(const gid& k) const
190 {
191 return k.id;
192 }
193 };
194
195 template <>
196 struct hash<lid>
197 {
198 inline std::size_t operator()(const lid& k) const
199 {
200 return k.id;
201 }
202 };
203
204}
205
206
207#endif /* SRC_GRAPH_IDS_HPP_ */
Definition ids.hpp:149
gid()
Constructor.
Definition ids.hpp:153
gid(size_t id)
Constructor.
Definition ids.hpp:156
Definition ids.hpp:169
Definition ids.hpp:19
rid operator-(struct rid i) const
Subtract two gid.
Definition ids.hpp:82
rid(size_t id)
Cosntructor from id.
Definition ids.hpp:28
idx_t id
id
Definition ids.hpp:21
rid()
Constructor.
Definition ids.hpp:33
rid & operator+=(const rid &i)
Sum two gid.
Definition ids.hpp:110
rid & operator++()
Increment the id.
Definition ids.hpp:121
rid operator+(int i) const
Sum two gid.
Definition ids.hpp:96
bool operator<=(const rid &r) const
Compare two gid.
Definition ids.hpp:44
rid operator-(int i) const
Subtract two gid.
Definition ids.hpp:68
bool operator<(const rid &r) const
Compare two gid.
Definition ids.hpp:56
bool operator==(const rid &r) const
compare two ids
Definition ids.hpp:135