Skip to content

Commit acfadfb

Browse files
committed
---
yaml --- r: 50588 b: refs/heads/try c: 86cf248 h: refs/heads/master v: v3
1 parent de78526 commit acfadfb

File tree

3 files changed

+46
-58
lines changed

3 files changed

+46
-58
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: d55225f04a459c574d9533dcc4c06f953fa8fce5
5+
refs/heads/try: 86cf2482624b89150615313662d2e823cdcaa31d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/cell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use prelude::*;
1515
///
1616
/// Similar to a mutable option type, but friendlier.
1717
18+
#[deriving_eq]
1819
pub struct Cell<T> {
1920
mut value: Option<T>
2021
}

branches/try/src/libstd/treemap.rs

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,21 @@ pure fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
7777

7878
impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
7979
#[inline(always)]
80-
pure fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
80+
pure fn lt(&self, other: &TreeMap<K, V>) -> bool {
81+
lt(self, other)
82+
}
8183
#[inline(always)]
82-
pure fn le(&self, other: &TreeMap<K, V>) -> bool { !lt(other, self) }
84+
pure fn le(&self, other: &TreeMap<K, V>) -> bool {
85+
!lt(other, self)
86+
}
8387
#[inline(always)]
84-
pure fn ge(&self, other: &TreeMap<K, V>) -> bool { !lt(self, other) }
88+
pure fn ge(&self, other: &TreeMap<K, V>) -> bool {
89+
!lt(self, other)
90+
}
8591
#[inline(always)]
86-
pure fn gt(&self, other: &TreeMap<K, V>) -> bool { lt(other, self) }
92+
pure fn gt(&self, other: &TreeMap<K, V>) -> bool {
93+
lt(other, self)
94+
}
8795
}
8896

8997
impl<'self, K: TotalOrd, V> BaseIter<(&'self K, &'self V)> for TreeMap<K, V> {
@@ -141,9 +149,9 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
141149
match *current {
142150
Some(ref r) => {
143151
match key.cmp(&r.key) {
144-
Less => current = &r.left,
145-
Greater => current = &r.right,
146-
Equal => return Some(&r.value)
152+
Less => current = &r.left,
153+
Greater => current = &r.right,
154+
Equal => return Some(&r.value)
147155
}
148156
}
149157
None => return None
@@ -236,24 +244,19 @@ pub struct TreeSet<T> {
236244

237245
impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
238246
/// Visit all values in order
239-
#[inline(always)]
240247
pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) }
241-
#[inline(always)]
242248
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
243249
}
244250

245251
impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> {
246252
/// Visit all values in reverse order
247-
#[inline(always)]
248253
pure fn each_reverse(&self, f: &fn(&T) -> bool) {
249254
self.map.each_key_reverse(f)
250255
}
251256
}
252257

253258
impl<T: Eq + TotalOrd> Eq for TreeSet<T> {
254-
#[inline(always)]
255259
pure fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
256-
#[inline(always)]
257260
pure fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
258261
}
259262

@@ -270,35 +273,29 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
270273

271274
impl<T: TotalOrd> Container for TreeSet<T> {
272275
/// Return the number of elements in the set
273-
#[inline(always)]
274276
pure fn len(&self) -> uint { self.map.len() }
275277

276278
/// Return true if the set contains no elements
277-
#[inline(always)]
278279
pure fn is_empty(&self) -> bool { self.map.is_empty() }
279280
}
280281

281282
impl<T: TotalOrd> Mutable for TreeSet<T> {
282283
/// Clear the set, removing all values.
283-
#[inline(always)]
284284
fn clear(&mut self) { self.map.clear() }
285285
}
286286

287287
impl<T: TotalOrd> Set<T> for TreeSet<T> {
288288
/// Return true if the set contains a value
289-
#[inline(always)]
290289
pure fn contains(&self, value: &T) -> bool {
291290
self.map.contains_key(value)
292291
}
293292

294293
/// Add a value to the set. Return true if the value was not already
295294
/// present in the set.
296-
#[inline(always)]
297295
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
298296

299297
/// Remove a value from the set. Return true if the value was
300298
/// present in the set.
301-
#[inline(always)]
302299
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
303300

304301
/// Return true if the set has no elements in common with `other`.
@@ -323,7 +320,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
323320
}
324321

325322
/// Return true if the set is a subset of another
326-
#[inline(always)]
327323
pure fn is_subset(&self, other: &TreeSet<T>) -> bool {
328324
other.is_superset(self)
329325
}
@@ -492,12 +488,10 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
492488

