11#ifndef ZYPP_BASE_SETTRACKER_H
12#define ZYPP_BASE_SETTRACKER_H
66 bool changed = ( new_r !=
_current );
80 bool changed = ( new_r !=
_current );
102 bool done =
_current.insert( val_r ).second;
116 bool done =
_current.erase( val_r );
119 if ( !
_added.erase( val_r ) )
163 {
return set_r.find( key_r ) != set_r.end(); }
165 template <
class TORDERED_SET,
typename enable_if =
typename TORDERED_SET::key_compare>
166 static void setDifference(
const TORDERED_SET & lhs,
const TORDERED_SET & rhs, TORDERED_SET & result_r )
169 std::set_difference( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(),
170 std::inserter( result_r, result_r.end() ),
171 typename TORDERED_SET::key_compare() );
174 template <
class TUNORDERED_SET,
typename enable_if =
typename TUNORDERED_SET::hasher,
typename =
void>
175 static void setDifference(
const TUNORDERED_SET & lhs,
const TUNORDERED_SET & rhs, TUNORDERED_SET & result_r )
178 for (
const auto & l : lhs )
179 {
if ( rhs.find( l ) == rhs.end() ) result_r.insert( l ); }
189 template <
class TSet>
191 {
return str <<
"set(" << obj.
current().size() <<
"|+" << obj.
added().size() <<
"|-" << obj.
removed().size() <<
')'; }
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Track added/removed set items based on an initial set.
std::ostream & operator<<(std::ostream &str, const SetTracker< TSet > &obj)
Stream output.
bool wasRemoved(const key_type &key_r) const
Whether val_r is tracked as removed.
bool setInitial(set_type new_r)
Start tracking a new set (discards previously tracked changes).
TSet::value_type value_type
const set_type & current() const
Return the current set.
set_type & current()
Return the current set.
static void setDifference(const TORDERED_SET &lhs, const TORDERED_SET &rhs, TORDERED_SET &result_r)
static bool find(const set_type &set_r, const key_type &key_r)
SetTracker(set_type initial_r)
Ctor taking an initial set.
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 wasAdded(const key_type &key_r) const
Whether val_r is tracked as added.
const set_type & added() const
Return the set of added items.
set_type & added()
Return the set of added items.
set_type & removed()
Return the set of removed items.
bool remove(const value_type &val_r)
Remove an element from the set and track changes.
static void setDifference(const TUNORDERED_SET &lhs, const TUNORDERED_SET &rhs, TUNORDERED_SET &result_r)
SetTracker()
Default Ctor: empty set.
const set_type & removed() const
Return the set of removed items.
bool setInitial()
(Re-)Start tracking the current set (discards previously tracked changes).
bool contains(const key_type &key_r) const
Whether val_r is in the set.