1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #ifndef __U_ARRAYLIST_H_
22 #define __U_ARRAYLIST_H_
33 * Use this default size when initialized
35 #define U_ARRAYLIST_DEFAULT_SIZE 1
38 * @struct u_arraylist_t
39 * @brief array list structure
41 typedef struct u_arraylist_t
49 * @brief API to creates array list and initializes the elements.
50 * @return u_arraylist_t if Success, NULL otherwise
52 u_arraylist_t* u_arraylist_create();
55 * @brief Resets and deletes the array list
56 * application should free the memory of data in array list
57 * @param list- u_arraylist pointer
59 * CA_STATUS_OK if Success, CA_STATUS_FAILED otherwise
61 CAResult_t u_arraylist_free(u_arraylist_t *list);
64 * @brief Returns the data of the index from the array list
66 * [IN] pointer of array list
68 * [IN] index of array list
69 * @return void pointer of the data
71 void* u_arraylist_get(const u_arraylist_t *list, uint32_t index);
74 * @brief Add data in the array list
76 * [IN] pointer of array list
78 * [IN] pointer of data
80 * CA_STATUS_OK if Success, CA_STATUS_FAILED otherwise
82 CAResult_t u_arraylist_add(u_arraylist_t *list, void *data);
85 * @brief Remove the data of the index from the array list
87 * [IN] pointer of array list
89 * [IN] index of array list
90 * @return void pointer of the data
92 void* u_arraylist_remove(u_arraylist_t *list, uint32_t index);
95 * @brief Returns the length of the array list
97 * [IN] pointer of array list
98 * @return length of the array list
100 uint32_t u_arraylist_length(const u_arraylist_t *list);
103 * @brief Returns whether the data exists or not
105 * [IN] pointer of array list
107 * [IN] pointer of data
108 * @return 1 if exists, 0 otherwise
110 uint8_t u_arraylist_contains(const u_arraylist_t *list, void *data);
116 #endif /* _U_ARRAYLIST_H_ */