NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Priority Queues

This module implements a priority queue adaptor, supporting O(log(N)) push/pop operations. Unlike std::priority_queue, this class can be used both in host and device CUDA code:

Example

// build a simple priority_queue over 4 integers
typedef vector_view<uint32*> vector_type;
typedef priority_queue<uint32, vector_type> queue_type;
uint32 queue_storage[4];
// construct the queue
queue_type queue( vector_type( 0u, queue_storage ) );
// push a few items
queue.push( 3 );
queue.push( 8 );
queue.push( 1 );
queue.push( 5 );
// pop from the top
printf( "%u\n", queue.top() ); // -> 8
queue.pop();
printf( "%u\n", queue.top() ); // -> 5
queue.pop();
printf( "%u\n", queue.top() ); // -> 3
queue.pop();
printf( "%u\n", queue.top() ); // -> 1