58 lines
1.6 KiB
Plaintext
58 lines
1.6 KiB
Plaintext
include "NSLog.incl"
|
|
|
|
local fn DoIt
|
|
// create
|
|
CFSetRef s1 = fn SetWithArray( @[@"a",@"b",@"c",@"d",@"e"] )
|
|
CFSetRef s2 = fn SetWithArray( @[@"b",@"c",@"d",@"e",@"f",@"h"] )
|
|
CFSetRef s3 = fn SetWithArray( @[@"b",@"c",@"d"] )
|
|
CFSetRef s4 = fn SetWithArray( @[@"b",@"c",@"d"] )
|
|
NSLog(@"s1: %@",s1)
|
|
NSLog(@"s2: %@",s2)
|
|
NSLog(@"s3: %@",s3)
|
|
NSLog(@"s4: %@\n",s4)
|
|
|
|
// membership
|
|
NSLog(@"\"b\" in s1: %d", fn SetContainsObject( s1, @"b" ))
|
|
NSLog(@"\"f\" in s1: %d\n", fn SetContainsObject( s1, @"f" ))
|
|
|
|
// union
|
|
CFMutableSetRef s12 = fn MutableSetWithSet( s1 )
|
|
MutableSetUnionSet( s12, s2 )
|
|
NSLog(@"s1 union s2: %@\n", s12)
|
|
|
|
// intersection
|
|
CFMutableSetRef s1i2 = fn MutableSetWithSet( s1 )
|
|
MutableSetIntersectSet( s1i2, s2 )
|
|
NSLog(@"s1 intersect s2: %@\n", s1i2)
|
|
|
|
// difference
|
|
CFMutableSetRef s1d2 = fn MutableSetWithSet( s1 )
|
|
MutableSetMinusSet( s1d2, s2 )
|
|
NSLog(@"s1 - s2: %@\n", s1d2)
|
|
|
|
// subsetof
|
|
NSLog(@"s3 subset of s1: %d\n", fn SetIsSubsetOfSet( s3, s1 ))
|
|
|
|
// equality
|
|
NSLog(@"s3 == s4: %d\n", fn SetIsEqual( s3, s4 ))
|
|
|
|
// cardinality
|
|
NSLog(@"size of s1: %lu\n", fn SetCount(s1))
|
|
|
|
// has intersection (not disjoint)
|
|
NSLog(@"s1 intersects s2: %d\n", fn SetIntersectsSet( s1, s2 ))
|
|
|
|
// adding and removing elements from mutable set
|
|
CFMutableSetRef s1mut = fn MutableSetWithSet( s1 )
|
|
MutableSetAddObject( s1mut, @"g" )
|
|
NSLog(@"s1mut after adding \"g\": %@\n", s1mut)
|
|
MutableSetAddObject( s1mut, @"b" )
|
|
NSLog(@"s1mut after adding \"b\" again: %@\n", s1mut)
|
|
MutableSetRemoveObject( s1mut, @"c" )
|
|
NSLog(@"s1mut after removing \"c\": %@\n", s1mut)
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|