NSSet5413174

From iPhone Development Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


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