NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Methods | Static Public Members | Proteced Methods | Related Functions | List of all members
nvbio::priority_deque< Type, Sequence, Compare > Class Template Reference

Detailed description

template< typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
class nvbio::priority_deque< Type, Sequence, Compare >

Efficient double-ended priority queue.

Author
Nathaniel McClatchey
Parameters
TypeType of elements in the priority deque.
SequenceUnderlying sequence container. Must provide random-access iterators, front(), push_back(Type const &), and pop_back(). Defaults to std::vector<Type>.
CompareComparison class. Compare(A, B) should return true if A should be placed earlier than B in a strict weak ordering. Defaults to std::less<Type>, which encapsulates operator<.

Priority deques are adaptors, designed to provide efficient insertion and access to both ends of a weakly-ordered list of elements. As a container adaptor, priority_deque is implemented on top of another container type. By default, this is std::vector, but a different container may be specified explicitly. Although the priority deque does permit iteration through its elements, there is no ordering guaranteed, as different implementations may benefit from different structures, and all iterators should be discarded after using any function not labeled const.

Note
priority_deque does not provide a stable ordering. If both A<B and B<A are false, then the order in which they appear may differ from the order in which they were added to the priority deque.
Remarks
priority_deque replicates the interface of the STL priority_queue class template.
priority_deque is most useful when removals are interspersed with insertions. If no further insertions are to be performed after the first removal, consider using an array and a sorting algorithm instead.
priority_deque sorts elements as they are added, removed, and modified by its member functions. If the elements are modified by some means other than the public member functions, the order must be restoreed before the priority_deque is used.
See Also
priority_queue

Definition at line 110 of file priority_deque.h.

#include <priority_deque.h>

Public Types

enum  Constructed { CONSTRUCTED }
 
typedef Sequence container_type
 
typedef container_type::value_type value_type
 
typedef Compare value_compare
 
typedef container_type::size_type size_type
 
typedef
container_type::const_reference 
const_reference
 
typedef container_type::reference reference
 
typedef container_type::pointer pointer
 
typedef pointer const_pointer
 
typedef
container_type::const_iterator 
const_iterator
 
typedef const_iterator iterator
 
typedef
container_type::difference_type 
difference_type
 

Public Methods

NVBIO_FORCEINLINE NVBIO_HOST_DEVICE priority_deque (const Compare &=Compare(), const Sequence &=Sequence())
 Constructs a new priority deque. More...
 
template<typename InputIterator >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE priority_deque (InputIterator first, InputIterator last, const Compare &=Compare(), const Sequence &=Sequence())
 
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE priority_deque (const Sequence &seq, const bool constructed=false)
 
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE priority_deque (const Sequence &seq, const Constructed flag)
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
push (const value_type &)
 Copies an element into the priority deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
clear (void)
 Removes all elements from the priority deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
swap (priority_deque< Type, Sequence, Compare > &)
 Moves the elements from this deque into another, and vice-versa. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_reference 
maximum (void) const
 Accesses a maximal element in the deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_reference 
minimum (void) const
 Accesses a minimal element in the deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_reference 
top (void) const
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_reference 
bottom (void) const
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
pop_top (void)
 Removes a maximal element from the deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
pop_bottom (void)
 Removes a minimal element from the deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
pop (void)
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE bool 
empty (void) const
 Returns true if the priority deque is empty, false if it is not. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE size_type 
size (void) const
 Returns the number of elements in the priority deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE size_type 
max_size (void) const
 Returns the maximum number of elements that can be contained. More...
 
template<typename InputIterator >
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
merge (InputIterator first, InputIterator last)
 Merges a sequence of elements into the priority deque. More...
 
template<typename SourceContainer >
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
merge (const SourceContainer &source)
 Merges a container's elements into the priority deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_iterator 
begin (void) const
 Returns a const iterator at the beginning of the sequence. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
const_iterator 
end (void) const
 Returns a const iterator past the end of the sequence. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
update (const_iterator, const value_type &)
 Modifies a specified element of the deque. More...
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE void 
erase (const_iterator)
 Removes a specified element from the deque. More...
 

Static Public Members

static const bool constant_time_size = true
 
static const bool has_ordered_iterators = false
 
static const bool is_mergable = true
 
static const bool is_stable = false
 
static const bool has_reserve = false
 

Proteced Methods

NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
container_type
sequence (void)
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE const
container_type
sequence (void) const
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
value_compare
compare (void)
 
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE const
value_compare
compare (void) const
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename S , typename C >
void swap (priority_deque< T, S, C > &deque1, priority_deque< T, S, C > &deque2)
 

Member Typedef Documentation

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::const_iterator nvbio::priority_deque< Type, Sequence, Compare >::const_iterator

May be used to examine, but not modify, elements in the deque.

