FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    SlotOrderMap

    struct · ferroui-system · v0.5.0

    struct SlotOrderMap<K, V>
    

    A map from keys to values that enumerates its entries in the order of the slots of .NET's Dictionary<TKey, TValue>: in the order they were added, except that an entry added after a removal takes the slot of the entry removed last (the free list of .NET), and clear starts over.

    Code ported from .NET that enumerates a dictionary (its keys, values, or a Select over it) produces the same sequence with this type. HashMap gives an arbitrary order, and indexmap::IndexMap the order of addition, which differs from this one after a removal (with shift_remove and with swap_remove): use HashMap where nothing enumerates the map, IndexMap where the order of addition is what is observed, and this type only where the exact .NET sequence after removals is (the caches of DynamicData, whose change sets list their items in it).

    View source

    Members

    iter

    fn iter(self: &Self) -> impl Iterator<Item = (&K, &V)>
    

    The entries in the order of enumeration.

    Source

    iter_mut

    fn iter_mut(self: &mut Self) -> impl Iterator<Item = (&K, &mut V)>
    

    The entries in the order of enumeration, with their values to change.

    Source

    keys

    fn keys(self: &Self) -> impl Iterator<Item = &K>
    

    The keys in the order of enumeration (Keys).

    Source

    values

    fn values(self: &Self) -> impl Iterator<Item = &V>
    

    The values in the order of enumeration (Values).

    Source

    new

    fn new() -> Self
    

    An empty map.

    Source

    with_capacity

    fn with_capacity(capacity: usize) -> Self
    

    An empty map with room for capacity entries.

    Source

    len

    fn len(self: &Self) -> usize
    

    The number of entries (Count).

    Source

    is_empty

    fn is_empty(self: &Self) -> bool
    

    Source

    contains_key

    fn contains_key<Q: Hash + Eq + ?Sized>(self: &Self, key: &Q) -> bool
    where K: Borrow<Q>
    

    Whether the map has key (ContainsKey).

    Source

    get

    fn get<Q: Hash + Eq + ?Sized>(self: &Self, key: &Q) -> Option<&V>
    where K: Borrow<Q>
    

    The value of key (TryGetValue).

    Source

    get_mut

    fn get_mut<Q: Hash + Eq + ?Sized>(self: &mut Self, key: &Q) -> Option<&mut V>
    where K: Borrow<Q>
    

    The value of key, to change.

    Source

    insert

    fn insert(self: &mut Self, key: K, value: V) -> Option<V>
    

    Sets the value of key (the indexer's setter, this[key] = value): an existing entry keeps its place; the previous value is returned.

    Source

    try_add

    fn try_add(self: &mut Self, key: K, value: V) -> bool
    

    Adds an entry unless the key is there already (TryAdd); false when it is.

    Source

    add

    fn add(self: &mut Self, key: K, value: V)
    

    Adds an entry (Add).

    Panics

    When the key is there already (ArgumentException).

    Source

    remove

    fn remove<Q: Hash + Eq + ?Sized>(self: &mut Self, key: &Q) -> Option<V>
    where K: Borrow<Q>
    

    Removes the entry of key and gives its value (Remove(TKey, out TValue)).

    Source

    clear

    fn clear(self: &mut Self)
    

    Removes every entry (Clear); the next entry is the first again.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • Clone
    • Default
    • Debug
    • FromIterator<(K, V)>
    • IntoIterator
    • Extend<(K, V)>
    • PartialEq

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.