Skip to content

Commit

Permalink
extra: remove sort in favour of the std method.
Browse files Browse the repository at this point in the history
Fixes #9676.
  • Loading branch information
huonw committed Dec 20, 2013
1 parent 721609e commit 48fedcb
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 1,247 deletions.
8 changes: 2 additions & 6 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ use std::io;
use std::io::fs;
use std::path::is_sep;

use sort;

/**
* An iterator that yields Paths from the filesystem that match a particular
* pattern - see the `glob` function for more details.
Expand Down Expand Up @@ -149,9 +147,8 @@ impl Iterator<Path> for GlobIterator {

fn list_dir_sorted(path: &Path) -> ~[Path] {
match io::result(|| fs::readdir(path)) {
Ok(children) => {
let mut children = children;
sort::quick_sort(children, |p1, p2| p2.filename() <= p1.filename());
Ok(mut children) => {
children.sort(|p1, p2| p2.filename() <= p1.filename());
children
}
Err(..) => ~[]
Expand Down Expand Up @@ -771,4 +768,3 @@ mod test {
assert!(Pattern::new("a/b").matches_path(&Path::new("a/b")));
}
}

2 changes: 0 additions & 2 deletions src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ pub mod ringbuf;
pub mod priority_queue;
pub mod smallintmap;

pub mod sort;

pub mod dlist;
pub mod treemap;
pub mod btree;
Expand Down
15 changes: 9 additions & 6 deletions src/libextra/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ impl<T: Ord> Extendable<T> for PriorityQueue<T> {

#[cfg(test)]
mod tests {
use sort::merge_sort;
use priority_queue::PriorityQueue;

#[test]
Expand All @@ -231,7 +230,8 @@ mod tests {
#[test]
fn test_top_and_pop() {
let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
let mut sorted = merge_sort(data, |x, y| x.le(y));
let mut sorted = data.clone();
sorted.sort(|x, y| x.le(y));
let mut heap = PriorityQueue::from_vec(data);
while !heap.is_empty() {
assert_eq!(heap.top(), sorted.last());
Expand Down Expand Up @@ -311,11 +311,14 @@ mod tests {
assert_eq!(heap.len(), 5);
}

fn check_to_vec(data: ~[int]) {
fn check_to_vec(mut data: ~[int]) {
let heap = PriorityQueue::from_vec(data.clone());
assert_eq!(merge_sort(heap.clone().to_vec(), |x, y| x.le(y)),
merge_sort(data, |x, y| x.le(y)));
assert_eq!(heap.to_sorted_vec(), merge_sort(data, |x, y| x.le(y)));
let mut v = heap.clone().to_vec();
v.sort(|x, y| x.le(y));
data.sort(|x, y| x.le(y));

assert_eq!(v, data);
assert_eq!(heap.to_sorted_vec(), data);
}

#[test]
Expand Down

0 comments on commit 48fedcb

Please sign in to comment.