cds  2.2.0
cds::container::FCPriorityQueue< T, PriorityQueue, Traits > Class Template Reference

Flat-combining priority queue. More...

#include <cds/container/fcpriority_queue.h>

Public Types

typedef T value_type
 Value type.
 
typedef PriorityQueue priority_queue_type
 Sequential priority queue class.
 
typedef Traits traits
 Priority queue type traits.
 
typedef traits::stat stat
 Internal statistics type.
 

Public Member Functions

 FCPriorityQueue ()
 Initializes empty priority queue object.
 
 FCPriorityQueue (unsigned int nCompactFactor, unsigned int nCombinePassCount)
 Initializes empty priority queue object and gives flat combining parameters. More...
 
bool push (value_type const &val)
 Inserts a new element in the priority queue. More...
 
bool push (value_type &&val)
 Inserts a new element in the priority queue (move semantics) More...
 
bool pop (value_type &val)
 Removes the top element from priority queue. More...
 
void clear ()
 Clears the priority queue.
 
size_t size () const
 Returns the number of elements in the priority queue. More...
 
bool empty ()
 Checks if the priority queue is empty. More...
 
stat const & statistics () const
 Internal statistics.
 

Protected Types

typedef cds::algo::flat_combining::kernel< fc_record, traitsfc_kernel
 Flat combining kernel.
 

Detailed Description

template<typename T, class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
class cds::container::FCPriorityQueue< T, PriorityQueue, Traits >

Flat-combining priority queue.

Flat combining sequential priority queue. The class can be considered as a concurrent FC-based wrapper for std::priority_queue.

Template parameters:

  • T - a value type stored in the queue
  • PriorityQueue - sequential priority queue implementation, default is std::priority_queue<T>
  • Traits - type traits of flat combining, default is fcpqueue::traits. fcpqueue::make_traits metafunction can be used to construct specialized fcpqueue::traits

Constructor & Destructor Documentation

§ FCPriorityQueue()

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::FCPriorityQueue ( unsigned int  nCompactFactor,
unsigned int  nCombinePassCount 
)
inline

Initializes empty priority queue object and gives flat combining parameters.

Parameters
nCompactFactorFlat combining: publication list compacting factor
nCombinePassCountFlat combining: number of combining passes for combiner thread

Member Function Documentation

§ empty()

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
bool cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::empty ( )
inline

Checks if the priority queue is empty.

If the combining is in process the function waits while combining done.

§ pop()

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
bool cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::pop ( value_type val)
inline

Removes the top element from priority queue.

The function returns false if the queue is empty, true otherwise. If the queue is empty val is not changed.

Parameters
valTarget to be received the copy of top element

§ push() [1/2]

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
bool cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::push ( value_type const &  val)
inline

Inserts a new element in the priority queue.

The function always returns true

Parameters
valValue to be copied to inserted element

§ push() [2/2]

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
bool cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::push ( value_type &&  val)
inline

Inserts a new element in the priority queue (move semantics)

The function always returns true

Parameters
valValue to be moved to inserted element

§ size()

template<typename T , class PriorityQueue = std::priority_queue<T>, typename Traits = fcpqueue::traits>
size_t cds::container::FCPriorityQueue< T, PriorityQueue, Traits >::size ( ) const
inline

Returns the number of elements in the priority queue.

Note that size() == 0 does not mean that the queue is empty because combining record can be in process. To check emptiness use empty function.


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

cds 2.2.0 Developed by Maxim Khizhinsky aka khizmax 2007 - 2017
Autogenerated Wed Jan 4 2017 08:49:35 by Doxygen 1.8.12