annotate LinkedList.h @ 14:1c27a52c5b15

Added copyright.
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 06 Nov 2010 00:44:35 -0700
parents 54aa96ae8912
children d58eb38c771b
rev   line source
14
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
1 /*
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
2 LinkedList
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
3 Copyright (C) 2010 Eric Wing <ewing . public @ playcontrol.net>
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
4
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
5 This library is free software; you can redistribute it and/or
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
6 modify it under the terms of the GNU Library General Public
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
7 License as published by the Free Software Foundation; either
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
8 version 2 of the License, or (at your option) any later version.
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
9
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
10 This library is distributed in the hope that it will be useful,
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
13 Library General Public License for more details.
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
14
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
15 You should have received a copy of the GNU Library General Public
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
16 License along with this library; if not, write to the Free
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
18 */
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
19
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
20 /* I'm so sick of constantly rewriting linked lists in C.
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
21 So here's some initial work to write a very simple reusable implementation.
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
22 The API could use a lot more functions, but I'll add them as I need them.
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
23 */
1c27a52c5b15 Added copyright.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
24
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
25 #ifndef C_LINKED_LIST_H
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
26 #define C_LINKED_LIST_H
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
27
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
28 /* Set up for C function definitions, even when using C++ */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
29 #ifdef __cplusplus
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
30 extern "C" {
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
31 #endif
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
32
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
33 #include <stddef.h>
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
34
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
35 typedef struct LinkedListNode LinkedListNode;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
36 typedef struct LinkedList LinkedList;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
37
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
38 LinkedList* LinkedList_Create();
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
39
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
40 void LinkedList_Free(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
41
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
42 void* LinkedList_Front(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
43 void* LinkedList_Back(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
44
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
45 unsigned int LinkedList_PushFront(LinkedList* linked_list, void* new_item);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
46
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
47 unsigned int LinkedList_PushBack(LinkedList* linked_list, void* new_item);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
48
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
49 void* LinkedList_PopFront(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
50
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
51 void* LinkedList_PopBack(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
52
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
53 size_t LinkedList_Size(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
54
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
55 void LinkedList_Clear(LinkedList* linked_list);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
56
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
57 void* LinkedListNode_GetData(LinkedListNode* list_node);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
58
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
59 LinkedListNode* LinkedList_Find(LinkedList* linked_list, void* the_data, LinkedListNode* start_node);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
60
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
61 unsigned int LinkedList_Remove(LinkedList* linked_list, LinkedListNode* list_node);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
62
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
63 /* Ends C function definitions when using C++ */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
64 #ifdef __cplusplus
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
65 }
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
66 #endif
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
67
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
68 #endif /* C_LINKED_LIST_H */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
69