2
2
* A deque, for fun. Untested as of yet. Likely buggy.
3
3
*/
4
4
5
- import std. util ;
5
+ import std. option ;
6
6
import std. _vec ;
7
7
import std. _int ;
8
8
@@ -23,7 +23,7 @@ type t[T] = obj {
23
23
24
24
fn create[ T ] ( ) -> t[ T ] {
25
25
26
- type cell [ T ] = mutable util . option [ T ] ;
26
+ type cell [ T ] = mutable option. t [ T ] ;
27
27
28
28
let uint initial_capacity = 32 u; // 2^5
29
29
@@ -39,7 +39,7 @@ fn create[T]() -> t[T] {
39
39
if ( i < nelts) {
40
40
ret old. ( ( lo + i) % nelts) ;
41
41
} else {
42
- ret util . none [ T ] ;
42
+ ret option . none ;
43
43
}
44
44
}
45
45
@@ -50,7 +50,7 @@ fn create[T]() -> t[T] {
50
50
51
51
fn get[ T ] ( vec[ cell[ T ] ] elts, uint i) -> T {
52
52
alt ( elts. ( i) ) {
53
- case ( util . some [ T ] ( ?t) ) { ret t; }
53
+ case ( option . some [ T ] ( ?t) ) { ret t; }
54
54
case ( _) { fail; }
55
55
}
56
56
}
@@ -77,7 +77,7 @@ fn create[T]() -> t[T] {
77
77
hi = nelts;
78
78
}
79
79
80
- elts. ( lo) = util . some [ T ] ( t) ;
80
+ elts. ( lo) = option . some [ T ] ( t) ;
81
81
nelts += 1 u;
82
82
}
83
83
@@ -88,7 +88,7 @@ fn create[T]() -> t[T] {
88
88
hi = nelts;
89
89
}
90
90
91
- elts. ( hi) = util . some [ T ] ( t) ;
91
+ elts. ( hi) = option . some [ T ] ( t) ;
92
92
hi = ( hi + 1 u) % _vec. len [ cell[ T ] ] ( elts) ;
93
93
nelts += 1 u;
94
94
}
@@ -99,7 +99,7 @@ fn create[T]() -> t[T] {
99
99
*/
100
100
fn pop_front ( ) -> T {
101
101
let T t = get[ T ] ( elts, lo) ;
102
- elts. ( lo) = util . none [ T ] ;
102
+ elts. ( lo) = option . none [ T ] ;
103
103
lo = ( lo + 1 u) % _vec. len [ cell[ T ] ] ( elts) ;
104
104
nelts -= 1 u;
105
105
ret t;
@@ -113,7 +113,7 @@ fn create[T]() -> t[T] {
113
113
}
114
114
115
115
let T t = get[ T ] ( elts, hi) ;
116
- elts. ( hi) = util . none [ T ] ;
116
+ elts. ( hi) = option . none [ T ] ;
117
117
nelts -= 1 u;
118
118
ret t;
119
119
}
@@ -132,7 +132,7 @@ fn create[T]() -> t[T] {
132
132
}
133
133
134
134
}
135
- let vec[ cell[ T ] ] v = _vec. init_elt [ cell[ T ] ] ( util . none [ T ] ,
135
+ let vec[ cell[ T ] ] v = _vec. init_elt [ cell[ T ] ] ( option . none [ T ] ,
136
136
initial_capacity) ;
137
137
138
138
ret deque[ T ] ( 0 u, 0 u, 0 u, v) ;
0 commit comments