STXXL
1.4-dev
|
Guarded loser tree/tournament tree, either copying the whole element into the tree structure, or looking up the element via the index.
This is a base class for the LoserTreeCopy<true> and <false> classes.
Guarding is done explicitly through one flag sup per element, inf is not needed due to a better initialization routine. This is a well-performing variant.
ValueType | the element type |
Comparator | comparator to use for binary comparisons. |
Definition at line 44 of file losertree.h.
Classes | |
struct | Loser |
Internal representation of a loser tree player/node. More... | |
Public Types | |
typedef unsigned int | size_type |
size of counters and array indexes More... | |
typedef int | source_type |
type of the source field More... | |
Public Member Functions | |
LoserTreeCopyBase (size_type _k, Comparator _comp=std::less< ValueType >()) | |
~LoserTreeCopyBase () | |
source_type | get_min_source () |
return the index of the player with the smallest element. More... | |
void | init () |
size_type | init_winner (size_type root) |
void | insert_start (const ValueType &key, source_type source, bool sup) |
void | print (std::ostream &os) |
Protected Attributes | |
Comparator | comp |
the comparator object More... | |
bool | first_insert |
still have to construct keys More... | |
const size_type | ik |
number of nodes More... | |
const size_type | k |
log_2(ik) next greater power of 2 More... | |
Loser * | losers |
array containing loser tree nodes More... | |
typedef unsigned int stxxl::parallel::LoserTreeCopyBase< ValueType, Comparator >::size_type |
size of counters and array indexes
Definition at line 48 of file losertree.h.
typedef int stxxl::parallel::LoserTreeCopyBase< ValueType, Comparator >::source_type |
type of the source field
Definition at line 50 of file losertree.h.
|
inline |
Definition at line 76 of file losertree.h.
References stxxl::parallel::LoserTreeCopyBase< ValueType, Comparator >::Loser::sup.
|
inline |
Definition at line 93 of file losertree.h.
|
inline |
return the index of the player with the smallest element.
Definition at line 108 of file losertree.h.
|
inline |
Definition at line 169 of file losertree.h.
|
inline |
Computes the winner of the competition at player root. Called recursively (starting at 0) to build the initial tree.
root | index of the game to start. |
Definition at line 145 of file losertree.h.
|
inline |
Initializes the player source with the element key.
key | the element to insert |
source | index of the player |
sup | flag that determines whether the value to insert is an explicit supremum sentinel. |
Definition at line 121 of file losertree.h.
References UNLIKELY.
|
inline |
Definition at line 101 of file losertree.h.
|
protected |
the comparator object
Definition at line 71 of file losertree.h.
|
protected |
still have to construct keys
Definition at line 73 of file losertree.h.
|
protected |
number of nodes
Definition at line 65 of file losertree.h.
|
protected |
log_2(ik) next greater power of 2
Definition at line 67 of file losertree.h.
|
protected |
array containing loser tree nodes
Definition at line 69 of file losertree.h.