NSSet5413174

From iPhone Development Wiki
Revision as of 16:24, 4 October 2009 by KennyTM~ (talk | contribs) (Created page with '{{occlass|library=Foundation.framework}} NSSet5413174 is a mutable array pretending to be a mutable set. Therefore, searching, insertion and deletion would cost O(N) instead…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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