Data Structures Lerax 1.0.0
Essential Data Structures for C language
Loading...
Searching...
No Matches
list.h File Reference

Go to the source code of this file.

Data Structures

struct  ListNode

Typedefs

typedef struct ListNode 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_append (List *l, int data)
 Insert a new element 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.
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.
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.

Typedef Documentation

◆ List

typedef struct ListNode List

Public type List for Singly Linked Lists

Function Documentation

◆ list__is_perfect_number()

int list__is_perfect_number ( int n)

Check if a given number is perfect.

◆ list__new_node()

List * list__new_node ( int data)

Create a new node for the list.

◆ list_append()

List * list_append ( List * l,
int data )

Insert a new element on the end of the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_concat()

List * list_concat ( List * l_x,
List * l_y )

Return a concatenation of the two lists as a new list.

◆ list_copy()

List * list_copy ( List * l)

Create a copy of the list l.

◆ list_create()

List * list_create ( void )

create a new list instance

◆ list_empty()

int list_empty ( List * l)

Verify if the list is empty.

Returns
1 if empty and 0 if is not

◆ list_equal()

int list_equal ( List * l_x,
List * l_y )

Check if two lists are equal.

◆ list_free()

void list_free ( List * l)

Free memory of List and its nodes.

◆ list_head()

int list_head ( List * l)

Get the data from the first element.

◆ list_init()

List * list_init ( int size_list,
... )

Create a list based on its variadic arguments.

Parameters
size_listnumber of paramaters passed to the function

◆ list_insert()

List * list_insert ( List * l,
int data )

Insert a new element on the beginning of the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_insert_ord()

List * list_insert_ord ( List * l,
int data )

Ordered insert of a new element in the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_last()

int list_last ( List * l)

Get the data from last element.

◆ list_length()

int list_length ( List * l)

Return the length of the list.

◆ list_less_than()

int list_less_than ( List * l,
int n )

Return the number of numbers less n.

◆ list_perfect()

int list_perfect ( List * l)

Return the count of perfect numbers on list.

◆ list_pop_head()

int list_pop_head ( List ** l)

Get and pop the head of the list.

◆ list_pop_last()

int list_pop_last ( List ** l)

Get and pop the last element of the list.

◆ list_print()

void list_print ( List * l)

Print the list without a new line.

Parameters
lthe list to print

◆ list_print_reverse()

void list_print_reverse ( List * l)

Print the list reversed without a new line.

Parameters
lthe list to print

◆ list_println()

void list_println ( List * l)

Print the list with a new line.

Parameters
lthe list to print

◆ list_println_reverse()

void list_println_reverse ( List * l)

Print the list reversed with a new line.

Parameters
lthe list to print

◆ list_remove()

List * list_remove ( List * l,
int data )

Remove specific element from List.

Parameters
lList to insert data on
datainteger value to remove
Returns
new list without the node which contains data

◆ list_reverse()

void list_reverse ( List ** l)

Reverse a list (no creating a new) WARNING: side-effects.

◆ list_search()

List * list_search ( List * l,
int data )

Search on the list by data and return the node which contains it.

Parameters
lList to insert data on
datainteger value to search on
Returns
the node to return it

◆ list_sum()

int list_sum ( List * l)

Return the sum of numbers on the list.

◆ list_tail()

List * list_tail ( List * l)

Get the tail of the list.