PULSAR  2.0.0
Parallel Ultra-Light Systolic Array Runtime
 All Data Structures Files Functions Typedefs Enumerations Macros Groups
icl_list.c File Reference

Dependency-free linked list. More...

#include <stdio.h>
#include <stdlib.h>
#include "icl_list.h"

Go to the source code of this file.

Functions

icl_list_ticl_list_new ()
 Creates a new linked list. More...
 
icl_list_ticl_list_insert (icl_list_t *head, icl_list_t *pos, void *data)
 Inserts a new node after the specified node. More...
 
int icl_list_delete (icl_list_t *head, icl_list_t *pos, void(*free_function)(void *))
 Deletes the specified node. More...
 
icl_list_ticl_list_search (icl_list_t *head, void *data, int(*compare)(void *, void *))
 Finds a data item in a linked list. More...
 
icl_list_ticl_list_isort (icl_list_t *head, void *data, int(*compare)(void *, void *))
 Inserts data into a sorted list. Does not support direct comparison of pointers. More...
 
int icl_list_destroy (icl_list_t *head, void(*free_function)(void *))
 Destroys a linked list. More...
 
int icl_list_size (icl_list_t *head)
 Returns the number of items in a linked list. More...
 
icl_list_ticl_list_first (icl_list_t *head)
 Returns the first item in a linked list. More...
 
icl_list_ticl_list_last (icl_list_t *head)
 Returns the last item in a linked list. More...
 
icl_list_ticl_list_next (icl_list_t *head, icl_list_t *pos)
 Returns the node following the specified node. More...
 
icl_list_ticl_list_prev (icl_list_t *head, icl_list_t *pos)
 Returns the node preceding the specified node. More...
 
icl_list_ticl_list_concat (icl_list_t *head1, icl_list_t *head2)
 Concatenates two linked lists. More...
 
icl_list_ticl_list_prepend (icl_list_t *head, void *data)
 Inserts a node at the beginning of a list. More...
 
icl_list_ticl_list_append (icl_list_t *head, void *data)
 Inserts a node at the end of a list. More...
 

Detailed Description

Dependency-free linked list.

Author
Keith Seymour

PULSAR Runtime http://icl.utk.edu/pulsar/ Copyright (C) 2012-2015 University of Tennessee.

Definition in file icl_list.c.

Function Documentation

icl_list_t* icl_list_append ( icl_list_t head,
void *  data 
)

Inserts a node at the end of a list.

Parameters
head– The linked list.
data– The data to be inserted.
Returns
A pointer to the new node. NULL on error.

Definition at line 326 of file icl_list.c.

icl_list_t* icl_list_concat ( icl_list_t head1,
icl_list_t head2 
)

Concatenates two linked lists.

Parameters
head1– The first linked list.
head2– The second linked list.
Returns
A pointer to the new linked list, which consists of <head1,head2>. NULL on error.

Definition at line 290 of file icl_list.c.

int icl_list_delete ( icl_list_t head,
icl_list_t pos,
void(*)(void *)  free_function 
)

Deletes the specified node.

Parameters
head– The linked list containing the node to be deleted.
pos– The node to be deleted.
free_function– The function that frees the node's data.
Return values
0on success.
-1on failure.

Definition at line 82 of file icl_list.c.

int icl_list_destroy ( icl_list_t head,
void(*)(void *)  free_function 
)

Destroys a linked list.

Parameters
head– The linked list to be destroyed.
free_function– The function that frees the node's data.
Return values
0on success.
-1on failure.

Definition at line 173 of file icl_list.c.

icl_list_t* icl_list_first ( icl_list_t head)

Returns the first item in a linked list.

Parameters
head– The linked list.
Returns
A pointer to the first item. NULL on error.

Definition at line 221 of file icl_list.c.

icl_list_t* icl_list_insert ( icl_list_t head,
icl_list_t pos,
void *  data 
)

Inserts a new node after the specified node.

Parameters
head– The linked list.
pos– The insertion position (the node to append to).
data– The pointer to the data to be inserted.
Returns
A pointer to the new node. NULL on error.

Definition at line 47 of file icl_list.c.

icl_list_t* icl_list_isort ( icl_list_t head,
void *  data,
int(*)(void *, void *)  compare 
)

Inserts data into a sorted list. Does not support direct comparison of pointers.

Parameters
head– The linked list.
data– The data to be inserted.
compare– The function that compares the data items.
Returns
A pointer to the new node. NULL on error.

Definition at line 144 of file icl_list.c.

icl_list_t* icl_list_last ( icl_list_t head)

Returns the last item in a linked list.

Parameters
head– The linked list.
Returns
A pointer to the last item. NULL on error.

Definition at line 237 of file icl_list.c.

icl_list_t* icl_list_new ( )

Creates a new linked list.

Returns
A new linked list. NULL on error.

Definition at line 22 of file icl_list.c.

icl_list_t* icl_list_next ( icl_list_t head,
icl_list_t pos 
)

Returns the node following the specified node.

Parameters
head– The list containing the specified node.
pos– The node whose successor should be returned.
Returns
A pointer to the next node. NULL on error.

Definition at line 254 of file icl_list.c.

icl_list_t* icl_list_prepend ( icl_list_t head,
void *  data 
)

Inserts a node at the beginning of a list.

Parameters
head– The linked list.
data– The data to be inserted.
Returns
A pointer to the new node. NULL on error.

Definition at line 312 of file icl_list.c.

icl_list_t* icl_list_prev ( icl_list_t head,
icl_list_t pos 
)

Returns the node preceding the specified node.

Parameters
head– The list containing the specified node.
pos– The node whose predecessor should be returned.
Returns
A pointer to the previous node. NULL on error.

Definition at line 271 of file icl_list.c.

icl_list_t* icl_list_search ( icl_list_t head,
void *  data,
int(*)(void *, void *)  compare 
)

Finds a data item in a linked list.

Parameters
head– The linked list.
data– The data to be found.
compare– The function that compares the data items.
Returns
A pointer to the node, if found. Otherwise NULL.

Definition at line 114 of file icl_list.c.

int icl_list_size ( icl_list_t head)

Returns the number of items in a linked list.

Parameters
head– The linked list.
Returns
The number of items in the list. -1 on error.

Definition at line 200 of file icl_list.c.