Skip to content

Commit 30b1e51

Browse files
committed
---
yaml --- r: 64316 b: refs/heads/snap-stage3 c: bbe03da h: refs/heads/master v: v3
1 parent a31c1c4 commit 30b1e51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+729
-881
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 9fd2ac7428afa4f414f32b8b4876ca817ee85f16
4+
refs/heads/snap-stage3: bbe03da9c6bad23d8e09077461c1616872e1aca0
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/dist.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ PKG_FILES := \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
2121
$(S)AUTHORS.txt \
22-
$(S)CONTRIBUTING.md \
2322
$(S)README.md \
24-
$(S)RELEASES.txt \
2523
$(S)configure $(S)Makefile.in \
2624
$(S)man \
2725
$(S)doc \

branches/snap-stage3/mk/install.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ uninstall:
183183
do rm -f $$i ; \
184184
done
185185
$(Q)rm -Rf $(PHL)/rustc
186-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rust.1
187186
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1
188-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustdoc.1
189-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rusti.1
190-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustpkg.1
191187

192188
# target platform specific variables
193189
# for arm-linux-androidabi

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

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,38 @@ impl Set<uint> for BitvSet {
718718
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
719719
}
720720

721+
fn insert(&mut self, value: uint) -> bool {
722+
if self.contains(&value) {
723+
return false;
724+
}
725+
let nbits = self.capacity();
726+
if value >= nbits {
727+
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
728+
assert!(newsize > self.bitv.storage.len());
729+
self.bitv.storage.grow(newsize, &0);
730+
}
731+
self.size += 1;
732+
self.bitv.set(value, true);
733+
return true;
734+
}
735+
736+
fn remove(&mut self, value: &uint) -> bool {
737+
if !self.contains(value) {
738+
return false;
739+
}
740+
self.size -= 1;
741+
self.bitv.set(*value, false);
742+
743+
// Attempt to truncate our storage
744+
let mut i = self.bitv.storage.len();
745+
while i > 1 && self.bitv.storage[i - 1] == 0 {
746+
i -= 1;
747+
}
748+
self.bitv.storage.truncate(i);
749+
750+
return true;
751+
}
752+
721753
fn is_disjoint(&self, other: &BitvSet) -> bool {
722754
for self.intersection(other) |_| {
723755
return false;
@@ -784,40 +816,6 @@ impl Set<uint> for BitvSet {
784816
}
785817
}
786818

787-
impl MutableSet<uint> for BitvSet {
788-
fn insert(&mut self, value: uint) -> bool {
789-
if self.contains(&value) {
790-
return false;
791-
}
792-
let nbits = self.capacity();
793-
if value >= nbits {
794-
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
795-
assert!(newsize > self.bitv.storage.len());
796-
self.bitv.storage.grow(newsize, &0);
797-
}
798-
self.size += 1;
799-
self.bitv.set(value, true);
800-
return true;
801-
}
802-
803-
fn remove(&mut self, value: &uint) -> bool {
804-
if !self.contains(value) {
805-
return false;
806-
}
807-
self.size -= 1;
808-
self.bitv.set(*value, false);
809-
810-
// Attempt to truncate our storage
811-
let mut i = self.bitv.storage.len();
812-
while i > 1 && self.bitv.storage[i - 1] == 0 {
813-
i -= 1;
814-
}
815-
self.bitv.storage.truncate(i);
816-
817-
return true;
818-
}
819-
}
820-
821819
impl BitvSet {
822820
/// Visits each of the words that the two bit vectors (self and other)
823821
/// both have in common. The three yielded arguments are (bit location,

branches/snap-stage3/src/libextra/priority_queue.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use std::unstable::intrinsics::{move_val_init, init};
1717
use std::util::{replace, swap};
1818
use std::vec;
19+
use std::iterator::FromIterator;
1920

2021
/// A priority queue implemented with a binary heap
2122
pub struct PriorityQueue<T> {
@@ -191,6 +192,21 @@ impl<'self, T> Iterator<&'self T> for PriorityQueueIterator<'self, T> {
191192
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
192193
}
193194

195+
impl<T: Ord, Iter: Iterator<T>> FromIterator<T, Iter> for PriorityQueue<T> {
196+
pub fn from_iterator(iter: &mut Iter) -> PriorityQueue<T> {
197+
let (lower, _) = iter.size_hint();
198+
199+
let mut q = PriorityQueue::new();
200+
q.reserve_at_least(lower);
201+
202+
for iter.advance |elem| {
203+
q.push(elem);
204+
}
205+
206+
q
207+
}
208+
}
209+
194210
#[cfg(test)]
195211
mod tests {
196212
use sort::merge_sort;
@@ -341,4 +357,15 @@ mod tests {
341357
#[should_fail]
342358
#[ignore(cfg(windows))]
343359
fn test_empty_replace() { let mut heap = PriorityQueue::new(); heap.replace(5); }
360+
361+
#[test]
362+
fn test_from_iter() {
363+
let xs = ~[9u, 8, 7, 6, 5, 4, 3, 2, 1];
364+
365+
let mut q: PriorityQueue<uint> = xs.rev_iter().transform(|&x| x).collect();
366+
367+
for xs.iter().advance |&x| {
368+
assert_eq!(q.pop(), x);
369+
}
370+
}
344371
}

branches/snap-stage3/src/libextra/rl.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,24 @@ pub unsafe fn read(prompt: &str) -> Option<~str> {
6666
}
6767
}
6868

69-
pub type CompletionCb = @fn(~str, @fn(~str));
69+
pub type CompletionCb<'self> = @fn(~str, &'self fn(~str));
7070

71-
#[cfg(not(stage0))]
72-
static complete_key: local_data::Key<@CompletionCb> = &local_data::Key;
73-
#[cfg(stage0)]
74-
fn complete_key(_: @CompletionCb) {}
71+
fn complete_key(_v: @CompletionCb) {}
7572

7673
/// Bind to the main completion callback
7774
pub unsafe fn complete(cb: CompletionCb) {
78-
local_data::set(complete_key, @cb);
75+
local_data::set(complete_key, @(cb));
7976

8077
extern fn callback(line: *c_char, completions: *()) {
81-
do local_data::get(complete_key) |cb| {
82-
let cb = **cb.unwrap();
83-
84-
unsafe {
85-
do cb(str::raw::from_c_str(line)) |suggestion| {
86-
do str::as_c_str(suggestion) |buf| {
87-
rustrt::linenoiseAddCompletion(completions, buf);
88-
}
78+
unsafe {
79+
let cb = *local_data::get(complete_key, |k| k.map(|&k| *k))
80+
.get();
81+
82+
do cb(str::raw::from_c_str(line)) |suggestion| {
83+
do str::as_c_str(suggestion) |buf| {
84+
rustrt::linenoiseAddCompletion(completions, buf);
8985
}
90-
}
86+
}
9187
}
9288
}
9389

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818

1919
use std::cmp;
20-
use std::iterator::{Iterator,IteratorUtil,ZipIterator,Counter,EnumerateIterator,FilterMapIterator};
20+
use std::container::{Container, Mutable, Map, Set};
21+
use std::iterator::*;
2122
use std::uint;
2223
use std::util::replace;
2324
use std::vec::{VecIterator,VecMutIterator,VecRevIterator,VecMutRevIterator};
@@ -67,9 +68,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
6768
None
6869
}
6970
}
70-
}
7171

72-
impl<V> MutableMap<uint, V> for SmallIntMap<V> {
7372
/// Return a mutable reference to the value corresponding to the key
7473
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> {
7574
if *key < self.v.len() {
@@ -350,6 +349,14 @@ impl Set<uint> for SmallIntSet {
350349
/// Return true if the set contains a value
351350
fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) }
352351

352+
/// Add a value to the set. Return true if the value was not already
353+
/// present in the set.
354+
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
355+
356+
/// Remove a value from the set. Return true if the value was
357+
/// present in the set.
358+
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
359+
353360
/// Return true if the set has no elements in common with `other`.
354361
/// This is equivalent to checking for an empty uintersection.
355362
fn is_disjoint(&self, other: &SmallIntSet) -> bool {
@@ -405,16 +412,6 @@ impl Set<uint> for SmallIntSet {
405412
}
406413
}
407414

408-
impl MutableSet<uint> for SmallIntSet {
409-
/// Add a value to the set. Return true if the value was not already
410-
/// present in the set.
411-
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
412-
413-
/// Remove a value from the set. Return true if the value was
414-
/// present in the set.
415-
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
416-
}
417-
418415
impl SmallIntSet {
419416
/// Create an empty SmallIntSet
420417
pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }

branches/snap-stage3/src/libextra/sort.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,4 +1195,39 @@ mod big_tests {
11951195
isSorted(arr);
11961196
}
11971197
}
1198+
1199+
struct LVal<'self> {
1200+
val: uint,
1201+
key: &'self fn:Copy(@uint),
1202+
}
1203+
1204+
#[unsafe_destructor]
1205+
impl<'self> Drop for LVal<'self> {
1206+
fn drop(&self) {
1207+
let x = unsafe { local_data::get(self.key, |k| k.map(|&k| *k)) };
1208+
match x {
1209+
Some(@y) => {
1210+
unsafe {
1211+
local_data::set(self.key, @(y+1));
1212+
}
1213+
}
1214+
_ => fail!("Expected key to work"),
1215+
}
1216+
}
1217+
}
1218+
1219+
impl<'self> Ord for LVal<'self> {
1220+
fn lt<'a>(&self, other: &'a LVal<'self>) -> bool {
1221+
(*self).val < other.val
1222+
}
1223+
fn le<'a>(&self, other: &'a LVal<'self>) -> bool {
1224+
(*self).val <= other.val
1225+
}
1226+
fn gt<'a>(&self, other: &'a LVal<'self>) -> bool {
1227+
(*self).val > other.val
1228+
}
1229+
fn ge<'a>(&self, other: &'a LVal<'self>) -> bool {
1230+
(*self).val >= other.val
1231+
}
1232+
}
11981233
}

0 commit comments

Comments
 (0)