Struct OrderedMap

Source
pub struct OrderedMap<K, V> { /* private fields */ }
Expand description

順序付き辞書

Implementations§

Source§

impl<K: Ord, V> OrderedMap<K, V>

Source

pub fn new() -> Self

空のOrderedMapを返す。

Source

pub fn len(&self) -> usize

要素数を返す。

Source

pub fn is_empty(&self) -> bool

要素数が0ならばtrueを返す。

keyが存在するとき、それが何番目のキーであるかをOkで返す。 そうでないとき、仮にkeyがあったとき何番目のキーであったか、をErrで返す。

Source

pub fn max_le(&self, key: &K) -> Option<(&K, &V)>

key以下の最大のキーをもつキーと値のペアを返す。

Source

pub fn min_ge(&self, key: &K) -> Option<(&K, &V)>

key以上の最小のキーをもつキーと値のペアを返す。

Source

pub fn contains(&self, key: &K) -> bool

keyをキーとして持つならばtrueを返す。

Source

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

keyがすでに存在している場合、値をvalueで更新して、古い値をSomeで返す。 そうでないとき、keyvalueを紐付けて、Noneを返す。

Source

pub fn get(&self, key: &K) -> Option<&V>

キーkeyに対応する値の参照を返す。

Source

pub fn get_mut(&mut self, key: &K) -> Option<&mut V>

キーkeyに対応する値の可変参照を返す

Source

pub fn remove(&mut self, key: &K) -> Option<V>

キーkeyがあれば、そのキーと対応する値を削除して、その値をSomeで返す。

Source

pub fn get_by_index(&self, i: usize) -> Option<(&K, &V)>

i番目のキーとその対応する値のペアへの参照を返す。

Source

pub fn get_key_by_index(&self, i: usize) -> Option<&K>

i番目のキーへの参照を返す。

Source

pub fn get_value_by_index(&self, i: usize) -> Option<&V>

i番目のキーに対応する値への参照を返す。

Source

pub fn get_value_mut_by_index(&mut self, i: usize) -> Option<&mut V>

i番目のキーに対応する値への可変参照を返す。

Source

pub fn remove_by_index(&mut self, i: usize) -> Option<(K, V)>

i番目の要素を削除して、そのキーと値のペアを返す。

Source

pub fn for_each(&self, f: impl FnMut(&K, &mut V))

順序付き辞書のすべての要素を順番にfに渡す。

Trait Implementations§

Source§

impl<K: Ord, V> Default for OrderedMap<K, V>

Source§

fn default() -> Self

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

impl<K, V> Drop for OrderedMap<K, V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<K, V> !Freeze for OrderedMap<K, V>

§

impl<K, V> !RefUnwindSafe for OrderedMap<K, V>

§

impl<K, V> !Send for OrderedMap<K, V>

§

impl<K, V> !Sync for OrderedMap<K, V>

§

impl<K, V> Unpin for OrderedMap<K, V>

§

impl<K, V> UnwindSafe for OrderedMap<K, V>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.