2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseColIMapT.h
19 * @brief This is the header file for the %IMapT interface.
21 * This header file contains the declarations of the %IMapT interface.
23 #ifndef _FBASE_COL_IMAP_T_H_
24 #define _FBASE_COL_IMAP_T_H_
26 #include <FBaseColICollectionT.h>
27 #include <FBaseColIMapEnumeratorT.h>
28 #include <FBaseColMapEntryT.h>
31 namespace Tizen { namespace Base { namespace Collection
34 template< class Type > class IListT;
38 * @brief This interface abstracts a template-based collection of key-value pairs.
42 * The %IMapT interface abstracts a template-based collection of key-value pairs. An %IMapT
43 * contains unique keys and each key maps to a single value.
44 * The key and value cannot be a @c null reference.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/hashmap_multihashmap.htm">HashMap and MultiHashMap</a>.
49 template< class KeyType, class ValueType >
51 : public virtual ICollectionT< MapEntryT< KeyType, ValueType > >
55 * This polymorphic destructor should be overridden if required. @n
56 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
60 virtual ~IMapT(void) {}
63 * Adds the specified key-value pair to the map.
67 * @return An error code
68 * @param[in] key The key to add
69 * @param[in] value The corresponding value to add
70 * @exception E_SUCCESS The method is successful.
71 * @exception E_INVALID_ARG A specified input parameter is invalid, or
72 * the comparer has failed to compare the keys.
73 * @exception E_OBJ_ALREADY_EXIST The specified @c key already exists.
76 virtual result Add(const KeyType& key, const ValueType& value) = 0;
79 * Gets the value associated with the specified @c key.
83 * @return The value associated with the specified @c key, @n
84 * else @c null if an exception occurs
85 * @param[in] key The key to find the associated value
86 * @param[out] value The value associated with the key
87 * @exception E_SUCCESS The method is successful.
88 * @exception E_INVALID_ARG A specified input parameter is invalid, or
89 * the comparer has failed to compare the keys.
90 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
93 virtual result GetValue(const KeyType& key, ValueType& value) const = 0;
96 * Gets the value associated with the specified @c key.
100 * @return An error code
101 * @param[in] key The key to find the associated value
102 * @param[out] value The value associated with the key
103 * @exception E_SUCCESS The method is successful.
104 * @exception E_INVALID_ARG A specified input parameter is invalid, or
105 * the comparer has failed to compare the keys.
106 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
109 virtual result GetValue(const KeyType& key, ValueType& value) = 0;
112 * Gets a list of all the keys in the map.
116 * @return A pointer to a list of all the keys in the map, @n
117 * else @c null if an exception occurs
118 * @exception E_SUCCESS The method is successful.
119 * @exception E_OUT_OF_MEMORY The memory is insufficient.
120 * @remarks The order of the keys is the same as the corresponding values in the IListT interface returned by the GetValuesN() method.
121 * @remarks The specific error code can be accessed using the GetLastResult() method.
124 virtual IListT< KeyType >* GetKeysN(void) const = 0;
127 * Gets a list of all the values in the map.
131 * @return A pointer to a list of all values in the map, @n
132 * else @c null if an exception occurs
133 * @exception E_SUCCESS The method is successful.
134 * @exception E_OUT_OF_MEMORY The memory is insufficient.
135 * @remarks The specific error code can be accessed using the GetLastResult() method.
138 virtual IListT< ValueType >* GetValuesN(void) const = 0;
141 * Removes the value associated with the specified @c key.
145 * @return An error code
146 * @param[in] key The key for which the value is to remove
147 * @exception E_SUCCESS The method is successful.
148 * @exception E_INVALID_ARG A specified input parameter is invalid, or
149 * the comparer has failed to compare the keys.
150 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
153 virtual result Remove(const KeyType& key) = 0;
156 * Removes all key-value pairs in the map.
160 virtual void RemoveAll(void) = 0;
163 * Replaces the value associated with the specified @c key with the specified @c value.
167 * @return An error code
168 * @param[in] key The key whose value is to replace
169 * @param[in] value The new value
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_INVALID_ARG A specified input parameter is invalid, or
172 * the comparer has failed to compare the keys.
173 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
174 * @remarks Use the Add() method to add a new key-value pair.
178 virtual result SetValue(const KeyType& key, const ValueType& value) = 0;
181 * Checks whether the map contains the specified @c key.
185 * @return An error code
186 * @param[in] key The key to locate
187 * @param[out] out Set to @c true if the map contains the specified @c key, @n
189 * @exception E_SUCCESS The method is successful, or
190 * the map contains the specified @c key.
191 * @exception E_INVALID_ARG A specified input parameter is invalid, or
192 * the comparer has failed to compare the keys.
193 * @see ContainsValue()
195 virtual result ContainsKey(const KeyType& key, bool& out) const = 0;
198 * Checks whether the map contains the specified @c value.
202 * @return @c true if the map contains the specified @c value, @n
204 * @param[in] value The value to locate
208 virtual bool ContainsValue(const ValueType& value) const = 0;
211 * Gets an instance of the IMapEnumeratorT class for the map.
215 * @return An object of this map, @n
216 * else @c null if an exception occurs
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_OUT_OF_MEMORY The memory is insufficient.
219 * @remarks The specific error code can be accessed using the GetLastResult() method.
220 * @see Tizen::Base::Collection::IEnumerator
221 * @see Tizen::Base::Collection::IMapEnumerator
223 virtual IMapEnumeratorT< KeyType, ValueType >* GetMapEnumeratorN(void) const = 0;
227 }}} // Tizen::Base::Collection
229 #endif // _FBASE_COL_IMAP_T_H_