OpenASIP  2.0
MapTools.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file MapTools.hh
26  *
27  * @author Pekka Jääskeläinen (pekka.jaaskelainen-no.spam-tut.fi) 2004
28  *
29  * Tools for handling STL Pair Associative Containers (usually map).
30  *
31  * Declarations.
32  *
33  */
34 
35 #ifndef TTA_MAP_TOOLS_HH
36 #define TTA_MAP_TOOLS_HH
37 
38 #include <set>
39 
40 #include "Exception.hh"
41 
42 class MapTools {
43 public:
44  template <typename MapType, typename ValueType>
45  static bool containsValue(const MapType& aMap, const ValueType& aValue);
46 
47  template <typename MapType, typename KeyType>
48  static bool containsKey(const MapType& aMap, const KeyType& aKey);
49 
50  template <typename KeyType, typename MapType, typename ValueType>
51  static KeyType keyForValue(const MapType& aMap, const ValueType& aValue);
52 
53  template <typename ValueType, typename MapType, typename KeyType>
54  static ValueType valueForKey(const MapType& aMap, const KeyType& aKey);
55 
56  template <typename ValueType, typename MapType, typename KeyType>
57  static const ValueType valueForKeyNoThrow(
58  const MapType& aMap, const KeyType& aKey);
59 
60  template <typename MapType>
61  static void deleteAllValues(MapType& aMap);
62 
63  template <typename MapType>
64  static void deleteAllKeys(MapType& aMap);
65 
66  template <typename MapType, typename KeyType>
67  static void deleteByKey(MapType& aMap, const KeyType& aKey);
68 
69  template <typename MapType, typename ValueType>
70  static bool removeItemsByValue(MapType& aMap, const ValueType& aValue);
71 
72  template <typename KeyType, typename MapType>
73  static std::set<KeyType> keys(const MapType& aMap);
74 };
75 
76 #include "MapTools.icc"
77 
78 #endif
MapTools::deleteAllKeys
static void deleteAllKeys(MapType &aMap)
MapTools.icc
Exception.hh
MapTools::valueForKeyNoThrow
static const ValueType valueForKeyNoThrow(const MapType &aMap, const KeyType &aKey)
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
MapTools::deleteByKey
static void deleteByKey(MapType &aMap, const KeyType &aKey)
MapTools::removeItemsByValue
static bool removeItemsByValue(MapType &aMap, const ValueType &aValue)
MapTools
Definition: MapTools.hh:42
MapTools::keyForValue
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
MapTools::keys
static std::set< KeyType > keys(const MapType &aMap)
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
MapTools::valueForKey
static ValueType valueForKey(const MapType &aMap, const KeyType &aKey)
MapTools::containsValue
static bool containsValue(const MapType &aMap, const ValueType &aValue)