Miam-Player  0.8.0
A nice music player
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 "taglib.h"
30 
31 #include <list>
32 
33 namespace TagLib {
34 
36 
53  template <class T> class List
54  {
55  public:
56 #ifndef DO_NOT_DOCUMENT
57  typedef typename std::list<T>::iterator Iterator;
58  typedef typename std::list<T>::const_iterator ConstIterator;
59 #endif
60 
64  List();
65 
71  List(const List<T> &l);
72 
77  virtual ~List();
78 
83  Iterator begin();
84 
89  ConstIterator begin() const;
90 
95  Iterator end();
96 
101  ConstIterator end() const;
102 
106  Iterator insert(Iterator it, const T &value);
107 
113  List<T> &sortedInsert(const T &value, bool unique = false);
114 
119  List<T> &append(const T &item);
120 
125  List<T> &append(const List<T> &l);
126 
131  List<T> &prepend(const T &item);
132 
137  List<T> &prepend(const List<T> &l);
138 
145  List<T> &clear();
146 
152  unsigned int size() const;
153 
159  bool isEmpty() const;
160 
164  Iterator find(const T &value);
165 
169  ConstIterator find(const T &value) const;
170 
174  bool contains(const T &value) const;
175 
179  Iterator erase(Iterator it);
180 
184  const T &front() const;
185 
189  T &front();
190 
194  const T &back() const;
195 
199  T &back();
200 
209  void setAutoDelete(bool autoDelete);
210 
216  T &operator[](unsigned int i);
217 
223  const T &operator[](unsigned int i) const;
224 
230  List<T> &operator=(const List<T> &l);
231 
236  bool operator==(const List<T> &l) const;
237 
241  bool operator!=(const List<T> &l) const;
242 
243  protected:
244  /*
245  * If this List is being shared via implicit sharing, do a deep copy of the
246  * data and separate from the shared members. This should be called by all
247  * non-const subclass members.
248  */
249  void detach();
250 
251  private:
252 #ifndef DO_NOT_DOCUMENT
253  template <class TP> class ListPrivate;
254  ListPrivate<T> *d;
255 #endif
256  };
257 
258 }
259 
260 // Since GCC doesn't support the "export" keyword, we have to include the
261 // implementation.
262 
263 #include "tlist.tcc"
264 
265 #endif
List< T > & append(const T &item)
Appends item to the end of the list and returns a reference to the list.
std::list< T >::iterator Iterator
Definition: tlist.h:57
Iterator begin()
Returns an STL style iterator to the beginning of the list.
Iterator end()
Returns an STL style iterator to the end of the list.
A generic, implicitly shared list.
Definition: tlist.h:53
void setAutoDelete(bool autoDelete)
Auto delete the members of the list when the last reference to the list passes out of scope...
List< T > & sortedInsert(const T &value, bool unique=false)
Inserts the value into the list.
T & operator[](unsigned int i)
Returns a reference to item i in the list.
const T & back() const
Returns a reference to the last item in the list.
Iterator erase(Iterator it)
Erase the item at it from the list.
bool isEmpty() const
Returns whether or not the list is empty.
List< T > & prepend(const T &item)
Prepends item to the beginning list and returns a reference to the list.
bool operator==(const List< T > &l) const
Compares this list with l and returns true if all of the elements are the same.
List< T > & operator=(const List< T > &l)
Make a shallow, implicitly shared, copy of l.
List()
Constructs an empty list.
bool operator!=(const List< T > &l) const
Compares this list with l and returns true if the lists differ.
A namespace for all TagLib related classes and functions.
Definition: aifffile.h:33
bool contains(const T &value) const
Returns true if the list contains value.
List< T > & clear()
Clears the list.
const T & front() const
Returns a reference to the first item in the list.
std::list< T >::const_iterator ConstIterator
Definition: tlist.h:58
Iterator find(const T &value)
Find the first occurrence of value.
Iterator insert(Iterator it, const T &value)
Inserts a copy of value before it.
virtual ~List()
Destroys this List instance.
unsigned int size() const
Returns the number of elements in the list.