Skip to content

Commit 31457a7

Browse files
committed
---
yaml --- r: 152390 b: refs/heads/try2 c: a6a9e09 h: refs/heads/master v: v3
1 parent 6958f4e commit 31457a7

33 files changed

+453
-274
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: c1c76590cb4cf4afdc0545d8515cfc3a92078506
8+
refs/heads/try2: a6a9e09f98cceecc866c5e6a0d9392735c351ae6
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/licenseck.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"libstd/sync/spsc_queue.rs", # BSD
4343
"libstd/sync/mpmc_bounded_queue.rs", # BSD
4444
"libsync/mpsc_intrusive.rs", # BSD
45+
"test/bench/shootout-fannkuch-redux.rs", # BSD
4546
"test/bench/shootout-meteor.rs", # BSD
47+
"test/bench/shootout-regex-dna.rs", # BSD
4648
]
4749

4850
def check_license(name, contents):

branches/try2/src/libcollections/bitv.rs

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use core::iter::{Enumerate, Repeat, Map, Zip};
1818
use core::ops;
1919
use core::slice;
2020
use core::uint;
21+
use std::hash;
2122

2223
use vec::Vec;
2324

@@ -34,12 +35,12 @@ fn small_mask(nbits: uint) -> uint {
3435
}
3536

