src/cx/list.h

changeset 1479
ac1baaed2fd7
parent 1477
9170a7dff573
equal deleted inserted replaced
1478:bba2e5efdca0 1479:ac1baaed2fd7
976 * @param clone_func the clone function for the elements 976 * @param clone_func the clone function for the elements
977 * @param clone_allocator the allocator that is passed to the clone function 977 * @param clone_allocator the allocator that is passed to the clone function
978 * @param data optional additional data that is passed to the clone function 978 * @param data optional additional data that is passed to the clone function
979 * @retval zero when all elements were successfully cloned 979 * @retval zero when all elements were successfully cloned
980 * @retval non-zero when an allocation error occurred 980 * @retval non-zero when an allocation error occurred
981 * @see cxListUnion() 981 * @see cxListCloneSimple()
982 */ 982 */
983 cx_attr_nonnull_arg(1, 2, 3) 983 cx_attr_nonnull_arg(1, 2, 3)
984 CX_EXPORT int cxListClone(CxList *dst, const CxList *src, 984 CX_EXPORT int cxListClone(CxList *dst, const CxList *src,
985 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); 985 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
986 986
999 * @param clone_func the clone function for the elements 999 * @param clone_func the clone function for the elements
1000 * @param clone_allocator the allocator that is passed to the clone function 1000 * @param clone_allocator the allocator that is passed to the clone function
1001 * @param data optional additional data that is passed to the clone function 1001 * @param data optional additional data that is passed to the clone function
1002 * @retval zero when the elements were successfully cloned 1002 * @retval zero when the elements were successfully cloned
1003 * @retval non-zero when an allocation error occurred 1003 * @retval non-zero when an allocation error occurred
1004 * @see cxListDifferenceSimple()
1004 */ 1005 */
1005 cx_attr_nonnull_arg(1, 2, 3, 4) 1006 cx_attr_nonnull_arg(1, 2, 3, 4)
1006 CX_EXPORT int cxListDifference(CxList *dst, 1007 CX_EXPORT int cxListDifference(CxList *dst,
1007 const CxList *minuend, const CxList *subtrahend, 1008 const CxList *minuend, const CxList *subtrahend,
1008 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); 1009 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
1022 * @param clone_func the clone function for the elements 1023 * @param clone_func the clone function for the elements
1023 * @param clone_allocator the allocator that is passed to the clone function 1024 * @param clone_allocator the allocator that is passed to the clone function
1024 * @param data optional additional data that is passed to the clone function 1025 * @param data optional additional data that is passed to the clone function
1025 * @retval zero when the elements were successfully cloned 1026 * @retval zero when the elements were successfully cloned
1026 * @retval non-zero when an allocation error occurred 1027 * @retval non-zero when an allocation error occurred
1028 * @see cxListIntersectionSimple()
1027 */ 1029 */
1028 cx_attr_nonnull_arg(1, 2, 3, 4) 1030 cx_attr_nonnull_arg(1, 2, 3, 4)
1029 CX_EXPORT int cxListIntersection(CxList *dst, const CxList *src, const CxList *other, 1031 CX_EXPORT int cxListIntersection(CxList *dst, const CxList *src, const CxList *other,
1030 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); 1032 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
1031 1033
1046 * @param clone_func the clone function for the elements 1048 * @param clone_func the clone function for the elements
1047 * @param clone_allocator the allocator that is passed to the clone function 1049 * @param clone_allocator the allocator that is passed to the clone function
1048 * @param data optional additional data that is passed to the clone function 1050 * @param data optional additional data that is passed to the clone function
1049 * @retval zero when the elements were successfully cloned 1051 * @retval zero when the elements were successfully cloned
1050 * @retval non-zero when an allocation error occurred 1052 * @retval non-zero when an allocation error occurred
1051 * @see cxListClone() 1053 * @see cxListUnionSimple()
1052 */ 1054 */
1053 cx_attr_nonnull_arg(1, 2, 3, 4) 1055 cx_attr_nonnull_arg(1, 2, 3, 4)
1054 CX_EXPORT int cxListUnion(CxList *dst, const CxList *src, const CxList *other, 1056 CX_EXPORT int cxListUnion(CxList *dst, const CxList *src, const CxList *other,
1055 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); 1057 cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
1056 1058
1059 /**
1060 * Performs a shallow clone of one list into another.
1061 *
1062 * This function uses the default allocator, if needed, and performs
1063 * shallow clones with @c memcpy().
1064 *
1065 * If the destination list already contains elements, the cloned elements
1066 * are appended to that list.
1067 *
1068 * @attention If the cloned elements need to be destroyed by a destructor
1069 * function, you must make sure that the destination list also uses this
1070 * destructor function.
1071 *
1072 * @param dst the destination list
1073 * @param src the source list
1074 * @retval zero when all elements were successfully cloned
1075 * @retval non-zero when an allocation error occurred
1076 * @see cxListClone()
1077 */
1078 cx_attr_nonnull
1079 CX_EXPORT int cxListCloneSimple(CxList *dst, const CxList *src);
1080
1081 /**
1082 * Clones elements from a list only if they are not present in another list.
1083 *
1084 * This function uses the default allocator, if needed, and performs
1085 * shallow clones with @c memcpy().
1086 *
1087 * If the @p minuend does not contain duplicates, this is equivalent to adding
1088 * the set difference to the destination list.
1089 *
1090 * This function is optimized for the case when both the @p minuend and the
1091 * @p subtrahend are sorted.
1092 *
1093 * @param dst the destination list
1094 * @param minuend the list to subtract elements from
1095 * @param subtrahend the elements that shall be subtracted
1096 * @retval zero when the elements were successfully cloned
1097 * @retval non-zero when an allocation error occurred
1098 * @see cxListDifference()
1099 */
1100 cx_attr_nonnull
1101 CX_EXPORT int cxListDifferenceSimple(CxList *dst,
1102 const CxList *minuend, const CxList *subtrahend);
1103
1104 /**
1105 * Clones elements from a list only if they are also present in another list.
1106 *
1107 * This function uses the default allocator, if needed, and performs
1108 * shallow clones with @c memcpy().
1109 *
1110 * This function is optimized for the case when both the @p src and the
1111 * @p other list are sorted.
1112 *
1113 * If the destination list already contains elements, the intersection is appended
1114 * to that list.
1115 *
1116 * @param dst the destination list
1117 * @param src the list to clone the elements from
1118 * @param other the list to check the elements for existence
1119 * @retval zero when the elements were successfully cloned
1120 * @retval non-zero when an allocation error occurred
1121 * @see cxListIntersection()
1122 */
1123 cx_attr_nonnull
1124 CX_EXPORT int cxListIntersectionSimple(CxList *dst, const CxList *src, const CxList *other);
1125
1126 /**
1127 * Performs a deep clone of one list into another, skipping duplicates.
1128 *
1129 * This function uses the default allocator, if needed, and performs
1130 * shallow clones with @c memcpy().
1131 *
1132 * This function is optimized for the case when both the @p src and the
1133 * @p other list are sorted.
1134 * In that case, the union will also be sorted.
1135 *
1136 * If the destination list already contains elements, the union is appended
1137 * to that list. In that case the destination is not necessarily sorted.
1138 *
1139 * @param dst the destination list
1140 * @param src the primary source list
1141 * @param other the other list, where elements are only cloned from
1142 * when they are not in @p src
1143 * @retval zero when the elements were successfully cloned
1144 * @retval non-zero when an allocation error occurred
1145 * @see cxListUnion()
1146 */
1147 cx_attr_nonnull
1148 CX_EXPORT int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other);
1057 1149
1058 #ifdef __cplusplus 1150 #ifdef __cplusplus
1059 } // extern "C" 1151 } // extern "C"
1060 #endif 1152 #endif
1061 1153

mercurial