IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
IMP::algebra::SparseGridStorageD< D, VT, Base, Map > Class Template Reference

#include <IMP/algebra/grid_storages.h>

Inheritance diagram for IMP::algebra::SparseGridStorageD< D, VT, Base, Map >:

Detailed Description

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
class IMP::algebra::SparseGridStorageD< D, VT, Base, Map >

Store a grid as a sparse set of voxels (only the voxels which have been added are actually stored). The get_has_index() functions allow one to tell if a voxel has been added.

Warning: SparseGridStorageD has not been stabilized and is likely to change without notice.

Base should be one of BoundedGridRangeD or UnboundedGridRangeD.

See also
Grid3D

Definition at line 188 of file grid_storages.h.

Public Types

typedef VT Value

Public Member Functions

 SparseGridStorageD (const Ints &counts, const VT &default_value)
GridIndexD< D > add_voxel (const ExtendedGridIndexD< D > &i, const VT &gi)
 Add a voxel to the storage, this voxel will now have a GridIndex3D.
template<class Functor, class Grid>
Functor apply (const Grid &g, Functor f) const
bool get_has_index (const ExtendedGridIndexD< D > &i) const
 Return true if the voxel has been added.
GridIndexD< D > get_index (const ExtendedGridIndexD< D > &i) const
 requires get_has_index(i) is true.
unsigned int get_number_of_voxels () const
void remove_voxel (const GridIndexD< D > &gi)
void show (std::ostream &out=std::cout) const

Iterators through set cells

Iterate through the voxels which have been set. The value type is a pair of GridIndex3D and VT.

typedef Data::const_iterator AllConstIterator
typedef boost::transform_iterator< GetIndex, AllConstIterator > AllIndexIterator
AllConstIterator all_begin () const
AllConstIterator all_end () const
AllIndexIterator all_indexes_begin () const
AllIndexIterator all_indexes_end () const

Operator []

Operator[] isn't very useful at the moment as it can only be used with a cell which has already been set. This behavior/the existence of these functions is likely to change.

const VT at (GridIndexD< D >) const
VT & at (GridIndexD< D >)
const VT operator[] (GridIndexD< D >) const
VT & operator[] (GridIndexD< D >)

Index Iterators

Iterate through a range of actual indexes. The value type for the iterator is an GridIndex3D.

The range is defined by a pair of indexes. It includes all indexes in the axis aligned box defined by lb as the lower corner and the second as the ub. That is, if lb is \((l_x, l_y, l_z)\) and ub is \((u_x, u_y, u_z)\), then the range includes all indexes \((i_x, i_y, i_z)\) such that \(l_x \leq i_x \leq u_x\), \(l_y \leq i_y \leq u_y\) and \(l_z \leq i_z \leq u_z\).

IndexIterator indexes_begin (const ExtendedGridIndexD< D > &lb, const ExtendedGridIndexD< D > &ub) const
IndexIterator indexes_end (const ExtendedGridIndexD< D > &, const ExtendedGridIndexD< D > &) const
Vector< GridIndexD< D > > get_indexes (const ExtendedGridIndexD< D > &lb, const ExtendedGridIndexD< D > &ub) const

Member Typedef Documentation

◆ AllConstIterator

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
typedef Data::const_iterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::AllConstIterator

Definition at line 284 of file grid_storages.h.

◆ AllIndexIterator

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
typedef boost::transform_iterator<GetIndex, AllConstIterator> IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::AllIndexIterator

Definition at line 288 of file grid_storages.h.

◆ Value

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
typedef VT IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::Value

Definition at line 217 of file grid_storages.h.

Constructor & Destructor Documentation

◆ SparseGridStorageD()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::SparseGridStorageD ( const Ints & counts,
const VT & default_value )

Definition at line 218 of file grid_storages.h.

Member Function Documentation

◆ add_voxel()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
GridIndexD< D > IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::add_voxel ( const ExtendedGridIndexD< D > & i,
const VT & gi )

Add a voxel to the storage, this voxel will now have a GridIndex3D.

Definition at line 223 of file grid_storages.h.

◆ all_begin()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
AllConstIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::all_begin ( ) const

Definition at line 285 of file grid_storages.h.

◆ all_end()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
AllConstIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::all_end ( ) const

Definition at line 286 of file grid_storages.h.

◆ all_indexes_begin()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
AllIndexIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::all_indexes_begin ( ) const

Definition at line 289 of file grid_storages.h.

◆ all_indexes_end()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
AllIndexIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::all_indexes_end ( ) const

Definition at line 292 of file grid_storages.h.

◆ apply()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
template<class Functor, class Grid>
Functor IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::apply ( const Grid & g,
Functor f ) const

Definition at line 348 of file grid_storages.h.

◆ get_has_index()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
bool IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::get_has_index ( const ExtendedGridIndexD< D > & i) const

Return true if the voxel has been added.

Definition at line 237 of file grid_storages.h.

◆ get_index()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
GridIndexD< D > IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::get_index ( const ExtendedGridIndexD< D > & i) const

requires get_has_index(i) is true.

Definition at line 241 of file grid_storages.h.

Here is the call graph for this function:

◆ get_indexes()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
Vector< GridIndexD< D > > IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::get_indexes ( const ExtendedGridIndexD< D > & lb,
const ExtendedGridIndexD< D > & ub ) const

Definition at line 340 of file grid_storages.h.

◆ get_number_of_voxels()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
unsigned int IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::get_number_of_voxels ( ) const

Definition at line 235 of file grid_storages.h.

◆ indexes_begin()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
IndexIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::indexes_begin ( const ExtendedGridIndexD< D > & lb,
const ExtendedGridIndexD< D > & ub ) const

Definition at line 323 of file grid_storages.h.

◆ indexes_end()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
IndexIterator IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::indexes_end ( const ExtendedGridIndexD< D > & ,
const ExtendedGridIndexD< D > &  ) const

Definition at line 333 of file grid_storages.h.

◆ remove_voxel()

template<int D, class VT, class Base, class Map = typename boost::unordered_map<GridIndexD<D>, VT>>
void IMP::algebra::SparseGridStorageD< D, VT, Base, Map >::remove_voxel ( const GridIndexD< D > & gi)

Definition at line 229 of file grid_storages.h.


The documentation for this class was generated from the following file: