NSSet5413174

From iPhone Development Wiki
Jump to: navigation, search


NSSet5413174 is a mutable array pretending to be a mutable set. Therefore, searching, insertion and deletion would cost O(N) instead of O(log N) as guaranteed by CFSet. Nevertheless, you gain the property that enumeration is always in the insertion order.

Example

	NSSet5413174* xset = [[NSSet5413174 alloc] init];
	[xset addObject:@"d"];
	[xset addObject:@"a"];
	[xset addObject:@"c"];
	[xset addObject:@"b"];
	[xset addObject:@"a"];
	[xset removeObject:@"a"];
	for (NSString* obj in xset) {
		NSLog(@"%@", obj);	// prints d, c, b.
	}
	[xset release];

Header