2004-02-24 21:23:53 +00:00
|
|
|
/** Interface for NSIndexSet, NSMutableIndexSet for GNUStep
|
|
|
|
Copyright (C) 2004 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
Created: Feb 2004
|
2012-03-27 17:05:19 +00:00
|
|
|
|
2004-02-24 21:23:53 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2004-02-24 21:23:53 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2012-03-27 17:05:19 +00:00
|
|
|
|
2004-02-24 21:23:53 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
2012-03-27 17:05:19 +00:00
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2004-02-24 21:23:53 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
AutogsdocSource: NSIndexSet.m
|
|
|
|
|
2012-03-27 17:05:19 +00:00
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
#ifndef _NSIndexSet_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define _NSIndexSet_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2012-03-27 17:05:19 +00:00
|
|
|
#import <GNUstepBase/GSBlocks.h>
|
2004-02-24 21:23:53 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2004-02-24 21:23:53 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <Foundation/NSRange.h>
|
2004-02-24 21:23:53 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-02-24 21:23:53 +00:00
|
|
|
/**
|
|
|
|
* Instances of this class are collections of unsigned integers in the
|
|
|
|
* range 0 to NSNotFound-1.<br />
|
|
|
|
* Each integer can appear in a collection only once.
|
|
|
|
*/
|
|
|
|
@interface NSIndexSet : NSObject <NSCopying, NSMutableCopying, NSCoding>
|
|
|
|
{
|
2010-02-14 10:48:10 +00:00
|
|
|
#if GS_EXPOSE(NSIndexSet)
|
2004-02-24 21:23:53 +00:00
|
|
|
void *_data;
|
2010-02-14 10:48:10 +00:00
|
|
|
#endif
|
2004-02-24 21:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an empty set.
|
|
|
|
*/
|
|
|
|
+ (id) indexSet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a set containing the single value anIndex, or returns nil if
|
|
|
|
* anIndex is NSNotFound.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
+ (id) indexSetWithIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a set containing all the values in aRange, or returns nil if
|
|
|
|
* aRange contains NSNotFound.
|
|
|
|
*/
|
|
|
|
+ (id) indexSetWithIndexesInRange: (NSRange)aRange;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver contains anIndex, NO otherwise.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (BOOL) containsIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver contains all the index values present
|
|
|
|
* in aSet, NO otherwise.
|
|
|
|
*/
|
|
|
|
- (BOOL) containsIndexes: (NSIndexSet*)aSet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver contains all the index values present
|
|
|
|
* in aRange, NO otherwise.
|
|
|
|
*/
|
|
|
|
- (BOOL) containsIndexesInRange: (NSRange)aRange;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of index values present in the receiver.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) count;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
2008-06-06 13:57:06 +00:00
|
|
|
/** Not implemented
|
|
|
|
* Returns the number of indexes set within the specified range.
|
|
|
|
*/
|
|
|
|
- (NSUInteger) countOfIndexesInRange: (NSRange)range;
|
|
|
|
#endif
|
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST)
|
2012-03-27 17:05:19 +00:00
|
|
|
DEFINE_BLOCK_TYPE(GSIndexSetEnumerationBlock, void, NSUInteger, BOOL*);
|
2015-08-28 09:21:45 +00:00
|
|
|
- (void) enumerateIndexesInRange: (NSRange)range
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSIndexSetEnumerationBlock)aBlock;
|
2012-03-27 17:05:19 +00:00
|
|
|
/**
|
|
|
|
* Enumerate all indices in the set by applying a block to them.
|
|
|
|
*/
|
2015-08-28 09:21:45 +00:00
|
|
|
- (void) enumerateIndexesUsingBlock: (GSIndexSetEnumerationBlock)aBlock;
|
2012-03-27 17:05:19 +00:00
|
|
|
|
2015-08-28 09:21:45 +00:00
|
|
|
- (void) enumerateIndexesWithOptions: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSIndexSetEnumerationBlock)aBlock;
|
2012-03-27 17:05:19 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-02-24 21:23:53 +00:00
|
|
|
/**
|
|
|
|
* Returns the first index value in the receiver or NSNotFound if the
|
|
|
|
* receiver is empty.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) firstIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies index values into aBuffer until there are no index values left or
|
|
|
|
* aBuffer is full (assuming that the size of aBuffer is given by aCount).<br />
|
|
|
|
* Only copies index values present in aRange and copies them in order.<br />
|
2005-11-06 13:53:40 +00:00
|
|
|
* Returns the number of index values placed in aBuffer.<br />
|
2004-02-24 21:23:53 +00:00
|
|
|
* Modifies aRange to start after the last index value copied.<br />
|
2004-08-24 05:20:40 +00:00
|
|
|
* If aRange is a null pointer, this method attempts to get <em>all</em>
|
|
|
|
* index values from the set (and of course no range can be returned in it).
|
2004-02-24 21:23:53 +00:00
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) getIndexes: (NSUInteger*)aBuffer
|
|
|
|
maxCount: (NSUInteger)aCount
|
|
|
|
inIndexRange: (NSRangePointer)aRange;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first index value in the receiver which is greater than
|
|
|
|
* anIndex.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) indexGreaterThanIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first index value in the receiver which is greater than
|
|
|
|
* or equal to anIndex.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) indexGreaterThanOrEqualToIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first index value in the receiver which is less than
|
|
|
|
* anIndex.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) indexLessThanIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first index value in the receiver which is less than
|
|
|
|
* or equal to anIndex.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) indexLessThanOrEqualToIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the receiver to contain anIndex. Returns the initialised
|
|
|
|
* object or nil if anIndex is NSNotFound.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (id) initWithIndex: (NSUInteger)anIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
/** <init />
|
|
|
|
* Initialise the receiver to contain all index values in aRange.
|
|
|
|
* Returns the initialised object or nil if aRange contains NSNotFound.
|
|
|
|
*/
|
|
|
|
- (id) initWithIndexesInRange: (NSRange)aRange;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialises the receiver with the index values from aSet.
|
|
|
|
*/
|
|
|
|
- (id) initWithIndexSet: (NSIndexSet*)aSet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver contains any index values which lie in aRange,
|
|
|
|
* No otherwise.
|
|
|
|
*/
|
|
|
|
- (BOOL) intersectsIndexesInRange: (NSRange)aRange;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests two index sets for equality and returns either YES or NO.
|
|
|
|
*/
|
|
|
|
- (BOOL) isEqualToIndexSet: (NSIndexSet*)aSet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the last index value in the receiver or NSNotFound if the
|
|
|
|
* receiver is empty.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) lastIndex;
|
2004-02-24 21:23:53 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface NSMutableIndexSet : NSIndexSet
|
|
|
|
|
2004-03-18 06:56:12 +00:00
|
|
|
/**
|
|
|
|
* Adds anIndex to the set of indexes stored in the receiver.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (void) addIndex: (NSUInteger)anIndex;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all the indexes from aSet to the set of indexes stored in the receiver.
|
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
- (void) addIndexes: (NSIndexSet*)aSet;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all the indexes in aRange to the set of indexes stored in the receiver.
|
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
- (void) addIndexesInRange: (NSRange)aRange;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all indexes stored in the receiver.
|
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
- (void) removeAllIndexes;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes anIndex from the set of indexes stored in the receiver.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (void) removeIndex: (NSUInteger)anIndex;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all the indexes in aSet from the set of indexes
|
|
|
|
* stored in the receiver.
|
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
- (void) removeIndexes: (NSIndexSet*)aSet;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all the indexes in aRange from the set of indexes
|
|
|
|
* stored in the receiver.
|
|
|
|
*/
|
2004-02-24 21:23:53 +00:00
|
|
|
- (void) removeIndexesInRange: (NSRange)aRange;
|
2004-03-18 06:56:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves all the indexes from anIndex upwards by the amount specified.<br />
|
|
|
|
* If amount is negative, index values below anIndex will be overwritten
|
|
|
|
* by the shifted values.<br />
|
|
|
|
* If amount is positive, a 'hole' will be left in the index range after
|
|
|
|
* anIndex.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
- (void) shiftIndexesStartingAtIndex: (NSUInteger)anIndex
|
2012-03-27 17:05:19 +00:00
|
|
|
by: (NSInteger)amount;
|
2004-02-24 21:23:53 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-02-24 21:23:53 +00:00
|
|
|
#endif
|
|
|
|
#endif
|