3637
impl SmallBitv {
37-
pub fn new(bits: uint) -> SmallBitv {
38+
fn new(bits: uint) -> SmallBitv {
3839
SmallBitv {bits: bits}
3940
}
4041

4142
#[inline]
42-
pub fn bits_op(&mut self,
43+
fn bits_op(&mut self,
4344
right_bits: uint,
4445
nbits: uint,
4546
f: |uint, uint| -> uint)
@@ -52,32 +53,32 @@ impl SmallBitv {
5253
}
5354

5455
#[inline]
55-
pub fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool {
56+
fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool {
5657
self.bits_op(s.bits, nbits, |u1, u2| u1 | u2)
5758
}
5859

5960
#[inline]
60-
pub fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool {
61+
fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool {
6162
self.bits_op(s.bits, nbits, |u1, u2| u1 & u2)
6263
}
6364

6465
#[inline]
65-
pub fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool {
66+
fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool {
6667
self.bits_op(s.bits, nbits, |_u1, u2| u2)
6768
}
6869

6970
#[inline]
70-
pub fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool {
71+
fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool {
7172
self.bits_op(s.bits, nbits, |u1, u2| u1 & !u2)
7273
}
7374

7475
#[inline]
75-
pub fn get(&self, i: uint) -> bool {
76+
fn get(&self, i: uint) -> bool {
7677
(self.bits & (1 << i)) != 0
7778
}
7879

7980
#[inline]
80-
pub fn set(&mut self, i: uint, x: bool) {
81+
fn set(&mut self, i: uint, x: bool) {
8182
if x {
8283
self.bits |= 1<<i;
8384
}
@@ -87,29 +88,29 @@ impl SmallBitv {
8788
}
8889

8990
#[inline]
90-
pub fn equals(&self, b: &SmallBitv, nbits: uint) -> bool {
91+
fn equals(&self, b: &SmallBitv, nbits: uint) -> bool {
9192
let mask = small_mask(nbits);
9293
mask & self.bits == mask & b.bits
9394
}
9495

9596
#[inline]
96-
pub fn clear(&mut self) { self.bits = 0; }
97+
fn clear(&mut self) { self.bits = 0; }
9798

9899
#[inline]
99-
pub fn set_all(&mut self) { self.bits = !0; }
100+
fn set_all(&mut self) { self.bits = !0; }
100101

101102
#[inline]
102-
pub fn all(&self, nbits: uint) -> bool {
103+
fn all(&self, nbits: uint) -> bool {
103104
small_mask(nbits) & !self.bits == 0
104105
}
105106

106107
#[inline]
107-
pub fn none(&self, nbits: uint) -> bool {
108+
fn none(&self, nbits: uint) -> bool {
108109
small_mask(nbits) & self.bits == 0
109110
}
110111

111112
#[inline]
112-
pub fn negate(&mut self) { self.bits = !self.bits; }
113+
fn negate(&mut self) { self.bits = !self.bits; }
113114
}
114115

115116
#[deriving(Clone)]
@@ -134,12 +135,12 @@ fn big_mask(nbits: uint, elem: uint) -> uint {
134135
}
135136

136137
impl BigBitv {
137-
pub fn new(storage: Vec<uint>) -> BigBitv {
138+
fn new(storage: Vec<uint>) -> BigBitv {
138139
BigBitv {storage: storage}
139140
}
140141

141142
#[inline]
142-
pub fn process(&mut self,
143+
fn process(&mut self,
143144
b: &BigBitv,
144145
nbits: uint,
145146
op: |uint, uint| -> uint)
@@ -163,45 +164,45 @@ impl BigBitv {
163164
}
164165

165166
#[inline]
166-
pub fn each_storage(&mut self, op: |v: &mut uint| -> bool) -> bool {
167+
fn each_storage(&mut self, op: |v: &mut uint| -> bool) -> bool {
167168
self.storage.mut_iter().advance(|elt| op(elt))
168169
}
169170

170171
#[inline]
171-
pub fn negate(&mut self) {
172+
fn negate(&mut self) {
172173
self.each_storage(|w| { *w = !*w; true });
173174
}
174175

175176
#[inline]
176-
pub fn union(&mut self, b: &BigBitv, nbits: uint) -> bool {
177+
fn union(&mut self, b: &BigBitv, nbits: uint) -> bool {
177178
self.process(b, nbits, |w1, w2| w1 | w2)
178179
}
179180

180181
#[inline]
181-
pub fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool {
182+
fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool {
182183
self.process(b, nbits, |w1, w2| w1 & w2)
183184
}
184185

185186
#[inline]
186-
pub fn become(&mut self, b: &BigBitv, nbits: uint) -> bool {
187+
fn become(&mut self, b: &BigBitv, nbits: uint) -> bool {
187188
self.process(b, nbits, |_, w| w)
188189
}
189190

190191
#[inline]
191-
pub fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool {
192+
fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool {
192193
self.process(b, nbits, |w1, w2| w1 & !w2)
193194
}
194195

195196
#[inline]
196-
pub fn get(&self, i: uint) -> bool {
197+
fn get(&self, i: uint) -> bool {
197198
let w = i / uint::BITS;
198199
let b = i % uint::BITS;
199200
let x = 1 & self.storage.get(w) >> b;
200201
x == 1
201202
}
202203

203204
#[inline]
204-
pub fn set(&mut self, i: uint, x: bool) {
205+
fn set(&mut self, i: uint, x: bool) {
205206
let w = i / uint::BITS;
206207
let b = i % uint::BITS;
207208
let flag = 1 << b;
@@ -210,7 +211,7 @@ impl BigBitv {
210211
}
211212

212213
#[inline]
213-
pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
214+
fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
214215
for (i, elt) in b.storage.iter().enumerate() {
215216
let mask = big_mask(nbits, i);
216217
if mask & *self.storage.get(i) != mask & *elt {
@@ -596,6 +597,20 @@ impl fmt::Show for Bitv {
596597
}
597598
}
598599

600+
impl<S: hash::Writer> hash::Hash<S> for Bitv {
601+
fn hash(&self, state: &mut S) {
602+
self.nbits.hash(state);
603+
match self.rep {
604+
Small(ref s) => (s.bits & small_mask(self.nbits)).hash(state),
605+
Big(ref b) => {
606+
for (i, ele) in b.storage.iter().enumerate() {
607+
(ele & big_mask(self.nbits, i)).hash(state);
608+
}
609+
}
610+
}
611+
}
612+
}
613+
599614
#[inline]
600615
fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
601616
if bits == 0 {
@@ -834,6 +849,14 @@ impl fmt::Show for BitvSet {
834849
}
835850
}
836851

852+
impl<S: hash::Writer> hash::Hash<S> for BitvSet {
853+
fn hash(&self, state: &mut S) {
854+
for pos in self.iter() {
855+
pos.hash(state);
856+
}
857+
}
858+
}
859+
837860
impl Container for BitvSet {
838861
#[inline]
839862
fn len(&self) -> uint { self.size }

branches/try2/src/libcollections/dlist.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use core::prelude::*;
2525

2626
use alloc::owned::Box;
27+
use core::fmt;
2728
use core::iter;
2829
use core::mem;
2930
use core::ptr;
@@ -608,6 +609,19 @@ impl<A: Clone> Clone for DList<A> {
608609
}
609610
}
610611

612+
impl<A: fmt::Show> fmt::Show for DList<A> {
613+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
614+
try!(write!(f, "["));
615+
616+
for (i, e) in self.iter().enumerate() {
617+
if i != 0 { try!(write!(f, ", ")); }
618+
try!(write!(f, "{}", *e));
619+
}
620+
621+
write!(f, "]")
622+
}
623+
}
624+
611625
#[cfg(test)]
612626
mod tests {
613627
use std::prelude::*;
@@ -1027,6 +1041,17 @@ mod tests {
10271041
}
10281042
}
10291043

1044+
#[test]
1045+
fn test_show() {
1046+
let list: DList<int> = range(0, 10).collect();
1047+
assert!(list.to_str().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
1048+
1049+
let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
1050+
.map(|&s| s)
1051+
.collect();
1052+
assert!(list.to_str().as_slice() == "[just, one, test, more]");
1053+
}
1054+
10301055
#[cfg(test)]
10311056
fn fuzz_test(sz: int) {
10321057
let mut m: DList<int> = DList::new();

branches/try2/src/libcollections/smallintmap.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use core::prelude::*;
1919

20+
use core::fmt;
2021
use core::iter::{Enumerate, FilterMap};
2122
use core::mem::replace;
2223

@@ -176,6 +177,18 @@ impl<V:Clone> SmallIntMap<V> {
176177
}
177178
}
178179

180+
impl<V: fmt::Show> fmt::Show for SmallIntMap<V> {
181+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
182+
try!(write!(f, r"\{"));
183+
184+
for (i, (k, v)) in self.iter().enumerate() {
185+
if i != 0 { try!(write!(f, ", ")); }
186+
try!(write!(f, "{}: {}", k, *v));
187+
}
188+
189+
write!(f, r"\}")
190+
}
191+
}
179192

180193
macro_rules! iterator {
181194
(impl $name:ident -> $elem:ty, $getter:ident) => {
@@ -461,6 +474,20 @@ mod test_map {
461474
assert!(called);
462475
m.insert(2, box 1);
463476
}
477+
478+
#[test]
479+
fn test_show() {
480+
let mut map = SmallIntMap::new();
481+
let empty = SmallIntMap::<int>::new();
482+
483+
map.insert(1, 2);
484+
map.insert(3, 4);
485+
486+
let map_str = map.to_str();
487+
let map_str = map_str.as_slice();
488+
assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
489+
assert_eq!(format!("{}", empty), "{}".to_string());
490+
}
464491
}
465492

466493
#[cfg(test)]

branches/try2/src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ impl<T> FromVec<T> for ~[T] {
15321532

15331533
// In a post-DST world, we can attempt to reuse the Vec allocation by calling
15341534
// shrink_to_fit() on it. That may involve a reallocation+memcpy, but that's no
1535-
// diffrent than what we're doing manually here.
1535+
// different than what we're doing manually here.
15361536

15371537
let vp = v.as_mut_ptr();
15381538

branches/try2/src/libcore/cmp.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
4040
/// Trait for values that can be compared for equality and inequality.
4141
///
42-
/// This trait allows partial equality, where types can be unordered instead of
43-
/// strictly equal or unequal. For example, with the built-in floating-point
44-
/// types `a == b` and `a != b` will both evaluate to false if either `a` or
45-
/// `b` is NaN (cf. IEEE 754-2008 section 5.11).
42+
/// This trait allows for partial equality, for types that do not have an
43+
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
44+
/// so floating point types implement `PartialEq` but not `Eq`.
4645
///
47-
/// PartialEq only requires the `eq` method to be implemented; `ne` is its negation by
48-
/// default.
46+
/// PartialEq only requires the `eq` method to be implemented; `ne` is defined
47+
/// in terms of it by default. Any manual implementation of `ne` *must* respect
48+
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
49+
/// only if `a != b`.
4950
///
5051
/// Eventually, this will be implemented by default for types that implement
5152
/// `Eq`.
@@ -147,9 +148,10 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
147148
/// PartialOrd only requires implementation of the `lt` method,
148149
/// with the others generated from default implementations.
149150
///
150-
/// However it remains possible to implement the others separately,
151-
/// for compatibility with floating-point NaN semantics
152-
/// (cf. IEEE 754-2008 section 5.11).
151+
/// However it remains possible to implement the others separately for types
152+
/// which do not have a total order. For example, for floating point numbers,
153+
/// `NaN < 0 == false` and `NaN >= 0 == false` (cf. IEEE 754-2008 section
154+
/// 5.11).
153155
#[lang="ord"]
154156
pub trait PartialOrd: PartialEq {
155157
/// This method tests less than (for `self` and `other`) and is used by the `<` operator.

branches/try2/src/libcore/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! ## Stability Note
3333
//!
34-
//! These are all experimental. The inferface may change entirely, without
34+
//! These are all experimental. The interface may change entirely, without
3535
//! warning.
3636
3737
#![allow(non_camel_case_types)]

branches/try2/src/libcore/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl TwoWaySearcher {
478478
}
479479

480480
/// The internal state of an iterator that searches for matches of a substring
481-
/// within a larger string using a dynamically chosed search algorithm
481+
/// within a larger string using a dynamically chosen search algorithm
482482
#[deriving(Clone)]
483483
enum Searcher {
484484
Naive(NaiveSearcher),
@@ -1120,7 +1120,7 @@ pub trait StrSlice<'a> {
11201120
///
11211121
/// That is, each returned value `(start, end)` satisfies
11221122
/// `self.slice(start, end) == sep`. For matches of `sep` within
1123-
/// `self` that overlap, only the indicies corresponding to the
1123+
/// `self` that overlap, only the indices corresponding to the
11241124
/// first match are returned.
11251125
///
11261126
/// # Example

0 commit comments

Comments
 (0)