Skip to main content

WeakHashList

Struct WeakHashList 

Source
pub struct WeakHashList<T: ?Sized + 'static> { /* private fields */ }
Expand description

A list of weakly referenced items, compared by identity.

Up to DEFAULT_ARRAY_SIZE items are kept in an array; beyond that the list switches to a dictionary that counts how many times each item was added.

Implementations§

Source§

impl<T: ?Sized + 'static> WeakHashList<T>

Source

pub const DEFAULT_ARRAY_SIZE: usize = 8

Source

pub fn new() -> Self

Source

pub fn is_empty(&self) -> bool

Source

pub fn need_compact(&self) -> bool

Source

pub fn add(&mut self, item: &Rc<T>)

Source

pub fn remove(&mut self, item: &Rc<T>)

Source

pub fn compact(&mut self)

Source

pub fn return_to_shared_pool(list: Vec<Rc<T>>)

Clears list and keeps it for a later get_alive.

Source

pub fn get_alive( &mut self, factory: Option<&dyn Fn() -> Vec<Rc<T>>>, ) -> Option<Vec<Rc<T>>>

The items that are still alive, or None if there are none. The list comes from factory when given, else from the shared pool.

Trait Implementations§

Source§

impl<T: ?Sized + 'static> Default for WeakHashList<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for WeakHashList<T>

§

impl<T> !RefUnwindSafe for WeakHashList<T>

§

impl<T> !Send for WeakHashList<T>

§

impl<T> !Sync for WeakHashList<T>

§

impl<T> !UnwindSafe for WeakHashList<T>

§

impl<T> Unpin for WeakHashList<T>
where Option<OrderedDic<T>>: Unpin, Option<Vec<Option<Weak<T>>>>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for WeakHashList<T>
where Option<OrderedDic<T>>: UnsafeUnpin, Option<Vec<Option<Weak<T>>>>: UnsafeUnpin, T: ?Sized,

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.