14 return atoi(s.c_str());
57 _bound.first = vin[0][0], _bound.second = vin[0][0], _inv.clear();
60 for (i = 0; i < vin.size(); i++)
62 for (j = 0; j < vin[i].size(); ++j)
64 if (_bound.first > vin[i][j])
65 _bound.first = vin[i][j];
66 if (_bound.second < vin[i][j])
67 _bound.second = vin[i][j];
70 unsigned int gap = _bound.second - _bound.first + 1;
72 for (i = 0; i < gap; i++)
75 for (i = 0; i < vin.size(); i++)
77 for (j = 0; j < vin[i].size(); ++j)
79 _inv[vin[i][j] - _bound.first].push_back(i);
82 shift_bits_subsequence = 0;
100 _bound.first = 0, _bound.second = 0, _inv.clear();
102 vector<vector<int> > vin_after_shift;
104 unordered_map<int, int> _map;
105 for(i = 0; i < vin.size(); ++i)
108 for(j = 0; j < vin[i].size(); ++j)
111 unordered_map<int, int>::iterator result = _map.find(vin[i][j]);
112 if(result == _map.end())
114 temp_value = vin[i][j]<<shift_bits;
115 _map.insert({vin[i][j], 0});
119 if(result->second < 63)
121 temp_value = (result->first<<shift_bits) + result->second;
124 unordered_map<int, int>::iterator it = _distinct.find(temp_value);
125 if(it != _distinct.end())
126 temp_value = it->second;
129 _distinct.insert({temp_value, _distinct.size()});
131 temp_value = _distinct.size() - 1;
134 line.push_back(temp_value);
136 vin_after_shift.push_back(line);
139 _bound.second = _distinct.size() - 1;
141 unsigned int gap = _bound.second - _bound.first + 1;
144 for (i = 0; i < gap; i++)
147 for (i = 0; i < vin_after_shift.size(); ++i)
149 for (j = 0; j < vin_after_shift[i].size(); ++j)
151 _inv[vin_after_shift[i][j] - _bound.first].push_back(i);
155 shift_bits_subsequence = 0;
161 unsigned int *index,
unsigned int row_num)
167 for (i = 0; i < item_num; ++i)
169 if (_bound.first > data[i])
170 _bound.first = data[i];
171 if (_bound.second < data[i])
172 _bound.second = data[i];
174 unsigned int gap = _bound.second - _bound.first + 1;
176 for (i = 0; i < gap; ++i)
178 for (i = 0; i < row_num - 1; ++i)
179 for (j = index[i] - index[0]; j < index[i + 1] - index[0]; ++j)
180 _inv[data[j] - _bound.first].push_back(i);
182 for (i = index[row_num - 1]; i < item_num; ++i)
183 _inv[data[i] - _bound.first].push_back(row_num - 1);
185 shift_bits_subsequence = 0;
195 _bound.first = vin[0][0], _bound.second = vin[0][0], _inv.clear();
197 unsigned int i, j, max_offset_subsequence=0;
198 for (i = 0; i < vin.size(); i++)
200 if(vin[i].size() > max_offset_subsequence)
201 max_offset_subsequence = vin[i].size();
202 for (j = 0; j < vin[i].size(); ++j)
204 if (_bound.first > vin[i][j])
205 _bound.first = vin[i][j];
206 if (_bound.second < vin[i][j])
207 _bound.second = vin[i][j];
210 unsigned int gap = _bound.second - _bound.first + 1;
213 shift_bits_subsequence = 0;
214 for(i = 1 ; i < max_offset_subsequence ; i *= 2)
215 shift_bits_subsequence++;
217 for (i = 0; i < gap; i++)
220 unsigned int rowID_offset;
221 for (i = 0; i < vin.size(); i++)
223 for (j = 0; j < vin[i].size(); ++j)
225 rowID_offset = (i<<shift_bits_subsequence) + j;
226 _inv[vin[i][j] - _bound.first].push_back(rowID_offset);
237 unsigned int i, j, max_offset_subsequence=0;
239 _bound.first = data[0], _bound.second = data[0], _inv.clear();
240 for( i = 1; i < row_num ;++i )
242 length = index[i] - index[i-1];
243 if(length > max_offset_subsequence)
244 max_offset_subsequence = length;
246 length = item_num - index[row_num - 1];
247 if(length > max_offset_subsequence)
248 max_offset_subsequence = length;
250 for (i = 0; i < item_num; ++i)
252 if (_bound.first > data[i])
253 _bound.first = data[i];
254 if (_bound.second < data[i])
255 _bound.second = data[i];
257 unsigned int gap = _bound.second - _bound.first + 1;
260 shift_bits_subsequence = 0;
261 for(i = 1 ; i < max_offset_subsequence ; i *= 2)
262 shift_bits_subsequence++;
264 for (i = 0; i < gap; ++i)
267 unsigned int rowID_offset;
269 for (i = 0; i < row_num - 1; ++i)
272 for (j = index[i] - index[0]; j < index[i + 1] - index[0]; ++j)
274 rowID_offset = (i<<shift_bits_subsequence) + offset;
275 _inv[data[j] - _bound.first].push_back(rowID_offset);
280 int rowID = (row_num - 1)<<shift_bits_subsequence;
281 for (i = index[row_num - 1] - index[0]; i < item_num; ++i)
283 rowID_offset = rowID + offset;
284 _inv[data[i] - _bound.first].push_back(rowID_offset);
292 return shift_bits_subsequence;
301 _bound.first = vin[0], _bound.second = vin[0], _inv.clear();
304 for (i = 0; i < vin.size(); i++)
306 if (_bound.first > vin[i])
307 _bound.first = vin[i];
308 if (_bound.second < vin[i])
309 _bound.second = vin[i];
312 unsigned int gap = _bound.second - _bound.first + 1;
314 for (i = 0; i < gap; i++)
317 for (i = 0; i < vin.size(); i++)
318 _inv[vin[i] - _bound.first].push_back(i);
338 int (*stoi)(
string&))
344 _bound.first = stoi(vin[0]);
345 _bound.second = stoi(vin[0]);
349 for (i = 0; i < vin.size(); i++)
351 if (_bound.first > stoi(vin[i]))
352 _bound.first = stoi(vin[i]);
353 if (_bound.second < stoi(vin[i]))
354 _bound.second = stoi(vin[i]);
357 unsigned int gap = _bound.second - _bound.first + 1;
359 for (i = 0; i < gap; i++)
362 for (i = 0; i < vin.size(); i++)
363 _inv[stoi(vin[i]) - _bound.first].push_back(i);
368 int (*stoi)(
string&))
375 if (value > _bound.second || value < _bound.first)
383 if (!contains(value))
385 return &_inv[value - min()];
void invert_bijectMap(std::vector< std::vector< int > > &vin)
int size()
Return the number of instances.
void invert_subsequence(std::vector< std::vector< int >> &vin)
inv_list()
Create an empty inv_list.
unsigned int _shift_bits_subsequence()
int max()
Return the max value of the inverted vector.
int value_range()
Return the number of different values in the attribute.
int min()
Return the min value of the inverted vector.
Declaration of inv_list class.
std::vector< int > * index(int value)
The indexes of the value.
void invert(std::vector< int > &vin)
bool contains(int value)
Check whether the vaule is in the inv_list.
void invert_sequence(std::vector< std::vector< int >> &vin, int shift_bits)
This is used for sequence match.