Skip to content

Commit eeefa3d

Browse files
committed
---
yaml --- r: 153838 b: refs/heads/try2 c: f4ef36e h: refs/heads/master v: v3
1 parent 8ac57cf commit eeefa3d

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c6b992a53f6a9f3eee0883640adc270910dc9d87
8+
refs/heads/try2: f4ef36ee4269644ca97907a06c924b5d8be36b89
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ differently.
118118
## Container iterators
119119

120120
Containers implement iteration over the contained elements by returning an
121-
iterator object. For example, vector slices several iterators available:
121+
iterator object. For example, for vector slices several iterators are available:
122122

123123
* `iter()` for immutable references to the elements
124124
* `mut_iter()` for mutable references to the elements

branches/try2/src/libcollections/ringbuf.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use core::cmp;
1919
use core::default::Default;
2020
use core::fmt;
2121
use core::iter::RandomAccessIterator;
22+
use core::iter;
23+
use std::hash::{Writer, Hash};
2224

2325
use {Deque, Collection, Mutable, MutableSeq};
2426
use vec::Vec;
@@ -450,6 +452,21 @@ impl<A: PartialEq> PartialEq for RingBuf<A> {
450452
}
451453
}
452454

455+
impl<A: PartialOrd> PartialOrd for RingBuf<A> {
456+
fn partial_cmp(&self, other: &RingBuf<A>) -> Option<Ordering> {
457+
iter::order::partial_cmp(self.iter(), other.iter())
458+
}
459+
}
460+
461+
impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
462+
fn hash(&self, state: &mut S) {
463+
self.len().hash(state);
464+
for elt in self.iter() {
465+
elt.hash(state);
466+
}
467+
}
468+
}
469+
453470
impl<A> FromIterator<A> for RingBuf<A> {
454471
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
455472
let (lower, _) = iterator.size_hint();
@@ -485,6 +502,7 @@ mod tests {
485502
use std::fmt::Show;
486503
use std::prelude::*;
487504
use std::gc::{GC, Gc};
505+
use std::hash;
488506
use test::Bencher;
489507
use test;
490508

@@ -912,6 +930,37 @@ mod tests {
912930
assert!(e == RingBuf::new());
913931
}
914932

933+
#[test]
934+
fn test_hash() {
935+
let mut x = RingBuf::new();
936+
let mut y = RingBuf::new();
937+
938+
x.push(1i);
939+
x.push(2);
940+
x.push(3);
941+
942+
y.push(0i);
943+
y.push(1i);
944+
y.pop_front();
945+
y.push(2);
946+
y.push(3);
947+
948+
assert!(hash::hash(&x) == hash::hash(&y));
949+
}
950+
951+
#[test]
952+
fn test_ord() {
953+
let x = RingBuf::new();
954+
let mut y = RingBuf::new();
955+
y.push(1i);
956+
y.push(2);
957+
y.push(3);
958+
assert!(x < y);
959+
assert!(y > x);
960+
assert!(x <= x);
961+
assert!(x >= x);
962+
}
963+
915964
#[test]
916965
fn test_show() {
917966
let ringbuf: RingBuf<int> = range(0i, 10).collect();

branches/try2/src/libstd/collections/hashmap.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,7 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
18501850
///
18511851
/// # Example
18521852
///
1853+
/// ```
18531854
/// use std::collections::HashSet;
18541855
/// let mut set: HashSet<int> = HashSet::new();
18551856
/// ```
@@ -1863,6 +1864,7 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
18631864
///
18641865
/// # Example
18651866
///
1867+
/// ```
18661868
/// use std::collections::HashSet;
18671869
/// let mut set: HashSet<int> = HashSet::with_capacity(10);
18681870
/// ```
@@ -1920,6 +1922,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
19201922
///
19211923
/// # Example
19221924
///
1925+
/// ```
19231926
/// use std::collections::HashSet;
19241927
/// let mut set: HashSet<int> = HashSet::new();
19251928
/// set.reserve(10);

0 commit comments

Comments
 (0)