libzypp: zyppng::base::SetTracker< TSet > Class Template Reference

libzypp 17.38.7

zyppng::base::SetTracker< TSet > Class Template Reference

Track added/removed set items based on an initial set. More...

`#include <zypp/base/SetTracker.h>`

## Public Types
typedef TSet | set_type
typedef TSet::key_type | key_type
typedef TSet::value_type | value_type

## Public Member Functions
| SetTracker ()
| Default Ctor: empty set.
| SetTracker (set_type initial_r)
| Ctor taking an initial set.
Tracking API
bool | setInitial ()
| (Re-)Start tracking the current set (discards previously tracked changes).
bool | setInitial (set_type new_r)
| Start tracking a new set (discards previously tracked changes).
bool | set (set_type new_r)
| Set a new_r set and track changes.
bool | add (const value_type &val_r)
| Add an element to the set and track changes.
bool | remove (const value_type &val_r)
| Remove an element from the set and track changes.
Query and retrieval
bool | contains (const key_type &key_r) const
| Whether val_r is in the set.
bool | wasAdded (const key_type &key_r) const
| Whether val_r is tracked as added.
bool | wasRemoved (const key_type &key_r) const
| Whether val_r is tracked as removed.
const set_type & | current () const
| Return the current set.
const set_type & | added () const
| Return the set of added items.
const set_type & | removed () const
| Return the set of removed items.

## Direct manipulation
set_type | _current
set_type | _added
set_type | _removed
set_type & | current ()
| Return the current set.
set_type & | added ()
| Return the set of added items.
set_type & | removed ()
| Return the set of removed items.
static bool | find (const set_type &set_r, const key_type &key_r)
template<class TORDERED_SET, typename enable_if = typename TORDERED_SET::key_compare>
static void | setDifference (const TORDERED_SET &lhs, const TORDERED_SET &rhs, TORDERED_SET &result_r)
template<class TUNORDERED_SET, typename enable_if = typename TUNORDERED_SET::hasher, typename = void>
static void | setDifference (const TUNORDERED_SET &lhs, const TUNORDERED_SET &rhs, TUNORDERED_SET &result_r)

## Detailed Description

template<class TSet>
class zyppng::base::SetTracker< TSet >

Track added/removed set items based on an initial set.

The class maintains the current set of items and also records the changes compared to the initial set (added and removed items) if you use the tracking API.

It is also possible to directly manipulate the three sets.

Note
  The tracking API expects the template arg to have set semantic.

Definition at line 38 of file SetTracker.h.

## Member Typedef Documentation

## ◆ set_type

template<class TSet>

typedef TSet zypp::base::SetTracker< TSet >::set_type

Definition at line 40 of file SetTracker.h.

## ◆ key_type

template<class TSet>

typedef TSet::key_type zypp::base::SetTracker< TSet >::key_type

Definition at line 41 of file SetTracker.h.

## ◆ value_type

template<class TSet>

typedef TSet::value_type zypp::base::SetTracker< TSet >::value_type

Definition at line 42 of file SetTracker.h.

## Constructor & Destructor Documentation

## ◆ SetTracker() [1/2]

template<class TSet>

zypp::base::SetTracker< TSet >::SetTracker | ( |  | ) |
| inline

Default Ctor: empty set.

Definition at line 45 of file SetTracker.h.

## ◆ SetTracker() [2/2]

template<class TSet>

zypp::base::SetTracker< TSet >::SetTracker | ( | set_type | initial_r | ) |
| inline

Ctor taking an initial set.

Definition at line 49 of file SetTracker.h.

## Member Function Documentation

## ◆ setInitial() [1/2]

template<class TSet>

bool zypp::base::SetTracker< TSet >::setInitial | ( |  | ) |
| inline

(Re-)Start tracking the current set (discards previously tracked changes).

Returns
  `False` (set did not change)

Definition at line 58 of file SetTracker.h.

## ◆ setInitial() [2/2]

template<class TSet>

bool zypp::base::SetTracker< TSet >::setInitial | ( | set_type | new_r | ) |
| inline

Start tracking a new set (discards previously tracked changes).

Returns
  Whether the set did change (new!=current)

Definition at line 64 of file SetTracker.h.

## ◆ set()

template<class TSet>

bool zypp::base::SetTracker< TSet >::set | ( | set_type | new_r | ) |
| inline

Set a new_r set and track changes.

