forked from paulfitz/daff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexItem.hx
58 lines (51 loc) · 1.01 KB
/
IndexItem.hx
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
// -*- mode:java; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
#if !TOPLEVEL
package coopy;
#end
/**
*
* A list of instances of a given row in a table.
*
*/
class IndexItem {
private var lst : Array<Int>;
public function new() : Void {
}
/**
*
* Add an extra instance to the list.
*
* @param i the row number
* @return the number of instances seen
*
*/
public inline function add(i: Int) : Int {
if (lst==null) lst = new Array<Int>();
lst.push(i);
return lst.length;
}
/**
*
* @return the number of instances seen
*
*/
public inline function length() : Int {
return lst.length;
}
/**
*
* @return the row number of the first instance seen
*
*/
public inline function value() : Int {
return lst[0];
}
/**
*
* @return the full list of rows seen
*
*/
public inline function asList() : Array<Int> {
return lst;
}
}