pub struct SearchResults<T>(/* private fields */);Expand description
A collection of scored values, sorted in descending order by score.
Implementations§
Source§impl<T> SearchResults<T>
impl<T> SearchResults<T>
Sourcepub fn new() -> SearchResults<T>
pub fn new() -> SearchResults<T>
Create an empty collection of scored values.
Sourcepub fn from_min_heap(
queue: &mut BinaryHeap<Reverse<Scored<T>>>,
) -> SearchResults<T>
pub fn from_min_heap( queue: &mut BinaryHeap<Reverse<Scored<T>>>, ) -> SearchResults<T>
Create a collection of search results from a min-heap of scored values.
Sourcepub fn push(&mut self, scored: Scored<T>)
pub fn push(&mut self, scored: Scored<T>)
Add a new scored value to this collection.
The score provided must be less than or equal to every other score in this collection, otherwise this method will panic.
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalizes the scores in this collection such that all scores are in
the range [0, 1] where the top result always has score 1.0.
This operation is idempotent and does not change the ordering of results.
Sourcepub fn rescore<F: FnMut(&T) -> f64>(&mut self, rescore: F)
pub fn rescore<F: FnMut(&T) -> f64>(&mut self, rescore: F)
Recomputes the scores in this collection using the given function.
The results are then re-sorted according to the new scores.
Trait Implementations§
Source§impl<T: Clone> Clone for SearchResults<T>
impl<T: Clone> Clone for SearchResults<T>
Source§fn clone(&self) -> SearchResults<T>
fn clone(&self) -> SearchResults<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for SearchResults<T>
impl<T: Debug> Debug for SearchResults<T>
Source§impl<T: Default> Default for SearchResults<T>
impl<T: Default> Default for SearchResults<T>
Source§fn default() -> SearchResults<T>
fn default() -> SearchResults<T>
Returns the “default value” for a type. Read more
Source§impl<T> IntoIterator for SearchResults<T>
impl<T> IntoIterator for SearchResults<T>
Auto Trait Implementations§
impl<T> Freeze for SearchResults<T>
impl<T> RefUnwindSafe for SearchResults<T>where
T: RefUnwindSafe,
impl<T> Send for SearchResults<T>where
T: Send,
impl<T> Sync for SearchResults<T>where
T: Sync,
impl<T> Unpin for SearchResults<T>where
T: Unpin,
impl<T> UnwindSafe for SearchResults<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more