PengZheng commented on code in PR #727:
URL: https://github.com/apache/celix/pull/727#discussion_r1486373102
##########
libs/utils/include/celix_array_list.h:
##########
@@ -468,11 +868,48 @@ CELIX_UTILS_EXPORT
void celix_arrayList_sortEntries(celix_array_list_t *list,
celix_array_list_compare_entries_fp compare);
/**
- * @warning Never use this function with array of doubles, since on some
32-bit platform (sizeof(double)==8 && sizeof(void*)==4)
- * @deprecated This function is deprecated, use celix_arrayList_sortEntries
instead.
+ * @brief Sort the array list using the array list configured compare function.
+ * Note that undefined the array list compare function can be NULL and in that
case the array list will not be sorted.
*/
-CELIX_UTILS_DEPRECATED_EXPORT
-void celix_arrayList_sort(celix_array_list_t *list, celix_arrayList_sort_fp
sortFp);
+CELIX_UTILS_EXPORT
+void celix_arrayList_sort(celix_array_list_t *list);
+
+/**
+ * @brief Check if the array list are equal.
+ *
+ * Equal is defined as:
+ * - The array list have the same size
+ * - The array list have the same element type
+ * - The array list have the same equals callback
+ * - The array list have the same values at the same index
+ *
+ * Note that the remove callback and compare callback are ignored.
+ *
+ * If both array list are NULL, they are considered equal.
+ *
+ * @param listA The first array list.
+ * @param listB The second array list.
+ * @return true if the array list are equal, false otherwise.
+ */
+CELIX_UTILS_EXPORT
+bool celix_arrayList_equals(const celix_array_list_t* listA, const
celix_array_list_t* listB);
+
+/**
+ * @Brief Copy the array list to a new array list.
+ *
+ * The new array list will have the same element type and the same callbacks
as the original array list.
+ * If the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING, the strings
will be copied and
+ * if the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION, the versions
will be copied.
+ * For all other element types the values will be copied.
+ *
+ * If a NULL is returned and the original array list is not NULL, a error
message is logged to celix_err.
+ *
+ * @param[in] list The array list to copy.
+ * @return A new array list with the same element type and values as the
original array list or NULL if the original
+ * array list is NULL or out of memory.
+ */
+CELIX_UTILS_EXPORT
+celix_array_list_t* celix_arrayList_copy(const celix_array_list_t* list);
Review Comment:
If `CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED` is reserved for user-defined
type, then how these user-defined type should be copied is left undefined.
##########
libs/utils/include/celix_array_list.h:
##########
@@ -40,36 +41,83 @@
extern "C" {
#endif
+/**
+ * @enum celix_array_list_element_type_t
+ * @brief An enumeration of the types of elements that can be stored in a
Celix array list.
+ */
+typedef enum celix_array_list_element_type {
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED = 0, /**< Represents an undefined
element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER = 1, /**< Represents a pointer
element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING = 2, /**< Represents a string element
type where the array list is the owner */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING_REF =
+ 3, /**< Represents a string element type where the array list is not
the owner */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_INT = 4, /**< Represents an integer
element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG = 5, /**< Represents a long integer
element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_UINT = 6, /**< Represents an unsigned
integer element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_ULONG = 7, /**< Represents an unsigned long
integer element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_FLOAT = 8, /**< Represents a float element
type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE = 9, /**< Represents a double element
type. */
Review Comment:
If we have `double`, do we still need `float`? The same remarks apply to
`size_t`/`unsigned long`/`unsigned int`, `long`/`int`. Moreover, when use JSON
as serialization format, how to encode these (redundant) types?
##########
libs/utils/include/celix_array_list.h:
##########
@@ -468,11 +868,48 @@ CELIX_UTILS_EXPORT
void celix_arrayList_sortEntries(celix_array_list_t *list,
celix_array_list_compare_entries_fp compare);
/**
- * @warning Never use this function with array of doubles, since on some
32-bit platform (sizeof(double)==8 && sizeof(void*)==4)
- * @deprecated This function is deprecated, use celix_arrayList_sortEntries
instead.
+ * @brief Sort the array list using the array list configured compare function.
+ * Note that undefined the array list compare function can be NULL and in that
case the array list will not be sorted.
*/
-CELIX_UTILS_DEPRECATED_EXPORT
-void celix_arrayList_sort(celix_array_list_t *list, celix_arrayList_sort_fp
sortFp);
+CELIX_UTILS_EXPORT
+void celix_arrayList_sort(celix_array_list_t *list);
+
+/**
+ * @brief Check if the array list are equal.
+ *
+ * Equal is defined as:
+ * - The array list have the same size
+ * - The array list have the same element type
Review Comment:
This is not checked in the implementation.
##########
libs/utils/include/celix_array_list.h:
##########
@@ -240,102 +484,207 @@ bool celix_arrayList_getBool(const celix_array_list_t
*list, int index);
/**
* @brief Returns the value for the provided index.
*
- * @param map The array list.
+ * Can be used for array list with element type
CELIX_ARRAY_LIST_ELEMENT_TYPE_SIZE or
+ * CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED.
+ *
+ * @param list The array list.
* @param index The entry index to return.
* @return Returns the size_t value for the index. Returns 0 if index is out
of bound.
*/
CELIX_UTILS_EXPORT
size_t celix_arrayList_getSize(const celix_array_list_t *list, int index);
+/**
+ * @brief Returns the value for the provided index.
+ *
+ * Can be used for array list with element type
CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION,
+ * or CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED.
Review Comment:
Dangerous for `CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]