This is test4.m in view mode; [Download] [Up]
#include <coll/coll.h>
#define N 20
main()
{
int i;
short s, s1, s2;
Heap* heap = [[Heap alloc] initEncoding:"s"];
Array* array = [[Array alloc] initEncoding:"s"];
for (i = 0; i < N; i++)
{
s = (short)random();
[heap addElement:s];
[array addElement:s];
}
[array sortContents];
for (i = 0; i < N; i++)
{
s1 = [heap removeFirstElement].short_int_u;
s2 = [array removeLastElement].short_int_u;
printf("(%d,%d) ", s1, s2);
if (s1 != s2)
exit(1);
}
printf("\n");
/* cause an error */
/* s = [heap elementAtIndex:999].short_int_u; */
[heap free];
exit(0);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.