Template Class LoserTree

Class Documentation

template<class T, class C = std::less<>>
class LoserTree

the tree of losers of k players, the winner the smallest key by less

Public Functions

explicit LoserTree(std::vector<std::optional<T>> keys, C less = C())

the players with their first keys, an empty key for an exhausted one

Pre:

at least one player

std::size_t players(void) const

k, the players

bool empty(void) const

all the players exhausted

std::size_t winner(void) const

the player with the smallest key

Pre:

! empty()

const T &top(void) const

its key

Pre:

! empty()

void replace(std::optional<T> key)

the winner takes the key, or is exhausted if it is empty, and the matches on its path are replayed

Pre:

! empty()