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 FBaseColIListT.h
19 * @brief This is the header file for the %IListT interface.
21 * This header file contains the declarations of the %IListT interface.
23 #ifndef _FBASE_COL_ILIST_T_H_
24 #define _FBASE_COL_ILIST_T_H_
26 #include <FBaseColIBidirectionalEnumeratorT.h>
27 #include <FBaseColICollectionT.h>
28 #include <FBaseColIComparerT.h>
30 namespace Tizen { namespace Base { namespace Collection
35 * @brief This interface represents a template-based collection of objects that can be individually accessed by an index.
39 * The %IListT interface represents a template-based collection of objects that can be individually accessed by an index.
42 template< class Type >
44 : public virtual ICollectionT< Type >
48 * This polymorphic destructor should be overridden if required. @n
49 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
53 virtual ~IListT(void) {}
56 * Adds the specified object to the list.
60 * @return An error code
61 * @param[in] obj The object to add
62 * @exception E_SUCCESS The method is successful.
63 * @exception E_OUT_OF_MEMORY The memory is insufficient.
64 * @remarks In a collection of contiguous elements, such as a list, the elements
65 * that follow the insertion point move down to accommodate the new element.
66 * If the collection is indexed, the indexes of the elements that are moved
67 * are also updated. This behavior does not apply to collections where
68 * elements are conceptually grouped into buckets, such as a hashtable.
71 virtual result Add(const Type& obj) = 0;
74 * Adds the elements of the specified collection to the end of the list.
78 * @return An error code
79 * @param[in] collection The collection to add
80 * @exception E_SUCCESS The method is successful.
81 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
82 * - The current state of the instance prohibits the execution of the specified operation.
83 * - The specified @c collection is modified during the operation of this method.
86 virtual result AddItems(const ICollectionT< Type >& collection) = 0;
89 * Searches for an object in this list. @n
90 * Gets the @c index of the object if found.
94 * @return An error code
95 * @param[in] obj The object to locate
96 * @param[out] index The index of the object
97 * @exception E_SUCCESS The method is successful.
98 * @exception E_OBJ_NOT_FOUND The specified @c obj has not been found.
100 virtual result IndexOf(const Type& obj, int& index) const = 0;
103 * Searches for an object starting from the specified @c startIndex. @n
104 * Gets the @c index of the object if found.
108 * @return An error code
109 * @param[in] obj The object to locate
110 * @param[in] startIndex The starting index for the search @n
111 * It must be less than the number of elements.
112 * @param[out] index The index of the object
113 * @exception E_SUCCESS The method is successful.
114 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
115 * - The specified @c index is outside the bounds of the data structure.
116 * - The specified @c startIndex is either greater than or equal to the number of elements in the list.
117 * - The specified @c startIndex is less than @c 0.
118 * @exception E_OBJ_NOT_FOUND The specified @c obj has not been found.
121 virtual result IndexOf(const Type& obj, int startIndex, int& index) const = 0;
124 * Searches for an object within the specified range. @n
125 * Gets the @c index of the object if found.
129 * @return An error code
130 * @param[in] obj The object to locate
131 * @param[in] startIndex The starting index of the range
132 * @param[in] count The number of elements to read
133 * @param[out] index The index of the object
134 * @exception E_SUCCESS The method is successful.
135 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
136 * - The specified @c index is outside the bounds of the data structure.
137 * - The specified @c startIndex is either greater than or equal to the number of elements in the list.
138 * - The specified @c startIndex is less than @c 0.
139 * - The specified @c count is greater than the number of elements starting from @c startIndex.
140 * - The specified @c count is less than @c 0.
141 * @exception E_OBJ_NOT_FOUND The specified @c obj has not been found.
144 virtual result IndexOf(const Type& obj, int startIndex, int count, int& index) const = 0;
147 * Searches for the last occurrence of an object in this list. @n
148 * Gets the @c index of the object if found.
152 * @return An error code
153 * @param[in] obj The object to locate
154 * @param[out] index The index of the last occurrence of the specified object
155 * @exception E_SUCCESS The method is successful.
156 * @exception E_OBJ_NOT_FOUND The specified @c obj has not been found.
159 virtual result LastIndexOf(const Type& obj, int& index) const = 0;
162 * Inserts an object at the specified location in the list.
166 * @return An error code
167 * @param[in] obj The object to insert
168 * @param[in] index The index at which the object is inserted
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
171 * - The specified @c index is outside the bounds of the data structure.
172 * - The specified @c index is greater than the number of elements in the list.
173 * - The specified @c index is less than @c 0.
174 * @remarks If the @c index is equal to the number of elements in the list, the new element
175 * is added at the end of the list.
179 virtual result InsertAt(const Type& obj, int index) = 0;
182 * Inserts the elements of a collection at the specified location in the list.
186 * @return An error code
187 * @param[in] collection The collection to insert
188 * @param[in] startIndex The starting index at which the collection is inserted
189 * @exception E_SUCCESS The method is successful.
190 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
191 * - The specified @c index is outside the bounds of the data structure.
192 * - The specified @c startIndex is greater than the number of elements in the list.
193 * - The specified @c startIndex is less than @c 0.
194 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
195 * - The current state of the instance prohibits the execution of the specified operation.
196 * - The specified @c collection is modified during the operation of this method.
197 * @remarks If the @c startIndex equals the number of elements in the list, the new elements
198 * are added at the end of the list.
202 virtual result InsertItemsFrom(const ICollectionT< Type >& collection, int startIndex) = 0;
205 * Gets the object at the specified location.
209 * @return An error code
210 * @param[in] index The index of the object to get
211 * @param[out] obj The object obtained from the list
212 * @exception E_SUCCESS The method is successful.
213 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
214 * - The specified @c index is outside the bounds of the data structure.
215 * - The specified @c index is either greater than or equal to the number of elements in the list.
216 * - The specified @c index is less than @c 0.
219 virtual result GetAt(int index, Type& obj) const = 0;
222 * Gets the object at the specified location.
226 * @return An error code
227 * @param[in] index The index of the object to get
228 * @param[out] obj The object obtained from the list
229 * @exception E_SUCCESS The method is successful.
230 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
231 * - The specified @c index is outside the bounds of the data structure.
232 * - The specified @c index is either greater than or equal to the number of elements in the list.
233 * - The specified @c index is less than @c 0.
236 virtual result GetAt(int index, Type& obj) = 0;
239 * Gets all the elements of the list within the specified range.
243 * @return A pointer to %IListT that contains the elements lying within the specified range, @n
244 * else @c null if an exception occurs
245 * @param[in] startIndex The starting index of the range
246 * @param[in] count The number of elements to read
247 * @exception E_SUCCESS The method is successful.
248 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
249 * - The specified @c index is outside the bounds of the data structure.
250 * - The specified @c startIndex is either greater than or equal to the number of elements in the list.
251 * - The specified @c startIndex is less than @c 0.
252 * - The specified @c count is greater than the number of elements in the list starting from @c startIndex.
253 * - The specified @c count is less than @c 0.
254 * @remarks The specific error code can be accessed using the GetLastResult() method.
256 virtual IListT< Type >* GetItemsN(int startIndex, int count) const = 0;
259 * Removes the first occurrence of the specified object.
263 * @return An error code
264 * @param[in] obj The object to remove
265 * @exception E_SUCCESS The method is successful.
266 * @exception E_OBJ_NOT_FOUND The specified @c obj has not been found.
268 virtual result Remove(const Type& obj) = 0;
271 * Removes the object at the specified location.
275 * @return An error code
276 * @param[in] index The index at which the object is removed
277 * @exception E_SUCCESS The method is successful.
278 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
279 * - The specified @c index is outside the bounds of the data structure.
280 * - The specified @c index is either greater than or equal to the number of elements in the list.
281 * - The specified @c index is less than @c 0.
283 virtual result RemoveAt(int index) = 0;
286 * Removes all the elements from the list that are common to the specified @c collection.
290 * @return An error code
291 * @param[in] collection The collection to remove from this list
292 * @exception E_SUCCESS The method is successful.
293 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
294 * - The current state of the instance prohibits the execution of the specified operation.
295 * - The specified @c collection is modified during the operation of this method.
299 virtual result RemoveItems(const ICollectionT< Type >& collection) = 0;
302 * Removes all the elements within the specified range.
306 * @return An error code
307 * @param[in] startIndex The starting index of the range
308 * @param[in] count The number of elements in the range
309 * @exception E_SUCCESS The method is successful.
310 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
311 * - The specified @c index is outside the bounds of the data structure.
312 * - The specified @c startIndex is either greater than or equal to the number of elements in the list.
313 * - The specified @c startIndex is less than @c 0.
314 * - The specified @c count is greater than the number of elements starting from @c startIndex.
315 * - The specified @c count is less than @c 0.
317 * @see InsertItemsFrom()
319 virtual result RemoveItems(int startIndex, int count) = 0;
322 * Removes all the elements from the list.
326 virtual void RemoveAll(void) = 0;
329 * Sets the object at the specified @c index with the specified object.
333 * @return An error code
334 * @param[in] obj The new object
335 * @param[in] index The index at which the new object is set
336 * @exception E_SUCCESS The method is successful.
337 * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
338 * - The specified @c index is outside the bounds of the data structure.
339 * - The specified @c index is either greater than or equal to the number of elements in the list.
340 * - The specified @c index is less than @c 0.
343 virtual result SetAt(const Type& obj, int index) = 0;
346 * Sorts the elements of this list using the @c comparer provided.
350 * @return An error code
351 * @param[in] comparer The IComparerT implementation to use when comparing the elements
352 * @exception E_SUCCESS The method is successful.
353 * @exception E_INVALID_ARG The specified input parameter is invalid.
355 virtual result Sort(const IComparerT< Type >& comparer) = 0;
358 * Checks whether the list contains the specified object.
362 * @return @c true if the list contains the specified object, @n
364 * @param[in] obj The object to locate
366 virtual bool Contains(const Type& obj) const = 0;
369 * Checks whether the list contains all the elements of the specified @c collection.
373 * @return An error code
374 * @param[in] collection The collection to check for containment in this list
375 * @param[out] out Set to @c true if the list contains all the elements of the specified collection, @n
377 * @exception E_SUCCESS The method is successful.
378 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
379 * - The current state of the instance prohibits the execution of the specified operation.
380 * - The specified @c collection is modified during the operation of this method.
381 * @remarks If the given @c collection is empty, then @c out is set to @c true.
384 virtual result ContainsAll(const ICollectionT< Type >& collection, bool& out) const = 0;
387 * Gets the bidirectional enumerator (an instance of the IBidirectionalEnumeratorT derived class) of this list.
391 * @return A pointer to the bidirectional enumerator interface of the %IListT derived class, @n
392 * else @c null if an exception occurs
393 * @exception E_SUCCESS The method is successful.
394 * @exception E_OUT_OF_MEMORY The memory is insufficient.
396 * - Use this method to obtain a bidirectional enumerator (an instance of the IBidirectionalEnumeratorT derived class)
397 * to iterate over a collection (an instance of the %IListT derived class).
398 * - The specific error code can be accessed using the GetLastResult() method.
400 virtual IBidirectionalEnumeratorT< Type >* GetBidirectionalEnumeratorN(void) const = 0;
404 }}} // Tizen::Base::Collection
406 #endif // _FBASE_COL_ILIST_T_H_