aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/utils/MCOIndexSet.h
blob: 3705fa3a3eb2aabd58c795ce07eba1c83bdac313 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
//  MCOIndexSet.h
//  mailcore2
//
//  Created by DINH Viêt Hoà on 3/23/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#ifndef MAILCORE_MCOINDEXSET_H

#define MAILCORE_MCOINDEXSET_H

#import <Foundation/Foundation.h>

#import <MailCore/MCORange.h>

/** similar to NSMutableIndexSet but supports int64_t.  MCORange has a location (uint64_t) and length (uint64_t). */

@interface MCOIndexSet : NSObject <NSCopying, NSCoding>

/** Creates an empty index set.*/
+ (MCOIndexSet *) indexSet;

/** Creates an index set that contains a range of integers.*/
+ (MCOIndexSet *) indexSetWithRange:(MCORange)range;

/** Creates an index set with a single integer.*/
+ (MCOIndexSet *) indexSetWithIndex:(uint64_t)idx;

/** Returns the number of integers in that index set.*/
- (unsigned int) count;

/** Adds an integer to the index set.*/
- (void) addIndex:(uint64_t)idx;

/** Removes an integer from the index set.*/
- (void) removeIndex:(uint64_t)idx;

/** Returns YES if the index set contains the given integer.*/
- (BOOL) containsIndex:(uint64_t)idx;

/** Adds a range of integers to the index set.*/
- (void) addRange:(MCORange)range;

/** Removes a range of integers from the index set.*/
- (void) removeRange:(MCORange)range;

/** Removes all integers that are not in the given range.*/
- (void) intersectsRange:(MCORange)range;

/** Adds all indexes from an other index set to the index set.*/
- (void) addIndexSet:(MCOIndexSet *)indexSet;

/** Remove all indexes from an other index set from the index set.*/
- (void) removeIndexSet:(MCOIndexSet *)indexSet;

/** Removes all integers that are not in the given index set.*/
- (void) intersectsIndexSet:(MCOIndexSet *)indexSet;

/** Returns all the ranges of ths index set.*/
- (MCORange *) allRanges;

/** Returns the number of ranges in this index set.*/
- (unsigned int) rangesCount;

/** Enumerates all the indexes of the index set.*/
- (void) enumerateIndexes:(void (^)(uint64_t idx))block;

/** Returns an NSIndexSet from a MCOIndexSet */
- (NSIndexSet *) nsIndexSet;

@end

#endif