ucx
UAP Common Extensions
Loading...
Searching...
No Matches
cx_list_class_s Struct Reference

The class definition for arbitrary lists. More...

#include <list.h>

Data Fields

void(* deallocate )(struct cx_list_s *list)
 Destructor function.
 
void *(* insert_element )(struct cx_list_s *list, size_t index, const void *data)
 Member function for inserting a single element.
 
size_t(* insert_array )(struct cx_list_s *list, size_t index, const void *data, size_t n)
 Member function for inserting multiple elements.
 
size_t(* insert_sorted )(struct cx_list_s *list, const void *sorted_data, size_t n)
 Member function for inserting sorted elements into a sorted list.
 
size_t(* insert_unique )(struct cx_list_s *list, const void *sorted_data, size_t n)
 Member function for inserting multiple elements if they do not exist.
 
int(* insert_iter )(struct cx_iterator_s *iter, const void *elem, int prepend)
 Member function for inserting an element relative to an iterator position.
 
size_t(* remove )(struct cx_list_s *list, size_t index, size_t num, void *targetbuf)
 Member function for removing elements.
 
void(* clear )(struct cx_list_s *list)
 Member function for removing all elements.
 
int(* swap )(struct cx_list_s *list, size_t i, size_t j)
 Member function for swapping two elements.
 
void *(* at )(const struct cx_list_s *list, size_t index)
 Member function for element lookup.
 
size_t(* find_remove )(struct cx_list_s *list, const void *elem, bool remove)
 Member function for finding and optionally removing an element.
 
void(* sort )(struct cx_list_s *list)
 Member function for sorting the list.
 
int(* compare )(const struct cx_list_s *list, const struct cx_list_s *other)
 Optional member function for comparing this list to another list of the same type.
 
void(* reverse )(struct cx_list_s *list)
 Member function for reversing the order of the items.
 
int(* change_capacity )(struct cx_list_s *list, size_t new_capacity)
 Optional member function for changing the capacity.
 
struct cx_iterator_s(* iterator )(const struct cx_list_s *list, size_t index, bool backward)
 Member function for returning an iterator pointing to the specified index.
 

Detailed Description

The class definition for arbitrary lists.

Field Documentation

◆ change_capacity

int(* cx_list_class_s::change_capacity) (struct cx_list_s *list, size_t new_capacity)

Optional member function for changing the capacity.

If the list does not support overallocation, this can be set to NULL.

◆ compare

int(* cx_list_class_s::compare) (const struct cx_list_s *list, const struct cx_list_s *other)

Optional member function for comparing this list to another list of the same type.

If set to NULL, the comparison won't be optimized.

◆ deallocate

void(* cx_list_class_s::deallocate) (struct cx_list_s *list)

Destructor function.

Implementations SHALL invoke the content destructor functions if provided and SHALL deallocate the entire list memory.

◆ insert_array

size_t(* cx_list_class_s::insert_array) (struct cx_list_s *list, size_t index, const void *data, size_t n)

Member function for inserting multiple elements.

The data pointer may be NULL, in which case the function shall only allocate memory. Returns the number of successfully inserted or allocated elements.

See also
cx_list_default_insert_array()

◆ insert_element

void *(* cx_list_class_s::insert_element) (struct cx_list_s *list, size_t index, const void *data)

Member function for inserting a single element.

The data pointer may be NULL, in which case the function shall only allocate memory. Returns a pointer to the allocated memory or NULL if allocation fails.

◆ insert_sorted

size_t(* cx_list_class_s::insert_sorted) (struct cx_list_s *list, const void *sorted_data, size_t n)

Member function for inserting sorted elements into a sorted list.

Returns the number of successfully inserted elements.

See also
cx_list_default_insert_sorted()

◆ insert_unique

size_t(* cx_list_class_s::insert_unique) (struct cx_list_s *list, const void *sorted_data, size_t n)

Member function for inserting multiple elements if they do not exist.

Implementations shall return the number of successfully processed elements (including those which were not added because they are already contained).

See also
cx_list_default_insert_unique()

◆ remove

size_t(* cx_list_class_s::remove) (struct cx_list_s *list, size_t index, size_t num, void *targetbuf)

Member function for removing elements.

Implementations SHALL check if targetbuf is set and copy the elements to the buffer without invoking any destructor. When targetbuf is not set, the destructors SHALL be invoked.

The function SHALL return the actual number of elements removed, which might be lower than num when going out of bounds.

◆ sort

void(* cx_list_class_s::sort) (struct cx_list_s *list)

Member function for sorting the list.

See also
cx_list_default_sort()

◆ swap

int(* cx_list_class_s::swap) (struct cx_list_s *list, size_t i, size_t j)

Member function for swapping two elements.

See also
cx_list_default_swap()

The documentation for this struct was generated from the following file: