TagLib  2.2.1
tlist.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2002 - 2008 by Scott Wheeler
3  email : wheeler@kde.org
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * This library is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU Lesser General Public License version *
9  * 2.1 as published by the Free Software Foundation. *
10  * *
11  * This library is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19  * 02110-1301 USA *
20  * *
21  * Alternatively, this file is available under the Mozilla Public *
22  * License Version 1.1. You may obtain a copy of the License at *
23  * http://www.mozilla.org/MPL/ *
24  ***************************************************************************/
25 
26 #ifndef TAGLIB_LIST_H
27 #define TAGLIB_LIST_H
28 
29 #include <list>
30 #include <initializer_list>
31 #include <memory>
32 
33 namespace TagLib {
34 
36 
53  template <class T> class List
54  {
55  public:
56 #ifndef DO_NOT_DOCUMENT
57  using Iterator = typename std::list<T>::iterator;
58  using ConstIterator = typename std::list<T>::const_iterator;
59 #endif
60 
64  List();
65 
71  List(const List<T> &l);
72 
76  List(std::initializer_list<T> init);
77 
82  ~List();
83 
88  Iterator begin();
89 
94  ConstIterator begin() const;
95 
100  ConstIterator cbegin() const;
101 
106  Iterator end();
107 
112  ConstIterator end() const;
113 
118  ConstIterator cend() const;
119 
127  Iterator insert(Iterator it, const T &item);
128 
134  List<T> &sortedInsert(const T &value, bool unique = false);
135 
140  List<T> &append(const T &item);
141 
146  List<T> &append(const List<T> &l);
147 
152  List<T> &prepend(const T &item);
153 
158  List<T> &prepend(const List<T> &l);
159 
166  List<T> &clear();
167 
173  unsigned int size() const;
174 
180  bool isEmpty() const;
181 
185  Iterator find(const T &value);
186 
190  ConstIterator find(const T &value) const;
191 
195  ConstIterator cfind(const T &value) const;
196 
200  bool contains(const T &value) const;
201 
209  Iterator erase(Iterator it);
210 
214  const T &front() const;
215 
219  T &front();
220 
224  const T &back() const;
225 
229  T &back();
230 
239  void setAutoDelete(bool autoDelete);
240 
244  bool autoDelete() const;
245 
251  T &operator[](unsigned int i);
252 
258  const T &operator[](unsigned int i) const;
259 
265  List<T> &operator=(const List<T> &l);
266 
272  List<T> &operator=(std::initializer_list<T> init);
273 
277  void swap(List<T> &l) noexcept;
278 
283  bool operator==(const List<T> &l) const;
284 
288  bool operator!=(const List<T> &l) const;
289 
293  void sort();
294 
300  template<class Compare>
301  void sort(Compare&& comp);
302 
303  protected:
309  void detach();
310 
311  private:
312 #ifndef DO_NOT_DOCUMENT
313  template <class TP> class ListPrivate;
314  std::shared_ptr<ListPrivate<T>> d;
315 #endif
316  };
317 
318 } // namespace TagLib
319 
320 // Since GCC doesn't support the "export" keyword, we have to include the
321 // implementation.
322 
323 #include "tlist.tcc"
324 
325 #endif
A generic, implicitly shared list.
Definition: tlist.h:53
Iterator erase(Iterator it)
const T & back() const
bool operator==(const List< T > &l) const
const T & front() const
Iterator insert(Iterator it, const T &item)
List< T > & clear()
List< T > & prepend(const T &item)
List< T > & append(const T &item)
Iterator find(const T &value)
bool operator!=(const List< T > &l) const
void swap(List< T > &l) noexcept
bool contains(const T &value) const
bool isEmpty() const
ConstIterator cend() const
ConstIterator cbegin() const
ConstIterator cfind(const T &value) const
Iterator begin()
Iterator end()
List< T > & operator=(const List< T > &l)
unsigned int size() const
void setAutoDelete(bool autoDelete)
List< T > & sortedInsert(const T &value, bool unique=false)
bool autoDelete() const
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
T & operator[](unsigned int i)