FerroDictionary
struct · ferroui-base · v0.5.0
struct FerroDictionary<K, V>
A notifying dictionary.
Changes raise the collection changed event and property changed
notifications for Count and Item[key] (Item when the dictionary is
cleared). Keys are shown in those names through their Display form.
Enumeration works on a copy, so the dictionary may be modified from within an enumeration or a change notification.
The dictionary is a reference object: the value is a shared handle, clones refer to the same dictionary and handles compare by identity.
Members
ptr_eqnewwith_capacityfrom_dictionaryadd_collection_changedremove_collection_changedhas_collection_changed_subscriberscountis_emptyis_read_onlykeysvaluesgettry_get_valuesetaddclearcontains_keycontainsto_veccopy_tofor_eachremove
ptr_eq
fn ptr_eq(self: &Self, other: &Self) -> bool
Whether two handles refer to the same dictionary.
new
fn new() -> Self
Creates an empty dictionary.
with_capacity
fn with_capacity(capacity: usize) -> Self
Creates an empty dictionary with room for capacity entries.
from_dictionary
fn from_dictionary(dictionary: impl IntoIterator<Item = (K, V)>) -> Self
Creates a dictionary with the entries of dictionary. A key that
occurs more than once keeps its last value.
add_collection_changed
fn add_collection_changed(self: &Self, handler: Rc<CollectionChangedHandler<(K, V)>>) -> u64
Subscribes to changes of the collection. Returns a token for
remove_collection_changed.
remove_collection_changed
fn remove_collection_changed(self: &Self, token: u64) -> bool
Unsubscribes a handler.
has_collection_changed_subscribers
fn has_collection_changed_subscribers(self: &Self) -> bool
Whether anything is subscribed to changes of the collection, typed or untyped.
count
fn count(self: &Self) -> usize
The number of entries.
is_empty
fn is_empty(self: &Self) -> bool
is_read_only
fn is_read_only(self: &Self) -> bool
keys
fn keys(self: &Self) -> Vec<K>
The keys, in enumeration order.
values
fn values(self: &Self) -> Vec<V>
The values, in enumeration order.
get
fn get(self: &Self, key: &K) -> V
The value for key. Panics if the key is not present.
try_get_value
fn try_get_value(self: &Self, key: &K) -> Option<V>
The value for key, if present.
set
fn set(self: &Self, key: K, value: V)
Sets the value for key, adding the entry if it is not present.
add
fn add(self: &Self, key: K, value: V)
Adds an entry. Panics if the key is already present.
clear
fn clear(self: &Self)
Removes all entries.
contains_key
fn contains_key(self: &Self, key: &K) -> bool
contains
fn contains(self: &Self, key: &K, value: &V) -> bool
where V: PartialEq
Whether the dictionary has the entry key with a value equal to
value.
to_vec
fn to_vec(self: &Self) -> Vec<(K, V)>
The entries, in enumeration order.
copy_to
fn copy_to(self: &Self, array: &mut [(K, V)], array_index: usize)
Copies the entries, in enumeration order, to array, starting at
array_index (CopyTo).
Panics
Panics if array is too small, as the managed original throws.
for_each
fn for_each(self: &Self, f: impl FnMut(&K, &V) -> ())
Calls f for each entry of a copy of the dictionary.
remove
fn remove(self: &Self, key: &K) -> bool
Removes the entry for key. Returns false if it is not present.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherWeakEventSenderClonePartialEqDebugDefaultINotifyCollectionChangedINotifyPropertyChangedIFerroDictionary<K, V>IFerroReadOnlyDictionary<K, V>MarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.