Created
December 2, 2012 07:47
-
-
Save numist/4187633 to your computer and use it in GitHub Desktop.
NNStrongCollections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Generated on Sun Dec 02 00:41:17 -0800 2012. | |
// Contents copyright © 2012 Scott Perry (http://numist.net) | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
// | |
#import <Foundation/Foundation.h> | |
#include <stdarg.h> | |
#define _NNInternalCollections(_class_, _lname_, _Uname_, _pluralSuffix_) \ | |
@interface NNMutable##_Uname_##Array : NSMutableArray \ | |
- (void)add##_Uname_:(_class_ *)some##_Uname_; \ | |
- (void)insert##_Uname_:(_class_ *)some##_Uname_ atIndex:(NSUInteger)index; \ | |
- (void)removeLast##_Uname_; \ | |
- (void)remove##_Uname_##AtIndex:(NSUInteger)index; \ | |
- (void)replace##_Uname_##AtIndex:(NSUInteger)index with##_Uname_:(_class_ *)some##_Uname_; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NNExtendedMutable##_Uname_##Array) \ | |
- (void)add##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (void)exchange##_Uname_##AtIndex:(NSUInteger)idx1 with##_Uname_##AtIndex:(NSUInteger)idx2; \ | |
- (void)removeAll##_Uname_##_pluralSuffix_; \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_; \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (void)remove##_Uname_##_pluralSuffix_##InArray:(NSArray *)otherArray; \ | |
- (void)remove##_Uname_##_pluralSuffix_##InRange:(NSRange)range; \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray range:(NSRange)otherRange; \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (void)sortUsing##_Uname_##Function:(NSInteger (*)(_class_ *, _class_ *, void *))compare context:(void *)context; \ | |
- (void)insert##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_ atIndexes:(NSIndexSet *)indexes; \ | |
- (void)remove##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (void)replace##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes with##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_; \ | |
- (void)set##_Uname_:(_class_ *)some##_Uname_ atIndexedSubscript:(NSUInteger)idx; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (_class_ *)last##_Uname_; \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)anObject; \ | |
- (NNMutable##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NN##_Uname_##Array) \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
@end \ | |
\ | |
@interface NN##_Uname_##Array : NSArray \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
@end \ | |
@interface NN##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (_class_ *)last##_Uname_; \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)anObject; \ | |
- (NN##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
@end \ | |
@class NNMutable##_Uname_##Array; \ | |
@interface NN##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
+ (NN##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
@end \ | |
\ | |
@interface NNMutable##_Uname_##Array () { \ | |
NSMutableArray *_secretInternalMutableArray; \ | |
} \ | |
+ (void)nnCheckObject:(id)obj; \ | |
+ (void)nnCheckCollection:(id<NSFastEnumeration>)collection; \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array \ | |
- (void)add##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
[self addObject:some##_Uname_]; \ | |
} \ | |
- (void)insert##_Uname_:(_class_ *)some##_Uname_ atIndex:(NSUInteger)index; \ | |
{ \ | |
[self insertObject:some##_Uname_ atIndex:index]; \ | |
} \ | |
- (void)removeLast##_Uname_; \ | |
{ \ | |
[self removeLastObject]; \ | |
} \ | |
- (void)remove##_Uname_##AtIndex:(NSUInteger)index; \ | |
{ \ | |
[self removeObjectAtIndex:index]; \ | |
} \ | |
- (void)replace##_Uname_##AtIndex:(NSUInteger)index with##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
[self replaceObjectAtIndex:index withObject:some##_Uname_]; \ | |
} \ | |
+ (void)nnCheckObject:(id)obj; \ | |
{ \ | |
if (![obj isKindOfClass:[_class_ class]]) { \ | |
@throw [NSException exceptionWithName:@"NNMutable##_Uname_##ArrayInvalidTypeException" \ | |
reason:[NSString stringWithFormat:@"Parameter to %@ is the wrong type: %@", NSStringFromClass(self), obj] \ | |
userInfo:nil]; \ | |
} \ | |
} \ | |
+ (void)nnCheckCollection:(id<NSFastEnumeration>)collection; \ | |
{ \ | |
for (id obj in collection) { \ | |
[[self class] nnCheckObject:obj]; \ | |
} \ | |
} \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array (NNExtendedMutable##_Uname_##Array) \ | |
- (void)add##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
{ \ | |
[self addObjectsFromArray:otherArray]; \ | |
} \ | |
- (void)exchange##_Uname_##AtIndex:(NSUInteger)idx1 with##_Uname_##AtIndex:(NSUInteger)idx2; \ | |
{ \ | |
[self exchangeObjectAtIndex:idx1 withObjectAtIndex:idx2]; \ | |
} \ | |
- (void)removeAll##_Uname_##_pluralSuffix_; \ | |
{ \ | |
[self removeAllObjects]; \ | |
} \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
[self removeObject:some##_Uname_ inRange:range]; \ | |
} \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
[self removeObject:some##_Uname_]; \ | |
} \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
[self removeObjectIdenticalTo:some##_Uname_ inRange:range]; \ | |
} \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
{ \ | |
[self removeObjectIdenticalTo:some##_Uname_]; \ | |
} \ | |
- (void)remove##_Uname_##_pluralSuffix_##InArray:(NSArray *)otherArray; \ | |
{ \ | |
[self removeObjectsInArray:otherArray]; \ | |
} \ | |
- (void)remove##_Uname_##_pluralSuffix_##InRange:(NSRange)range; \ | |
{ \ | |
[self removeObjectsInRange:range]; \ | |
} \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray range:(NSRange)otherRange; \ | |
{ \ | |
[self replaceObjectsInRange:range withObjectsFromArray:otherArray range:otherRange]; \ | |
} \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
{ \ | |
[self replaceObjectsInRange:range withObjectsFromArray:otherArray]; \ | |
} \ | |
- (void)sortUsing##_Uname_##Function:(NSInteger (*)(_class_ *, _class_ *, void *))compare context:(void *)context; \ | |
{ \ | |
[self sortUsingFunction:(NSInteger (*)(id, id, void *))compare context:context]; \ | |
} \ | |
- (void)insert##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_ atIndexes:(NSIndexSet *)indexes; \ | |
{ \ | |
[self insertObjects:_lname_##_pluralSuffix_ atIndexes:indexes]; \ | |
} \ | |
- (void)remove##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
{ \ | |
[self removeObjectsAtIndexes:indexes]; \ | |
} \ | |
- (void)replace##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes with##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_; \ | |
{ \ | |
[self replaceObjectsAtIndexes:indexes withObjects:_lname_##_pluralSuffix_]; \ | |
} \ | |
- (void)set##_Uname_:(_class_ *)some##_Uname_ atIndexedSubscript:(NSUInteger)idx; \ | |
{ \ | |
[self setObject:some##_Uname_ atIndexedSubscript:idx]; \ | |
} \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
NNMutable##_Uname_##Array *result = [[self class] arrayWithArray:self]; \ | |
[result addObject:some##_Uname_]; \ | |
return result; \ | |
} \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
{ \ | |
NNMutable##_Uname_##Array *result = [[self class] arrayWithArray:self]; \ | |
[result addObjectsFromArray:otherArray]; \ | |
return result; \ | |
} \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self containsObject:some##_Uname_]; \ | |
} \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
{ \ | |
return (_class_ *)[self firstObjectCommonWithArray:otherArray]; \ | |
} \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
{ \ | |
[self getObjects:_lname_##_pluralSuffix_ range:range]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_ inRange:range]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self indexOfObjectIdenticalTo:some##_Uname_]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
return [self indexOfObjectIdenticalTo:some##_Uname_ inRange:range]; \ | |
} \ | |
- (_class_ *)last##_Uname_; \ | |
{ \ | |
return (_class_ *)[self lastObject]; \ | |
} \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
{ \ | |
return [self objectEnumerator]; \ | |
} \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
{ \ | |
return [self reverseObjectEnumerator]; \ | |
} \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
{ \ | |
[self makeObjectsPerformSelector:aSelector]; \ | |
} \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)argument; \ | |
{ \ | |
[self makeObjectsPerformSelector:aSelector withObject:argument]; \ | |
} \ | |
- (NNMutable##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
{ \ | |
return [[self class] strongArrayWithArray:[self objectsAtIndexes:indexes]]; \ | |
} \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
{ \ | |
return (_class_ *)[self objectAtIndexedSubscript:idx]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsUsingBlock:block]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsWithOptions:opts usingBlock:block]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsAtIndexes:s options:opts usingBlock:block]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectPassingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectWithOptions:opts passingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectAtIndexes:s options:opts passingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsPassingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsWithOptions:opts passingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsAtIndexes:s options:opts passingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_ inSortedRange:r options:opts usingComparator:cmp]; \ | |
} \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array (NN##_Uname_##Array) \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
{ \ | |
return (_class_ *)[self objectAtIndex:index]; \ | |
} \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [[self alloc] initWithArray:@[some##_Uname_]]; \ | |
} \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
{ \ | |
return [[self alloc] initWith##_Uname_##_pluralSuffix_:_lname_##_pluralSuffix_ count:cnt]; \ | |
} \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ...; \ | |
{ \ | |
NSMutableArray *array = [NSMutableArray array]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
\ | |
do { \ | |
[array addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
\ | |
return [[self alloc] initWithArray:array]; \ | |
} \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
{ \ | |
return [[self alloc] initWithArray:array]; \ | |
} \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
{ \ | |
return [self initWithObjects:_lname_##_pluralSuffix_ count:cnt]; \ | |
} \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ...; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
\ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] init]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
\ | |
do { \ | |
[self->_secretInternalMutableArray addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
\ | |
[[self class] nnCheckCollection:self->_secretInternalMutableArray]; \ | |
return self; \ | |
} \ | |
- (id)init; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] init]; \ | |
return self; \ | |
} \ | |
- (id)initWithCapacity:(NSUInteger)numItems; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] initWithCapacity:numItems]; \ | |
return self; \ | |
} \ | |
- (id)initWithArray:(NSArray *)array; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
[[self class] nnCheckCollection:array]; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] initWithArray:array]; \ | |
return self; \ | |
} \ | |
- (id)initWithArray:(NSArray *)array copyItems:(BOOL)flag; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
[[self class] nnCheckCollection:array]; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] initWithArray:array copyItems:flag]; \ | |
return self; \ | |
} \ | |
- (id)initWithObjects:(id)firstObj, ...; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] init]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
do { \ | |
[self->_secretInternalMutableArray addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
[[self class] nnCheckCollection:self->_secretInternalMutableArray]; \ | |
return self; \ | |
} \ | |
- (id)initWithObjects:(const id[])objects count:(NSUInteger)count; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalMutableArray = [[NSMutableArray alloc] initWithObjects:objects count:count]; \ | |
[[self class] nnCheckCollection:self->_secretInternalMutableArray]; \ | |
return self; \ | |
} \ | |
@end \ | |
@implementation NNMutable##_Uname_##Array (NNSubclassing) \ | |
- (NSUInteger)count; \ | |
{ \ | |
return [self->_secretInternalMutableArray count]; \ | |
} \ | |
- (id)objectAtIndex:(NSUInteger)index; \ | |
{ \ | |
return [self->_secretInternalMutableArray objectAtIndex:index]; \ | |
} \ | |
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index; \ | |
{ \ | |
[[self class] nnCheckObject:anObject]; \ | |
[self->_secretInternalMutableArray insertObject:anObject atIndex:index]; \ | |
} \ | |
- (void)removeObjectAtIndex:(NSUInteger)index; \ | |
{ \ | |
[self->_secretInternalMutableArray removeObjectAtIndex:index]; \ | |
} \ | |
- (void)addObject:(id)anObject; \ | |
{ \ | |
[[self class] nnCheckObject:anObject]; \ | |
[self->_secretInternalMutableArray addObject:anObject]; \ | |
} \ | |
- (void)removeLastObject; \ | |
{ \ | |
[self->_secretInternalMutableArray removeLastObject]; \ | |
} \ | |
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject; \ | |
{ \ | |
[[self class] nnCheckObject:anObject]; \ | |
[self->_secretInternalMutableArray replaceObjectAtIndex:index withObject:anObject]; \ | |
} \ | |
@end \ | |
\ | |
@interface NN##_Uname_##Array () { \ | |
NSArray *_secretInternalArray; \ | |
} \ | |
+ (void)nnCheckObject:(id)obj; \ | |
+ (void)nnCheckCollection:(id<NSFastEnumeration>)collection; \ | |
@end \ | |
@implementation NN##_Uname_##Array \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
{ \ | |
return (_class_ *)[self objectAtIndex:index]; \ | |
} \ | |
+ (void)nnCheckObject:(id)obj; \ | |
{ \ | |
if (![obj isKindOfClass:[_class_ class]]) { \ | |
@throw [NSException exceptionWithName:@"NNMutable##_Uname_##ArrayInvalidTypeException" \ | |
reason:[NSString stringWithFormat:@"Parameter to %@ is the wrong type: %@", NSStringFromClass(self), obj] \ | |
userInfo:nil]; \ | |
} \ | |
} \ | |
+ (void)nnCheckCollection:(id<NSFastEnumeration>)collection; \ | |
{ \ | |
for (id obj in collection) { \ | |
[[self class] nnCheckObject:obj]; \ | |
} \ | |
} \ | |
@end \ | |
@implementation NN##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
NSMutableArray *array = [NSMutableArray arrayWithArray:self->_secretInternalArray]; \ | |
[array addObject:some##_Uname_]; \ | |
return [[self class] strongArrayWithArray:array]; \ | |
} \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
{ \ | |
NSMutableArray *array = [NSMutableArray arrayWithArray:self->_secretInternalArray]; \ | |
[array addObjectsFromArray:otherArray]; \ | |
return [[self class] strongArrayWithArray:array]; \ | |
} \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self containsObject:some##_Uname_]; \ | |
} \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
{ \ | |
return (_class_ *)[self firstObjectCommonWithArray:otherArray]; \ | |
} \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
{ \ | |
[self getObjects:_lname_##_pluralSuffix_ range:range]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_ inRange:range]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [self indexOfObjectIdenticalTo:some##_Uname_]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
{ \ | |
return [self indexOfObjectIdenticalTo:some##_Uname_ inRange:range]; \ | |
} \ | |
- (_class_ *)last##_Uname_; \ | |
{ \ | |
return (_class_ *)[self lastObject]; \ | |
} \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
{ \ | |
return [self objectEnumerator]; \ | |
} \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
{ \ | |
return [self reverseObjectEnumerator]; \ | |
} \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
{ \ | |
[self makeObjectsPerformSelector:aSelector]; \ | |
} \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)argument; \ | |
{ \ | |
[self makeObjectsPerformSelector:aSelector withObject:argument]; \ | |
} \ | |
- (NN##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
{ \ | |
return [[self class] strongArrayWithArray:[[self class] objectsAtIndexes:indexes]]; \ | |
} \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
{ \ | |
return (_class_ *)[self objectAtIndexedSubscript:idx]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsUsingBlock:block]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsWithOptions:opts usingBlock:block]; \ | |
} \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
{ \ | |
[self enumerateObjectsAtIndexes:s options:opts usingBlock:block]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectPassingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectWithOptions:opts passingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexOfObjectAtIndexes:s options:opts passingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsPassingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsWithOptions:opts passingTest:predicate]; \ | |
} \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
{ \ | |
return [self indexesOfObjectsAtIndexes:s options:opts passingTest:predicate]; \ | |
} \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
{ \ | |
return [self indexOfObject:some##_Uname_ inSortedRange:r options:opts usingComparator:cmp]; \ | |
} \ | |
@end \ | |
@implementation NN##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
{ \ | |
return [[self alloc] initWithArray:@[some##_Uname_]]; \ | |
} \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
{ \ | |
return [[self alloc] initWith##_Uname_##_pluralSuffix_:_lname_##_pluralSuffix_ count:cnt]; \ | |
} \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ...; \ | |
{ \ | |
NSMutableArray *array = [NSMutableArray array]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
\ | |
do { \ | |
[array addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
\ | |
return [[self alloc] initWithArray:array]; \ | |
} \ | |
+ (NN##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
{ \ | |
return [[self alloc] initWithArray:array]; \ | |
} \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
{ \ | |
return [self initWithObjects:_lname_##_pluralSuffix_ count:cnt]; \ | |
} \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ...; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
\ | |
NSMutableArray *array = [[NSMutableArray alloc] init]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
\ | |
do { \ | |
[array addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
\ | |
self->_secretInternalArray = array; \ | |
[[self class] nnCheckCollection:self->_secretInternalArray]; \ | |
\ | |
return self;} \ | |
- (id)init; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalArray = [[NSArray alloc] init]; \ | |
return self; \ | |
} \ | |
- (id)initWithArray:(NSArray *)array; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
[[self class] nnCheckCollection:array]; \ | |
self->_secretInternalArray = [[NSArray alloc] initWithArray:array]; \ | |
return self; \ | |
} \ | |
- (id)initWithArray:(NSArray *)array copyItems:(BOOL)flag; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
[[self class] nnCheckCollection:array]; \ | |
self->_secretInternalArray = [[NSArray alloc] initWithArray:array copyItems:flag]; \ | |
return self; \ | |
} \ | |
- (id)initWithObjects:(id)firstObj, ...; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
\ | |
NSMutableArray *array = [[NSMutableArray alloc] init]; \ | |
id arg = firstObj; \ | |
\ | |
va_list argp; \ | |
va_start(argp, firstObj); \ | |
\ | |
do { \ | |
[array addObject:arg]; \ | |
} while ((arg = va_arg(argp, id))); \ | |
\ | |
va_end(argp); \ | |
\ | |
self->_secretInternalArray = array; \ | |
[[self class] nnCheckCollection:self->_secretInternalArray]; \ | |
\ | |
return self; \ | |
} \ | |
- (id)initWithObjects:(const id[])objects count:(NSUInteger)count; \ | |
{ \ | |
self = [super init]; \ | |
if (!self) return nil; \ | |
self->_secretInternalArray = [[NSArray alloc] initWithObjects:objects count:count]; \ | |
[[self class] nnCheckCollection:self->_secretInternalArray]; \ | |
return self; \ | |
} \ | |
@end \ | |
@implementation NN##_Uname_##Array (NNSubclassing) \ | |
- (NSUInteger)count; \ | |
{ \ | |
return [self->_secretInternalArray count]; \ | |
} \ | |
- (id)objectAtIndex:(NSUInteger)index; \ | |
{ \ | |
return [self->_secretInternalArray objectAtIndex:index]; \ | |
} \ | |
@end \ | |
#define NNStrongCollections(class, lowerName, UpperName, pluralSuffix) \ | |
_NNInternalCollections(class, lowerName, UpperName, pluralSuffix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Generated on Sun Dec 02 00:41:17 -0800 2012. | |
// Contents copyright © 2012 Scott Perry (http://numist.net) | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
// | |
#import <Foundation/Foundation.h> | |
#define _NNInternalCollections(_class_, _lname_, _Uname_, _pluralSuffix_) \ | |
@interface NNMutable##_Uname_##Array : NSMutableArray \ | |
- (void)add##_Uname_:(_class_ *)some##_Uname_; \ | |
- (void)insert##_Uname_:(_class_ *)some##_Uname_ atIndex:(NSUInteger)index; \ | |
- (void)removeLast##_Uname_; \ | |
- (void)remove##_Uname_##AtIndex:(NSUInteger)index; \ | |
- (void)replace##_Uname_##AtIndex:(NSUInteger)index with##_Uname_:(_class_ *)some##_Uname_; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NNExtendedMutable##_Uname_##Array) \ | |
- (void)add##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (void)exchange##_Uname_##AtIndex:(NSUInteger)idx1 with##_Uname_##AtIndex:(NSUInteger)idx2; \ | |
- (void)removeAll##_Uname_##_pluralSuffix_; \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (void)remove##_Uname_:(_class_ *)some##_Uname_; \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (void)remove##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (void)remove##_Uname_##_pluralSuffix_##InArray:(NSArray *)otherArray; \ | |
- (void)remove##_Uname_##_pluralSuffix_##InRange:(NSRange)range; \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray range:(NSRange)otherRange; \ | |
- (void)replace##_Uname_##_pluralSuffix_##InRange:(NSRange)range with##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (void)sortUsing##_Uname_##Function:(NSInteger (*)(_class_ *, _class_ *, void *))compare context:(void *)context; \ | |
- (void)insert##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_ atIndexes:(NSIndexSet *)indexes; \ | |
- (void)remove##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (void)replace##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes with##_Uname_##_pluralSuffix_:(NSArray *)_lname_##_pluralSuffix_; \ | |
- (void)set##_Uname_:(_class_ *)some##_Uname_ atIndexedSubscript:(NSUInteger)idx; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NNMutable##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (_class_ *)last##_Uname_; \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)anObject; \ | |
- (NNMutable##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NN##_Uname_##Array) \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
@end \ | |
@interface NNMutable##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
+ (NNMutable##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
@end \ | |
\ | |
@interface NN##_Uname_##Array : NSArray \ | |
- (_class_ *)_lname_##AtIndex:(NSUInteger)index; \ | |
@end \ | |
@interface NN##_Uname_##Array (NNExtended##_Uname_##Array) \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NN##_Uname_##Array *)strongArrayByAdding##_Uname_##_pluralSuffix_##FromArray:(NSArray *)otherArray; \ | |
- (BOOL)contains##_Uname_:(_class_ *)some##_Uname_; \ | |
- (_class_ *)first##_Uname_##CommonWithArray:(NSArray *)otherArray; \ | |
- (void)get##_Uname_##_pluralSuffix_:(id __unsafe_unretained [])_lname_##_pluralSuffix_ range:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_; \ | |
- (NSUInteger)indexOf##_Uname_##IdenticalTo:(_class_ *)some##_Uname_ inRange:(NSRange)range; \ | |
- (_class_ *)last##_Uname_; \ | |
- (NSEnumerator *)_lname_##Enumerator; \ | |
- (NSEnumerator *)reverse##_Uname_##Enumerator; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector; \ | |
- (void)make##_Uname_##_pluralSuffix_##PerformSelector:(SEL)aSelector withObject:(id)anObject; \ | |
- (NN##_Uname_##Array *)_lname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)indexes; \ | |
- (_class_ *)_lname_##AtIndexedSubscript:(NSUInteger)idx; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##UsingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (void)enumerate##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))block; \ | |
- (NSUInteger)indexOf##_Uname_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##PassingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##WithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSIndexSet *)indexesOf##_Uname_##_pluralSuffix_##AtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(_class_ * some##_Uname_, NSUInteger idx, BOOL *stop))predicate; \ | |
- (NSUInteger)indexOf##_Uname_:(_class_ *)some##_Uname_ inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; \ | |
@end \ | |
@class NNMutable##_Uname_##Array; \ | |
@interface NN##_Uname_##Array (NN##_Uname_##ArrayCreation) \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_:(_class_ *)some##_Uname_; \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
+ (NN##_Uname_##Array *)strongArrayWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
+ (NN##_Uname_##Array *)strongArrayWithArray:(NSArray *)array; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ const * [])_lname_##_pluralSuffix_ count:(NSUInteger)cnt; \ | |
- (id)initWith##_Uname_##_pluralSuffix_:(_class_ *)firstObj, ... NS_REQUIRES_NIL_TERMINATION; \ | |
@end \ | |
#define NNStrongCollections(class, lowerName, UpperName, pluralSuffix) \ | |
_NNInternalCollections(class, lowerName, UpperName, pluralSuffix) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment