Sayonara Player
Set.h
1 /* Set.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef SET_H
24 #define SET_H
25 
26 #include <set>
27 
28 #include <QList>
29 
30 
31 namespace SP {
32  template<typename T>
33 
38  class Set :
39  public std::set<T>
40  {
41 
42  public:
43 
47  Set() :
48  std::set<T>()
49  {
50 
51  }
52 
53 
58  Set(const T& one_element) :
59  Set()
60  {
61  this->insert(one_element);
62  }
63 
64 
69  QList<T> toList() const
70  {
71  QList<T> ret;
72  for(auto it=this->begin(); it!=this->end(); it++){
73  ret << *it;
74  }
75  return ret;
76  }
77 
78 
83  bool isEmpty() const
84  {
85  return (this->size() == 0);
86  }
87 
88 
93  T first() const
94  {
95  return *(this->begin());
96  }
97 
103  bool contains(const T& value) const
104  {
105  auto it = this->find(value);
106  return (it != this->end());
107  }
108 
113  void remove(const T& value)
114  {
115  auto it = this->find(value);
116  if(it != this->end()){
117  this->erase(it);
118  }
119  }
120  };
121 }
122 
123 
124 #endif // SET_H
Set()
Standard constructor.
Definition: Set.h:47
bool contains(const T &value) const
check, if set contains a specific value
Definition: Set.h:103
Definition: MetaDataList.h:39
T first() const
get copy of first element
Definition: Set.h:93
Set namespace defines the setting: Which key and which type.
Definition: SettingKey.h:177
bool isEmpty() const
Definition: Set.h:83
QList< T > toList() const
converts the set to a list. The order is random
Definition: Set.h:69
Set(const T &one_element)
Constructs a set with a single element.
Definition: Set.h:58
Definition: org_mpris_media_player2_adaptor.h:20