libmoost
moost::container::neigh_multi_map< TLocMap > Class Template Reference

neigh_multi_map is a container that associates keys to list of pairs of integers and floats read from the standard-mir format neigh. More...

#include <neigh_multi_map.hpp>

Inheritance diagram for moost::container::neigh_multi_map< TLocMap >:
Collaboration diagram for moost::container::neigh_multi_map< TLocMap >:

List of all members.

Public Types

typedef multi_map< int,
std::pair< int, float >
, TLocMap >
::loc_map_policy_type 
loc_map_policy_type

Public Member Functions

 neigh_multi_map (const loc_map_policy_type &locHandlerPolicy)
 neigh_multi_map ()
void create_map (const std::string &dataFileName, int maxEntriesPerVec=(std::numeric_limits< int >::max)())
template<typename TranformIDPolicy >
void create_map (const std::string &dataFileName, const TranformIDPolicy &getIDPolicy, int maxEntriesPerVec=(std::numeric_limits< int >::max)())
void create_map_from_vector (std::vector< std::pair< int, std::pair< int, float > > > &i2i)

Private Attributes

bool m_externalLocMap

Detailed Description

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
class moost::container::neigh_multi_map< TLocMap >

neigh_multi_map is a container that associates keys to list of pairs of integers and floats read from the standard-mir format neigh.

It is similar in concept of having an hashmap: hm[key] -> { pair<int, float>, pair<int, float>, pair<int, float>, ..} but it's way more efficient.

Note:
This is a read only data structure: once it has been built no other data can be added, unless clear has been called.

Example usage:

moost::container::neigh_multi_map test;
test.create_map( "myFile.bin" );

moost::container::multi_map<int, float>::range rt;
rt = test[10];
moost::container::multi_map<int, float>::range_iterator mapIt;
for ( mapIt = rt.begin(); mapIt != rt.end(); ++mapIt )
   cout << *mapIt << endl;

Please note that the default policy uses moost::container::dense_hash_map to map the keys. If you expect keys with zero value, please specify a policy with a different empty key, i.e.

typedef moost::container::neigh_multi_map<> multi_map_type;
// this defines empty_key=-1
// also note that the bucket size is less important here because neigh_multi_map figures
// out the optimal size given the number of entries
multi_map_type::loc_map_policy_type policy(-1);
multi_map_type data(policy);

Is it also possible to define a different container for the locatin map, i.e. if one want to use a sparse hash map the declaration is:

Definition at line 100 of file neigh_multi_map.hpp.


Member Typedef Documentation

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
typedef multi_map< int, std::pair<int, float>, TLocMap >::loc_map_policy_type moost::container::neigh_multi_map< TLocMap >::loc_map_policy_type

Constructor & Destructor Documentation

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
moost::container::neigh_multi_map< TLocMap >::neigh_multi_map ( const loc_map_policy_type locHandlerPolicy) [inline]

Definition at line 117 of file neigh_multi_map.hpp.

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
moost::container::neigh_multi_map< TLocMap >::neigh_multi_map ( ) [inline]

Definition at line 121 of file neigh_multi_map.hpp.


Member Function Documentation

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
void moost::container::neigh_multi_map< TLocMap >::create_map ( const std::string &  dataFileName,
int  maxEntriesPerVec = (std::numeric_limits<int>::max)() 
) [inline]

Definition at line 128 of file neigh_multi_map.hpp.

Here is the caller graph for this function:

template<typename TLocMap >
template<typename TranformIDPolicy >
void moost::container::neigh_multi_map< TLocMap >::create_map ( const std::string &  dataFileName,
const TranformIDPolicy &  getIDPolicy,
int  maxEntriesPerVec = (std::numeric_limits<int>::max)() 
)

Definition at line 185 of file neigh_multi_map.hpp.

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
void moost::container::neigh_multi_map< TLocMap >::create_map_from_vector ( std::vector< std::pair< int, std::pair< int, float > > > &  i2i) [inline]

Definition at line 143 of file neigh_multi_map.hpp.


Member Data Documentation

template<typename TLocMap = moost::container::dense_hash_map<int, multimap_value_type>>
bool moost::container::neigh_multi_map< TLocMap >::m_externalLocMap [private]

Definition at line 155 of file neigh_multi_map.hpp.


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