ObjFW  Check-in [59ab431af4]

Overview
Comment:Add - items to OFList.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 59ab431af40bda9a57645a33400cf12ac05ab80012012729272e1b66dbe75c46
User & Date: js on 2009-05-04 17:54:22
Other Links: manifest | tags
Context
2009-05-04
18:04
Add - averageItemsPerBucket to OFDictionary. check-in: c90c6510f1 user: js tags: trunk
17:54
Add - items to OFList. check-in: 59ab431af4 user: js tags: trunk
17:27
Add - changeHashSize: to OFDictionary. check-in: 5e77541e4d user: js tags: trunk
Changes

Modified src/OFList.h from [08eab0576a] to [01b97195c0].

96
97
98
99
100
101
102








103

/**
 * Removes an object from the list.
 *
 * \param listobj The list object returned by append / prepend
 */
- remove: (of_list_object_t*)listobj;








@end







>
>
>
>
>
>
>
>

96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

/**
 * Removes an object from the list.
 *
 * \param listobj The list object returned by append / prepend
 */
- remove: (of_list_object_t*)listobj;

/**
 * Get the number of items in the list. Use with caution, as this means one
 * iteration through the whole list!
 *
 * \return The number of items in the list.
 */
- (size_t)items;
@end

Modified src/OFList.m from [fdd9a22612] to [d0531ab5cf].

164
165
166
167
168
169
170











171
	if (retain_and_release)
		[listobj->object release];

	[self freeMem: listobj];

	return self;
}











@end







>
>
>
>
>
>
>
>
>
>
>

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
	if (retain_and_release)
		[listobj->object release];

	[self freeMem: listobj];

	return self;
}

- (size_t)items
{
	size_t i;
	of_list_object_t *iter;

	for (i = 0, iter = first; iter != NULL; iter = iter->next)
		i++;

	return i;
}
@end

Modified tests/OFList/OFList.m from [1222e8617f] to [dda59ebbf8].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif

#define NUM_TESTS 10
#define SUCCESS								\
{									\
	printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m",	\
	    (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS);		\
	fflush(stdout);							\
}
#define FAIL								\







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif

#define NUM_TESTS 11
#define SUCCESS								\
{									\
	printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m",	\
	    (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS);		\
	fflush(stdout);							\
}
#define FAIL								\
83
84
85
86
87
88
89


90
91
92
93
94
	[list insert: [OFString stringWithCString: strings[0]]
	      before: [list last]];
	[list insert: [OFString stringWithCString: strings[2]]
	       after: [list first]->next];

	for (iter = [list first], j = 0; iter != NULL; iter = iter->next, j++)
		CHECK(!strcmp([iter->object cString], strings[j]))



	puts("");

	return 0;
}







>
>





83
84
85
86
87
88
89
90
91
92
93
94
95
96
	[list insert: [OFString stringWithCString: strings[0]]
	      before: [list last]];
	[list insert: [OFString stringWithCString: strings[2]]
	       after: [list first]->next];

	for (iter = [list first], j = 0; iter != NULL; iter = iter->next, j++)
		CHECK(!strcmp([iter->object cString], strings[j]))

	CHECK ([list items] == 3)

	puts("");

	return 0;
}