@@ -12,24 +12,24 @@ use map::map;
12
12
13
13
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
14
14
// requires this to be.
15
- type smallintmap_ < T : copy > = { v : DVec < Option < T > > } ;
15
+ type SmallIntMap_ < T : copy > = { v : DVec < Option < T > > } ;
16
16
17
- enum smallintmap < T : copy > {
18
- smallintmap_ ( @ smallintmap_ < T > )
17
+ enum SmallIntMap < T : copy > {
18
+ SmallIntMap_ ( @ SmallIntMap_ < T > )
19
19
}
20
20
21
21
/// Create a smallintmap
22
- fn mk < T : copy > ( ) -> smallintmap < T > {
22
+ fn mk < T : copy > ( ) -> SmallIntMap < T > {
23
23
let v = DVec ( ) ;
24
- return smallintmap_ ( @{ v: v} ) ;
24
+ return SmallIntMap_ ( @{ v: v} ) ;
25
25
}
26
26
27
27
/**
28
28
* Add a value to the map. If the map already contains a value for
29
29
* the specified key then the original value is replaced.
30
30
*/
31
31
#[ inline( always) ]
32
- fn insert < T : copy > ( self : smallintmap < T > , key : uint , +val : T ) {
32
+ fn insert < T : copy > ( self : SmallIntMap < T > , key : uint , +val : T ) {
33
33
//io::println(fmt!("%?", key));
34
34
self . v . grow_set_elt ( key, None , Some ( val) ) ;
35
35
}
@@ -38,7 +38,7 @@ fn insert<T: copy>(self: smallintmap<T>, key: uint, +val: T) {
38
38
* Get the value for the specified key. If the key does not exist
39
39
* in the map then returns none
40
40
*/
41
- pure fn find < T : copy > ( self : smallintmap < T > , key : uint ) -> Option < T > {
41
+ pure fn find < T : copy > ( self : SmallIntMap < T > , key : uint ) -> Option < T > {
42
42
if key < self . v . len ( ) { return self . v . get_elt ( key) ; }
43
43
return None :: < T > ;
44
44
}
@@ -50,7 +50,7 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> Option<T> {
50
50
*
51
51
* If the key does not exist in the map
52
52
*/
53
- pure fn get < T : copy > ( self : smallintmap < T > , key : uint ) -> T {
53
+ pure fn get < T : copy > ( self : SmallIntMap < T > , key : uint ) -> T {
54
54
match find ( self , key) {
55
55
None => {
56
56
error ! ( "smallintmap::get(): key not present" ) ;
@@ -61,12 +61,12 @@ pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
61
61
}
62
62
63
63
/// Returns true if the map contains a value for the specified key
64
- fn contains_key < T : copy > ( self : smallintmap < T > , key : uint ) -> bool {
64
+ fn contains_key < T : copy > ( self : SmallIntMap < T > , key : uint ) -> bool {
65
65
return !option:: is_none ( find ( self , key) ) ;
66
66
}
67
67
68
68
/// Implements the map::map interface for smallintmap
69
- impl < V : copy > smallintmap < V > : map:: map < uint , V > {
69
+ impl < V : copy > SmallIntMap < V > : map:: map < uint , V > {
70
70
pure fn size ( ) -> uint {
71
71
let mut sz = 0 u;
72
72
for self . v. each |item| {
@@ -137,7 +137,7 @@ impl<V: copy> smallintmap<V>: map::map<uint, V> {
137
137
}
138
138
}
139
139
140
- impl < V : copy > smallintmap < V > : ops:: Index < uint , V > {
140
+ impl < V : copy > SmallIntMap < V > : ops:: Index < uint , V > {
141
141
pure fn index ( & & key: uint ) -> V {
142
142
unchecked {
143
143
get( self , key)
@@ -146,6 +146,6 @@ impl<V: copy> smallintmap<V>: ops::Index<uint, V> {
146
146
}
147
147
148
148
/// Cast the given smallintmap to a map::map
149
- fn as_map < V : copy > ( s : smallintmap < V > ) -> map:: map < uint , V > {
149
+ fn as_map < V : copy > ( s : SmallIntMap < V > ) -> map:: map < uint , V > {
150
150
s as map:: map:: < uint , V >
151
151
}
0 commit comments