Salad  1.0.15
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
list.h
Go to the documentation of this file.
1 /*
2  * Salad - An assortment of useful C stuff
3  * Copyright (C) 2016 Lloyd Dilley
4  * http://www.dilley.me/
5  *
6  * This file is part of Salad.
7  *
8  * Salad is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version
11  * 3 of the License, or (at your option) any later version.
12  *
13  * Salad is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Salad. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
24 #ifndef LIST_H
25 #define LIST_H
26 
27 #include "salad/types.h"
28 
36 typedef struct sld_node
37 {
38  void *object;
39  struct sld_node *next;
40  struct sld_node *previous;
41 } sld_node;
42 
44 typedef struct sld_list
45 {
47  struct sld_node *head;
48 } sld_list;
49 
61 SLD_SSINT sld_list_init(struct sld_list *list);
62 
74 SLD_UINT sld_list_size(struct sld_list *list);
75 
88 SLD_SSINT sld_list_add(struct sld_list *list, void *object);
89 
100 void sld_list_delete(struct sld_list *list, SLD_UINT index);
101 
113 void *sld_list_get(struct sld_list *list, SLD_UINT index);
114 
125 void *sld_list_pop(struct sld_list *list);
126 
136 void sld_list_free(struct sld_list *list);
137 
140 #endif /* LIST_H */
SLD_UINT sld_list_size(struct sld_list *list)
Returns the size of a sld_list.
Definition: list.c:55
Definition: list.h:36
struct sld_list sld_list
void * object
Definition: list.h:38
void * sld_list_get(struct sld_list *list, SLD_UINT index)
Returns an object from an sld_list at index.
Definition: list.c:148
SLD_SSINT sld_list_add(struct sld_list *list, void *object)
Adds an object to a sld_list.
Definition: list.c:60
void sld_list_delete(struct sld_list *list, SLD_UINT index)
Removes an object from a sld_list at the specified index.
Definition: list.c:105
struct sld_node * previous
Definition: list.h:40
struct sld_node sld_node
signed short int SLD_SSINT
Definition: types.h:47
Definition: list.h:44
SLD_UINT size
Definition: list.h:46
struct sld_node * next
Definition: list.h:39
void sld_list_free(struct sld_list *list)
Frees any memory allocated for an initialized sld_list.
Definition: list.c:183
unsigned int SLD_UINT
Definition: types.h:56
struct sld_node * head
Definition: list.h:47
SLD_SSINT sld_list_init(struct sld_list *list)
Initializes a sld_list.
Definition: list.c:32
void * sld_list_pop(struct sld_list *list)
Returns and removes the last object in a sld_list.
Definition: list.c:173