libmoost
moost::algorithm::partitioner< T > Class Template Reference

A partitioner can assign templatized types to a specified number of buckets. More...

#include <partitioner.hpp>

Inheritance diagram for moost::algorithm::partitioner< T >:

List of all members.

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

Detailed Description

template<typename T>
class moost::algorithm::partitioner< T >

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.


Constructor & Destructor Documentation

template<typename T >
moost::algorithm::partitioner< T >::partitioner ( size_t  num_buckets) [inline]

Constructs a partitioner.

Parameters:
num_bucketsthe number of buckets to partition into.

Definition at line 49 of file partitioner.hpp.

template<typename T >
virtual moost::algorithm::partitioner< T >::~partitioner ( ) [inline, virtual]

Definition at line 52 of file partitioner.hpp.


Member Function Documentation

template<typename T >
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.

Here is the caller graph for this function:

template<typename T >
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 >.


Member Data Documentation

template<typename T >
size_t moost::algorithm::partitioner< T >::m_num_buckets [private]

Definition at line 43 of file partitioner.hpp.


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