Definition at line 168 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef pointer nvbio::priority_deque< Type, Sequence, Compare >::const_pointer

Definition at line 166 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::const_reference nvbio::priority_deque< Type, Sequence, Compare >::const_reference

May be used to examine, but not modify, an element in the deque.

Definition at line 163 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef Sequence nvbio::priority_deque< Type, Sequence, Compare >::container_type

Underlying container type.

Definition at line 157 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::difference_type nvbio::priority_deque< Type, Sequence, Compare >::difference_type

STL Container specifies that this is a signed integral type.

Definition at line 171 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef const_iterator nvbio::priority_deque< Type, Sequence, Compare >::iterator

Definition at line 169 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::pointer nvbio::priority_deque< Type, Sequence, Compare >::pointer

Definition at line 165 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::reference nvbio::priority_deque< Type, Sequence, Compare >::reference

Definition at line 164 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::size_type nvbio::priority_deque< Type, Sequence, Compare >::size_type

STL Container specifies that this is an unsigned integral type.

Definition at line 161 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef Compare nvbio::priority_deque< Type, Sequence, Compare >::value_compare

Definition at line 159 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
typedef container_type::value_type nvbio::priority_deque< Type, Sequence, Compare >::value_type

Definition at line 158 of file priority_deque.h.

Member Enumeration Documentation

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
enum nvbio::priority_deque::Constructed
Enumerator
CONSTRUCTED 

Definition at line 173 of file priority_deque.h.

Constructor & Destructor Documentation

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
template<typename InputIterator >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE nvbio::priority_deque< Type, Sequence, Compare >::priority_deque ( InputIterator  first,
InputIterator  last,
const Compare &  = Compare(),
const Sequence &  = Sequence() 
)
template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE nvbio::priority_deque< Type, Sequence, Compare >::priority_deque ( const Sequence &  seq,
const Constructed  flag 
)
inline

O(1) Creates a new priority deque from an already heapified container

Definition at line 194 of file priority_deque.h.

Member Function Documentation

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE const_iterator nvbio::priority_deque< Type, Sequence, Compare >::begin ( void  ) const
inline

Returns a const iterator at the beginning of the sequence.

Definition at line 263 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::priority_deque< Type, Sequence, Compare >::clear ( void  )
inline

Removes all elements from the priority deque.

Definition at line 244 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE value_compare& nvbio::priority_deque< Type, Sequence, Compare >::compare ( void  )
inlineprotected

Definition at line 294 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE const value_compare& nvbio::priority_deque< Type, Sequence, Compare >::compare ( void  ) const
inlineprotected

Definition at line 296 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool nvbio::priority_deque< Type, Sequence, Compare >::empty ( void  ) const
inline

Returns true if the priority deque is empty, false if it is not.

Definition at line 232 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE const_iterator nvbio::priority_deque< Type, Sequence, Compare >::end ( void  ) const
inline

Returns a const iterator past the end of the sequence.

Definition at line 266 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE size_type nvbio::priority_deque< Type, Sequence, Compare >::max_size ( void  ) const
inline

Returns the maximum number of elements that can be contained.

Definition at line 238 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
template<typename InputIterator >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::priority_deque< Type, Sequence, Compare >::merge ( InputIterator  first,
InputIterator  last 
)

Merges a sequence of elements into the priority deque.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
template<typename SourceContainer >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::priority_deque< Type, Sequence, Compare >::merge ( const SourceContainer &  source)
inline

Merges a container's elements into the priority deque.

Definition at line 256 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE container_type& nvbio::priority_deque< Type, Sequence, Compare >::sequence ( void  )
inlineprotected

Definition at line 290 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE const container_type& nvbio::priority_deque< Type, Sequence, Compare >::sequence ( void  ) const
inlineprotected

Definition at line 292 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE size_type nvbio::priority_deque< Type, Sequence, Compare >::size ( void  ) const
inline

Returns the number of elements in the priority deque.

Definition at line 235 of file priority_deque.h.

Member Data Documentation

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
const bool nvbio::priority_deque< Type, Sequence, Compare >::constant_time_size = true
static

Definition at line 277 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
const bool nvbio::priority_deque< Type, Sequence, Compare >::has_ordered_iterators = false
static

Definition at line 279 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
const bool nvbio::priority_deque< Type, Sequence, Compare >::has_reserve = false
static

Definition at line 285 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
const bool nvbio::priority_deque< Type, Sequence, Compare >::is_mergable = true
static

Definition at line 281 of file priority_deque.h.

template<typename Type, typename Sequence = std::vector<Type>, typename Compare = ::std::less<typename Sequence::value_type>>
const bool nvbio::priority_deque< Type, Sequence, Compare >::is_stable = false
static

Definition at line 283 of file priority_deque.h.


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