libBf 0.1

core.h

00001 #ifndef DETAIL_CORE_H
00002 #define DETAIL_CORE_H
00003 
00004 namespace bf {
00005 namespace detail {
00006 namespace core {
00007 
00013 template <typename T, typename Core>
00014 typename std::enable_if<
00015     std::is_same<typename Core::part_type, partitioning>::value
00016   , std::vector<typename Core::store_type::size_type>
00017 >::type
00018 positions(const T& x, const Core& core)
00019 {
00020     std::vector<typename Core::store_type::size_type> v;
00021     v.reserve(core.hash.k());
00022 
00023     auto h = core.hash.hash(x);
00024     for (unsigned i = 0; i < h.size(); ++i)
00025         v.push_back(core.part.position(h[i], i, core.store.size()));
00026 
00027     v.shrink_to_fit();
00028     return v;
00029 }
00030 
00036 template <typename T, typename Core>
00037 typename std::enable_if<
00038     std::is_same<typename Core::part_type, no_partitioning>::value
00039   , std::vector<typename Core::store_type::size_type>
00040 >::type
00041 positions(const T& x, const Core& core)
00042 {
00043     std::vector<typename Core::store_type::size_type> v;
00044     v.reserve(core.hash.k());
00045 
00046     auto h = core.hash.hash(x);
00047     for (unsigned i = 0; i < h.size(); ++i)
00048     {
00049         auto pos = core.part.position(h[i], i, core.store.size());
00050         auto j = std::lower_bound(v.begin(), v.end(), pos);
00051         if (j == v.end() || *j != pos)
00052             v.insert(j, pos);
00053     }
00054 
00055     v.shrink_to_fit();
00056     return v;
00057 }
00058 
00059 } // namespace core
00060 } // namespace detail
00061 } // namespace bf
00062 
00063 #endif
 All Classes Functions Variables