Data Structures UFC  1.0.0
Essential Data Structures for C language
Data Structures | Typedefs | Functions
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 More...
 
Listlist_insert (List *l, int data)
 Insert a new element on the beginning of the list. More...
 
Listlist_append (List *l, int data)
 Insert a new element on the end of the list. More...
 
Listlist_insert_ord (List *l, int data)
 Ordered insert of a new element in the list. More...
 
Listlist_search (List *l, int data)
 Search on the list by data and return the node which contains it. More...
 
void list_print (List *l)
 Print the list without a new line. More...
 
void list_println (List *l)
 Print the list with a new line. More...
 
void list_print_reverse (List *l)
 Print the list reversed without a new line. More...
 
void list_println_reverse (List *l)
 Print the list reversed with a new line. More...
 
Listlist_remove (List *l, int data)
 Remove specific element from List. More...
 
void list_free (List *l)
 Free memory of List and its nodes. More...
 
int list_empty (List *l)
 Verify if the list is empty. More...
 
int list_equal (List *l_x, List *l_y)
 Check if two lists are equal. More...
 
int list_perfect (List *l)
 Return the count of perfect numbers on list. More...
 
int list_length (List *l)
 Return the length of the list. More...
 
int list_less_than (List *l, int n)
 Return the number of numbers less n. More...
 
int list_sum (List *l)
 Return the sum of numbers on the list. More...
 
Listlist_copy (List *l)
 Create a copy of the list l. More...
 
Listlist_concat (List *l_x, List *l_y)
 Return a concatenation of the two lists as a new list. More...
 
Listlist_init (int size_list,...)
 Create a list based on its variadic arguments. More...
 
int list_last (List *l)
 Get the data from last element. More...
 
int list_head (List *l)
 Get the data from the first element. More...
 
Listlist_tail (List *l)
 Get the tail of the list. More...
 
int list_pop_head (List **l)
 Get and pop the head of the list. More...
 
int list_pop_last (List **l)
 Get and pop the last element of the list. More...
 
void list_reverse (List **l)
 Reverse a list (no creating a new) WARNING: side-effects. More...
 
int list__is_perfect_number (int n)
 Check if a given number is perfect. More...
 
Listlist__new_node (int data)
 Create a new node for the list. More...
 

Typedef Documentation

typedef struct ListNode List

Public type List for Singly Linked Lists

Function Documentation

int list__is_perfect_number ( int  n)

Check if a given number is perfect.

List* list__new_node ( int  data)

Create a new node for the list.

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* list_concat ( List l_x,
List l_y 
)

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

List* list_copy ( List l)

Create a copy of the list l.

List* list_create ( void  )

create a new list instance

int list_empty ( List l)

Verify if the list is empty.

Returns
1 if empty and 0 if is not
int list_equal ( List l_x,
List l_y 
)

Check if two lists are equal.

void list_free ( List l)

Free memory of List and its nodes.

int list_head ( List l)

Get the data from the first element.

List* list_init ( int  size_list,
  ... 
)

Create a list based on its variadic arguments.

Parameters
size_listnumber of paramaters passed to the function
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* 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
int list_last ( List l)

Get the data from last element.

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_perfect ( List l)

Return the count of perfect numbers on 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_print ( List l)

Print the list without a new line.

Parameters
lthe list to print
void list_print_reverse ( List l)

Print the list reversed without a new line.

Parameters
lthe list to print
void list_println ( List l)

Print the list with a new line.

Parameters
lthe list to print
void list_println_reverse ( List l)

Print the list reversed with a new line.

Parameters
lthe list to print
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
void list_reverse ( List **  l)

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

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
int list_sum ( List l)

Return the sum of numbers on the list.

List* list_tail ( List l)

Get the tail of the list.