Data Structures Lerax  v3.0-101-gb1f7
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
list.h File Reference

Go to the source code of this file.

Data Structures

struct  ListNode
 A node in a singly linked list. More...

Macros

#define EMPTY_LIST   (List*) 0

Typedefs

typedef struct ListNode List
 A singly linked list.

Functions

Listlist_create (void)
 create a new list instance
Listlist_insert (List *l, int data)
 Insert a new element on the beginning of the list.
Listlist_insert_with_key (List *l, int key, int data)
 Insert a new element on the beginning of the list.
Listlist_append (List *l, int data)
 Insert a new element on the end of the list.
Listlist_append_with_key (List *l, int key, int data)
 Insert a new element on the end of the list with key.
Listlist_append_node (List *l, struct ListNode *node)
 Insert a new node on the end of the list.
Listlist_insert_ord (List *l, int data)
 Ordered insert of a new element in the list.
Listlist_search (List *l, int data)
 Search on the list by data and return the node which contains it.
Listlist_search_by_key (List *l, int key)
 Search on the list by key and return the node which contains it.
void list_print (List *l)
 Print the list without a new line.
void list_println (List *l)
 Print the list with a new line.
void list_print_reverse (List *l)
 Print the list reversed without a new line.
void list_println_reverse (List *l)
 Print the list reversed with a new line.
Listlist_remove (List *l, int data)
 Remove specific element from List.
Listlist_remove_by_key (List *l, int key)
 Remove specific element from List by a key.
void list_free (List *l)
 Free memory of List and its nodes.
int list_empty (List *l)
 Verify if the list is empty.
int list_equal (List *l_x, List *l_y)
 Check if two lists are equal.
int list_perfect (List *l)
 Return the count of perfect numbers on list.
int list_length (List *l)
 Return the length of the list.
int list_less_than (List *l, int n)
 Return the number of numbers less n.
int list_sum (List *l)
 Return the sum of numbers on the list.
Listlist_copy (List *l)
 Create a copy of the list l.
Listlist_concat (List *l_x, List *l_y)
 Return a concatenation of the two lists as a new list.
Listlist_init (int size_list,...)
 Create a list based on its variadic arguments.
int list_last (List *l)
 Get the data from last element.
int list_head (List *l)
 Get the data from the first element.
Listlist_tail (List *l)
 Get the tail of the list.
int list_pop_head (List **l)
 Get and pop the head of the list.
int list_pop_last (List **l)
 Get and pop the last element of the list.
void list_reverse (List **l)
 Reverse a list (no creating a new) WARNING: side-effects.
int list__is_perfect_number (int n)
 Check if a given number is perfect.
Listlist__new_node (int data)
 Create a new node for the list.
Iteratorlist_iterator_keys (List *l)
 Creates an iterator for the list keys.
Iteratorlist_iterator_data (List *l)
 Creates an iterator for the list data.
Listlist_from_iterator (Iterator *it)
 Creates a list from an iterator.

Macro Definition Documentation

◆ EMPTY_LIST

#define EMPTY_LIST   (List*) 0

Typedef Documentation

◆ List

typedef struct ListNode List

A singly linked list.

A List is a pointer to the first node in the list. An empty list is represented by a null pointer.

Function Documentation

◆ list_from_iterator()

List * list_from_iterator ( Iterator * it)

Creates a list from an iterator.

Parameters
itThe iterator to create the list from.
Returns
A pointer to the new list.

◆ list_iterator_data()

Iterator * list_iterator_data ( List * l)

Creates an iterator for the list data.

Parameters
lThe list to iterate over.
Returns
A pointer to the new iterator.

◆ list_iterator_keys()

Iterator * list_iterator_keys ( List * l)

Creates an iterator for the list keys.

Parameters
lThe list to iterate over.
Returns
A pointer to the new iterator.