//
// NSIndexPath+MPRemoveFirstIndex.h
// MathPad
//
// Created by Kim Wittenburg on 23.04.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
/*!
@header
This file contains the NSIndexPath(MPAdditions) category.
*/
/*!
@category NSIndexPath (MPAdditions)
@abstract This category adds some methods for working with index paths to
the NSIndexPath class.
*/
@interface NSIndexPath (MPAdditions)
/*!
@property firstIndex
@abstract The first index from the receiver.
@discussion If the receiver is empty NSNotFound is returned.
*/
@property (readonly, nonatomic) NSUInteger firstIndex;
/*!
@property lastIndex
@abstract The last index from the receiver.
@discussion If the receiver is empty NSNotFound is returned.
*/
@property (readonly, nonatomic) NSUInteger lastIndex;
/*!
@method indexPathByReplacingLastIndexWithIndex:
@abstract Provides an index path with the indexes of the receiver where the
last one is replaced by anIndex.
@discussion If the receiver is empty an index path of length 1
is returned. The last index in the returned index path is
anIndex.
@param anIndex
The index with which to replace the last index in the receiving
index path.
@return A new index path with anIndex as its last index.
*/
- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)anIndex;
/*!
@method indexPathByRemovingFirstIndex
@abstract Provides an index path with the indexes in the receiving index
path, excluding the first one.
@discussion Returns an empty NSIndexPath instance if the receiving index
path’s length is 1 or less.
@return A new index path with the receiving index path’s indexes,
excluding the first one.
*/
- (NSIndexPath *)indexPathByRemovingFirstIndex;
/*!
@method indexPathByPreceedingIndex:
@abstract Provides an index path with the specified index followed by the
indexes of the receiver.
@discussion If the receiver does not contain any indexes the specified index
is the only index contained in the returned index path.
@param anIndex
The index new index preceeding all others
@return A new index path with all the receiver's indexes preceeded by
anIndex
*/
- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)anIndex;
/*!
@method indexPathByIncrementingLastIndex
@abstract Provides an index path with the indexes in the receiving index
path where the last one is incremented by 1.
@discussion If the receiver does not contain any indexes an empty index path
is returned.
@return A new index path with all the receiver's indexes and the last one
incremented by 1.
*/
- (NSIndexPath *)indexPathByIncrementingLastIndex;
/*!
@method indexPathByDecrementingLastIndex
@abstract Provides an index path with the indexes in the receiving index
path where the last one is decremented by 1.
@discussion If the receiver does not contain any indexes an empty index path
is returned.
@return A new index path with all the receiver's indexes and the last one
decremented by 1.
*/
- (NSIndexPath *)indexPathByDecrementingLastIndex;
/*!
@method indexPathByRemovingIndexesFrom:
@abstract Provides an index path with the indexes in the recieving index
path up to the index at the specified position.
@discussion If from is greater or equal to the number of indexes
in the receiving index path only the indexes to the end of the
receiver are removed.
@param from
The position of the first index to be excluded in the returned
index path.
@return An index path with all indexes from the receiver up to position
from.
*/
- (NSIndexPath *)indexPathByRemovingIndexesFrom:(NSUInteger)from;
/*!
@method indexPathByRemovingIndexesTo:
@abstract Provides an index path with the indexes in the receiving index
path where the first indexes are removed.
@discussion to specifies the number of indexes to be removed
from the front. Thus the index at position to will
be included in the returned index path.
@param to
The number of indexes to remove from the front.
@return A new index path with all the receiver's indexes exept the first
to ones.
*/
- (NSIndexPath *)indexPathByRemovingIndexesTo:(NSUInteger)to;
/*!
@method commonIndexPathWith:
@abstract Provides an index path that contains the first indexes of the
receiver that are equal to the specified index path.
@discussion If one index path is completely included in the other a new index
path is returned that is equal to the contained index path.
@param indexPath
The index path to compare the receiver against.
@return A new index path with the first indexes of the receiver that are
also present in indexPath.
*/
- (NSIndexPath *)commonIndexPathWith:(NSIndexPath *)indexPath;
@end