pub struct forward_list<T: AbiType + 'static> { /* private fields */ }Expand description
cpp class: template<class T, class Allocator> std::forward_list<T, Allocator>
Implementations§
Source§impl<T: AbiType + 'static> forward_list<T>
impl<T: AbiType + 'static> forward_list<T>
Sourcepub fn pop_front(&mut self)
pub fn pop_front(&mut self)
如果为空则忽略.
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.pop_front();
assert!(list.is_empty());Sourcepub fn front(&self) -> Option<T::OutputRef<'_>>
pub fn front(&self) -> Option<T::OutputRef<'_>>
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
assert_eq!(list.front(), Some(&1));Sourcepub fn front_mut(&mut self) -> Option<T::OutputRefMut<'_>>
pub fn front_mut(&mut self) -> Option<T::OutputRefMut<'_>>
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
*list.front_mut().unwrap() = 2;
assert_eq!(list.front(), Some(&2));
use hicc_std::{string, ForwardListString};
use hicc::AbiClass;
let mut list = ForwardListString::new();
list.push_front(&string::from(c"hello"));
list.front_mut().unwrap().write(string::from(c"world"));
assert_eq!(list.front() , Some(string::from(c"world").into_ref()));Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
use hicc_std::ForwardListInt;
let list = ForwardListInt::new();
assert!(list.is_empty());Sourcepub fn max_size(&self) -> usize
pub fn max_size(&self) -> usize
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
assert!(list.max_size() >= 1);Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.clear();
assert!(list.is_empty());Sourcepub fn resize(&mut self, n: usize, val: &<T as AbiType>::InputType)
pub fn resize(&mut self, n: usize, val: &<T as AbiType>::InputType)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.resize(10, &1);
assert_eq!(list.iter().count(), 10);
list.iter().for_each(|v| { println!("{v}"); });Sourcepub fn push_front(&mut self, val: &<T as AbiType>::InputType)
pub fn push_front(&mut self, val: &<T as AbiType>::InputType)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
assert_eq!(list.front(), Some(&1));Sourcepub fn swap(&mut self, other: &mut <forward_list<T> as AbiType>::InputType)
pub fn swap(&mut self, other: &mut <forward_list<T> as AbiType>::InputType)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.swap(&mut ForwardListInt::new());
assert!(list.is_empty());Sourcepub fn assign(&mut self, ncount: usize, val: &<T as AbiType>::InputType)
pub fn assign(&mut self, ncount: usize, val: &<T as AbiType>::InputType)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.assign(10, &1);
assert_eq!(list.iter().count(), 10);
assert_eq!(list.front(), Some(&1));
list.iter().for_each(|v| { assert_eq!(v, &1); });Sourcepub fn reverse(&mut self)
pub fn reverse(&mut self)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&2);
list.push_front(&1);
assert_eq!(list.front(), Some(&1));
list.reverse();
assert_eq!(list.front(), Some(&2));
list.iter().for_each(|v| { println!("{v}"); });Sourcepub fn remove(&mut self, val: &<T as AbiType>::InputType)
pub fn remove(&mut self, val: &<T as AbiType>::InputType)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.push_front(&2);
list.push_front(&1);
list.remove(&1);
assert_eq!(list.iter().count(), 1);
assert_eq!(list.front(), Some(&2));Sourcepub fn remove_if<'a>(&'a mut self, pred: Function<fn(&'a T::InputType) -> bool>)
pub fn remove_if<'a>(&'a mut self, pred: Function<fn(&'a T::InputType) -> bool>)
cpp global function: void SelfMethods::remove_if(Self&, std::function<bool(const T&)>)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.push_front(&2);
list.push_front(&3);
list.remove_if(|v: &i32| -> bool {
(v & 1) == 1
}.into());
assert_eq!(list.iter().count(), 1);
assert_eq!(list.front(), Some(&2));Sourcepub fn sort<'a>(
&'a mut self,
comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>,
)
pub fn sort<'a>( &'a mut self, comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>, )
cpp global function: void SelfMethods::sort(Self&, std::function<bool(const T&, const T&)>)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.push_front(&2);
list.push_front(&3);
assert_eq!(list.front(), Some(&3));
list.sort(|v1: &i32, v2: &i32| -> bool {
v1 < v2
}.into());
let mut it = list.iter();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), None);Sourcepub fn merge<'a>(
&'a mut self,
other: &mut <forward_list<T> as AbiType>::InputType,
comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>,
)
pub fn merge<'a>( &'a mut self, other: &mut <forward_list<T> as AbiType>::InputType, comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>, )
cpp global function: void SelfMethods::merge(Self&, Self&, std::function<bool(const T&, const T&)>)
如果不满足如下条件则忽略.
self.get_allocator() == other.get_allocator().
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.push_front(&3);
let cmp = |v1: &i32, v2: &i32| -> bool {
v1 < v2
};
list.sort(cmp.clone().into());
let mut other = ForwardListInt::new();
other.push_front(&2);
other.push_front(&4);
other.sort(cmp.clone().into());
list.merge(&mut other, cmp.into());
let mut it = list.iter();
assert!(other.is_empty());
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&4));
assert_eq!(it.next(), None);Sourcepub fn unique_with<'a>(
&'a mut self,
comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>,
)
pub fn unique_with<'a>( &'a mut self, comp: Function<fn(&'a T::InputType, &'a T::InputType) -> bool>, )
cpp global function: void SelfMethods::unique(Self&, std::function<bool(const T&, const T&)>)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&3);
list.push_front(&3);
list.push_front(&1);
list.push_front(&1);
let mut n = 0;
list.unique_with(|v1: &i32, v2: &i32| -> bool {
v1 == v2
}.into());
let mut it = list.iter();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), None);Sourcepub fn unique(&mut self)
pub fn unique(&mut self)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&3);
list.push_front(&3);
list.push_front(&1);
list.push_front(&1);
list.unique();
let mut it = list.iter();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), None);Sourcepub fn insert_front(&mut self, ncount: usize, val: &<T as AbiType>::InputType)
pub fn insert_front(&mut self, ncount: usize, val: &<T as AbiType>::InputType)
cpp global function: void insert_after(Self&, size_t, const T&)
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.insert_front(2, &1);
let mut it = list.iter();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), None);Sourcepub fn splice_front(
&mut self,
other: &mut <forward_list<T> as AbiType>::InputType,
)
pub fn splice_front( &mut self, other: &mut <forward_list<T> as AbiType>::InputType, )
cpp global function: void splice_after(Self&, Self&)
不满足下面条件则不做任何修改:
self.get_allocator() == other.get_allocator()&self != &other
use hicc_std::ForwardListInt;
let mut src = ForwardListInt::new();
src.push_front(&1);
src.push_front(&2);
let mut dst = ForwardListInt::new();
dst.splice_front(&mut src);
assert!(src.is_empty());
let mut it = dst.iter();
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), None);Source§impl<T: AbiType> forward_list<T>
impl<T: AbiType> forward_list<T>
Sourcepub fn iter(&self) -> ForwardListIter<'_, T> ⓘ
pub fn iter(&self) -> ForwardListIter<'_, T> ⓘ
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.push_front(&2);
let mut it = list.iter();
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), None);Sourcepub fn iter_mut(&mut self) -> ForwardListIterMut<'_, T> ⓘ
pub fn iter_mut(&mut self) -> ForwardListIterMut<'_, T> ⓘ
use hicc_std::ForwardListInt;
let mut list = ForwardListInt::new();
list.push_front(&1);
list.iter_mut().for_each(|v| *v -= 1);
assert_eq!(list.front(), Some(&0));Trait Implementations§
Source§impl<T: AbiType + 'static> AbiClass for forward_list<T>
impl<T: AbiType + 'static> AbiClass for forward_list<T>
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>作为返回值实质是等价.Source§impl<T: AbiType + 'static> Debug for forward_list<T>
impl<T: AbiType + 'static> Debug for forward_list<T>
Source§impl<T: AbiType + 'static> Drop for forward_list<T>
impl<T: AbiType + 'static> Drop for forward_list<T>
impl<T: AbiType + Sync> Send for forward_list<T>
impl<T: AbiType + Sync> Sync for forward_list<T>
Auto Trait Implementations§
impl<T> Freeze for forward_list<T>
impl<T> RefUnwindSafe for forward_list<T>
impl<T> Unpin for forward_list<T>
impl<T> UnwindSafe for forward_list<T>
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