+ (instancetype)indexSet(空的)
+ (instancetype)indexSetWithIndex:(NSUInteger)index(包含有一个index的对象)
+ (instancetype)indexSetWithIndexesInRange:(NSRange)indexRange (包含有从indexRange中的所有的元素)
- (instancetype)init
- (instancetype)indexSet(空的)
- (instancetype)indexSetWithIndex:(NSUInteger)index(包含有一个index的对象)
- (instancetype)indexSetWithIndexesInRange:(NSRange)indexRange (包含有从indexRange中的所有的元素)
NSIndexSet *indexset = [NSIndexSet indexSet];
NSIndexSet * indexSet2 = [NSIndexSetindexSetWithIndex:1];
NSIndexSet * indexset3 = [NSIndexSetindexSetWithIndexesInRange:NSMakeRange(0, 10)];
[indexset3 enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) {
NSLog(@"%lu",(long)idx);
}];
结果:
1. 空的
2.输出1
3.输出0-9
查询indexsets
- (BOOL)containsIndex:(NSUInteger)index
- (BOOL)containsIndexes:(NSIndexSet *)
indexSet
- (BOOL)containsIndexesInRange:(NSRange)
indexRange
- (BOOL)intersectsIndexesInRange:(NSRange)
indexRange
@property(readonly) NSUInteger count
- (NSUInteger)countOfIndexesInRange:(NSRange)
indexRange
- (NSUInteger)indexPassingTest:(BOOL (^)(NSUInteger idx, BOOL *stop))
predicate
- (NSIndexSet *)indexesPassingTest:(BOOL (^)(NSUInteger idx, BOOL *stop))
predicate
- (NSUInteger)indexWithOptions:(NSEnumerationOptions)
opts
passingTest:(BOOL (^)(NSUInteger idx, BOOL *stop))predicate
- (NSIndexSet *)indexesWithOptions:(NSEnumerationOptions)
opts
passingTest:(BOOL (^)(NSUIntegeridx, BOOL *stop))predicate
- (NSUInteger)indexInRange:(NSRange)
range
options:(NSEnumerationOptions)opts
passingTest:(BOOL (^)(NSUIntegeridx, BOOL *stop))predicate
- (NSIndexSet *)indexesInRange:(NSRange)
range
options:(NSEnumerationOptions)opts
passingTest:(BOOL (^)(NSUIntegeridx, BOOL *stop))predicate
迭代器遍历
- (void)enumerateRangesInRange:(NSRange)
range
options:(NSEnumerationOptions)opts
usingBlock:(void (^)(NSRangerange, BOOL *stop))block
- (void)enumerateRangesUsingBlock:(void (^)(NSRange range, BOOL *stop))
block
- (void)enumerateRangesWithOptions:(NSEnumerationOptions)
opts
usingBlock:(void (^)(NSRangerange, BOOL *stop))block
比较
- (BOOL)isEqualToIndexSet:(NSIndexSet *)
indexSet
获取indexsets
@property(readonly) NSUInteger firstIndex
@property(readonly) NSUInteger lastIndex
- (NSUInteger)indexLessThanIndex:(NSUInteger)
index
- (NSUInteger)indexLessThanOrEqualToIndex:(NSUInteger)
index
- (NSUInteger)indexGreaterThanOrEqualToIndex:(NSUInteger)
index
- (NSUInteger)indexGreaterThanIndex:(NSUInteger)
index
- (NSUInteger)getIndexes:(NSUInteger *)
indexBuffer
maxCount:(NSUInteger)bufferSize
inIndexRange:(NSRangePointer)indexRange
迭代Indexes
- (void)enumerateIndexesUsingBlock:(void (^)(NSUInteger idx, BOOL *stop))
block
- (void)enumerateIndexesWithOptions:(NSEnumerationOptions)
opts
usingBlock:(void (^)(NSUIntegeridx, BOOL *stop))block
- (void)enumerateIndexesInRange:(NSRange)
range
options:(NSEnumerationOptions)opts
usingBlock:(void (^)(NSUIntegeridx, BOOL *stop))block
API列表如上 代码有空贴