---
name: "__gnu_parallel::_LoserTreeBase"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_parallel::_LoserTreeBase"
---

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

Guarded loser/tournament tree.

## NAME

\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \> - Guarded loser/tournament tree.

## SYNOPSIS

\#include \<losertree.h\>

Inherited by **\_\_gnu\_parallel::\_LoserTree\< false, \_Tp, \_Compare \>**, **\_\_gnu\_parallel::\_LoserTree\< \_\_stable, \_Tp, \_Compare \>**, and **\_\_gnu\_parallel::\_LoserTree\< false, \_Tp, \_Compare \>**.

### Classes

struct **\_Loser**\
 Internal representation of a \_LoserTree element.

### Public Member Functions

**\_LoserTreeBase** (unsigned int \_\_k, \_Compare \_\_comp)\
 The constructor.  **~\_LoserTreeBase** ()\
 The destructor.  int **\_\_get\_min\_source** ()\
 void **\_\_insert\_start** (const \_Tp &\_\_key, int \_\_source, bool \_\_sup)\
 Initializes the sequence *\_M\_source"*with*the*element*\_\_key*.

### Protected Attributes

\_Compare **\_M\_comp**\
 \_Compare to use.  bool **\_M\_first\_insert**\
 State flag that determines whether the \_LoserTree is empty.  unsigned int **\_M\_ik**\
 unsigned int **\_M\_k**\
 unsigned int **\_M\_log\_k**\
 **\_Loser** \* **\_M\_losers**\
 \_LoserTree \_\_elements.  unsigned int **\_M\_offset**\

## Detailed Description

### template\<typename \_Tp, typename \_Compare\>

class \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>"Guarded loser/tournament tree.

The smallest element is at the top.

Guarding is done explicitly through one flag \_M\_sup per element, inf is not needed due to a better initialization routine. This is a well-performing variant.

**Parameters**

*\_Tp* the element type \
 *\_Compare* the comparator to use, defaults to std::less\<\_Tp\>

## Constructor & Destructor Documentation

### template\<typename \_Tp, typename \_Compare\> \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_LoserTreeBase (unsigned int \_\_k, \_Compare \_\_comp) \[inline\]

The constructor.

**Parameters**

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

References **\_\_gnu\_parallel::\_\_rd\_log2()**, **\_M\_comp**, **\_M\_first\_insert**, **\_M\_log\_k**, and **\_M\_losers**.

### template\<typename \_Tp, typename \_Compare\> \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::~\_LoserTreeBase () \[inline\]

The destructor.

References **\_M\_losers**.

## Member Function Documentation

### template\<typename \_Tp, typename \_Compare\> int \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_\_get\_min\_source () \[inline\]

**Returns**

the index of the sequence with the smallest element.

References **\_M\_losers**.

### template\<typename \_Tp, typename \_Compare\> void \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_\_insert\_start (const \_Tp & \_\_key, int \_\_source, bool \_\_sup) \[inline\]

Initializes the sequence "\_M\_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.

References **\_M\_first\_insert**, and **\_M\_losers**.

## Member Data Documentation

### template\<typename \_Tp, typename \_Compare\> \_Compare \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_comp \[protected\]

\_Compare to use.

Referenced by **\_LoserTreeBase()**.

### template\<typename \_Tp, typename \_Compare\> bool \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_first\_insert \[protected\]

State flag that determines whether the \_LoserTree is empty. Only used for building the \_LoserTree.

Referenced by **\_LoserTreeBase()**, and **\_\_insert\_start()**.

### template\<typename \_Tp, typename \_Compare\> unsigned int \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_log\_k \[protected\]

log\_2{\_M\_k}

Referenced by **\_LoserTreeBase()**.

### template\<typename \_Tp, typename \_Compare\> \_Loser\* \_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_losers \[protected\]

\_LoserTree \_\_elements.

Referenced by **\_LoserTreeBase()**, **~\_LoserTreeBase()**, **\_\_get\_min\_source()**, and **\_\_insert\_start()**.

## Author

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