src/cx/list.h

Sun, 09 Apr 2023 19:03:58 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 09 Apr 2023 19:03:58 +0200
changeset 677
b09aae58bba4
parent 669
dce9b8450656
child 681
502105523db7
permissions
-rw-r--r--

refactoring of collections to make use of destructors in map implementations

universe@390 1 /*
universe@390 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@390 3 *
universe@390 4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
universe@390 5 *
universe@390 6 * Redistribution and use in source and binary forms, with or without
universe@390 7 * modification, are permitted provided that the following conditions are met:
universe@390 8 *
universe@390 9 * 1. Redistributions of source code must retain the above copyright
universe@390 10 * notice, this list of conditions and the following disclaimer.
universe@390 11 *
universe@390 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@390 13 * notice, this list of conditions and the following disclaimer in the
universe@390 14 * documentation and/or other materials provided with the distribution.
universe@390 15 *
universe@390 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@390 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@390 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@390 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@390 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@390 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@390 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@390 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@390 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@390 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@390 26 * POSSIBILITY OF SUCH DAMAGE.
universe@390 27 */
universe@453 28 /**
universe@453 29 * \file list.h
universe@453 30 * \brief Interface for list implementations.
universe@453 31 * \author Mike Becker
universe@453 32 * \author Olaf Wintermann
universe@453 33 * \version 3.0
universe@453 34 * \copyright 2-Clause BSD License
universe@453 35 */
universe@390 36
universe@390 37 #ifndef UCX_LIST_H
universe@390 38 #define UCX_LIST_H
universe@390 39
universe@677 40 #include "collection.h"
universe@398 41
universe@415 42 #ifdef __cplusplus
universe@415 43 extern "C" {
universe@415 44 #endif
universe@415 45
universe@464 46 /**
universe@500 47 * List class type.
universe@464 48 */
universe@500 49 typedef struct cx_list_class_s cx_list_class;
universe@435 50
universe@464 51 /**
universe@464 52 * Structure for holding the base data of a list.
universe@464 53 */
universe@435 54 struct cx_list_s {
universe@677 55 CX_COLLECTION_MEMBERS
universe@464 56 /**
universe@464 57 * The list class definition.
universe@464 58 */
universe@641 59 cx_list_class const *cl;
universe@641 60 /**
universe@641 61 * The actual implementation in case the list class is delegating.
universe@641 62 */
universe@641 63 cx_list_class const *climpl;
universe@435 64 };
universe@398 65
universe@464 66 /**
universe@500 67 * The class definition for arbitrary lists.
universe@500 68 */
universe@500 69 struct cx_list_class_s {
universe@500 70 /**
universe@524 71 * Destructor function.
universe@524 72 */
universe@524 73 void (*destructor)(struct cx_list_s *list);
universe@524 74
universe@524 75 /**
universe@641 76 * Member function for inserting a single elements.
universe@641 77 * Implementors SHOULD see to performant implementations for corner cases.
universe@641 78 */
universe@641 79 int (*insert_element)(
universe@641 80 struct cx_list_s *list,
universe@641 81 size_t index,
universe@641 82 void const *data
universe@641 83 );
universe@641 84
universe@641 85 /**
universe@638 86 * Member function for inserting multiple elements.
universe@640 87 * Implementors SHOULD see to performant implementations for corner cases.
universe@638 88 */
universe@638 89 size_t (*insert_array)(
universe@638 90 struct cx_list_s *list,
universe@638 91 size_t index,
universe@638 92 void const *data,
universe@638 93 size_t n
universe@638 94 );
universe@638 95
universe@638 96 /**
universe@500 97 * Member function for inserting an element relative to an iterator position.
universe@500 98 */
universe@500 99 int (*insert_iter)(
universe@630 100 struct cx_mut_iterator_s *iter,
universe@500 101 void const *elem,
universe@500 102 int prepend
universe@500 103 );
universe@500 104
universe@500 105 /**
universe@500 106 * Member function for removing an element.
universe@500 107 */
universe@500 108 int (*remove)(
universe@500 109 struct cx_list_s *list,
universe@500 110 size_t index
universe@500 111 );
universe@500 112
universe@500 113 /**
universe@664 114 * Member function for removing all elements.
universe@664 115 */
universe@664 116 void (*clear)(struct cx_list_s *list);
universe@664 117
universe@664 118 /**
universe@647 119 * Member function for swapping two elements.
universe@647 120 */
universe@647 121 int (*swap)(
universe@647 122 struct cx_list_s *list,
universe@647 123 size_t i,
universe@647 124 size_t j
universe@647 125 );
universe@647 126
universe@647 127 /**
universe@500 128 * Member function for element lookup.
universe@500 129 */
universe@500 130 void *(*at)(
universe@500 131 struct cx_list_s const *list,
universe@500 132 size_t index
universe@500 133 );
universe@500 134
universe@500 135 /**
universe@500 136 * Member function for finding an element.
universe@500 137 */
universe@500 138 size_t (*find)(
universe@500 139 struct cx_list_s const *list,
universe@500 140 void const *elem
universe@500 141 );
universe@500 142
universe@500 143 /**
universe@500 144 * Member function for sorting the list in place.
universe@500 145 */
universe@500 146 void (*sort)(struct cx_list_s *list);
universe@500 147
universe@500 148 /**
universe@500 149 * Member function for comparing this list to another list of the same type.
universe@500 150 */
universe@500 151 int (*compare)(
universe@500 152 struct cx_list_s const *list,
universe@500 153 struct cx_list_s const *other
universe@500 154 );
universe@500 155
universe@500 156 /**
universe@500 157 * Member function for reversing the order of the items.
universe@500 158 */
universe@500 159 void (*reverse)(struct cx_list_s *list);
universe@500 160
universe@500 161 /**
universe@640 162 * Member function for returning an iterator pointing to the specified index.
universe@500 163 */
universe@500 164 struct cx_iterator_s (*iterator)(
universe@630 165 struct cx_list_s const *list,
universe@655 166 size_t index,
universe@655 167 bool backward
universe@630 168 );
universe@500 169 };
universe@500 170
universe@500 171 /**
universe@464 172 * Common type for all list implementations.
universe@464 173 */
universe@500 174 typedef struct cx_list_s CxList;
universe@398 175
universe@464 176 /**
universe@641 177 * Advises the list to store copies of the objects (default mode of operation).
universe@641 178 *
universe@641 179 * Retrieving objects from this list will yield pointers to the copies stored
universe@641 180 * within this list.
universe@641 181 *
universe@641 182 * @param list the list
universe@641 183 * @see cxListStorePointers()
universe@641 184 */
universe@641 185 __attribute__((__nonnull__))
universe@641 186 void cxListStoreObjects(CxList *list);
universe@641 187
universe@641 188 /**
universe@641 189 * Advises the list to only store pointers to the objects.
universe@641 190 *
universe@641 191 * Retrieving objects from this list will yield the original pointers stored.
universe@641 192 *
universe@641 193 * @note This function forcibly sets the element size to the size of a pointer.
universe@641 194 * Invoking this function on a non-empty list that already stores copies of
universe@641 195 * objects is undefined.
universe@641 196 *
universe@641 197 * @param list the list
universe@641 198 * @see cxListStoreObjects()
universe@641 199 */
universe@641 200 __attribute__((__nonnull__))
universe@641 201 void cxListStorePointers(CxList *list);
universe@641 202
universe@641 203 /**
universe@641 204 * Returns true, if this list is storing pointers instead of the actual data.
universe@641 205 *
universe@641 206 * @param list
universe@677 207 * @return true, if this list is storing pointers
universe@641 208 * @see cxListStorePointers()
universe@641 209 */
universe@641 210 __attribute__((__nonnull__))
universe@677 211 static inline bool cxListIsStoringPointers(CxList const *list) {
universe@677 212 return list->store_pointer;
universe@677 213 }
universe@677 214
universe@677 215 /**
universe@677 216 * Returns the number of elements currently stored in the list.
universe@677 217 *
universe@677 218 * @param list the list
universe@677 219 * @return the number of currently stored elements
universe@677 220 */
universe@677 221 __attribute__((__nonnull__))
universe@677 222 static inline size_t cxListSize(CxList const *list) {
universe@677 223 return list->size;
universe@677 224 }
universe@641 225
universe@641 226 /**
universe@464 227 * Adds an item to the end of the list.
universe@464 228 *
universe@464 229 * @param list the list
universe@464 230 * @param elem a pointer to the element to add
universe@464 231 * @return zero on success, non-zero on memory allocation failure
universe@629 232 * @see cxListAddArray()
universe@464 233 */
universe@508 234 __attribute__((__nonnull__))
universe@489 235 static inline int cxListAdd(
universe@500 236 CxList *list,
universe@489 237 void const *elem
universe@489 238 ) {
universe@641 239 return list->cl->insert_element(list, list->size, elem);
universe@469 240 }
universe@398 241
universe@464 242 /**
universe@629 243 * Adds multiple items to the end of the list.
universe@629 244 *
universe@629 245 * This method is more efficient than invoking cxListAdd() multiple times.
universe@629 246 *
universe@629 247 * If there is not enough memory to add all elements, the returned value is
universe@629 248 * less than \p n.
universe@629 249 *
universe@641 250 * If this list is storing pointers instead of objects \p array is expected to
universe@641 251 * be an array of pointers.
universe@641 252 *
universe@629 253 * @param list the list
universe@629 254 * @param array a pointer to the elements to add
universe@629 255 * @param n the number of elements to add
universe@629 256 * @return the number of added elements
universe@629 257 */
universe@629 258 __attribute__((__nonnull__))
universe@629 259 static inline size_t cxListAddArray(
universe@629 260 CxList *list,
universe@629 261 void const *array,
universe@629 262 size_t n
universe@629 263 ) {
universe@640 264 return list->cl->insert_array(list, list->size, array, n);
universe@629 265 }
universe@629 266
universe@629 267 /**
universe@464 268 * Inserts an item at the specified index.
universe@464 269 *
universe@464 270 * If \p index equals the list \c size, this is effectively cxListAdd().
universe@464 271 *
universe@464 272 * @param list the list
universe@464 273 * @param index the index the element shall have
universe@464 274 * @param elem a pointer to the element to add
universe@464 275 * @return zero on success, non-zero on memory allocation failure
universe@464 276 * or when the index is out of bounds
universe@499 277 * @see cxListInsertAfter()
universe@499 278 * @see cxListInsertBefore()
universe@464 279 */
universe@508 280 __attribute__((__nonnull__))
universe@489 281 static inline int cxListInsert(
universe@500 282 CxList *list,
universe@489 283 size_t index,
universe@489 284 void const *elem
universe@489 285 ) {
universe@641 286 return list->cl->insert_element(list, index, elem);
universe@469 287 }
universe@398 288
universe@464 289 /**
universe@638 290 * Inserts multiple items to the list at the specified index.
universe@638 291 * If \p index equals the list size, this is effectively cxListAddArray().
universe@638 292 *
universe@638 293 * This method is usually more efficient than invoking cxListInsert()
universe@638 294 * multiple times.
universe@638 295 *
universe@638 296 * If there is not enough memory to add all elements, the returned value is
universe@638 297 * less than \p n.
universe@638 298 *
universe@641 299 * If this list is storing pointers instead of objects \p array is expected to
universe@641 300 * be an array of pointers.
universe@641 301 *
universe@638 302 * @param list the list
universe@638 303 * @param index the index where to add the elements
universe@638 304 * @param array a pointer to the elements to add
universe@638 305 * @param n the number of elements to add
universe@638 306 * @return the number of added elements
universe@638 307 */
universe@638 308 __attribute__((__nonnull__))
universe@638 309 static inline size_t cxListInsertArray(
universe@638 310 CxList *list,
universe@638 311 size_t index,
universe@638 312 void const *array,
universe@638 313 size_t n
universe@638 314 ) {
universe@638 315 return list->cl->insert_array(list, index, array, n);
universe@638 316 }
universe@638 317
universe@638 318 /**
universe@499 319 * Inserts an element after the current location of the specified iterator.
universe@499 320 *
universe@499 321 * The used iterator remains operational, but all other active iterators should
universe@499 322 * be considered invalidated.
universe@499 323 *
universe@499 324 * If \p iter is not a list iterator, the behavior is undefined.
universe@499 325 * If \p iter is a past-the-end iterator, the new element gets appended to the list.
universe@499 326 *
universe@499 327 * @param iter an iterator
universe@499 328 * @param elem the element to insert
universe@499 329 * @return zero on success, non-zero on memory allocation failure
universe@499 330 * @see cxListInsert()
universe@499 331 * @see cxListInsertBefore()
universe@499 332 */
universe@508 333 __attribute__((__nonnull__))
universe@499 334 static inline int cxListInsertAfter(
universe@630 335 CxMutIterator *iter,
universe@499 336 void const *elem
universe@499 337 ) {
universe@500 338 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0);
universe@499 339 }
universe@499 340
universe@499 341 /**
universe@499 342 * Inserts an element before the current location of the specified iterator.
universe@499 343 *
universe@499 344 * The used iterator remains operational, but all other active iterators should
universe@499 345 * be considered invalidated.
universe@499 346 *
universe@499 347 * If \p iter is not a list iterator, the behavior is undefined.
universe@499 348 * If \p iter is a past-the-end iterator, the new element gets appended to the list.
universe@499 349 *
universe@499 350 * @param iter an iterator
universe@499 351 * @param elem the element to insert
universe@499 352 * @return zero on success, non-zero on memory allocation failure
universe@499 353 * @see cxListInsert()
universe@499 354 * @see cxListInsertAfter()
universe@499 355 */
universe@508 356 __attribute__((__nonnull__))
universe@499 357 static inline int cxListInsertBefore(
universe@630 358 CxMutIterator *iter,
universe@499 359 void const *elem
universe@499 360 ) {
universe@500 361 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1);
universe@499 362 }
universe@499 363
universe@499 364 /**
universe@464 365 * Removes the element at the specified index.
universe@664 366 *
universe@664 367 * If an element destructor function is specified, it is called before
universe@664 368 * removing the element.
universe@664 369 *
universe@464 370 * @param list the list
universe@464 371 * @param index the index of the element
universe@464 372 * @return zero on success, non-zero if the index is out of bounds
universe@464 373 */
universe@508 374 __attribute__((__nonnull__))
universe@489 375 static inline int cxListRemove(
universe@500 376 CxList *list,
universe@489 377 size_t index
universe@489 378 ) {
universe@469 379 return list->cl->remove(list, index);
universe@469 380 }
universe@398 381
universe@464 382 /**
universe@664 383 * Removes all elements from this list.
universe@664 384 *
universe@664 385 * If an element destructor function is specified, it is called for each
universe@664 386 * element before removing them.
universe@664 387 *
universe@664 388 * @param list the list
universe@664 389 */
universe@664 390 __attribute__((__nonnull__))
universe@664 391 static inline void cxListClear(CxList *list) {
universe@664 392 list->cl->clear(list);
universe@664 393 }
universe@664 394
universe@664 395 /**
universe@647 396 * Swaps two items in the list.
universe@647 397 *
universe@647 398 * Implementations should only allocate temporary memory for the swap, if
universe@647 399 * it is necessary.
universe@647 400 *
universe@647 401 * @param list the list
universe@647 402 * @param i the index of the first element
universe@647 403 * @param j the index of the second element
universe@647 404 * @return zero on success, non-zero if one of the indices is out of bounds
universe@647 405 */
universe@647 406 __attribute__((__nonnull__))
universe@647 407 static inline int cxListSwap(
universe@647 408 CxList *list,
universe@647 409 size_t i,
universe@647 410 size_t j
universe@647 411 ) {
universe@647 412 return list->cl->swap(list, i, j);
universe@647 413 }
universe@647 414
universe@647 415 /**
universe@464 416 * Returns a pointer to the element at the specified index.
universe@464 417 *
universe@464 418 * @param list the list
universe@464 419 * @param index the index of the element
universe@464 420 * @return a pointer to the element or \c NULL if the index is out of bounds
universe@464 421 */
universe@508 422 __attribute__((__nonnull__))
universe@489 423 static inline void *cxListAt(
universe@500 424 CxList *list,
universe@489 425 size_t index
universe@489 426 ) {
universe@469 427 return list->cl->at(list, index);
universe@469 428 }
universe@439 429
universe@464 430 /**
universe@494 431 * Returns an iterator pointing to the item at the specified index.
universe@494 432 *
universe@494 433 * The returned iterator is position-aware.
universe@494 434 *
universe@494 435 * If the index is out of range, a past-the-end iterator will be returned.
universe@494 436 *
universe@494 437 * @param list the list
universe@494 438 * @param index the index where the iterator shall point at
universe@494 439 * @return a new iterator
universe@494 440 */
universe@508 441 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 442 static inline CxIterator cxListIteratorAt(
universe@630 443 CxList const *list,
universe@630 444 size_t index
universe@630 445 ) {
universe@655 446 return list->cl->iterator(list, index, false);
universe@655 447 }
universe@655 448
universe@655 449 /**
universe@655 450 * Returns a backwards iterator pointing to the item at the specified index.
universe@655 451 *
universe@655 452 * The returned iterator is position-aware.
universe@655 453 *
universe@655 454 * If the index is out of range, a past-the-end iterator will be returned.
universe@655 455 *
universe@655 456 * @param list the list
universe@655 457 * @param index the index where the iterator shall point at
universe@655 458 * @return a new iterator
universe@655 459 */
universe@655 460 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 461 static inline CxIterator cxListBackwardsIteratorAt(
universe@655 462 CxList const *list,
universe@655 463 size_t index
universe@655 464 ) {
universe@655 465 return list->cl->iterator(list, index, true);
universe@630 466 }
universe@630 467
universe@630 468 /**
universe@630 469 * Returns a mutating iterator pointing to the item at the specified index.
universe@630 470 *
universe@630 471 * The returned iterator is position-aware.
universe@630 472 *
universe@630 473 * If the index is out of range, a past-the-end iterator will be returned.
universe@630 474 *
universe@630 475 * @param list the list
universe@630 476 * @param index the index where the iterator shall point at
universe@630 477 * @return a new iterator
universe@630 478 */
universe@630 479 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 480 CxMutIterator cxListMutIteratorAt(
universe@655 481 CxList *list,
universe@655 482 size_t index
universe@655 483 );
universe@655 484
universe@655 485 /**
universe@655 486 * Returns a mutating backwards iterator pointing to the item at the
universe@655 487 * specified index.
universe@655 488 *
universe@655 489 * The returned iterator is position-aware.
universe@655 490 *
universe@655 491 * If the index is out of range, a past-the-end iterator will be returned.
universe@655 492 *
universe@655 493 * @param list the list
universe@655 494 * @param index the index where the iterator shall point at
universe@655 495 * @return a new iterator
universe@655 496 */
universe@655 497 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 498 CxMutIterator cxListMutBackwardsIteratorAt(
universe@500 499 CxList *list,
universe@494 500 size_t index
universe@640 501 );
universe@494 502
universe@494 503 /**
universe@494 504 * Returns an iterator pointing to the first item of the list.
universe@494 505 *
universe@494 506 * The returned iterator is position-aware.
universe@494 507 *
universe@494 508 * If the list is empty, a past-the-end iterator will be returned.
universe@494 509 *
universe@494 510 * @param list the list
universe@494 511 * @return a new iterator
universe@494 512 */
universe@508 513 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 514 static inline CxIterator cxListIterator(CxList const *list) {
universe@655 515 return list->cl->iterator(list, 0, false);
universe@494 516 }
universe@494 517
universe@494 518 /**
universe@630 519 * Returns a mutating iterator pointing to the first item of the list.
universe@630 520 *
universe@630 521 * The returned iterator is position-aware.
universe@630 522 *
universe@630 523 * If the list is empty, a past-the-end iterator will be returned.
universe@630 524 *
universe@630 525 * @param list the list
universe@630 526 * @return a new iterator
universe@630 527 */
universe@630 528 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 529 static inline CxMutIterator cxListMutIterator(CxList *list) {
universe@655 530 return cxListMutIteratorAt(list, 0);
universe@655 531 }
universe@655 532
universe@655 533
universe@655 534 /**
universe@655 535 * Returns a backwards iterator pointing to the last item of the list.
universe@655 536 *
universe@655 537 * The returned iterator is position-aware.
universe@655 538 *
universe@655 539 * If the list is empty, a past-the-end iterator will be returned.
universe@655 540 *
universe@655 541 * @param list the list
universe@655 542 * @return a new iterator
universe@655 543 */
universe@655 544 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 545 static inline CxIterator cxListBackwardsIterator(CxList const *list) {
universe@655 546 return list->cl->iterator(list, list->size - 1, true);
universe@655 547 }
universe@655 548
universe@655 549 /**
universe@655 550 * Returns a mutating backwards iterator pointing to the last item of the list.
universe@655 551 *
universe@655 552 * The returned iterator is position-aware.
universe@655 553 *
universe@655 554 * If the list is empty, a past-the-end iterator will be returned.
universe@655 555 *
universe@655 556 * @param list the list
universe@655 557 * @return a new iterator
universe@655 558 */
universe@655 559 __attribute__((__nonnull__, __warn_unused_result__))
universe@655 560 static inline CxMutIterator cxListMutBackwardsIterator(CxList *list) {
universe@655 561 return cxListMutBackwardsIteratorAt(list, list->size - 1);
universe@630 562 }
universe@630 563
universe@630 564 /**
universe@464 565 * Returns the index of the first element that equals \p elem.
universe@464 566 *
universe@464 567 * Determining equality is performed by the list's comparator function.
universe@464 568 *
universe@464 569 * @param list the list
universe@464 570 * @param elem the element to find
universe@464 571 * @return the index of the element or \c (size+1) if the element is not found
universe@464 572 */
universe@508 573 __attribute__((__nonnull__))
universe@489 574 static inline size_t cxListFind(
universe@621 575 CxList const *list,
universe@489 576 void const *elem
universe@489 577 ) {
universe@469 578 return list->cl->find(list, elem);
universe@469 579 }
universe@398 580
universe@464 581 /**
universe@469 582 * Sorts the list in place.
universe@469 583 *
universe@469 584 * \remark The underlying sort algorithm is implementation defined.
universe@469 585 *
universe@469 586 * @param list the list
universe@469 587 */
universe@508 588 __attribute__((__nonnull__))
universe@500 589 static inline void cxListSort(CxList *list) {
universe@469 590 list->cl->sort(list);
universe@469 591 }
universe@404 592
universe@488 593 /**
universe@490 594 * Reverses the order of the items.
universe@490 595 *
universe@490 596 * @param list the list
universe@490 597 */
universe@508 598 __attribute__((__nonnull__))
universe@500 599 static inline void cxListReverse(CxList *list) {
universe@490 600 list->cl->reverse(list);
universe@490 601 }
universe@490 602
universe@490 603 /**
universe@488 604 * Compares a list to another list of the same type.
universe@488 605 *
universe@618 606 * First, the list sizes are compared.
universe@618 607 * If they match, the lists are compared element-wise.
universe@488 608 *
universe@488 609 * @param list the list
universe@488 610 * @param other the list to compare to
universe@618 611 * @return zero, if both lists are equal element wise,
universe@618 612 * negative if the first list is smaller, positive if the first list is larger
universe@488 613 */
universe@508 614 __attribute__((__nonnull__))
universe@618 615 int cxListCompare(
universe@618 616 CxList const *list,
universe@618 617 CxList const *other
universe@618 618 );
universe@488 619
universe@503 620 /**
universe@528 621 * Deallocates the memory of the specified list structure.
universe@528 622 *
universe@528 623 * Also calls content a destructor function, depending on the configuration
universe@528 624 * in CxList.content_destructor_type.
universe@503 625 *
universe@503 626 * This function itself is a destructor function for the CxList.
universe@503 627 *
universe@528 628 * @param list the list which shall be destroyed
universe@503 629 */
universe@503 630 __attribute__((__nonnull__))
universe@528 631 void cxListDestroy(CxList *list);
universe@503 632
universe@415 633 #ifdef __cplusplus
universe@628 634 } // extern "C"
universe@415 635 #endif
universe@415 636
universe@628 637 #endif // UCX_LIST_H

mercurial