11 #include <boost/array.hpp>
12 #include <boost/functional/hash.hpp>
13 #include <boost/unordered/unordered_map.hpp>
18 #ifndef OPENMS_COMPARISON_CLUSTERING_HASHGRID_H
19 #define OPENMS_COMPARISON_CLUSTERING_HASHGRID_H
33 template<
typename Cluster>
51 typedef typename boost::unordered_multimap<ClusterCenter, Cluster>
CellContent;
56 typedef boost::unordered_map<CellIndex, CellContent>
Grid;
58 typedef typename CellContent::key_type
key_type;
143 return !(*
this == rhs);
245 return !(*
this == rhs);
303 return cell.insert(v);
323 auto cell =
cells_.find(cellkey);
326 return cell->second.erase(key);
343 if (grid_it ==
cells_.end())
356 if (grid_it ==
cells_.end())
396 ret += it->second.size();
473 for (; it != ret.
end(); ++it, ++lit, ++rit)
475 double t = std::floor(*lit / *rit);
476 if (t < std::numeric_limits<Int64>::min() || t > std::numeric_limits<Int64>::max())
478 *it =
static_cast<Int64>(t);
487 for (; it_new != d.
end(); ++it_new, ++it_cur)
489 if (*it_cur < *it_new)
496 template<UInt N,
typename T>
499 boost::hash<T> hasher;
500 std::size_t hash = 0;
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:29
ConstIterator end() const
Non-mutable end iterator.
Definition: DPosition.h:386
CoordinateType * iterator
Definition: DPosition.h:50
const CoordinateType * const_iterator
Definition: DPosition.h:51
ConstIterator begin() const
Non-mutable begin iterator.
Definition: DPosition.h:380
Out of range exception.
Definition: Exception.h:290
Constant element iterator for the hash grid.
Definition: HashGrid.h:166
ConstIterator(const Grid &grid, grid_iterator grid_it, cell_iterator cell_it)
Definition: HashGrid.h:215
const ConstIterator operator++(int)
Definition: HashGrid.h:231
bool operator!=(const ConstIterator &rhs) const
Definition: HashGrid.h:243
value_type * pointer
The pointer type as returned by operator->()
Definition: HashGrid.h:183
const Grid & grid_
Definition: HashGrid.h:188
const CellIndex index() const
Definition: HashGrid.h:258
grid_iterator grid_it_
Definition: HashGrid.h:189
HashGrid::value_type value_type
The iterator's value type.
Definition: HashGrid.h:179
bool operator==(const ConstIterator &rhs) const
Definition: HashGrid.h:238
value_type & reference
The reference type as returned by operator*()
Definition: HashGrid.h:181
Grid::const_iterator grid_iterator
Definition: HashGrid.h:170
ConstIterator & operator++()
Definition: HashGrid.h:224
const value_type * operator->() const
Definition: HashGrid.h:253
cell_iterator cell_it_
Definition: HashGrid.h:190
ConstIterator(const Iterator &it)
Definition: HashGrid.h:220
const value_type & operator*() const
Definition: HashGrid.h:248
ConstIterator(const Grid &grid)
Definition: HashGrid.h:211
std::input_iterator_tag iterator_category
The iterator's category type.
Definition: HashGrid.h:177
CellContent::const_iterator cell_iterator
Definition: HashGrid.h:171
std::ptrdiff_t difference_type
The difference type.
Definition: HashGrid.h:185
void searchNextCell_()
Definition: HashGrid.h:193
Element iterator for the hash grid.
Definition: HashGrid.h:67
value_type & operator*() const
Definition: HashGrid.h:146
CellContent::iterator cell_iterator
Definition: HashGrid.h:72
value_type * pointer
The pointer type as returned by operator->()
Definition: HashGrid.h:84
const CellIndex index() const
Definition: HashGrid.h:156
grid_iterator grid_it_
Definition: HashGrid.h:91
HashGrid::value_type value_type
The iterator's value type.
Definition: HashGrid.h:80
value_type & reference
The reference type as returned by operator*()
Definition: HashGrid.h:82
Grid::iterator grid_iterator
Definition: HashGrid.h:71
bool operator==(const Iterator &rhs) const
Definition: HashGrid.h:136
cell_iterator cell_it_
Definition: HashGrid.h:92
Iterator(Grid &grid, grid_iterator grid_it, cell_iterator cell_it)
Definition: HashGrid.h:117
Grid & grid_
Definition: HashGrid.h:90
std::input_iterator_tag iterator_category
The iterator's category type.
Definition: HashGrid.h:78
Iterator(Grid &grid)
Definition: HashGrid.h:113
std::ptrdiff_t difference_type
The difference type.
Definition: HashGrid.h:86
bool operator!=(const Iterator &rhs) const
Definition: HashGrid.h:141
void searchNextCell_()
Definition: HashGrid.h:95
const Iterator operator++(int)
Definition: HashGrid.h:129
Iterator & operator++()
Definition: HashGrid.h:122
value_type * operator->() const
Definition: HashGrid.h:151
Container for (2-dimensional coordinate, value) pairs.
Definition: HashGrid.h:35
CellContent::const_iterator const_cell_iterator
Definition: HashGrid.h:269
grid_iterator grid_end()
Definition: HashGrid.h:461
CellIndex cellindexAtClustercenter_(const ClusterCenter &key)
Definition: HashGrid.h:468
boost::unordered_multimap< ClusterCenter, Cluster > CellContent
Contents of a cell.
Definition: HashGrid.h:51
const CellIndex & grid_dimension
Upper-right corner of key space for cells.
Definition: HashGrid.h:286
Grid::const_iterator const_grid_iterator
Definition: HashGrid.h:267
CellIndex grid_dimension_
Definition: HashGrid.h:275
Iterator iterator
Definition: HashGrid.h:266
const_iterator begin() const
Returns iterator to first element.
Definition: HashGrid.h:353
CellContent::iterator cell_iterator
Definition: HashGrid.h:270
const_grid_iterator grid_find(const CellIndex &x) const
Returns the grid cell at given index if present, otherwise the grid_end iterator.
Definition: HashGrid.h:437
const_grid_iterator grid_end() const
Returns iterator to on after last grid cell.
Definition: HashGrid.h:413
DPosition< 2, Int64 > CellIndex
Index for cells.
Definition: HashGrid.h:46
DPosition< 2, double > ClusterCenter
Coordinate for stored pairs.
Definition: HashGrid.h:41
boost::unordered_map< CellIndex, CellContent > Grid
Map of (cell-index, cell-content).
Definition: HashGrid.h:56
cell_iterator insert(const value_type &v)
Inserts a (2-dimensional coordinate, value) pair.
Definition: HashGrid.h:298
ConstIterator const_iterator
Definition: HashGrid.h:265
size_type size() const
Return number of elements.
Definition: HashGrid.h:390
CellContent::value_type value_type
Definition: HashGrid.h:60
bool empty() const
Return true if HashGrid is empty.
Definition: HashGrid.h:382
Grid cells_
Definition: HashGrid.h:274
CellContent::size_type size_type
Definition: HashGrid.h:271
Grid::iterator grid_iterator
Definition: HashGrid.h:268
HashGrid(const ClusterCenter &c_dimension)
Definition: HashGrid.h:289
grid_iterator grid_find(const CellIndex &x)
Returns the grid cell at given index if present, otherwise the grid_end iterator.
Definition: HashGrid.h:445
CellContent::key_type key_type
Definition: HashGrid.h:58
void updateGridDimension_(const CellIndex &d)
Definition: HashGrid.h:483
grid_iterator grid_begin()
Definition: HashGrid.h:454
void clear()
Clears the map.
Definition: HashGrid.h:332
const Grid::mapped_type & grid_at(const CellIndex &x) const
Returns the grid cell at given index.
Definition: HashGrid.h:421
iterator end()
Returns iterator to first element.
Definition: HashGrid.h:366
const_iterator end() const
Returns iterator to first element.
Definition: HashGrid.h:374
void erase(iterator pos)
Erases element on given iterator.
Definition: HashGrid.h:309
const ClusterCenter cell_dimension
Dimension of cells.
Definition: HashGrid.h:281
Grid::mapped_type & grid_at(const CellIndex &x)
Definition: HashGrid.h:429
iterator begin()
Returns iterator to first element.
Definition: HashGrid.h:340
const_grid_iterator grid_begin() const
Returns iterator to first grid cell.
Definition: HashGrid.h:405
size_type erase(const key_type &key)
Erases elements matching the 2-dimensional coordinate.
Definition: HashGrid.h:320
CellContent::mapped_type mapped_type
Definition: HashGrid.h:59
int64_t Int64
Signed integer type (64bit)
Definition: Types.h:40
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
::size_t hash_value(OpenMS::String const &s)