Returns
  Whether the set has changed

Definition at line 79 of file SetTracker.h.

## ◆ add()

template<class TSet>

bool zypp::base::SetTracker< TSet >::add | ( | const value_type & | val_r | ) |
| inline

Add an element to the set and track changes.

Returns
  Whether the set has changed

Definition at line 101 of file SetTracker.h.

## ◆ remove()

template<class TSet>

bool zypp::base::SetTracker< TSet >::remove | ( | const value_type & | val_r | ) |
| inline

Remove an element from the set and track changes.

Returns
  Whether the set has changed

Definition at line 115 of file SetTracker.h.

## ◆ contains()

template<class TSet>

bool zypp::base::SetTracker< TSet >::contains | ( | const key_type & | key_r | ) | const
| inline

Whether val_r is in the set.

Definition at line 130 of file SetTracker.h.

## ◆ wasAdded()

template<class TSet>

bool zypp::base::SetTracker< TSet >::wasAdded | ( | const key_type & | key_r | ) | const
| inline

Whether val_r is tracked as added.

Definition at line 133 of file SetTracker.h.

## ◆ wasRemoved()

template<class TSet>

bool zypp::base::SetTracker< TSet >::wasRemoved | ( | const key_type & | key_r | ) | const
| inline

Whether val_r is tracked as removed.

Definition at line 136 of file SetTracker.h.

## ◆ current() [1/2]

template<class TSet>

const set_type & zypp::base::SetTracker< TSet >::current | ( |  | ) | const
| inline

Return the current set.

Definition at line 140 of file SetTracker.h.

## ◆ current() [2/2]

template<class TSet>

set_type & zypp::base::SetTracker< TSet >::current | ( |  | ) |
| inline

Return the current set.

Definition at line 152 of file SetTracker.h.

## ◆ added() [1/2]

template<class TSet>

const set_type & zypp::base::SetTracker< TSet >::added | ( |  | ) | const
| inline

Return the set of added items.

Definition at line 143 of file SetTracker.h.

## ◆ added() [2/2]

template<class TSet>

set_type & zypp::base::SetTracker< TSet >::added | ( |  | ) |
| inline

Return the set of added items.

Definition at line 155 of file SetTracker.h.

## ◆ removed() [1/2]

template<class TSet>

const set_type & zypp::base::SetTracker< TSet >::removed | ( |  | ) | const
| inline

Return the set of removed items.

Definition at line 146 of file SetTracker.h.

## ◆ removed() [2/2]

template<class TSet>

set_type & zypp::base::SetTracker< TSet >::removed | ( |  | ) |
| inline

Return the set of removed items.

Definition at line 158 of file SetTracker.h.

## ◆ find()

template<class TSet>

bool zypp::base::SetTracker< TSet >::find | ( | const set_type & | set_r,
|  | const key_type & | key_r )
| inlinestaticprivate

Definition at line 163 of file SetTracker.h.

## ◆ setDifference() [1/2]

template<class TSet>
template<class TORDERED_SET, typename enable_if = typename TORDERED_SET::key_compare>

void zypp::base::SetTracker< TSet >::setDifference | ( | const TORDERED_SET & | lhs,
|  | const TORDERED_SET & | rhs,
|  | TORDERED_SET & | result_r )
| inlinestaticprivate

Definition at line 167 of file SetTracker.h.

## ◆ setDifference() [2/2]

template<class TSet>
template<class TUNORDERED_SET, typename enable_if = typename TUNORDERED_SET::hasher, typename = void>

void zypp::base::SetTracker< TSet >::setDifference | ( | const TUNORDERED_SET & | lhs,
|  | const TUNORDERED_SET & | rhs,
|  | TUNORDERED_SET & | result_r )
| inlinestaticprivate

Definition at line 176 of file SetTracker.h.

## Member Data Documentation

## ◆ _current

template<class TSet>

set_type zypp::base::SetTracker< TSet >::_current
| private

Definition at line 184 of file SetTracker.h.

## ◆ _added

template<class TSet>

set_type zypp::base::SetTracker< TSet >::_added
| private

Definition at line 185 of file SetTracker.h.

## ◆ _removed

template<class TSet>

set_type zypp::base::SetTracker< TSet >::_removed
| private

Definition at line 186 of file SetTracker.h.

The documentation for this class was generated from the following file:

- zypp/base/SetTracker.h