Skip to content

Commit 88287c3

Browse files
committed
---
yaml --- r: 3753 b: refs/heads/master c: ccfbb74 h: refs/heads/master i: 3751: a8ce7f1 v: v3
1 parent b55071b commit 88287c3

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 8450ab9a2b2cafa9ef4fa624b1843b46a7b41a26
2+
refs/heads/master: ccfbb74f112c66db0eab8471efbdc689234c0f51

trunk/src/lib/map.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
2323

2424
let util::rational load_factor = rec(num=3, den=4);
2525
tag bucket[K, V] { nil; deleted; some(K, V); }
26-
fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
27-
ret vec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
26+
fn make_buckets[K, V](uint nbkts) -> (bucket[K, V])[mutable] {
27+
ret ivec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
2828
}
2929
// Derive two hash functions from the one given by taking the upper
3030
// half and lower half of the uint bits. Our bucket probing
@@ -52,7 +52,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
5252

5353
fn insert_common[K,
5454
V](&hashfn[K] hasher, &eqfn[K] eqer,
55-
vec[mutable bucket[K, V]] bkts, uint nbkts, &K key,
55+
&(bucket[K, V])[mutable] bkts, uint nbkts, &K key,
5656
&V val) -> bool {
5757
let uint i = 0u;
5858
let uint h = hasher(key);
@@ -77,7 +77,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
7777
}
7878
fn find_common[K,
7979
V](&hashfn[K] hasher, &eqfn[K] eqer,
80-
vec[mutable bucket[K, V]] bkts, uint nbkts, &K key) ->
80+
&(bucket[K, V])[mutable] bkts, uint nbkts, &K key) ->
8181
option::t[V] {
8282
let uint i = 0u;
8383
let uint h = hasher(key);
@@ -100,8 +100,8 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
100100
}
101101
fn rehash[K,
102102
V](&hashfn[K] hasher, &eqfn[K] eqer,
103-
vec[mutable bucket[K, V]] oldbkts, uint noldbkts,
104-
vec[mutable bucket[K, V]] newbkts, uint nnewbkts) {
103+
&(bucket[K, V])[mutable] oldbkts, uint noldbkts,
104+
&(bucket[K, V])[mutable] newbkts, uint nnewbkts) {
105105
for (bucket[K, V] b in oldbkts) {
106106
alt (b) {
107107
case (some(?k_, ?v_)) {
@@ -117,7 +117,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
117117
obj hashmap[K,
118118
V](hashfn[K] hasher,
119119
eqfn[K] eqer,
120-
mutable vec[mutable bucket[K, V]] bkts,
120+
mutable (bucket[K, V])[mutable] bkts,
121121
mutable uint nbkts,
122122
mutable uint nelts,
123123
util::rational lf) {
@@ -127,8 +127,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
127127
rec(num=nelts + 1u as int, den=nbkts as int);
128128
if (!util::rational_leq(load, lf)) {
129129
let uint nnewbkts = uint::next_power_of_two(nbkts + 1u);
130-
let vec[mutable bucket[K, V]] newbkts =
131-
make_buckets[K, V](nnewbkts);
130+
auto newbkts = make_buckets[K, V](nnewbkts);
132131
rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nnewbkts);
133132
bkts = newbkts;
134133
nbkts = nnewbkts;
@@ -177,7 +176,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
177176
ret option::none[V];
178177
}
179178
fn rehash() {
180-
let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nbkts);
179+
auto newbkts = make_buckets[K, V](nbkts);
181180
rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nbkts);
182181
bkts = newbkts;
183182
}
@@ -190,7 +189,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
190189
}
191190
}
192191
}
193-
let vec[mutable bucket[K, V]] bkts = make_buckets[K, V](initial_capacity);
192+
auto bkts = make_buckets[K, V](initial_capacity);
194193
ret hashmap[K, V](hasher, eqer, bkts, initial_capacity, 0u, load_factor);
195194
}
196195

0 commit comments

Comments
 (0)