ObjFW  Diff

Differences From Artifact [e40d20478e]:

To Artifact [8e66167c8d]:


1
2
3
4
5
6
7
8
9
10
11
12
13







14
15
16
17
18
19
20
21


22
23

24



25
26
27

28
29

30
31
32






33
34

35
36
37






38
39

40
41




42



43
44


45
46

47
48
49






50
51


52
53
54

55
56

57
58

59
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25


26
27
28
29
30

31
32
33
34
35

36
37

38
39
40

41
42
43
44
45
46
47

48
49
50

51
52
53
54
55
56
57

58
59
60
61
62
63
64

65
66
67
68

69
70
71
72
73



74
75
76
77
78
79
80

81
82
83
84

85
86

87
88

89
90












-
+
+
+
+
+
+
+






-
-
+
+


+
-
+
+
+


-
+

-
+


-
+
+
+
+
+
+

-
+


-
+
+
+
+
+
+

-
+


+
+
+
+
-
+
+
+

-
+
+


+
-
-
-
+
+
+
+
+
+

-
+
+


-
+

-
+

-
+

/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"
#import "OFListObject.h"

typedef struct __of_list_object
{
	id			object;
	struct __of_list_object *next;
	struct __of_list_object *prev;
} of_list_object_t;

/**
 * The OFList class provides easy to use double-linked lists.
 */
@interface OFList: OFObject
{
	OFListObject *first;
	OFListObject *last;
	of_list_object_t *first;
	of_list_object_t *last;
}

/**
- init;
 * \return The first object in the list
 */
- (of_list_object_t*)first;

/**
 * Frees the OFList and all OFListObjects, but not the data they contian.
 * \return The last object in the list
 */
- free;
- (of_list_object_t*)last;

/**
 * Frees the list and the data included in all OFListObjects it contains.
 * Appends an object to the list.
 *
 * \param obj The object to append
 * \return An of_list_object_t, needed to identify the object inside the list.
 *	   For example, if you want to remove an object from the list, you need
 *	   its of_list_object_t.
 */
- freeIncludingData;
- (of_list_object_t*)append: (id)obj;

/**
 * \returns The first OFListObject in the OFList
 * Prepends an object to the list.
 *
 * \param obj The object to prepend
 * \return An of_list_object_t, needed to identify the object inside the list.
 *	   For example, if you want to remove an object from the list, you need
 *	   its of_list_object_t.
 */
- (OFListObject*)first;
- (of_list_object_t*)prepend: (id)obj;

/**
 * Inserts an object before another object.
 * \param obj The object to insert
 * \param listobj The of_list_object_t of the object before which it should be
 *	  inserted
 * \returns The last OFListObject in the OFList
 * \return An of_list_object_t, needed to identify the object inside the list.
 *	   For example, if you want to remove an object from the list, you need
 *	   its of_list_object_t.
 */
- (OFListObject*)last;
- (of_list_object_t*)insert: (id)obj
		     before: (of_list_object_t*)listobj;

/**
 * Inserts an object after another object.
 * Adds a new OFListObject to the OFList.
 *
 * \param obj An OFListObject
 * \param obj The object to insert
 * \param listobj The of_list_object_t of the object after which it should be
 *	  inserted
 * \return An of_list_object_t, needed to identify the object inside the list.
 *	   For example, if you want to remove an object from the list, you need
 *	   its of_list_object_t.
 */
- add: (OFListObject*)obj;
- (of_list_object_t*)insert: (id)obj
		      after: (of_list_object_t*)listobj;

/**
 * Creates a new OFListObject and adds it to the OFList.
 * Removes an object from the list.
 *
 * \param obj A data object for the OFListObject which will be added
 * \param listobj The list object returned by append / prepend
 */
- addNew: (id)obj;
- remove: (of_list_object_t*)listobj;
@end