Doubly-linked list
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Groups
Pages
src
doubly-linked_list.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013 Andreas Misje
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
* DEALINGS IN THE SOFTWARE.
21
*/
22
51
#ifndef DOUBLYLINKED_LIST
52
#define DOUBLYLINKED_LIST
53
54
#include <stddef.h>
55
59
struct
dlList_node
60
{
62
void
*
data
;
64
struct
dlList_node
*
prev
;
66
struct
dlList_node
*
next
;
67
};
68
72
struct
dlList
73
{
75
size_t
size
;
77
struct
dlList_node
*
head
;
79
struct
dlList_node
*
tail
;
80
82
int ( *
compare
)(
const
void
*data1,
const
void
*data2 );
87
void ( *
destroy
)(
void
*
data
);
93
void
*( *copy )(
const
void
*
data
);
94
};
95
99
enum
dlList_returnValues
100
{
102
DLLIST_OK
= 0,
104
DLLIST_ERR_errArg
,
106
DLLIST_ERR_malloc
,
108
DLLIST_ERR_undefFunc
,
109
};
110
124
void
dlList_init
(
struct
dlList
*list,
125
void
( *destroyFunction )(
void
*
data
),
126
int
( *compareFunction )(
const
void
*data1,
const
void
*data2),
127
void
*( *dataDeepCopyFunction )(
const
void
*data ) );
128
137
void
dlList_destroy
(
struct
dlList
*list );
138
155
int
dlList_insertBefore
(
struct
dlList
*list,
struct
dlList_node
*beforeNode,
156
void
*data );
157
174
int
dlList_insertAfter
(
struct
dlList
*list,
struct
dlList_node
*afterNode,
175
void
*data );
176
193
int
dlList_insertOrdered
(
struct
dlList
*list,
void
*data );
194
206
int
dlList_append
(
struct
dlList
*list,
void
*data );
207
224
int
dlList_remove
(
struct
dlList
*list,
struct
dlList_node
*node,
225
void
**data );
226
241
struct
dlList_node
*
dlList_find
(
const
struct
dlList
*list,
const
void
*key );
242
254
struct
dlList
dlList_copy
( const struct
dlList
*list );
255
270
int
dlList_appendList
(
struct
dlList
*list1,
const
struct
dlList
*list2 );
271
279
void
dlList_sort
(
struct
dlList
*list );
280
284
size_t
dlList_size
(
const
struct
dlList
*list );
285
289
struct
dlList_node
*
dlList_first
(
const
struct
dlList
*list );
290
294
struct
dlList_node
*
dlList_last
(
const
struct
dlList
*list );
295
296
#endif //DOUBLYLINKED_LIST
297
Generated on Fri Jul 19 2013 19:32:09 for Doubly-linked list by
1.8.1.2