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>
30 namespace Tizen { namespace Base { namespace Collection
33 template< class Type > class IListT;
37 * @brief This interface abstracts a template-based collection of key-value pairs.
41 * The %IMapT interface abstracts a template-based collection of key-value pairs. An %IMapT
42 * contains unique keys and each key maps to a single value.
43 * The key and value cannot be a @c null reference.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/hashmap_multihashmap.htm">HashMap and MultiHashMap</a>.
48 template< class KeyType, class ValueType >
50 : public virtual ICollectionT< MapEntryT< KeyType, ValueType > >
54 * This polymorphic destructor should be overridden if required. @n
55 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
59 virtual ~IMapT(void) {}
62 * Adds the specified key-value pair to the map.
66 * @return An error code
67 * @param[in] key The key to add
68 * @param[in] value The corresponding value to add
69 * @exception E_SUCCESS The method is successful.
70 * @exception E_INVALID_ARG A specified input parameter is invalid, or
71 * the comparer has failed to compare the keys.
72 * @exception E_OBJ_ALREADY_EXIST The specified @c key already exists.
75 virtual result Add(const KeyType& key, const ValueType& value) = 0;
78 * Gets the value associated with the specified @c key.
82 * @return The value associated with the specified @c key, @n
83 * else @c null if an exception occurs
84 * @param[in] key The key to find the associated value
85 * @param[out] value The value associated with the key
86 * @exception E_SUCCESS The method is successful.
87 * @exception E_INVALID_ARG A specified input parameter is invalid, or
88 * the comparer has failed to compare the keys.
89 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
92 virtual result GetValue(const KeyType& key, ValueType& value) const = 0;
95 * Gets the value associated with the specified @c key.
99 * @return An error code
100 * @param[in] key The key to find the associated value
101 * @param[out] value The value associated with the key
102 * @exception E_SUCCESS The method is successful.
103 * @exception E_INVALID_ARG A specified input parameter is invalid, or
104 * the comparer has failed to compare the keys.
105 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
108 virtual result GetValue(const KeyType& key, ValueType& value) = 0;
111 * Gets a list of all the keys in the map.
115 * @return A pointer to a list of all the keys in the map, @n
116 * else @c null if an exception occurs
117 * @exception E_SUCCESS The method is successful.
118 * @exception E_OUT_OF_MEMORY The memory is insufficient.
119 * @remarks The order of the keys is the same as the corresponding values in the IListT interface returned by the GetValuesN() method.
120 * @remarks The specific error code can be accessed using the GetLastResult() method.
123 virtual IListT< KeyType >* GetKeysN(void) const = 0;
126 * Gets a list of all the values in the map.
130 * @return A pointer to a list of all values in the map, @n
131 * else @c null if an exception occurs
132 * @exception E_SUCCESS The method is successful.
133 * @exception E_OUT_OF_MEMORY The memory is insufficient.
134 * @remarks The specific error code can be accessed using the GetLastResult() method.
137 virtual IListT< ValueType >* GetValuesN(void) const = 0;
140 * Removes the value associated with the specified @c key.
144 * @return An error code
145 * @param[in] key The key for which the value is to remove
146 * @exception E_SUCCESS The method is successful.
147 * @exception E_INVALID_ARG A specified input parameter is invalid, or
148 * the comparer has failed to compare the keys.
149 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
152 virtual result Remove(const KeyType& key) = 0;
155 * Removes all key-value pairs in the map.
159 virtual void RemoveAll(void) = 0;
162 * Replaces the value associated with the specified @c key with the specified @c value.
166 * @return An error code
167 * @param[in] key The key whose value is to replace
168 * @param[in] value The new value
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_INVALID_ARG A specified input parameter is invalid, or
171 * the comparer has failed to compare the keys.
172 * @exception E_OBJ_NOT_FOUND The specified @c key is not found in the map.
173 * @remarks Use the Add() method to add a new key-value pair.
177 virtual result SetValue(const KeyType& key, const ValueType& value) = 0;
180 * Checks whether the map contains the specified @c key.
184 * @return An error code
185 * @param[in] key The key to locate
186 * @param[out] out Set to @c true if the map contains the specified @c key, @n
188 * @exception E_SUCCESS The method is successful, or
189 * the map contains the specified @c key.
190 * @exception E_INVALID_ARG A specified input parameter is invalid, or
191 * the comparer has failed to compare the keys.
192 * @see ContainsValue()
194 virtual result ContainsKey(const KeyType& key, bool& out) const = 0;
197 * Checks whether the map contains the specified @c value.
201 * @return @c true if the map contains the specified @c value, @n
203 * @param[in] value The value to locate
207 virtual bool ContainsValue(const ValueType& value) const = 0;
210 * Gets an instance of the IMapEnumeratorT class for the map.
214 * @return An object of this map, @n
215 * else @c null if an exception occurs
216 * @exception E_SUCCESS The method is successful.
217 * @exception E_OUT_OF_MEMORY The memory is insufficient.
218 * @remarks The specific error code can be accessed using the GetLastResult() method.
219 * @see Tizen::Base::Collection::IEnumerator
220 * @see Tizen::Base::Collection::IMapEnumerator
222 virtual IMapEnumeratorT< KeyType, ValueType >* GetMapEnumeratorN(void) const = 0;
226 }}} // Tizen::Base::Collection
228 #endif // _FBASE_COL_IMAP_T_H_