pub struct HashableIndex<TIndex: Serialize + Hash + Clone + Eq + Ord> {
pub values: Vec<TIndex>,
}
Expand description
a HashableIndex
Fields§
§values: Vec<TIndex>
Implementations§
Source§impl HashableIndex<NaiveDateTime>
impl HashableIndex<NaiveDateTime>
pub fn from_int_stamps(stamps: Vec<i64>) -> HashableIndex<NaiveDateTime>
Source§impl<TIndex: Serialize + Hash + Clone + Eq + Ord> HashableIndex<TIndex>
impl<TIndex: Serialize + Hash + Clone + Eq + Ord> HashableIndex<TIndex>
Sourcepub fn new(values: Vec<TIndex>) -> HashableIndex<TIndex>
pub fn new(values: Vec<TIndex>) -> HashableIndex<TIndex>
Create new index from a vec of values of type TIndex
§Example
use tsxlib::index::HashableIndex;
let values = vec![1, 2, 3, 4];
let index = HashableIndex::new(values);
assert_eq!(index.len(), 4);
Sourcepub fn is_monotonic(&self) -> bool
pub fn is_monotonic(&self) -> bool
test the monotonicity test for an index
§Example
use tsxlib::index::HashableIndex;
let vs = HashableIndex::new(vec![1, 2, 3, 4]);
let xs = HashableIndex::new(vec![1, 2, 3, 3]);
let ys = HashableIndex::new(vec![1, 2, 3, 2]);
assert_eq!(vs.is_monotonic(), true);
assert_eq!(xs.is_monotonic(), false);
assert_eq!(ys.is_monotonic(), false);
Trait Implementations§
Source§impl<TIndex: Clone + Serialize + Hash + Clone + Eq + Ord> Clone for HashableIndex<TIndex>
impl<TIndex: Clone + Serialize + Hash + Clone + Eq + Ord> Clone for HashableIndex<TIndex>
Source§fn clone(&self) -> HashableIndex<TIndex>
fn clone(&self) -> HashableIndex<TIndex>
Returns a copy 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 SampleableIndex<NaiveDateTime, Duration> for HashableIndex<NaiveDateTime>
Implementation of SampleableIndex for HashableIndex
impl SampleableIndex<NaiveDateTime, Duration> for HashableIndex<NaiveDateTime>
Implementation of SampleableIndex for HashableIndex
Source§fn sample_rates(&self) -> Vec<(usize, Duration)>
fn sample_rates(&self) -> Vec<(usize, Duration)>
Infer index sample rate, returns a vector that represtest (number of times a sample rate is observed, the sample rate)
§Example
use tsxlib::index::HashableIndex;
use tsxlib::index::SampleableIndex;
use tsxlib::timeutils;
use chrono::{NaiveDateTime,Duration};
let index = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25), timeutils::naive_datetime_from_millis(75)]);
let exp = vec![(5,Duration::milliseconds(5)),(1,Duration::milliseconds(50))];
assert_eq!(index.sample_rates(), exp);
Source§fn is_mono_intervaled(&self) -> bool
fn is_mono_intervaled(&self) -> bool
returns true if the index is spaced at equal itervals
§Example
use tsxlib::index::HashableIndex;
use tsxlib::index::SampleableIndex;
use tsxlib::timeutils;
use chrono::{NaiveDateTime,Duration};
let index = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25), timeutils::naive_datetime_from_millis(75)]);
let index_mono = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25)]);
assert_eq!(index.is_mono_intervaled(), false);
assert_eq!(index_mono.is_mono_intervaled(), true);
Auto Trait Implementations§
impl<TIndex> Freeze for HashableIndex<TIndex>
impl<TIndex> RefUnwindSafe for HashableIndex<TIndex>where
TIndex: RefUnwindSafe,
impl<TIndex> Send for HashableIndex<TIndex>where
TIndex: Send,
impl<TIndex> Sync for HashableIndex<TIndex>where
TIndex: Sync,
impl<TIndex> Unpin for HashableIndex<TIndex>where
TIndex: Unpin,
impl<TIndex> UnwindSafe for HashableIndex<TIndex>where
TIndex: 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