Skip to main content

FerroPropertyDictionary

Struct FerroPropertyDictionary 

Source
pub struct FerroPropertyDictionary<TValue> { /* private fields */ }
Expand description

Stores values with FerroProperty as key.

This struct is very similar to a sorted list, with the following differences:

  • The key is the id of the property, allowing very fast lookups.
  • The entries are stored in one array, which is the only heap allocation.
  • It is a plain value: the owner mutates it in place.

Implementations§

Source§

impl<TValue> FerroPropertyDictionary<TValue>

Source

pub fn new() -> Self

Initializes a new instance.

Source

pub fn new_with_capacity(capacity: usize) -> Self

Initializes a new instance with the specified initial capacity.

Source

pub fn count(&self) -> usize

Gets the number of items in the collection.

Source

pub fn get(&self, property: &FerroProperty) -> &TValue

Gets the value associated with the specified property (the getter of the indexer by property).

Panics when the property is not found.

Source

pub fn set(&mut self, property: &FerroProperty, value: TValue)

Sets the value associated with the specified property (the setter of the indexer by property). An existing value is replaced.

Source

pub fn get_at(&self, index: usize) -> &TValue

Gets the value at the specified index (the indexer by index).

Panics when the index is not less than count.

Source

pub fn add(&mut self, property: &FerroProperty, value: TValue)

Adds the specified property and value to the dictionary.

Panics when the dictionary has the property already.

Source

pub fn clear(&mut self)

Removes all property and values from the dictionary.

Source

pub fn contains_key(&self, property: &FerroProperty) -> bool

Determines whether the dictionary contains the specified property.

Source

pub fn get_value(&self, index: usize) -> &TValue

Gets the value at the specified index.

Panics when the index is not less than count.

Source

pub fn remove(&mut self, property: &FerroProperty) -> bool

Removes the value with the specified property from the dictionary.

Returns true if the property was found and removed; otherwise false.

Source

pub fn remove_value(&mut self, property: &FerroProperty) -> Option<TValue>

Removes the value with the specified property from the dictionary and returns it, or None when the property was not found.

Source

pub fn remove_at(&mut self, index: usize)

Removes the element at the specified index from the dictionary.

Panics when the index is not less than count.

Source

pub fn try_add(&mut self, property: &FerroProperty, value: TValue) -> bool

Attempts to add the specified property and value to the dictionary.

Returns false when the dictionary has the property already.

Source

pub fn try_get_value(&self, property: &FerroProperty) -> Option<&TValue>

Gets the value associated with the specified property, or None when the dictionary does not contain it.

Trait Implementations§

Source§

impl<TValue> Default for FerroPropertyDictionary<TValue>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<TValue> Freeze for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: Freeze,

§

impl<TValue> RefUnwindSafe for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: RefUnwindSafe,

§

impl<TValue> Send for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: Send,

§

impl<TValue> Sync for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: Sync,

§

impl<TValue> Unpin for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: Unpin,

§

impl<TValue> UnsafeUnpin for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: UnsafeUnpin,

§

impl<TValue> UnwindSafe for FerroPropertyDictionary<TValue>
where Vec<Entry<TValue>>: 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> 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.