Struct stack_graphs::arena::ReversibleList
source · #[repr(C)]pub struct ReversibleList<T> { /* private fields */ }
Expand description
An arena-allocated list that can be reversed.
Well, that is, you can reverse a List
just fine by yourself. This type takes care of
doing that for you, and importantly, saves the result so that if you only have to compute the
reversal once even if you need to access it multiple times.
Implementations§
source§impl<T> ReversibleList<T>
impl<T> ReversibleList<T>
sourcepub fn new_arena() -> ReversibleListArena<T>
pub fn new_arena() -> ReversibleListArena<T>
Creates a new ReversibleListArena
that will manage lists of this type.
sourcepub fn empty() -> ReversibleList<T>
pub fn empty() -> ReversibleList<T>
Returns an empty list.
sourcepub fn have_reversal(&self, arena: &ReversibleListArena<T>) -> bool
pub fn have_reversal(&self, arena: &ReversibleListArena<T>) -> bool
Returns whether we have already calculated the reversal of this list.
sourcepub fn push_front(&mut self, arena: &mut ReversibleListArena<T>, head: T)
pub fn push_front(&mut self, arena: &mut ReversibleListArena<T>, head: T)
Pushes a new element onto the front of this list.
sourcepub fn pop_front<'a>(
&mut self,
arena: &'a ReversibleListArena<T>
) -> Option<&'a T>
pub fn pop_front<'a>( &mut self, arena: &'a ReversibleListArena<T> ) -> Option<&'a T>
Removes and returns the element at the front of this list. If the list is empty, returns
None
.
sourcepub fn iter<'a>(
self,
arena: &'a ReversibleListArena<T>
) -> impl Iterator<Item = &'a T> + 'a
pub fn iter<'a>( self, arena: &'a ReversibleListArena<T> ) -> impl Iterator<Item = &'a T> + 'a
Returns an iterator over the elements of this list.
source§impl<T> ReversibleList<T>where
T: Clone,
impl<T> ReversibleList<T>where
T: Clone,
sourcepub fn reverse(&mut self, arena: &mut ReversibleListArena<T>)
pub fn reverse(&mut self, arena: &mut ReversibleListArena<T>)
Reverses the list. Since we’re already caching everything in an arena, we make sure to only calculate the reversal once, returning it as-is if you call this function multiple times.
sourcepub fn ensure_reversal_available(&mut self, arena: &mut ReversibleListArena<T>)
pub fn ensure_reversal_available(&mut self, arena: &mut ReversibleListArena<T>)
Ensures that the reversal of this list is available. It can be useful to precalculate this when you have mutable access to the arena, so that you can then reverse and un-reverse the list later when you only have shared access to it.
source§impl<T> ReversibleList<T>
impl<T> ReversibleList<T>
sourcepub fn reverse_reused(
&mut self,
arena: &ReversibleListArena<T>
) -> Result<(), ()>
pub fn reverse_reused( &mut self, arena: &ReversibleListArena<T> ) -> Result<(), ()>
Reverses the list, assuming that the reversal has already been computed. If it hasn’t we return an error.
source§impl<T> ReversibleList<T>
impl<T> ReversibleList<T>
pub fn equals_with<F>( self, arena: &ReversibleListArena<T>, other: ReversibleList<T>, eq: F ) -> bool
pub fn cmp_with<F>( self, arena: &ReversibleListArena<T>, other: ReversibleList<T>, cmp: F ) -> Ordering
source§impl<T> ReversibleList<T>where
T: Eq,
impl<T> ReversibleList<T>where
T: Eq,
pub fn equals( self, arena: &ReversibleListArena<T>, other: ReversibleList<T> ) -> bool
source§impl<T> ReversibleList<T>where
T: Ord,
impl<T> ReversibleList<T>where
T: Ord,
pub fn cmp( self, arena: &ReversibleListArena<T>, other: ReversibleList<T> ) -> Ordering
Trait Implementations§
source§impl<T> Clone for ReversibleList<T>
impl<T> Clone for ReversibleList<T>
source§fn clone(&self) -> ReversibleList<T>
fn clone(&self) -> ReversibleList<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Niche for ReversibleList<T>
impl<T> Niche for ReversibleList<T>
§type Output = MaybeUninit<ReversibleList<T>>
type Output = MaybeUninit<ReversibleList<T>>
Self
inside of a ControlledOption
. This might
be Self
itself, if your niche is a valid instance of the type, but which violates some
runtime constraint. But if you cannot easily create your niche as an instance of Self
,
you can use some other type, you can use some other type instead. Read moresource§fn none() -> Self::Output
fn none() -> Self::Output
None
for a
ControlledOption
.source§fn is_none(value: &Self::Output) -> bool
fn is_none(value: &Self::Output) -> bool
impl<T> Copy for ReversibleList<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ReversibleList<T>
impl<T> Send for ReversibleList<T>
impl<T> Sync for ReversibleList<T>
impl<T> Unpin for ReversibleList<T>where
T: Unpin,
impl<T> UnwindSafe for ReversibleList<T>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
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.