pub struct SearchIndexHashMap<P, V> { /* private fields */ }
Expand description
SearchIndexHashMap is a index backed by a HashMap that can match Exact queries.
§Example
use attribute_search_engine::{SearchIndex, SearchIndexHashMap};
use std::collections::HashSet;
use attribute_search_engine::Query;
let mut index_city = SearchIndexHashMap::<usize, String>::new();
index_city.insert(0, "Berlin".into());
index_city.insert(1, "New York".into());
index_city.insert(2, "Madrid".into());
let result = index_city.search(&Query::Exact("<unused>".into(), "New York".into()));
assert_eq!(result, Ok(HashSet::from_iter(vec![1])));
Implementations§
Source§impl<P, V> SearchIndexHashMap<P, V>
impl<P, V> SearchIndexHashMap<P, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SearchIndexHashMap
.
§Example
use attribute_search_engine::SearchIndexHashMap;
let index = SearchIndexHashMap::<usize, String>::new();
Sourcepub fn insert(&mut self, primary_id: P, attribute_value: V)
pub fn insert(&mut self, primary_id: P, attribute_value: V)
Insert a new entry in the index.
§Example
use attribute_search_engine::SearchIndexHashMap;
let mut index = SearchIndexHashMap::<usize, String>::new();
// You insert an entry by giving a row / primary id and an attribute value:
index.insert(123, "A".into());
// The same row / primary id can have multiple attributes assigned:
index.insert(123, "B".into());
// Add as much entries as you want for as many rows you want:
index.insert(124, "C".into());
Trait Implementations§
Source§impl<P, V> Default for SearchIndexHashMap<P, V>
impl<P, V> Default for SearchIndexHashMap<P, V>
Source§impl<P: Clone, V: Eq + Hash + FromStr> SearchIndex<P> for SearchIndexHashMap<P, V>
impl<P: Clone, V: Eq + Hash + FromStr> SearchIndex<P> for SearchIndexHashMap<P, V>
Auto Trait Implementations§
impl<P, V> Freeze for SearchIndexHashMap<P, V>
impl<P, V> RefUnwindSafe for SearchIndexHashMap<P, V>where
V: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, V> Send for SearchIndexHashMap<P, V>
impl<P, V> Sync for SearchIndexHashMap<P, V>
impl<P, V> Unpin for SearchIndexHashMap<P, V>
impl<P, V> UnwindSafe for SearchIndexHashMap<P, V>where
V: UnwindSafe,
P: 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