ObjFW  Diff

Differences From Artifact [7eccbfdc6d]:

To Artifact [10629d9d3f]:


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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * 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"


/**
 * The OFArray class provides a class for storing dynamically sized arrays.
 * If you plan to store large hunks of data, you should consider using
 * OFBigArray, which allocates the memory in pages and not in bytes.
 */
@interface OFArray: OFObject
{
	char   *data;
	size_t itemsize;
	size_t items;
}

/**
 * Creates a new OFArray whose items all have the same size.
 *
 * \param is The size of each element in the OFArray
 * \return A new autoreleased OFArray
 */
+ arrayWithItemSize: (size_t)is;

/*
 * Creates a new OFArray optimized for big arrays whose items all have the same
 * size, which means memory is allocated in pages rather than in bytes.
 *
 * \param is The size of each element in the OFArray
 * \return A new autoreleased OFArray
 */
+ bigArrayWithItemSize: (size_t)is;

/**
 * Initializes an already allocated OFArray whose items all have the same size.
 *
 * \param is The size of each element in the OFArray
 * \return An initialized OFArray
 */
- initWithItemSize: (size_t)is;

/**
 * \return The number of items in the OFArray
 */
- (size_t)items;

/**
 * \return The size of each item in the OFArray in bytes
 */
- (size_t)itemsize;

/**
 * \return All elements of the OFArray
 */
- (void*)data;

/**
 * Clones the OFArray, creating a new one.
 *
 * \return A new autoreleased copy of the OFArray
 */
- (id)copy;

/**
 * Compares the OFArray to another object.
 *
 * \param obj An object to compare with
 * \return An integer which is the result of the comparison, see for example
 *	   strcmp
 */
- (int)compare: (id)obj;

/**
 * Returns a specific item of the OFArray.
 *
 * \param item The number of the item to return
 * \return The specified item of the OFArray
 */
- (void*)item: (size_t)item;

/**
 * \return The last item of the OFArray
 */
- (void*)last;

/**
 * Adds an item to the OFArray.
 *
 * \param item A pointer to an arbitrary item
 */
- add: (void*)item;

/**
 * Adds items from a C array to the OFArray.
 *
 * \param nitems The number of items to add
 * \param carray A C array containing the items to add
 */
- addNItems: (size_t)nitems
 fromCArray: (void*)carray;

/**
 * Removes a specified amount of the last items from the OFArray.
 *
 * \param nitems The number of items to remove
 */
- removeNItems: (size_t)nitems;
@end

@interface OFBigArray: OFArray
{
	size_t size;
}
@end












>


|
<
<



|
<
<



<
<
<


|

<
<
<
<
<
<
<
<
<

<
<
<
<
<
<
<
<
|

|
<
<
<
<
<
<
<
<
<
<









<
<
<
<
<
<
<
<
<
|

|
|

|


|

|


|

|

|


<
<
<
<
<
<
<
|
<
<

|

|
<
<
<
<
<
<

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
/*
 * 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 "OFDataArray.h"

/**
 * The OFArray class provides a class for storing objects in an array.


 */
@interface OFArray: OFObject
{
	OFDataArray *array;


}

/**



 * \return A new autoreleased OFArray
 */
+ array;










/**








 * \return The number of objects in the OFArray
 */
- (size_t)objects;











/**
 * Clones the OFArray, creating a new one.
 *
 * \return A new autoreleased copy of the OFArray
 */
- (id)copy;

/**









 * Returns a specific object of the OFDataArray.
 *
 * \param index The number of the object to return
 * \return The specified object of the OFArray
 */
- (OFObject*)object: (size_t)index;

/**
 * \return The last object of the OFDataArray
 */
- (OFObject*)last;

/**
 * Adds an object to the OFDataArray.
 *
 * \param obj An object to add
 */
- add: (OFObject*)obj;

/**







 * Removes the specified amount of object from the end of the OFDataArray.


 *
 * \param nobjects The number of objects to remove
 */
- removeNObjects: (size_t)nobjects;






@end