Skip to content

Commit d804703

Browse files
committed
---
yaml --- r: 126919 b: refs/heads/snap-stage3 c: 72e2c7d h: refs/heads/master i: 126917: ee626bd 126915: 09384da 126911: 1fcca2e v: v3
1 parent 64766a3 commit d804703

File tree

26 files changed

+1182
-185
lines changed

26 files changed

+1182
-185
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ef96b54b874b6af417b93f31874a9cf7f4e6c473
4+
refs/heads/snap-stage3: 72e2c7dec34bd87fab6bb15bb7d3d97269d4afd3
55
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcollections/bitv.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use core::cmp;
6767
use core::default::Default;
6868
use core::fmt;
6969
use core::iter::Take;
70+
use core::iter;
7071
use core::ops::Index;
7172
use core::slice;
7273
use core::uint;
@@ -830,6 +831,20 @@ impl Clone for Bitv {
830831
}
831832
}
832833

834+
impl PartialOrd for Bitv {
835+
#[inline]
836+
fn partial_cmp(&self, other: &Bitv) -> Option<Ordering> {
837+
iter::order::partial_cmp(self.iter(), other.iter())
838+
}
839+
}
840+
841+
impl Ord for Bitv {
842+
#[inline]
843+
fn cmp(&self, other: &Bitv) -> Ordering {
844+
iter::order::cmp(self.iter(), other.iter())
845+
}
846+
}
847+
833848
impl fmt::Show for Bitv {
834849
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
835850
for bit in self.iter() {
@@ -955,7 +970,7 @@ impl<'a> RandomAccessIterator<bool> for Bits<'a> {
955970
/// assert!(bv.eq_vec([true, true, false, true,
956971
/// false, false, false, false]));
957972
/// ```
958-
#[deriving(Clone, PartialEq, Eq)]
973+
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
959974
pub struct BitvSet(Bitv);
960975

961976
impl Default for BitvSet {
@@ -2189,6 +2204,37 @@ mod tests {
21892204
assert_eq!(a.capacity(), uint::BITS);
21902205
}
21912206

2207+
#[test]
2208+
fn test_bitv_lt() {
2209+
let mut a = Bitv::with_capacity(5u, false);
2210+
let mut b = Bitv::with_capacity(5u, false);
2211+
2212+
assert!(!(a < b) && !(b < a));
2213+
b.set(2, true);
2214+
assert!(a < b);
2215+
a.set(3, true);
2216+
assert!(a < b);
2217+
a.set(2, true);
2218+
assert!(!(a < b) && b < a);
2219+
b.set(0, true);
2220+
assert!(a < b);
2221+
}
2222+
2223+
#[test]
2224+
fn test_ord() {
2225+
let mut a = Bitv::with_capacity(5u, false);
2226+
let mut b = Bitv::with_capacity(5u, false);
2227+
2228+
assert!(a <= b && a >= b);
2229+
a.set(1, true);
2230+
assert!(a > b && a >= b);
2231+
assert!(b < a && b <= a);
2232+
b.set(1, true);
2233+
b.set(2, true);
2234+
assert!(b > a && b >= a);
2235+
assert!(a < b && a <= b);
2236+
}
2237+
21922238
#[test]
21932239
fn test_bitv_clone() {
21942240
let mut a = BitvSet::new();

branches/snap-stage3/src/libcollections/hash/mod.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,36 @@ macro_rules! impl_hash_tuple(
155155
}
156156
);
157157

158-
($A:ident $($B:ident)*) => (
159-
impl<
160-
S: Writer,
161-
$A: Hash<S> $(, $B: Hash<S>)*
162-
> Hash<S> for ($A, $($B),*) {
158+
( $($name:ident)+) => (
159+
impl<S: Writer, $($name: Hash<S>),*> Hash<S> for ($($name,)*) {
160+
#[allow(uppercase_variables)]
163161
#[inline]
164162
fn hash(&self, state: &mut S) {
165163
match *self {
166-
(ref $A, $(ref $B),*) => {
167-
$A.hash(state);
164+
($(ref $name,)*) => {
168165
$(
169-
$B.hash(state);
166+
$name.hash(state);
170167
)*
171168
}
172169
}
173170
}
174171
}
175-
176-
impl_hash_tuple!($($B)*)
177172
);
178173
)
179174

180-
impl_hash_tuple!(a0 a1 a2 a3 a4 a5 a6 a7)
175+
impl_hash_tuple!()
176+
impl_hash_tuple!(A)
177+
impl_hash_tuple!(A B)
178+
impl_hash_tuple!(A B C)
179+
impl_hash_tuple!(A B C D)
180+
impl_hash_tuple!(A B C D E)
181+
impl_hash_tuple!(A B C D E F)
182+
impl_hash_tuple!(A B C D E F G)
183+
impl_hash_tuple!(A B C D E F G H)
184+
impl_hash_tuple!(A B C D E F G H I)
185+
impl_hash_tuple!(A B C D E F G H I J)
186+
impl_hash_tuple!(A B C D E F G H I J K)
187+
impl_hash_tuple!(A B C D E F G H I J K L)
181188

182189
impl<'a, S: Writer, T: Hash<S>> Hash<S> for &'a [T] {
183190
#[inline]

branches/snap-stage3/src/libcollections/smallintmap.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,20 @@ impl<V:Clone> SmallIntMap<V> {
373373
}
374374
}
375375

376+
impl<V: PartialOrd> PartialOrd for SmallIntMap<V> {
377+
#[inline]
378+
fn partial_cmp(&self, other: &SmallIntMap<V>) -> Option<Ordering> {
379+
iter::order::partial_cmp(self.iter(), other.iter())
380+
}
381+
}
382+
383+
impl<V: Ord> Ord for SmallIntMap<V> {
384+
#[inline]
385+
fn cmp(&self, other: &SmallIntMap<V>) -> Ordering {
386+
iter::order::cmp(self.iter(), other.iter())
387+
}
388+
}
389+
376390
impl<V: fmt::Show> fmt::Show for SmallIntMap<V> {
377391
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
378392
try!(write!(f, "{{"));
@@ -770,6 +784,38 @@ mod test_map {
770784
assert!(a == b);
771785
}
772786

787+
#[test]
788+
fn test_lt() {
789+
let mut a = SmallIntMap::new();
790+
let mut b = SmallIntMap::new();
791+
792+
assert!(!(a < b) && !(b < a));
793+
assert!(b.insert(2u, 5i));
794+
assert!(a < b);
795+
assert!(a.insert(2, 7));
796+
assert!(!(a < b) && b < a);
797+
assert!(b.insert(1, 0));
798+
assert!(b < a);
799+
assert!(a.insert(0, 6));
800+
assert!(a < b);
801+
assert!(a.insert(6, 2));
802+
assert!(a < b && !(b < a));
803+
}
804+
805+
#[test]
806+
fn test_ord() {
807+
let mut a = SmallIntMap::new();
808+
let mut b = SmallIntMap::new();
809+
810+
assert!(a <= b && a >= b);
811+
assert!(a.insert(1u, 1i));
812+
assert!(a > b && a >= b);
813+
assert!(b < a && b <= a);
814+
assert!(b.insert(2, 2));
815+
assert!(b > a && b >= a);
816+
assert!(a < b && a <= b);
817+
}
818+
773819
#[test]
774820
fn test_hash() {
775821
let mut x = SmallIntMap::new();

0 commit comments

Comments
 (0)