Struct Cursor

Source
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>

Source

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>

Source

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).

Source

pub fn empty(time: T) -> Cursor<T, Id>

Creates a cursor with no spans, set to the time interval [time, time].

Source

pub fn current(&self) -> (T, T)

Returns this cursors current time interval.

Source

pub fn advance_to(&mut self, start_time: T, end_time: T)

Source

pub fn active_ids<'a>(&'a self) -> impl Iterator<Item = Id> + 'a

Source

pub fn active_spans<'a>(&'a self) -> impl Iterator<Item = Span<T, Id>> + 'a

Source

pub fn is_finished(&self) -> bool

Trait Implementations§

Source§

impl<T: Debug + Ord + Copy, Id: Debug + Copy + Eq> Debug for Cursor<T, Id>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, Id> Freeze for Cursor<T, Id>
where T: Freeze,

§

impl<T, Id> RefUnwindSafe for Cursor<T, Id>

§

impl<T, Id> Send for Cursor<T, Id>
where T: Send, Id: Send,

§

impl<T, Id> Sync for Cursor<T, Id>
where T: Sync, Id: Sync,

§

impl<T, Id> Unpin for Cursor<T, Id>
where T: Unpin, Id: Unpin,

§

impl<T, Id> UnwindSafe for Cursor<T, Id>
where T: UnwindSafe, Id: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.