diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-01-25 13:39:04 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-01-25 13:39:04 -0800 |
| commit | d73077f82dc0f074f7abcb017bd73f4d70a685e9 (patch) | |
| tree | 1ea31e0c59add1d937a2bda9939b51ac19cc093f /src/libstd/priority_queue.rs | |
| parent | 18f1dba510f4710df7de4ba8f16f8029efe2015c (diff) | |
| download | rust-d73077f82dc0f074f7abcb017bd73f4d70a685e9.tar.gz rust-d73077f82dc0f074f7abcb017bd73f4d70a685e9.zip | |
Revert "Merge pull request #4633 from thestinger/treemap"
I was too hasty in merging -- this needs a snapshot. This reverts commit 4a7e1ab3745f519536ef6e0377427fc41e47f7c6, reversing changes made to e447521c1ca2dbead5b485ddc43060b282840817.
Diffstat (limited to 'src/libstd/priority_queue.rs')
| -rw-r--r-- | src/libstd/priority_queue.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 5231d51e31e..01b62797a8d 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -76,7 +76,8 @@ impl <T: Ord> PriorityQueue<T> { } /// Optimized version of a push followed by a pop - fn push_pop(&mut self, mut item: T) -> T { + fn push_pop(&mut self, item: T) -> T { + let mut item = item; if !self.is_empty() && self.data[0] > item { item <-> self.data[0]; self.siftdown(0); @@ -85,7 +86,8 @@ impl <T: Ord> PriorityQueue<T> { } /// Optimized version of a pop followed by a push - fails if empty - fn replace(&mut self, mut item: T) -> T { + fn replace(&mut self, item: T) -> T { + let mut item = item; item <-> self.data[0]; self.siftdown(0); item @@ -127,8 +129,9 @@ impl <T: Ord> PriorityQueue<T> { // vector over the junk element. This reduces the constant factor // compared to using swaps, which involves twice as many moves. - priv fn siftup(&mut self, start: uint, mut pos: uint) { + priv fn siftup(&mut self, start: uint, pos: uint) { unsafe { + let mut pos = pos; let new = move *addr_of(&self.data[pos]); while pos > start { @@ -146,8 +149,9 @@ impl <T: Ord> PriorityQueue<T> { } } - priv fn siftdown_range(&mut self, mut pos: uint, end: uint) { + priv fn siftdown_range(&mut self, pos: uint, end: uint) { unsafe { + let mut pos = pos; let start = pos; let new = move *addr_of(&self.data[pos]); |
