pub struct Cursor<T: Ord + Copy, Id: Copy + Eq> { /* private fields */ }
Expand description
A cursor allows for efficiently scanning through a collection of overlapping intervals (which
we call “spans”). It is optimized for the case where you need to repeatedly move the current
position by a little bit in either direction; in this case, the complexity is O(n),
where n
is the number of “active” spans that overlap the times you’re interested in.
Implementations§
Source§impl Cursor<Time, DrawSnippetId>
impl Cursor<Time, DrawSnippetId>
pub fn bboxes<'a, 'b: 'a, 'c: 'a>( &'b self, snippets: &'c DrawSnippets, ) -> impl Iterator<Item = Rect> + 'a
Source§impl<T: Ord + Copy, Id: Copy + Eq> Cursor<T, Id>
impl<T: Ord + Copy, Id: Copy + Eq> Cursor<T, Id>
Sourcepub fn new<I: IntoIterator<Item = Span<T, Id>>>(
spans: I,
start_time: T,
end_time: T,
) -> Cursor<T, Id>
pub fn new<I: IntoIterator<Item = Span<T, Id>>>( spans: I, start_time: T, end_time: T, ) -> Cursor<T, Id>
Creates a new cursor for the given set of spans, and initializes its current position to
be the interval [start_time, end_time]
(inclusive of both ends).
Sourcepub fn empty(time: T) -> Cursor<T, Id>
pub fn empty(time: T) -> Cursor<T, Id>
Creates a cursor with no spans, set to the time interval [time, time]
.
pub fn advance_to(&mut self, start_time: T, end_time: T)
pub fn active_ids<'a>(&'a self) -> impl Iterator<Item = Id> + 'a
pub fn active_spans<'a>(&'a self) -> impl Iterator<Item = Span<T, Id>> + 'a
pub fn is_finished(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<T, Id> Freeze for Cursor<T, Id>where
T: Freeze,
impl<T, Id> RefUnwindSafe for Cursor<T, Id>where
T: RefUnwindSafe,
Id: RefUnwindSafe,
impl<T, Id> Send for Cursor<T, Id>
impl<T, Id> Sync for Cursor<T, Id>
impl<T, Id> Unpin for Cursor<T, Id>
impl<T, Id> UnwindSafe for Cursor<T, Id>where
T: UnwindSafe,
Id: 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