Title: Theory / Important / CS / Programming / Objective-C / Library / NS / Collection / IndexSet
On every note of this deck, unless a note says otherwise:
Page: https://developer.apple.com/documentation/foundation/nsmutablearray?language=objc
Language: Objective-C

Typ: NSIndexSet
Meaning: An immutable collection of unique integer values that represent indexes in another collection.
Page: https://developer.apple.com/documentation/foundation/nsindexset?language=objc
Language: Objective-C

Typ: NSMutableIndexSet
Meaning: A mutable collection of unique integer values that represent indexes in another collection.
Page: https://developer.apple.com/documentation/foundation/nsmutablearray?language=objc
Language: Objective-C

Question: What is the difference between IndexSet and general set of ints
Answer: IndexSet is optimized for ranges of indices
Page: https://developer.apple.com/documentation/foundation/nsmutablearray?language=objc
Context: Objective-C

Instruction: [indexSet
  addIndex:value
]
Effect: Add value to the indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  addIndexes:other
]
Effect: Add content of other to this indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  addIndexesInRange:range
]
Effect: Add content of range to this indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  removeIndex:value
]
Effect: Remove value from indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  removeIndexes:other
]
Effect: Remove indices of other from indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  removeAllIndexes
]
Effect: Remove all indexes from indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  removeIndexesInRange:range
]
Effect: Remove all indexes from range from indexSet
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  shiftIndexesStartingAtIndex:startIndex
  by:delta
]
Effect: Add delta to all indexes starting at startIndex
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  containsIndex:value
]
Returns: Whether indexSet contains value
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  containsIndexex:other
]
Returns: Whether indexSet is a superset of other
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  containsIndexesInRange:range
]
Returns: Whether indexSet is a superset of range
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  intersectsIndexesInRange:range
]
Returns: Whether indexSet intersects range
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  count
]
Returns: The number of indexes in the index set
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  countOfIndexesInRange:range
]
Returns: The cardinal of indexSet and range
Variables: NSMutableIndexSet indexSet

Instruction: [indexSet
  indexPassingTest:predicate
]
Returns: Index of the first object that passes predicate
Variables: NSIndexSet indexSet

Instruction: [indexSet
  indexesPassingTest:predicate
]
Returns: the index set of indexes satisfying predicate
Variables: NSIndexSet indexSet

Instruction: [indexSet
  enumerateRangesUsingBlock:block
]
Effect: Executes a given block using each object in the index set, in the specified ranges.
Variables: NSIndexSet indexSet

Instruction: [indexSet
  isEqualToIndexSet:other
]
Effect: Whether indexSet equals other
Variables: NSIndexSet indexSet

Instruction: [indexSet
  firstIndex
]
Returns: First index in the set, or NSNotFound for empty set
Variables: NSIndexSet indexSet

Instruction: [indexSet
  lastIndex
]
Returns: Last index in the set, or NSNotFound for empty set
Variables: NSIndexSet indexSet

Instruction: [indexSet
  index(Less|Greater)Than(|OrEqualTo)Index:value
]
Returns: either the closest index in the index set that is (less|greater) than (| or equal to) value or the not-found indicator.
Variables: NSIndexSet indexSet

Instruction: [indexSet
  getIndexes:indexBuffer
  maxCount:bufferSize
  inIndexRange:rangePointer
]
Effect: Take at most bufferSize elements from (indexBuffer intersects range) and move them from range to indexBuffer
Returns: Number of indexes added to the buffer
Variables: NSIndexSet indexSet
Intuition: Calling this loop many time with the same indexSet and range pointer will ensure that the buffer will eventualy have contained all of the indexes of the indexSet

Instruction: [indexSet
  enumerateIndexesUsingBlock:block
]
Effect: Executes block using each object in the index set.
Variables: NSIndexSet indexSet

Instruction: [indexSet
  enumerateIndexesInRangeUsingBlock:block
]
Effect: Executes block using each object in (index set intersection range).
Variables: NSIndexSet indexSet

Instruction: [NSIndexSet indexSet]
[[NSIndexSet alloc] init]
Returns: An index set with no members
Variables: NSIndexSet indexSet

Instruction: [NSIndexSet
  indexSetWithIndex:value
]
[[NSIndexSet alloc]
  initWithIndex:value
]
Returns: An index set with singleton {value}
Variables: NSIndexSet indexSet

Instruction: [NSIndexSet
  indexSetWithIndexInRange:range
]
[[NSIndexSet alloc]
  initWithIndexInRange:range
]
Returns: An index set with range
Variables: NSIndexSet indexSet

Instruction: [[NSIndexSet alloc]
  initWithIndexSet:indexSet
]
Returns: a new index set with same content as indexSet
Variables: NSIndexSet indexSet