/
DTRangesArray.h
74 lines (58 loc) · 1.44 KB
/
DTRangesArray.h
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
//
// DTRangeDictionary.h
// DTMarkdownParser
//
// Created by Oliver Drobnik on 01/11/13.
// Copyright (c) 2013 Cocoanetics. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
A specialized lookup table to find locations in ranges
*/
@interface DTRangesArray : NSObject
/**
@name Modifying the Ranges Array
*/
/**
Adds a range as the last entry
@param range The range to add
*/
- (void)addRange:(NSRange)range;
/**
@name Enumerating Ranges
*/
/**
Enumerates all ranges stored by the receiver
@param block The block to execute for each line range
*/
- (void)enumerateLineRangesUsingBlock:(void(^)(NSRange range, NSUInteger idx, BOOL *stop))block;
/**
@name Getting Information
*/
/**
The number of ranges stored by the receiver
@returns The count
*/
- (NSUInteger)count;
/**
@name Finding Ranges
*/
/**
Returns the range at the given index
@param index The index to query
@returns The range
*/
- (NSRange)rangeAtIndex:(NSUInteger)index;
/**
Returns the index of the range containing the given location
@param location The location to search for in the ranges
@returns The index or `NSNotFound` if it is not found
*/
- (NSUInteger)indexOfRangeContainingLocation:(NSUInteger)location;
/**
Returns the range containing a given location
@param location The location to search for in the ranges
@returns The range or `{NSNotFound, 0}` if not found
*/
- (NSRange)rangeContainingLocation:(NSUInteger)location;
@end