pub struct FastArray<T, const LEN: usize> { /* private fields */ }Expand description
环形数组,适合高频数据,且数据量不大的场景。线程不安全,使用者请控制好访问时机。
- 适合高频数据,且数据量不大的场景
- 线程不安全,使用者请控制好访问时机
- 设计上,push方法会覆盖掉旧数据,且不删除旧数据。find方法会从最新的数据项开始往前找,直到找到满足条件的项为止。 3.1 例如,LEN=10,push了11项,那么第11项会覆盖掉第1项,但第1项仍然存在。find方法会先找第11项,再找第10项…直到找到满足条件的项为止。 3.2 例如,LEN=10,push了9项,那么第1项到第9项都存在。find方法会先找第9项,再找第8项…直到找到满足条件的项为止。 3.3 例如,LEN=10,push了10项,那么第1项到第10项都存在。find方法会先找第10项,再找第9项…直到找到满足条件的项为止。
- 适合的场景:例如,某个接口的调用日志,push方法记录每次调用的日志,find方法根据条件找出满足条件的调用日志。
Implementations§
Trait Implementations§
Source§impl<'a, T, const LEN: usize> IntoIterator for &'a FastArray<T, LEN>
impl<'a, T, const LEN: usize> IntoIterator for &'a FastArray<T, LEN>
Source§impl<T, const LEN: usize> IntoIterator for FastArray<T, LEN>
impl<T, const LEN: usize> IntoIterator for FastArray<T, LEN>
Auto Trait Implementations§
impl<T, const LEN: usize> !Freeze for FastArray<T, LEN>
impl<T, const LEN: usize> !RefUnwindSafe for FastArray<T, LEN>
impl<T, const LEN: usize> Send for FastArray<T, LEN>where
T: Send,
impl<T, const LEN: usize> Sync for FastArray<T, LEN>where
T: Sync,
impl<T, const LEN: usize> Unpin for FastArray<T, LEN>where
T: Unpin,
impl<T, const LEN: usize> UnsafeUnpin for FastArray<T, LEN>where
T: UnsafeUnpin,
impl<T, const LEN: usize> UnwindSafe for FastArray<T, LEN>where
T: 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