Skip to main content

HashList

Struct HashList 

Source
pub struct HashList<T: Hashable> { /* private fields */ }

Implementations§

Source§

impl<T: Hashable> HashList<T>

Source

pub fn new() -> Self

Source

pub fn with_capacity(hash_size: usize, list_capacity: usize) -> Self

Constructor with specified initial capacity

Source

pub fn from_vec(vec: Vec<T>) -> Self

Source

pub fn push(&mut self, value: T) -> usize

Append a new element, returns element index

Source

pub fn index_of(&self, value: &T) -> Option<usize>

Find index of given value.

Source

pub const fn remove_index(&mut self, index: usize) -> bool

Remove by index

Source

pub fn remove(&mut self, value: &T) -> bool

Remove by value

Source

pub fn compact(&mut self)

Compact list, purge deleted elements

Source

pub const fn count(&self) -> usize

Get count of valid elements

Source

pub const fn len(&self) -> usize

Get count of list valid + deleted elements

Source

pub const fn is_empty(&self) -> bool

Check if empty

Source

pub const fn capacity(&self) -> usize

Get list capacity

Source

pub const fn hash_bucket_count(&self) -> usize

Get hash bucket count

Source

pub const fn count_deleted(&self) -> usize

Get number of deleted elements

Source

pub const fn get(&self, index: usize) -> Option<&T>

Get value by index (if exists and not deleted)

Source

pub fn get_mut(&mut self, index: usize) -> Option<ElementGuard<'_, T>>

Get value mutable by index (if exists and not deleted)

Source

pub fn first(&self) -> Option<&T>

Get reference to first valid element

Source

pub fn last(&self) -> Option<&T>

Get reference to last valid element

Source

pub fn clear(&mut self)

Source

pub fn contains(&self, value: &T) -> bool

Check if contains specified element

Source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Try to reserve capacity for at least additional more elements

Source

pub fn reserve(&mut self, additional: usize)

List capacity reservation

Source

pub fn shrink_to_fit(&mut self)

List capacity shrink

Source

pub const fn iter(&self) -> HashLinkIter<'_, T>

Iterate valid values with its index, in insertion order

Source

pub const fn find_hash(&self, hash: u32) -> HashLinkFindIter<'_, T>

Iterate values matching given hash. Note: will actually iterator in reversed order of insertion, if many elements match the same hash.

Trait Implementations§

Source§

impl<T: Debug + Hashable> Debug for HashList<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Forget for HashList<T>

§

impl<T> Freeze for HashList<T>
where MemChunk<T>: Freeze,

§

impl<T> Move for HashList<T>

§

impl<T> RefUnwindSafe for HashList<T>
where MemChunk<T>: RefUnwindSafe,

§

impl<T> Send for HashList<T>
where MemChunk<T>: Send,

§

impl<T> Sync for HashList<T>
where MemChunk<T>: Sync,

§

impl<T> Unpin for HashList<T>
where MemChunk<T>: Unpin,

§

impl<T> UnsafeUnpin for HashList<T>
where MemChunk<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for HashList<T>
where MemChunk<T>: 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, 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.