Skip to content

Commit 78f51cc

Browse files
committed
---
yaml --- r: 40526 b: refs/heads/dist-snap c: 5c0206a h: refs/heads/master v: v3
1 parent fefd7dc commit 78f51cc

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: ff4075e553ccc5be73c05332f15ef46f761b0817
10+
refs/heads/dist-snap: 5c0206a1e4e5049a4a5d35ea6fee10cbd3f45aa0
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libstd/map.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
3535
* If the map contains a value for the key, use the function
3636
* to set a new value.
3737
*/
38-
fn insert_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool;
38+
fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool;
3939

4040
/**
4141
* Add a value to the map.
4242
*
43-
* If the map contains a value for the key, use the function
44-
* to set a new value. (Like insert_with_key, but with a function
45-
* of only values.)
43+
* If the map contains a value for the key, use the function to
44+
* set a new value. (Like `insert_or_update_with_key`, but with a
45+
* function of only values.)
4646
*/
47-
fn insert_with(key: K, newval: V, ff: fn(V, V) -> V) -> bool;
47+
fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool;
4848

4949
/// Returns true if the map contains a value for the specified key
5050
pure fn contains_key(key: K) -> bool;
@@ -281,7 +281,7 @@ pub mod chained {
281281
}
282282
}
283283

284-
fn insert_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool {
284+
fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool {
285285
/*
286286
match self.find(key) {
287287
None => return self.insert(key, val),
@@ -330,8 +330,8 @@ pub mod chained {
330330
}
331331
}
332332

333-
fn insert_with(key: K, newval: V, ff: fn(V, V) -> V) -> bool {
334-
return self.insert_with_key(key, newval, |_k, v, v1| ff(v,v1));
333+
fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool {
334+
return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1));
335335
}
336336

337337
pure fn get(k: K) -> V {
@@ -517,15 +517,15 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
517517
}
518518
}
519519

520-
fn insert_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool {
520+
fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool {
521521
match self.find(key) {
522522
None => return self.insert(key, newval),
523523
Some(copy orig) => return self.insert(key, ff(key, orig, newval))
524524
}
525525
}
526526

527-
fn insert_with(key: K, newval: V, ff: fn(V, V) -> V) -> bool {
528-
return self.insert_with_key(key, newval, |_k, v, v1| ff(v,v1));
527+
fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool {
528+
return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1));
529529
}
530530

531531
fn remove(key: K) -> bool {
@@ -833,7 +833,7 @@ mod tests {
833833
}
834834
835835
#[test]
836-
fn test_insert_with_key() {
836+
fn test_update_with_key() {
837837
let map = map::HashMap::<~str, uint>();
838838
839839
// given a new key, initialize it with this new count, given
@@ -848,11 +848,11 @@ mod tests {
848848
849849
// count the number of several types of animal,
850850
// adding in groups as we go
851-
map.insert_with(~"cat", 1, addMoreToCount_simple);
852-
map.insert_with_key(~"mongoose", 1, addMoreToCount);
853-
map.insert_with(~"cat", 7, addMoreToCount_simple);
854-
map.insert_with_key(~"ferret", 3, addMoreToCount);
855-
map.insert_with_key(~"cat", 2, addMoreToCount);
851+
map.update(~"cat", 1, addMoreToCount_simple);
852+
map.update_with_key(~"mongoose", 1, addMoreToCount);
853+
map.update(~"cat", 7, addMoreToCount_simple);
854+
map.update_with_key(~"ferret", 3, addMoreToCount);
855+
map.update_with_key(~"cat", 2, addMoreToCount);
856856

857857
// check the total counts
858858
assert 10 == option::get(map.find(~"cat"));

branches/dist-snap/src/libstd/smallintmap.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
103103
pure fn find(key: uint) -> Option<V> { find(self, key) }
104104
fn rehash() { fail }
105105

106-
fn insert_with_key(key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool {
106+
fn update_with_key(key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool {
107107
match self.find(key) {
108108
None => return self.insert(key, val),
109109
Some(copy orig) => return self.insert(key, ff(key, orig, val)),
110110
}
111111
}
112112

113-
fn insert_with(key: uint, newval: V, ff: fn(V, V) -> V) -> bool {
114-
return self.insert_with_key(key, newval, |_k, v, v1| ff(v,v1));
113+
fn update(key: uint, newval: V, ff: fn(V, V) -> V) -> bool {
114+
return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1));
115115
}
116116

117117
pure fn each(it: fn(key: uint, value: V) -> bool) {
@@ -172,11 +172,11 @@ mod tests {
172172
}
173173

174174
// count integers
175-
map.insert_with(3, 1, addMoreToCount_simple);
176-
map.insert_with_key(9, 1, addMoreToCount);
177-
map.insert_with(3, 7, addMoreToCount_simple);
178-
map.insert_with_key(5, 3, addMoreToCount);
179-
map.insert_with_key(3, 2, addMoreToCount);
175+
map.update(3, 1, addMoreToCount_simple);
176+
map.update_with_key(9, 1, addMoreToCount);
177+
map.update(3, 7, addMoreToCount_simple);
178+
map.update_with_key(5, 3, addMoreToCount);
179+
map.update_with_key(3, 2, addMoreToCount);
180180

181181
// check the total counts
182182
assert 10 == option::get(map.find(3));

0 commit comments

Comments
 (0)