1 /***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
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. *
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. *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
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 ***************************************************************************/
28 ////////////////////////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////////////////////////
32 template <class Key, class T>
33 template <class KeyP, class TP>
34 class Map<Key, T>::MapPrivate : public RefCounter
37 MapPrivate() : RefCounter() {}
38 #ifdef WANT_CLASS_INSTANTIATION_OF_MAP
39 MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounter(), map(m) {}
40 std::map<class KeyP, class TP> map;
42 MapPrivate(const std::map<KeyP, TP>& m) : RefCounter(), map(m) {}
43 std::map<KeyP, TP> map;
47 template <class Key, class T>
50 d = new MapPrivate<Key, T>;
53 template <class Key, class T>
54 Map<Key, T>::Map(const Map<Key, T> &m) : d(m.d)
59 template <class Key, class T>
66 template <class Key, class T>
67 typename Map<Key, T>::Iterator Map<Key, T>::begin()
70 return d->map.begin();
73 template <class Key, class T>
74 typename Map<Key, T>::ConstIterator Map<Key, T>::begin() const
76 return d->map.begin();
79 template <class Key, class T>
80 typename Map<Key, T>::Iterator Map<Key, T>::end()
86 template <class Key, class T>
87 typename Map<Key, T>::ConstIterator Map<Key, T>::end() const
92 template <class Key, class T>
93 Map<Key, T> &Map<Key, T>::insert(const Key &key, const T &value)
100 template <class Key, class T>
101 Map<Key, T> &Map<Key, T>::clear()
108 template <class Key, class T>
109 bool Map<Key, T>::isEmpty() const
111 return d->map.empty();
114 template <class Key, class T>
115 typename Map<Key, T>::Iterator Map<Key, T>::find(const Key &key)
118 return d->map.find(key);
121 template <class Key, class T>
122 typename Map<Key,T>::ConstIterator Map<Key, T>::find(const Key &key) const
124 return d->map.find(key);
127 template <class Key, class T>
128 bool Map<Key, T>::contains(const Key &key) const
130 return d->map.find(key) != d->map.end();
133 template <class Key, class T>
134 Map<Key, T> &Map<Key,T>::erase(Iterator it)
141 template <class Key, class T>
142 Map<Key, T> &Map<Key,T>::erase(const Key &key)
145 Iterator it = d->map.find(key);
146 if(it != d->map.end())
151 template <class Key, class T>
152 TagLib::uint Map<Key, T>::size() const
154 return d->map.size();
157 template <class Key, class T>
158 const T &Map<Key, T>::operator[](const Key &key) const
163 template <class Key, class T>
164 T &Map<Key, T>::operator[](const Key &key)
170 template <class Key, class T>
171 Map<Key, T> &Map<Key, T>::operator=(const Map<Key, T> &m)
183 ////////////////////////////////////////////////////////////////////////////////
185 ////////////////////////////////////////////////////////////////////////////////
187 template <class Key, class T>
188 void Map<Key, T>::detach()
192 d = new MapPrivate<Key, T>(d->map);
196 } // namespace TagLib