libmoost
|
A partitioner can assign templatized types to a specified number of buckets. More...
#include <partitioner.hpp>
Public Member Functions | |
partitioner (size_t num_buckets) | |
virtual | ~partitioner () |
virtual size_t | partition (const T &key) const =0 |
size_t | num_buckets () const |
Return the number of buckets the partitioner will assign keys to. | |
Private Attributes | |
size_t | m_num_buckets |
A partitioner can assign templatized types to a specified number of buckets.
This is useful, for example, for spreading items across servers. partitioner is a virtual class, and the partition method must be implemented by subclasses.
Definition at line 39 of file partitioner.hpp.
moost::algorithm::partitioner< T >::partitioner | ( | size_t | num_buckets | ) | [inline] |
Constructs a partitioner.
num_buckets | the number of buckets to partition into. |
Definition at line 49 of file partitioner.hpp.
virtual moost::algorithm::partitioner< T >::~partitioner | ( | ) | [inline, virtual] |
Definition at line 52 of file partitioner.hpp.
size_t moost::algorithm::partitioner< T >::num_buckets | ( | ) | const [inline] |
Return the number of buckets the partitioner will assign keys to.
Definition at line 59 of file partitioner.hpp.
virtual size_t moost::algorithm::partitioner< T >::partition | ( | const T & | key | ) | const [pure virtual] |
Returns a bucket for the given key, from 0 to num_buckets - 1. Must be overridden by implementing partitioners.
Implemented in moost::algorithm::ketama_partitioner< T >, and moost::algorithm::modulo_partitioner< T >.
size_t moost::algorithm::partitioner< T >::m_num_buckets [private] |
Definition at line 43 of file partitioner.hpp.