493489
pub impl <T: TotalOrd> TreeSet<T> {
494490
/// Create an empty TreeSet
495-
#[inline(always)]
496491
static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
497492

498493
/// Get a lazy iterator over the values in the set.
499494
/// Requires that it be frozen (immutable).
500-
#[inline(always)]
501495
pure fn iter(&self) -> TreeSetIterator/&self<T> {
502496
TreeSetIterator{iter: self.map.iter()}
503497
}
@@ -510,15 +504,13 @@ pub struct TreeSetIterator<T> {
510504

511505
/// Advance the iterator to the next node (in order). If this iterator is
512506
/// finished, does nothing.
513-
#[inline(always)]
514507
pub fn set_next<T>(iter: &mut TreeSetIterator/&r<T>) -> Option<&r/T> {
515508
do map_next(&mut iter.iter).map |&(value, _)| { value }
516509
}
517510

518511
/// Advance the iterator through the set
519-
#[inline(always)]
520-
pub fn set_advance<T>(iter: &mut TreeSetIterator/&r<T>,
521-
f: &fn(&r/T) -> bool) {
512+
fn set_advance<T>(iter: &mut TreeSetIterator/&r<T>,
513+
f: &fn(&r/T) -> bool) {
522514
do map_advance(&mut iter.iter) |(k, _)| { f(k) }
523515
}
524516

@@ -540,15 +532,15 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> {
540532
}
541533

542534
pure fn each<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
543-
f: &fn(&(&r/K, &r/V)) -> bool) {
535+
f: &fn(&(&r/K, &r/V)) -> bool) {
544536
for node.each |x| {
545537
each(&x.left, f);
546538
if f(&(&x.key, &x.value)) { each(&x.right, f) }
547539
}
548540
}
549541

550542
pure fn each_reverse<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
551-
f: &fn(&(&r/K, &r/V)) -> bool) {
543+
f: &fn(&(&r/K, &r/V)) -> bool) {
552544
for node.each |x| {
553545
each_reverse(&x.right, f);
554546
if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) }
@@ -673,20 +665,20 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
673665
skew(save);
674666

675667
match save.right {
676-
Some(ref mut right) => {
677-
skew(right);
678-
match right.right {
679-
Some(ref mut x) => { skew(x) },
680-
None => ()
668+
Some(ref mut right) => {
669+
skew(right);
670+
match right.right {
671+
Some(ref mut x) => { skew(x) },
672+
None => ()
673+
}
681674
}
682-
}
683-
None => ()
675+
None => ()
684676
}
685677

686678
split(save);
687679
match save.right {
688-
Some(ref mut x) => { split(x) },
689-
None => ()
680+
Some(ref mut x) => { split(x) },
681+
None => ()
690682
}
691683
}
692684

@@ -1141,30 +1133,25 @@ mod test_set {
11411133

11421134
#[test]
11431135
fn test_difference() {
1144-
fn check_difference(a: &[int], b: &[int], expected: &[int]) {
1145-
let mut set_a = TreeSet::new();
1146-
let mut set_b = TreeSet::new();
1136+
let mut a = TreeSet::new();
1137+
let mut b = TreeSet::new();
11471138

1148-
for a.each |x| { fail_unless!(set_a.insert(*x)) }
1149-
for b.each |y| { fail_unless!(set_b.insert(*y)) }
1139+
fail_unless!(a.insert(1));
1140+
fail_unless!(a.insert(3));
1141+
fail_unless!(a.insert(5));
1142+
fail_unless!(a.insert(9));
1143+
fail_unless!(a.insert(11));
11501144

1151-
let mut i = 0;
1152-
for set_a.difference(&set_b) |x| {
1153-
fail_unless!(*x == expected[i]);
1154-
i += 1;
1155-
}
1156-
fail_unless!(i == expected.len());
1157-
}
1145+
fail_unless!(b.insert(3));
1146+
fail_unless!(b.insert(9));
11581147

1159-
check_difference([], [], []);
1160-
check_difference([1, 12], [], [1, 12]);
1161-
check_difference([], [1, 2, 3, 9], []);
1162-
check_difference([1, 3, 5, 9, 11],
1163-
[3, 9],
1164-
[1, 5, 11]);
1165-
check_difference([-5, 11, 22, 33, 40, 42],
1166-
[-12, -5, 14, 23, 34, 38, 39, 50],
1167-
[11, 22, 33, 40, 42]);
1148+
let mut i = 0;
1149+
let expected = [1, 5, 11];
1150+
for a.difference(&b) |x| {
1151+
fail_unless!(*x == expected[i]);
1152+
i += 1
1153+
}
1154+
fail_unless!(i == expected.len());
11681155
}
11691156

11701157
#[test]

0 commit comments

Comments
 (0)