bzr branch
http://gegoxaren.bato24.eu/bzr/vqdr/trunk
54
by Gustav Hartvigsson
More work torwards inperementing the parser. |
1 |
/*
|
2 |
* The contects of this file is in the Public Domain.
|
|
3 |
*
|
|
4 |
* Created by Gustav Hartivgsson.
|
|
5 |
*/
|
|
64
by Gustav Hartvigsson
[General] Major refactoring. Utils -> Vee nenaming. |
6 |
|
7 |
namespace Vee { |
|
48
by Gustav Hartvigsson
Woops again. |
8 |
public class RangeIterator { |
9 |
private Range range; |
|
52.1.3
by Gustav Hartvigsson
int -> int32 |
10 |
private int32 current; |
48
by Gustav Hartvigsson
Woops again. |
11 |
public RangeIterator (Range range) { |
12 |
this.range = range; |
|
13 |
this.current = this.range.start; |
|
14 |
} |
|
52.1.3
by Gustav Hartvigsson
int -> int32 |
15 |
public int32 get () { |
48
by Gustav Hartvigsson
Woops again. |
16 |
return this.current; |
17 |
} |
|
18 |
||
19 |
public bool next () { |
|
20 |
if (!this.range.reverse) { |
|
21 |
if (this.current <= this.range.end) { |
|
22 |
this.current++; |
|
23 |
return true; |
|
24 |
} |
|
25 |
} else { |
|
26 |
if (this.current >= this.range.end){ |
|
27 |
this.current--; |
|
28 |
} |
|
29 |
} |
|
30 |
return false; |
|
31 |
} |
|
32 |
||
33 |
public bool has_next () { |
|
34 |
return (this.current < this.range.end); |
|
35 |
} |
|
36 |
} |
|
37 |
||
38 |
public class Range { |
|
39 |
public bool reverse {get; private set;} |
|
52.1.3
by Gustav Hartvigsson
int -> int32 |
40 |
public int32 start {get; private set;} |
41 |
public int32 end {get; private set;} |
|
48
by Gustav Hartvigsson
Woops again. |
42 |
|
52.1.3
by Gustav Hartvigsson
int -> int32 |
43 |
public Range (int32 start, int32 end) { |
48
by Gustav Hartvigsson
Woops again. |
44 |
if (start <= end) { |
45 |
this.reverse = false; |
|
46 |
} else { |
|
47 |
this.reverse = true; |
|
48 |
} |
|
49 |
this.start = start; |
|
50 |
this.end = end; |
|
51 |
} |
|
52 |
||
53 |
public Type element_type () { |
|
54 |
return typeof (int); |
|
55 |
} |
|
56 |
|
|
57 |
public RangeIterator iterator () { |
|
58 |
return new RangeIterator (this); |
|
59 |
} |
|
60 |
} |
|
61 |
}
|