mod linear;
use distances::number::UInt;
use crate::Instance;
use super::CodecData;
pub enum Algorithm {
Linear,
}
impl Default for Algorithm {
fn default() -> Self {
Self::Linear
}
}
impl Algorithm {
pub fn search<I, U, M>(&self, query: &I, k: usize, data: &CodecData<I, U, M>) -> Vec<(usize, U)>
where
I: Instance,
U: UInt,
M: Instance,
{
match self {
Self::Linear => linear::search(query, k, data),
}
}
#[must_use]
pub const fn name(&self) -> &str {
match self {
Self::Linear => "Linear",
}
}
pub fn from_name(s: &str) -> Result<Self, String> {
match s.to_lowercase().as_str() {
"linear" => Ok(Self::Linear),
_ => Err(format!("Unknown algorithm: {s}")),
}
}
#[must_use]
pub const fn baseline() -> Self {
Self::Linear
}
}