2020-03-03 06:24:41 +00:00
|
|
|
#include <Set.h>
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
void set_del_iter (set_iter_t *set_iter) = #0;
|
|
|
|
set_t *set_new (void) = #0;
|
|
|
|
void set_delete (set_t *set) = #0;
|
|
|
|
set_t *set_add (set_t *set, unsigned x) = #0;
|
|
|
|
set_t *set_remove (set_t *set, unsigned x) = #0;
|
|
|
|
set_t *set_invert (set_t *set) = #0;
|
|
|
|
set_t *set_union (set_t *dst, set_t *src) = #0;
|
|
|
|
set_t *set_intersection (set_t *dst, set_t *src) = #0;
|
|
|
|
set_t *set_difference (set_t *dst, set_t *src) = #0;
|
|
|
|
set_t *set_reverse_difference (set_t *dst, set_t *src) = #0;
|
|
|
|
set_t *set_assign (set_t *dst, set_t *src) = #0;
|
|
|
|
set_t *set_empty (set_t *set) = #0;
|
|
|
|
set_t *set_everything (set_t *set) = #0;
|
|
|
|
int set_is_empty (set_t *set) = #0;
|
|
|
|
int set_is_everything (set_t *set) = #0;
|
|
|
|
int set_is_disjoint (set_t *s1, set_t *s2) = #0;
|
|
|
|
int set_is_intersecting (set_t *s1, set_t *s2) = #0;
|
|
|
|
int set_is_equivalent (set_t *s1, set_t *s2) = #0;
|
|
|
|
int set_is_subset (set_t *set, set_t *sub) = #0;
|
|
|
|
int set_is_member (set_t *set, unsigned x) = #0;
|
2021-07-27 02:52:21 +00:00
|
|
|
unsigned set_count (set_t *set) = #0;
|
2012-12-16 04:48:36 +00:00
|
|
|
set_iter_t *set_first (set_t *set) = #0;
|
|
|
|
set_iter_t *set_next (set_iter_t *set_iter) = #0;
|
|
|
|
string set_as_string (set_t *set) = #0;
|
|
|
|
|
|
|
|
|
|
|
|
@implementation SetIterator: Object
|
2021-12-23 10:43:27 +00:00
|
|
|
|
|
|
|
- initWithSet: (Set *)set iterator:(set_iter_t *) iter
|
2020-03-03 01:43:29 +00:00
|
|
|
{
|
|
|
|
if (!(self = [super init])) {
|
|
|
|
return nil;
|
|
|
|
}
|
2021-12-23 10:43:27 +00:00
|
|
|
self.set = [set retain];
|
2020-03-03 01:43:29 +00:00
|
|
|
self.iter = iter;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-12-23 10:43:27 +00:00
|
|
|
+ (id) withSet: (Set *)set iterator:(set_iter_t *) iter
|
|
|
|
{
|
|
|
|
return [[[self alloc] initWithSet: set iterator: iter] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[set release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
- (SetIterator *) next
|
|
|
|
{
|
|
|
|
if ((iter = set_next (iter)))
|
|
|
|
return self;
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned) element = #0;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Set: Object
|
|
|
|
+ (id) set
|
|
|
|
{
|
|
|
|
return [[[Set alloc] init] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if (!(self = [super init]))
|
|
|
|
return nil;
|
|
|
|
set = set_new ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
set_delete (set);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (Set *) add: (unsigned) x = #0;
|
|
|
|
- (Set *) remove: (unsigned) x = #0;
|
|
|
|
- (Set *) invert = #0;
|
|
|
|
- (Set *) union: (Set *) src = #0;
|
|
|
|
- (Set *) intersection: (Set *) src = #0;
|
|
|
|
- (Set *) difference: (Set *) src = #0;
|
|
|
|
- (Set *) reverse_difference: (Set *) src = #0;
|
|
|
|
- (Set *) assign: (Set *) src = #0;
|
|
|
|
- (Set *) empty = #0;
|
|
|
|
- (Set *) everything = #0;
|
|
|
|
- (int) is_empty = #0;
|
|
|
|
- (int) is_everything = #0;
|
|
|
|
- (int) is_disjoint: (Set *) s2 = #0;
|
|
|
|
- (int) is_intersecting: (Set *) s2 = #0;
|
|
|
|
- (int) is_equivalent: (Set *) s2 = #0;
|
|
|
|
- (int) is_subset: (Set *) s2 = #0;
|
|
|
|
- (int) is_member: (unsigned) x = #0;
|
|
|
|
- (int) size = #0;
|
|
|
|
|
|
|
|
- (SetIterator *) first
|
|
|
|
{
|
|
|
|
set_iter_t *iter = set_first (set);
|
|
|
|
SetIterator *iterator;
|
|
|
|
|
|
|
|
if (!iter)
|
|
|
|
return nil;
|
2021-12-23 10:43:27 +00:00
|
|
|
iterator = [SetIterator withSet: self iterator: iter];
|
2012-12-16 04:48:36 +00:00
|
|
|
return iterator;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (string) as_string = #0;
|
|
|
|
@end
|