[−][src]Struct dary::double_array::DoubleArray
ダブル配列の実装。
Examples
use std::fmt::Debug; use dary::DoubleArray; use dary::Trie; use serde_derive::{Serialize, Deserialize}; fn main() { let key1 = String::from("foo"); let key2 = String::from("bar"); let key3 = String::from("baz"); let sample1 = Sample { surface: key1.clone(), cost: 1 }; let sample2 = Sample { surface: key1.clone(), cost: 2 }; let sample3 = Sample { surface: key2.clone(), cost: 1 }; let sample4 = Sample { surface: key3.clone(), cost: 1 }; let mut trie: Trie<Sample> = Trie::new(); trie.set(&key1, sample1.clone()); trie.set(&key1, sample2.clone()); trie.set(&key2, sample3.clone()); trie.set(&key3, sample4.clone()); let double_array = trie.to_double_array().ok().unwrap(); assert_eq!(vec![sample1, sample2], double_array.get(&key1).unwrap()); assert_eq!(vec![sample3] , double_array.get(&key2).unwrap()); assert_eq!(vec![sample4] , double_array.get(&key3).unwrap()); } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] struct Sample { surface: String, cost: usize, }
Methods
impl<T: Serialize + DeserializeOwned + Debug> DoubleArray<T>
[src]
pub fn from_arrays(
base_arr: &[u32],
check_arr: &[u32],
data_bytes: &[u8]
) -> Result<Self, Error>
[src]
base_arr: &[u32],
check_arr: &[u32],
data_bytes: &[u8]
) -> Result<Self, Error>
base配列, check配列, data配列からDoubleArrayインスタンスを生成する。
Arguments
base_arr
- base配列check_arr
- check配列data_bytes
- data配列
pub fn from_slice(bytes: &[u8]) -> Result<Self, Error>
[src]
pub fn from_file(dictionary_path: &str) -> Result<Self, Error>
[src]
pub fn dump(self, output_path: &str) -> Result<Self, Error>
[src]
pub fn get(&self, key: &str) -> Option<Vec<T>>
[src]
ダブル配列から指定されたkeyを探索する関数 途中で遷移できなくなった場合、data_arrに値が存在しない場合はNoneを返す 遷移ができて、data_arrに値が存在する場合はdata_arrのスライスを返す デバッグ用
Arguments
key
- 探索対象の文字列
pub fn prefix_search<'a>(&self, key: &'a str) -> Vec<(&'a str, Vec<T>)>
[src]
ⓘImportant traits for PrefixSearchIter<'a, T>pub fn prefix_search_iter<'a>(&'a self, key: &'a str) -> PrefixSearchIter<'a, T>
[src]
ⓘImportant traits for PrefixSearchIter<'a, T>
Trait Implementations
impl<T: Debug + Serialize + DeserializeOwned> Debug for DoubleArray<T>
[src]
Auto Trait Implementations
impl<T> Send for DoubleArray<T> where
T: Send,
T: Send,
impl<T> Sync for DoubleArray<T> where
T: Sync,
T: Sync,
impl<T> Unpin for DoubleArray<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for DoubleArray<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for DoubleArray<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,