pub struct map<K: AbiType + 'static, V: AbiType + 'static> { /* private fields */ }Expand description
cpp class: template<class K, class V, class Compare, class Allocator> std::map<K, V, Compare, Allocator>
Implementations§
Source§impl<K: AbiType + 'static, V: AbiType + 'static> map<K, V>
impl<K: AbiType + 'static, V: AbiType + 'static> map<K, V>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
use hicc_std::MapIntInt;
let map = MapIntInt::new();
assert!(map.is_empty());Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
use hicc_std::MapIntInt;
let map = MapIntInt::new();
assert_eq!(map.size(), 0_usize);Sourcepub fn max_size(&self) -> usize
pub fn max_size(&self) -> usize
use hicc_std::MapIntInt;
let map = MapIntInt::new();
println!("map.max_size() = {}", map.max_size());Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
assert_eq!(map.size(), 1_usize);
map.clear();
assert_eq!(map.size(), 0_usize);Sourcepub fn swap(&mut self, other: &mut <map<K, V> as AbiType>::InputType)
pub fn swap(&mut self, other: &mut <map<K, V> as AbiType>::InputType)
use hicc_std::MapIntInt;
let mut map1 = MapIntInt::new();
map1.insert(&1, &2);
let mut map2 = MapIntInt::new();
map2.swap(&mut map1);
assert_eq!(map1.size(), 0_usize);
assert_eq!(map2.size(), 1_usize);Sourcepub fn count(&self, key: &<K as AbiType>::InputType) -> usize
pub fn count(&self, key: &<K as AbiType>::InputType) -> usize
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
assert_eq!(map.count(&1), 1);
assert_eq!(map.count(&2), 0);Sourcepub fn contains(&self, key: &<K as AbiType>::InputType) -> bool
pub fn contains(&self, key: &<K as AbiType>::InputType) -> bool
cpp global function: bool SelfMethods::contains(const Self&, const K&)
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
assert!(map.contains(&1));
assert!(!map.contains(&2));Sourcepub fn assign(&mut self, other: &<map<K, V> as AbiType>::InputType)
pub fn assign(&mut self, other: &<map<K, V> as AbiType>::InputType)
cpp global function: void hicc::make_assign<Self, Self>(Self&, const Self&)
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.assign(&mut MapIntInt::new());
assert!(map.is_empty());Sourcepub fn insert(
&mut self,
key: &<K as AbiType>::InputType,
val: &<V as AbiType>::InputType,
) -> bool
pub fn insert( &mut self, key: &<K as AbiType>::InputType, val: &<V as AbiType>::InputType, ) -> bool
cpp global function: bool SelfMethods::insert(Self&, const K&, const V&)
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
assert!(map.insert(&1, &2));
assert_eq!(map.get(&1), Some(&2));
assert!(!map.insert(&1, &2));Source§impl<K: AbiType, V: AbiType> map<K, V>
impl<K: AbiType, V: AbiType> map<K, V>
Sourcepub fn get(&self, key: &K::InputType) -> Option<V::OutputRef<'_>>
pub fn get(&self, key: &K::InputType) -> Option<V::OutputRef<'_>>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
assert!(map.get(&1).is_some());
assert_eq!(map.get(&1), Some(&2));Sourcepub fn get_mut(&mut self, key: &K::InputType) -> Option<V::OutputRefMut<'_>>
pub fn get_mut(&mut self, key: &K::InputType) -> Option<V::OutputRefMut<'_>>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
assert!(map.get(&2).is_none());
assert_eq!(map.get(&1), Some(&2));
use hicc_std::{string, MapIntString};
use hicc::AbiClass;
let mut map = MapIntString::new();
map.insert(&1, &string::from(c"hello"));
assert!(*map.get(&1).unwrap() == string::from(c"hello"));
map.get_mut(&1).unwrap().write(string::from(c"world"));
assert!(*map.get(&1).unwrap() == string::from(c"world"));Sourcepub fn iter(&self) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
pub fn iter(&self) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
let mut it = map.iter();
assert_eq!(it.next(), Some((&1, &2)));
assert_eq!(it.next(), Some((&2, &3)));
assert!(it.next().is_none());Sourcepub fn iter_mut(
&mut self,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
map.iter_mut().for_each(|(_, v)| *v += 1);
let mut it = map.iter();
assert_eq!(it.next(), Some((&1, &3)));
assert_eq!(it.next(), Some((&2, &4)));
assert!(it.next().is_none());Sourcepub fn rev_iter(
&self,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
pub fn rev_iter( &self, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
let mut it = map.rev_iter();
assert_eq!(it.next(), Some((&2, &3)));
assert_eq!(it.next(), Some((&1, &2)));
assert!(it.next().is_none());Sourcepub fn rev_iter_mut(
&mut self,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
pub fn rev_iter_mut( &mut self, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
map.rev_iter_mut().for_each(|(_, v)| *v += 1);
let mut it = map.rev_iter();
assert_eq!(it.next(), Some((&2, &4)));
assert_eq!(it.next(), Some((&1, &3)));
assert!(it.next().is_none());Sourcepub fn iter_lower_upper_bound(
&self,
lower_key: Option<&K::InputType>,
upper_key: Option<&K::InputType>,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
pub fn iter_lower_upper_bound( &self, lower_key: Option<&K::InputType>, upper_key: Option<&K::InputType>, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
map.insert(&3, &4);
let mut it = map.iter_lower_upper_bound(Some(&1), Some(&2));
assert_eq!(it.next(), Some((&1, &2)));
assert_eq!(it.next(), Some((&2, &3)));
assert_eq!(it.next(), None);Sourcepub fn iter_lower_upper_bound_mut(
&mut self,
lower_key: Option<&K::InputType>,
upper_key: Option<&K::InputType>,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
pub fn iter_lower_upper_bound_mut( &mut self, lower_key: Option<&K::InputType>, upper_key: Option<&K::InputType>, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &2);
map.insert(&2, &3);
map.insert(&3, &4);
map.iter_lower_upper_bound_mut(Some(&1), Some(&2)).for_each(|(_, v)| *v -= 1);
let mut it = map.iter_lower_upper_bound(Some(&1), Some(&2));
assert_eq!(it.next(), Some((&1, &1)));
assert_eq!(it.next(), Some((&2, &2)));
assert_eq!(it.next(), None);Sourcepub fn rev_iter_lower_upper_bound(
&self,
lower_key: Option<&K::InputType>,
upper_key: Option<&K::InputType>,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
pub fn rev_iter_lower_upper_bound( &self, lower_key: Option<&K::InputType>, upper_key: Option<&K::InputType>, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRef<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &0);
map.insert(&2, &1);
map.insert(&3, &2);
let mut it = map.rev_iter_lower_upper_bound(Some(&1), Some(&2));
assert_eq!(it.next(), Some((&2, &1)));
assert_eq!(it.next(), Some((&1, &0)));
assert_eq!(it.next(), None);Sourcepub fn rev_iter_lower_upper_bound_mut(
&mut self,
lower_key: Option<&K::InputType>,
upper_key: Option<&K::InputType>,
) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
pub fn rev_iter_lower_upper_bound_mut( &mut self, lower_key: Option<&K::InputType>, upper_key: Option<&K::InputType>, ) -> impl Iterator<Item = (K::OutputRef<'_>, V::OutputRefMut<'_>)>
use hicc_std::MapIntInt;
let mut map = MapIntInt::new();
map.insert(&1, &0);
map.insert(&2, &1);
map.insert(&3, &2);
map.rev_iter_lower_upper_bound_mut(Some(&1), Some(&2)).for_each(|(_, v)| *v -= 1);
let mut it = map.rev_iter_lower_upper_bound(Some(&1), Some(&2));
assert_eq!(it.next(), Some((&2, &0)));
assert_eq!(it.next(), Some((&1, &-1)));
assert_eq!(it.next(), None);Trait Implementations§
Source§impl<K: AbiType + 'static, V: AbiType + 'static> AbiClass for map<K, V>
impl<K: AbiType + 'static, V: AbiType + 'static> AbiClass for map<K, V>
Source§fn get_raw_obj(&self) -> *const ()
fn get_raw_obj(&self) -> *const ()
仅内部使用.指针携带附加信息,不能转换为
c++类指针.Source§unsafe fn into_unique(self) -> Self
unsafe fn into_unique(self) -> Self
Safety Read more
Source§fn as_mut(&mut self) -> ClassRefMut<'_, Self>
fn as_mut(&mut self) -> ClassRefMut<'_, Self>
Source§fn as_mut_ptr(&mut self) -> ClassMutPtr<'_, Self>
fn as_mut_ptr(&mut self) -> ClassMutPtr<'_, Self>
AbiType::InputMutPtr<'_, T>参数类型实际是&ClassMutPtr<'_, T>,
当需要传递这类参数时可调用此接口.Source§fn into_ref(self) -> ClassRef<'static, Self>
fn into_ref(self) -> ClassRef<'static, Self>
T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.Source§fn into_mut(self) -> ClassRefMut<'static, Self>
fn into_mut(self) -> ClassRefMut<'static, Self>
T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.Source§fn into_ptr(self) -> ClassPtr<'static, Self>
fn into_ptr(self) -> ClassPtr<'static, Self>
T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.Source§fn into_mut_ptr(self) -> ClassMutPtr<'static, Self>
fn into_mut_ptr(self) -> ClassMutPtr<'static, Self>
T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.impl<K: AbiType + Sync, V: AbiType + Sync> Send for map<K, V>
impl<K: AbiType + Sync, V: AbiType + Sync> Sync for map<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for map<K, V>
impl<K, V> RefUnwindSafe for map<K, V>
impl<K, V> Unpin for map<K, V>
impl<K, V> UnwindSafe for map<K, V>
Blanket Implementations§
Source§impl<T> AbiType for Twhere
T: AbiClass,
impl<T> AbiType for Twhere
T: AbiClass,
type InputType = T
type InputPtr<'a, P, const N: usize> = &'a ClassPtr<'a, T, N> where T: 'a
type InputMutPtr<'a, P, const N: usize> = &'a ClassMutPtr<'a, T, N> where T: 'a
type OutputType = T
type OutputRef<'a> = ClassRef<'a, T> where T: 'a
type OutputRefMut<'a> = ClassRefMut<'a, T> where T: 'a
type OutputPtr<'a, P, const N: usize> = ClassPtr<'a, T, N> where T: 'a
type OutputMutPtr<'a, P, const N: usize> = ClassMutPtr<'a, T, N> where T: 'a
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more