This is test09.m in view mode; [Download] [Up]
#include <coll/coll.h> long random(); int main() { int i; id node; id s = [[EltNodeCollector alloc] initEncoding:@encode(int) nodeCollector:[[SplayTree alloc] init] nodeClass:[BinaryTreeEltNode class]]; void foo (id o) {[o self];} for (i = 1; i < 20; i++) [s addElement:(int)random()%99]; [[s contentsCollector] binaryTreePrintForDebugger]; [s free]; s = [[EltNodeCollector alloc] initEncoding:@encode(int) nodeCollector:[[SplayTree alloc] init] nodeClass:[BinaryTreeEltNode class]]; for (i = 1; i < 20; i++) [s addElement:(int)random()%99]; [[s contentsCollector] binaryTreePrintForDebugger]; [s removeElement:[s elementAtIndex:10]]; [[s contentsCollector] binaryTreePrintForDebugger]; [[s contentsCollector] withObjectsCall:foo]; [s free]; s = [[EltNodeCollector alloc] initEncoding:@encode(int) nodeCollector:[[BinaryTree alloc] init] nodeClass:[BinaryTreeEltNode class]]; [s appendElement:'i']; [s insertElement:'h' before:'i']; [s insertElement:'g' before:'h']; [s insertElement:'f' before:'g']; [s insertElement:'e' after:'f']; [s insertElement:'d' before:'e']; [s insertElement:'c' after:'d']; [s insertElement:'b' after:'c']; [s insertElement:'a' after:'b']; [[s contentsCollector] binaryTreePrintForDebugger]; [[s contentsCollector] binaryTreePrintForDebugger]; s = [[EltNodeCollector alloc] initEncoding:@encode(char) nodeCollector:[[SplayTree alloc] init] nodeClass:[BinaryTreeEltNode class]]; [s appendElement:(char)'i']; [s insertElement:(char)'h' before:(char)'i']; [s insertElement:(char)'g' before:(char)'h']; [s insertElement:(char)'f' before:(char)'g']; [s insertElement:(char)'e' after:(char)'f']; [s insertElement:(char)'d' before:(char)'e']; [s insertElement:(char)'c' after:(char)'d']; [s insertElement:(char)'b' after:(char)'c']; [s insertElement:(char)'a' after:(char)'b']; [[s contentsCollector] binaryTreePrintForDebugger]; [[s contentsCollector] splayNode:[s eltNodeWithElement:(char)'a']]; [[s contentsCollector] binaryTreePrintForDebugger]; /* while ([s eltNodeWithElement:(char)'a'] != [[s contentsCollector] rootNode]) { [[s contentsCollector] _doSplayOperationOnNode: [s eltNodeWithElement:(char)'a']]; printf("===============================\n"); [[s contentsCollector] binaryTreePrintForDebugger]; } */ if ((node = [s eltNodeWithElement:(char)'z']) != nil) [s error:"eltNodeWithElement: loses."]; exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.