jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Private Attributes | List of all members
jubatus::core::storage::fixed_size_heap< T, Comp > Class Template Reference

#include <fixed_size_heap.hpp>

Collaboration diagram for jubatus::core::storage::fixed_size_heap< T, Comp >:
Collaboration graph

Public Member Functions

 fixed_size_heap (size_t max)
 
 fixed_size_heap (size_t max, const Comp &comp)
 
size_t get_max_size () const
 
void get_sorted (std::vector< T > &v) const
 
void push (const T &v)
 
size_t size () const
 

Private Attributes

const Comp comp_
 
std::vector< T > data_
 
const size_t max_size_
 

Detailed Description

template<typename T, typename Comp = std::less<T>>
class jubatus::core::storage::fixed_size_heap< T, Comp >

Definition at line 29 of file fixed_size_heap.hpp.

Constructor & Destructor Documentation

template<typename T, typename Comp = std::less<T>>
jubatus::core::storage::fixed_size_heap< T, Comp >::fixed_size_heap ( size_t  max)
inlineexplicit

Definition at line 31 of file fixed_size_heap.hpp.

template<typename T, typename Comp = std::less<T>>
jubatus::core::storage::fixed_size_heap< T, Comp >::fixed_size_heap ( size_t  max,
const Comp &  comp 
)
inline

Definition at line 36 of file fixed_size_heap.hpp.

Member Function Documentation

template<typename T, typename Comp = std::less<T>>
size_t jubatus::core::storage::fixed_size_heap< T, Comp >::get_max_size ( ) const
inline
template<typename T, typename Comp = std::less<T>>
void jubatus::core::storage::fixed_size_heap< T, Comp >::get_sorted ( std::vector< T > &  v) const
inline
template<typename T, typename Comp = std::less<T>>
void jubatus::core::storage::fixed_size_heap< T, Comp >::push ( const T &  v)
inline

Definition at line 41 of file fixed_size_heap.hpp.

References jubatus::core::storage::fixed_size_heap< T, Comp >::comp_, jubatus::core::storage::fixed_size_heap< T, Comp >::data_, jubatus::core::storage::fixed_size_heap< T, Comp >::max_size_, and jubatus::core::common::jsonconfig::v().

Referenced by jubatus::core::storage::inverted_index_storage::calc_scores(), jubatus::core::nearest_neighbor::euclid_lsh::neighbor_row_from_hash(), jubatus::core::nearest_neighbor::ranking_hamming_bit_vectors(), and jubatus::core::storage::similar_row_one().

41  {
42  if (data_.size() < max_size_) {
43  data_.push_back(v);
44  if (data_.size() == max_size_) {
45  std::make_heap(data_.begin(), data_.end(), comp_);
46  }
47  } else {
48  if (max_size_ > 0 && comp_(v, data_.front())) {
49  std::pop_heap(data_.begin(), data_.end(), comp_);
50  data_.back() = v;
51  std::push_heap(data_.begin(), data_.end(), comp_);
52  }
53  }
54  }
std::vector< T > v(size)

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T, typename Comp = std::less<T>>
size_t jubatus::core::storage::fixed_size_heap< T, Comp >::size ( ) const
inline

Definition at line 62 of file fixed_size_heap.hpp.

References jubatus::core::storage::fixed_size_heap< T, Comp >::data_.

62  {
63  return data_.size();
64  }

Member Data Documentation

template<typename T, typename Comp = std::less<T>>
const Comp jubatus::core::storage::fixed_size_heap< T, Comp >::comp_
private
template<typename T, typename Comp = std::less<T>>
std::vector<T> jubatus::core::storage::fixed_size_heap< T, Comp >::data_
private
template<typename T, typename Comp = std::less<T>>
const size_t jubatus::core::storage::fixed_size_heap< T, Comp >::max_size_
private

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