VecBool

Struct VecBool 

Source
pub struct VecBool { /* private fields */ }
Expand description

cpp class: template<class Allocator> std::vector<bool, Allocator>

Implementations§

Source§

impl VecBool

Source

pub fn get(&self, pos: usize) -> Option<bool>

use hicc_std::VecBool;
let mut vec = VecBool::new();
assert_eq!(vec.get(0), None);
vec.push_back(true);
assert_eq!(vec.get(0), Some(true));
Source

pub fn back(&self) -> Option<bool>

use hicc_std::VecBool;
let mut vec = VecBool::new();
assert_eq!(vec.back(), None);
vec.push_back(true);
assert_eq!(vec.back(), Some(true));
Source

pub fn front(&self) -> Option<bool>

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.push_back(true);
assert_eq!(vec.front(), Some(true));
Source

pub fn assign(&mut self, n: usize, val: bool)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.assign(2, true);
assert_eq!(vec.size(), 2);
assert_eq!(vec.front(), Some(true));
assert_eq!(vec.back(), Some(true));
Source

pub fn pop_back(&mut self)

如果为空不做任何改变.

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.pop_back();
vec.push_back(true);
vec.pop_back();
assert!(vec.is_empty());
Source

pub fn is_empty(&self) -> bool

use hicc_std::VecBool;
let vec = VecBool::new();
assert!(vec.is_empty());
Source

pub fn size(&self) -> usize

use hicc_std::VecBool;
let vec = VecBool::new();
assert_eq!(vec.size(), 0);
Source

pub fn max_size(&self) -> usize

use hicc_std::VecBool;
let vec = VecBool::new();
println!("vec.max_size = {}", vec.max_size());
Source

pub fn capacity(&self) -> usize

use hicc_std::VecBool;
let vec = VecBool::new();
println!("vec.capacity = {}", vec.capacity());
Source

pub fn clear(&mut self)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.push_back(true);
vec.clear();
assert!(vec.is_empty());
Source

pub fn reserve(&mut self, n: usize)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.reserve(10_usize);
assert!(vec.is_empty());
println!("vec.capacity = {}", vec.capacity());
Source

pub fn shrink_to_fit(&mut self)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.reserve(10_usize);
// ...
vec.shrink_to_fit();
Source

pub fn resize(&mut self, n: usize, val: bool)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.resize(2, true);
assert_eq!(vec.size(), 2);
assert_eq!(vec.back(), Some(true));
assert_eq!(vec.front(), Some(true));
Source

pub fn set(&mut self, pos: usize, val: bool)

cpp global function: void SelfMethods::set(Self&, size_t, bool) 如果pos超出范围,则不做任何修改.

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.set(0, false);
assert_eq!(vec.get(0), None);
vec.push_back(true);
assert_eq!(vec.get(0), Some(true));
vec.set(0, false);
assert_eq!(vec.get(0), Some(false));
Source

pub fn push_back(&mut self, val: bool)

cpp global function: void SelfMethods::push_back(Self&, bool)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.push_back(true);
assert_eq!(vec.front(), Some(true));
Source

pub fn swap(&mut self, other: &mut <VecBool as AbiType>::InputType)

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.push_back(true);
vec.swap(&mut VecBool::new());
assert!(vec.is_empty());
Source

pub fn insert(&mut self, pos: usize, count: usize, val: bool)

cpp global function: void SelfMethods::insert(Self&, size_t, size_t, bool) 如果pos超出范围则添加到最后.

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.insert(0, 2, true);
vec.insert(vec.size(), 1, false);
assert_eq!(vec.get(0), Some(true));
assert_eq!(vec.get(1), Some(true));
assert_eq!(vec.get(2), Some(false));
assert_eq!(vec.get(3), None);
Source

pub fn erase(&mut self, pos: usize, count: usize)

cpp global function: void SelfMethods::erase(Self&, size_t, size_t) 如果pos超出范围则不做任何改变.

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.insert(0, 10, true);
vec.erase(1, 9);
assert_eq!(vec.size(), 1);
assert_eq!(vec.get(0), Some(true));
Source§

impl VecBool

Source

pub fn iter(&self) -> impl Iterator<Item = bool> + '_

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.resize(2, false);
vec.set(0, true);
let mut it = vec.iter();
assert_eq!(it.next(), Some(true));
assert_eq!(it.next(), Some(false));
assert_eq!(it.next(), None);
Source

pub fn rev_iter(&self) -> impl Iterator<Item = bool> + '_

use hicc_std::VecBool;
let mut vec = VecBool::new();
vec.resize(2, false);
vec.set(0, true);
let mut it = vec.rev_iter();
assert_eq!(it.next(), Some(false));
assert_eq!(it.next(), Some(true));
assert_eq!(it.next(), None);

Trait Implementations§

Source§

impl AbiClass for VecBool

Source§

fn get_raw_obj(&self) -> *const ()

仅内部使用.指针携带附加信息,不能转换为c++类指针.
Source§

unsafe fn make_ref(&self, obj: *const ()) -> Self

Safety Read more
Source§

unsafe fn into_unique(self) -> Self

Safety Read more
Source§

fn write(&mut self, other: Self)

更新对象本身. Read more
Source§

fn size_of(&self) -> usize

返回c++对象的大小.
Source§

fn is_null(&self) -> bool

rust侧的值类型实际都对应到c++侧的对象指针, 检查是否为空指针.
Source§

fn as_ref(&self) -> ClassRef<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_mut(&mut self) -> ClassRefMut<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_ptr(&self) -> ClassPtr<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_mut_ptr(&mut self) -> ClassMutPtr<'_, Self>

AbiType::InputMutPtr<'_, T>参数类型实际是&ClassMutPtr<'_, T>, 当需要传递这类参数时可调用此接口.
Source§

fn into_ref(self) -> ClassRef<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn into_mut(self) -> ClassRefMut<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

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>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn get_obj(&self) -> *const ()

一般内部使用. 返回值等同于c++侧的指针。
Source§

impl Debug for VecBool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for VecBool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for VecBool

Source§

impl Sync for VecBool

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AbiType for T
where T: AbiClass,

Source§

type InputType = T

Source§

type InputPtr<'a, P, const N: usize> = &'a ClassPtr<'a, T, N> where T: 'a

Source§

type InputMutPtr<'a, P, const N: usize> = &'a ClassMutPtr<'a, T, N> where T: 'a

Source§

type OutputType = T

Source§

type OutputRef<'a> = ClassRef<'a, T> where T: 'a

Source§

type OutputRefMut<'a> = ClassRefMut<'a, T> where T: 'a

Source§

type OutputPtr<'a, P, const N: usize> = ClassPtr<'a, T, N> where T: 'a

Source§

type OutputMutPtr<'a, P, const N: usize> = ClassMutPtr<'a, T, N> where T: 'a

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.