---
name: "__gnu_parallel::_LoserTree"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_parallel::_LoserTree/3cxx"
---

# \_\_gnu\_parallel::\_LoserTree(3cxx)

Stable \_LoserTree variant.

## NAME

\_\_gnu\_parallel::\_LoserTree\< \_\_stable, \_Tp, \_Compare \> - Stable \_LoserTree variant.

## SYNOPSIS

`#include <losertree.h>`

Inherits **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>**.

### Public Member Functions

**\_LoserTree** (unsigned int \_\_k, \_Compare \_\_comp)\
 void **\_\_delete\_min\_insert** (\_Tp \_\_key, bool \_\_sup)\
 Delete the smallest element and insert a new element from the previously smallest element's sequence.  int **\_\_get\_min\_source** ()\
 void **\_\_init** ()\
 unsigned int **\_\_init\_winner** (unsigned int \_\_root)\
 void **\_\_insert\_start** (const \_Tp &\_\_key, int \_\_source, bool \_\_sup)\
 Initializes the sequence '\_M\_source' with the element '\_\_key'.

### Protected Attributes

unsigned int **\_M\_ik**\
 unsigned int **\_M\_log\_k**\
 unsigned int **\_M\_offset**\

## Detailed Description

### template\<bool \_\_stable, typename \_Tp, typename \_Compare\>

class \_\_gnu\_parallel::\_LoserTree\< \_\_stable, \_Tp, \_Compare \>"Stable \_LoserTree variant.

Provides the stable implementations of insert\_start, \_\_init\_winner, \_\_init and \_\_delete\_min\_insert.

Unstable variant is done using partial specialisation below.

## Member Function Documentation

### template\<bool \_\_stable, typename \_Tp , typename \_Compare \> void \_\_gnu\_parallel::\_LoserTree\< \_\_stable, \_Tp, \_Compare \>::\_\_delete\_min\_insert (\_Tp \_\_key, bool \_\_sup)` [inline]`

Delete the smallest element and insert a new element from the previously smallest element's sequence. This implementation is stable.

References **std::swap()**.

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

**Returns**

the index of the sequence with the smallest element.

References **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_losers**, and **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_Loser::\_M\_source**.

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

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 **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_first\_insert**, **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_Loser::\_M\_key**, **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_M\_losers**, **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_Loser::\_M\_source**, and **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_Loser::\_M\_sup**.

## Member Data Documentation

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

log\_2{\_M\_k}

Referenced by **\_\_gnu\_parallel::\_LoserTreeBase\< \_Tp, \_Compare \>::\_LoserTreeBase()**.

## Author

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