---
name: "__gnu_parallel::LoserTreeBase"
section: "3"
platform: "linux"
package: "libstdc++6-4.3-doc"
version: "4.3.2-1.1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_parallel::LoserTreeBase"
---

# \_\_gnu\_parallel::LoserTreeBase(3)

## NAME

\_\_gnu\_parallel::LoserTreeBase -

## SYNOPSIS

Inherited by **\_\_gnu\_parallel::LoserTree\< stable, T, Comparator \>**, and **\_\_gnu\_parallel::LoserTree\< false, T, Comparator \>**.

## Detailed Description

### template\<typename T, typename Comparator\> class \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>

Guarded loser/tournament tree.

The smallest element is at the top.

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.

**Parameters:**

*T* the element type \
 *Comparator* the comparator to use, defaults to std::less\<T\>

Definition at line 63 of file losertree.h.

### Public Member Functions

int **get\_min\_source** ()\
 void **insert\_start** (const T &key, int source, bool sup)\
 **LoserTreeBase** (unsigned int \_k, Comparator \_comp)\
 **~LoserTreeBase** ()\

### Protected Attributes

unsigned int **\_M\_log\_k**\
 Comparator **comp**\
 bool **first\_insert**\
 unsigned int **ik**\
 unsigned int **k**\
 **Loser** \* **losers**\
 unsigned int **offset**\

### Classes

struct **Loser**\
 *Internal representation of a* **LoserTree** *element.*

## Constructor & Destructor Documentation

### template\<typename T, typename Comparator\> \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::LoserTreeBase (unsigned int \_k, Comparator \_comp)` [inline]`

The constructor.

**Parameters:**

*\_k* The number of sequences to merge. \
 *\_comp* The comparator to use.

Definition at line 102 of file losertree.h.

References \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::\_M\_log\_k, \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::first\_insert, \_\_gnu\_parallel::log2(), and \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::losers.

### template\<typename T, typename Comparator\> \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::~LoserTreeBase ()` [inline]`

The destructor.

Definition at line 125 of file losertree.h.

References \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::losers.

## Member Function Documentation

### template\<typename T, typename Comparator\> int \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::get\_min\_source ()` [inline]`

**Returns:**

the index of the sequence with the smallest element.

Definition at line 158 of file losertree.h.

References \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::losers, and \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::Loser::source.

### template\<typename T, typename Comparator\> void \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::insert\_start (const T & key, int source, bool sup)` [inline]`

Initializes the sequence 'source' with the element 'key'.

**Parameters:**

*key* the element to insert \
 *source* index of the source sequence \
 *sup* flag that determines whether the value to insert is an explicit supremum.

Definition at line 137 of file losertree.h.

References \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::first\_insert, \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::Loser::key, \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::losers, \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::Loser::source, and \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::Loser::sup.

## Member Data Documentation

### template\<typename T, typename Comparator\> unsigned int \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::\_M\_log\_k` [protected]`

log\_2{k}

Definition at line 80 of file losertree.h.

Referenced by \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::LoserTreeBase().

### template\<typename T, typename Comparator\> Comparator \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::comp` [protected]`

Comparator to use.

Definition at line 86 of file losertree.h.

### template\<typename T, typename Comparator\> bool \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::first\_insert` [protected]`

State flag that determines whether the **LoserTree** is empty.

Only used for building the **LoserTree**.

Definition at line 93 of file losertree.h.

Referenced by \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::insert\_start(), and \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::LoserTreeBase().

### template\<typename T, typename Comparator\> Loser\* \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::losers` [protected]`

**LoserTree** elements.

Definition at line 83 of file losertree.h.

Referenced by \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::get\_min\_source(), \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::insert\_start(), \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::LoserTreeBase(), and \_\_gnu\_parallel::LoserTreeBase\< T, Comparator \>::~LoserTreeBase().

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
