qBittorrent
OrderedSet< T, Compare > Class Template Reference

#include <orderedset.h>

Inheritance diagram for OrderedSet< T, Compare >:
Collaboration diagram for OrderedSet< T, Compare >:

Public Types

using BaseType = std::set< T, Compare >
 
using key_type = typename BaseType::key_type
 
using value_type = typename BaseType::value_type
 

Public Member Functions

bool contains (const key_type &value) const
 
int count () const
 
ThisTypeintersect (const ThisType &other)
 
bool isEmpty () const
 
template<typename std::enable_if_t< std::is_same_v< value_type, QString >, int > = 0>
QString join (const QString &separator) const
 
bool remove (const key_type &value)
 
ThisTypeunite (const ThisType &other)
 

Private Types

using ThisType = OrderedSet< T, Compare >
 

Detailed Description

template<typename T, typename Compare = std::less<T>>
class OrderedSet< T, Compare >

Definition at line 38 of file orderedset.h.

Member Typedef Documentation

◆ BaseType

template<typename T , typename Compare = std::less<T>>
using OrderedSet< T, Compare >::BaseType = std::set<T, Compare>

Definition at line 43 of file orderedset.h.

◆ key_type

template<typename T , typename Compare = std::less<T>>
using OrderedSet< T, Compare >::key_type = typename BaseType::key_type

Definition at line 45 of file orderedset.h.

◆ ThisType

template<typename T , typename Compare = std::less<T>>
using OrderedSet< T, Compare >::ThisType = OrderedSet<T, Compare>
private

Definition at line 40 of file orderedset.h.

◆ value_type

template<typename T , typename Compare = std::less<T>>
using OrderedSet< T, Compare >::value_type = typename BaseType::value_type

Definition at line 46 of file orderedset.h.

Member Function Documentation

◆ contains()

template<typename T , typename Compare = std::less<T>>
bool OrderedSet< T, Compare >::contains ( const key_type value) const
inline

Definition at line 54 of file orderedset.h.

55  {
56  return (BaseType::find(value) != BaseType::cend());
57  }
T value(const QString &key, const T &defaultValue={})
Definition: preferences.cpp:64

References anonymous_namespace{preferences.cpp}::value().

Referenced by TransferListWidget::displayListMenu(), BitTorrent::TorrentImpl::hasTag(), and OrderedSet< T, Compare >::intersect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count()

template<typename T , typename Compare = std::less<T>>
int OrderedSet< T, Compare >::count ( ) const
inline

Definition at line 60 of file orderedset.h.

61  {
62  return static_cast<int>(BaseType::size());
63  }

Referenced by TagFilterModel::findItems(), and TagFilterModel::torrentTagAdded().

Here is the caller graph for this function:

◆ intersect()

template<typename T , typename Compare = std::less<T>>
ThisType& OrderedSet< T, Compare >::intersect ( const ThisType other)
inline

Definition at line 65 of file orderedset.h.

66  {
67  Algorithm::removeIf(*this, [&other](const value_type &value) -> bool
68  {
69  return !other.contains(value);
70  });
71  return *this;
72  }
typename BaseType::value_type value_type
Definition: orderedset.h:46
void removeIf(T &dict, BinaryPredicate &&p)
Definition: algorithm.h:50

References OrderedSet< T, Compare >::contains(), Algorithm::removeIf(), and anonymous_namespace{preferences.cpp}::value().

Referenced by TransferListWidget::displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

template<typename T , typename Compare = std::less<T>>
bool OrderedSet< T, Compare >::isEmpty ( ) const
inline

Definition at line 74 of file orderedset.h.

75  {
76  return BaseType::empty();
77  }

Referenced by TorrentFilter::matchTag(), BitTorrent::DBResumeDataStorage::Worker::store(), and TagFilterModel::torrentAboutToBeRemoved().

Here is the caller graph for this function:

◆ join()

template<typename T , typename Compare = std::less<T>>
template<typename std::enable_if_t< std::is_same_v< value_type, QString >, int > = 0>
QString OrderedSet< T, Compare >::join ( const QString &  separator) const
inline

Definition at line 80 of file orderedset.h.

81  {
82  auto iter = BaseType::cbegin();
83  if (iter == BaseType::cend())
84  return {};
85 
86  QString ret = *iter;
87  ++iter;
88 
89  while (iter != BaseType::cend())
90  {
91  ret.push_back(separator + *iter);
92  ++iter;
93  }
94 
95  return ret;
96  }

Referenced by TransferListModel::displayValue(), Application::runExternalProgram(), serialize(), and BitTorrent::DBResumeDataStorage::Worker::store().

Here is the caller graph for this function:

◆ remove()

template<typename T , typename Compare = std::less<T>>
bool OrderedSet< T, Compare >::remove ( const key_type value)
inline

Definition at line 98 of file orderedset.h.

99  {
100  return (BaseType::erase(value) > 0);
101  }

References anonymous_namespace{preferences.cpp}::value().

Referenced by BitTorrent::TorrentImpl::removeTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unite()

template<typename T , typename Compare = std::less<T>>
ThisType& OrderedSet< T, Compare >::unite ( const ThisType other)
inline

Definition at line 103 of file orderedset.h.

104  {
105  BaseType::insert(other.cbegin(), other.cend());
106  return *this;
107  }

Referenced by TransferListWidget::displayListMenu().

Here is the caller graph for this function:

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