Type Alias CapeArrayBooleanVec

Source
pub type CapeArrayBooleanVec = CapeArrayVec<CapeBoolean, ICapeArrayBoolean>;
Expand description

Vector based CapeArrayBooleanOut implementation

ICapeArrayBoolean is passed as data container between CAPE-OPEN functions. It is up to the caller to provide the interface, and its implementation. This class provides a default impementation using a Vec<C::CapeBoolean>.

§Examples

use cobia::*;

fn test_content(a: &CapeArrayBooleanIn) {
    assert_eq!(a.as_bool_vec(), vec![true,false]);
}
 
let arr = cobia::CapeArrayBooleanVec::from_bool_slice(&[true,false]);
test_content(&CapeArrayBooleanInFromProvider::from(&arr).as_cape_array_boolean_in())

Aliased Type§

pub struct CapeArrayBooleanVec {
    vec: Vec<u32>,
    interface_type: PhantomData<ICapeArrayBoolean>,
}

Fields§

§vec: Vec<u32>§interface_type: PhantomData<ICapeArrayBoolean>

Implementations§

Source§

impl CapeArrayBooleanVec

Source

const VTABLE: ICapeArrayBoolean_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeBoolean, size: *mut CapeSize, )

Interface member function

Source

pub fn resize(&mut self, size: usize)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set to false.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayBooleanVec::from_bool_slice(&[true,false]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![true as cobia::CapeBoolean,false as cobia::CapeBoolean,false as cobia::CapeBoolean,false as cobia::CapeBoolean]);
Source

extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeBoolean, ) -> CapeResult

Interface member function

Source

pub fn set<T: CapeArrayBooleanProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the boolean array from any object that implements CapeArrayBooleanProviderIn.

§Arguments
  • array - An object that implements CapeArrayBooleanProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayBooleanVec::new();
let arr1 = cobia::CapeArrayBooleanVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);
Source§

impl CapeArrayBooleanVec

Source

pub fn from_bool_slice(slice: &[bool]) -> Self

Initialize from bool slice

Creates a new CapeArrayTypeImpl from a bool slice.

§Arguments
  • slice - A vector or array or slice of values to be converted to a CapeArrayTypeImpl - values are copied
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = CapeArrayBooleanVec::from_bool_slice(&[true,false,false]);
assert_eq!(arr.as_vec(), &vec![true as CapeBoolean,false as CapeBoolean,false as CapeBoolean]);

Trait Implementations§

Source§

impl CapeArrayBooleanProviderIn for CapeArrayBooleanVec

Source§

fn as_cape_array_boolean_in(&self) -> ICapeArrayBoolean

Convert to ICapeArrayBoolean

Returns a reference to the ICapeArrayBoolean interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayBooleanVec::from_bool_slice(&[false,true,false]);
let i_cape_array_boolean=arr.as_cape_array_boolean_in();
let mut i_cape_array_boolean_ptr=(&i_cape_array_boolean as *const C::ICapeArrayBoolean).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayBooleanIn::new(&mut i_cape_array_boolean_ptr); //CapeArrayBooleanIn from *mut C::ICapeArrayBoolean
assert_eq!(a.as_bool_vec(), vec![false,true,false]);
Source§

impl CapeArrayBooleanProviderOut for CapeArrayBooleanVec

Source§

fn as_cape_array_boolean_out(&mut self) -> ICapeArrayBoolean

Convert to ICapeArrayBoolean

Returns a mutable reference to the ICapeArrayBoolean interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayBooleanVec::from_bool_slice(&[false,true,false]);
let i_cape_array_boolean=arr.as_cape_array_boolean_in();
let mut i_cape_array_boolean_ptr=(&i_cape_array_boolean as *const C::ICapeArrayBoolean).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayBooleanIn::new(&mut i_cape_array_boolean_ptr); //CapeArrayBooleanIn from *mut C::ICapeArrayBoolean
assert_eq!(a.as_bool_vec(), vec![false,true,false]);
Source§

impl<T: CapeArrayBooleanProviderIn> PartialEq<T> for CapeArrayBooleanVec

Source§

fn eq(&self, other: &T) -> bool

Partial equality

Checks if the CapeArrayBooleanVec is equal to another CapeArrayBooleanProviderIn.

§Arguments
  • other - The other CapeArrayBooleanProviderIn to compare with
§Examples
use cobia::*;
use cobia::prelude::*;
let arr1 = cobia::CapeArrayBooleanVec::from_bool_slice(&[true,false]);
let arr2 = cobia::CapeArrayBooleanVec::from_bool_slice(&[true,false]);
let arr3 = cobia::CapeArrayBooleanVec::from_bool_slice(&[false,false]);
assert!(arr1 == arr2);
assert!(arr1 != arr3);
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.