pub struct AlphaMemoryIndex { /* private fields */ }Expand description
Alpha Memory with automatic indexing for O(1) fact lookups
Implementations§
Source§impl AlphaMemoryIndex
impl AlphaMemoryIndex
Sourcepub fn insert(&mut self, fact: TypedFacts) -> usize
pub fn insert(&mut self, fact: TypedFacts) -> usize
Insert fact and update indexes
Sourcepub fn filter(&self, field: &str, value: &FactValue) -> Vec<&TypedFacts>
pub fn filter(&self, field: &str, value: &FactValue) -> Vec<&TypedFacts>
Filter facts by field value Uses index if available (O(1)), otherwise falls back to linear scan (O(n))
Sourcepub fn filter_tracked(
&mut self,
field: &str,
value: &FactValue,
) -> Vec<&TypedFacts>
pub fn filter_tracked( &mut self, field: &str, value: &FactValue, ) -> Vec<&TypedFacts>
Filter facts and update statistics (mutable version for tracking)
Sourcepub fn create_index(&mut self, field: String)
pub fn create_index(&mut self, field: String)
Create index on a field
Sourcepub fn drop_index(&mut self, field: &str)
pub fn drop_index(&mut self, field: &str)
Remove index from a field
Sourcepub fn get_all(&self) -> &[TypedFacts]
pub fn get_all(&self) -> &[TypedFacts]
Get all facts
Sourcepub fn get(&self, idx: usize) -> Option<&TypedFacts>
pub fn get(&self, idx: usize) -> Option<&TypedFacts>
Get fact by index
Sourcepub fn indexed_fields(&self) -> Vec<&String>
pub fn indexed_fields(&self) -> Vec<&String>
Get indexed fields
Sourcepub fn stats(&self) -> &IndexStats
pub fn stats(&self) -> &IndexStats
Get statistics
Trait Implementations§
Source§impl Clone for AlphaMemoryIndex
impl Clone for AlphaMemoryIndex
Source§fn clone(&self) -> AlphaMemoryIndex
fn clone(&self) -> AlphaMemoryIndex
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 Debug for AlphaMemoryIndex
impl Debug for AlphaMemoryIndex
Auto Trait Implementations§
impl Freeze for AlphaMemoryIndex
impl RefUnwindSafe for AlphaMemoryIndex
impl Send for AlphaMemoryIndex
impl Sync for AlphaMemoryIndex
impl Unpin for AlphaMemoryIndex
impl UnwindSafe for AlphaMemoryIndex
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more