libcollections: use unboxed closures in TreeMap
methods
This commit is contained in:
parent
02e7389c5d
commit
0d39fc01bf
@ -616,7 +616,7 @@ impl<K, V> TreeMap<K, V> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[experimental = "likely to be renamed, may be removed"]
|
||||
pub fn find_with(&self, f:|&K| -> Ordering) -> Option<&V> {
|
||||
pub fn find_with<F>(&self, f: F) -> Option<&V> where F: FnMut(&K) -> Ordering {
|
||||
tree_find_with(&self.root, f)
|
||||
}
|
||||
|
||||
@ -641,7 +641,9 @@ impl<K, V> TreeMap<K, V> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[experimental = "likely to be renamed, may be removed"]
|
||||
pub fn find_with_mut<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> {
|
||||
pub fn find_with_mut<'a, F>(&'a mut self, f: F) -> Option<&'a mut V> where
|
||||
F: FnMut(&K) -> Ordering
|
||||
{
|
||||
tree_find_with_mut(&mut self.root, f)
|
||||
}
|
||||
}
|
||||
@ -1129,8 +1131,12 @@ fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
|
||||
// Next 2 functions have the same convention: comparator gets
|
||||
// at input current key and returns search_key cmp cur_key
|
||||
// (i.e. search_key.cmp(&cur_key))
|
||||
fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
|
||||
f: |&K| -> Ordering) -> Option<&'r V> {
|
||||
fn tree_find_with<'r, K, V, F>(
|
||||
node: &'r Option<Box<TreeNode<K, V>>>,
|
||||
mut f: F,
|
||||
) -> Option<&'r V> where
|
||||
F: FnMut(&K) -> Ordering,
|
||||
{
|
||||
let mut current: &'r Option<Box<TreeNode<K, V>>> = node;
|
||||
loop {
|
||||
match *current {
|
||||
@ -1147,8 +1153,12 @@ fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
|
||||
}
|
||||
|
||||
// See comments above tree_find_with
|
||||
fn tree_find_with_mut<'r, K, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
|
||||
f: |&K| -> Ordering) -> Option<&'r mut V> {
|
||||
fn tree_find_with_mut<'r, K, V, F>(
|
||||
node: &'r mut Option<Box<TreeNode<K, V>>>,
|
||||
mut f: F,
|
||||
) -> Option<&'r mut V> where
|
||||
F: FnMut(&K) -> Ordering,
|
||||
{
|
||||
|
||||
let mut current = node;
|
||||
loop {
|
||||
|
Loading…
Reference in New Issue
Block a user