Type Alias CapeArrayIntegerVec

Source
pub type CapeArrayIntegerVec = CapeArrayVec<CapeInteger, ICapeArrayInteger>;
Expand description

Vector based CapeArrayIntegerOut implementation

ICapeArrayInteger 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::CapeInteger>.

§Examples

use cobia::*;

fn set_content(a: &mut CapeArrayIntegerOut) {
    a.put_array(&[2,8,10]).unwrap();
}
 
let mut arr = cobia::CapeArrayIntegerVec::new();
set_content(&mut CapeArrayIntegerOutFromProvider::from(&mut arr).as_cape_array_integer_out());
assert_eq!(arr.as_vec(), &vec![2,8,10]);

Aliased Type§

pub struct CapeArrayIntegerVec {
    vec: Vec<i32>,
    interface_type: PhantomData<ICapeArrayInteger>,
}

Fields§

§vec: Vec<i32>§interface_type: PhantomData<ICapeArrayInteger>

Implementations§

Source§

impl CapeArrayIntegerVec

Source

const VTABLE: ICapeArrayInteger_VTable

Interface v-table

Source

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

Interface member function

Source

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

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 0.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayIntegerVec::from_slice(&[2,4]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![2 as cobia::CapeInteger,4 as cobia::CapeInteger,0 as cobia::CapeInteger,0 as cobia::CapeInteger]);
Source

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

Set the content of the integer array from any object that implements CapeArrayIntegerProviderIn.

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

Trait Implementations§

Source§

impl CapeArrayIntegerProviderIn for CapeArrayIntegerVec

Source§

fn as_cape_array_integer_in(&self) -> ICapeArrayInteger

Convert to ICapeArrayInteger

Returns a reference to the ICapeArrayInteger interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayIntegerVec::from_slice(&[9,10,2]);
let i_cape_array_integer=arr.as_cape_array_integer_out();
let mut i_cape_array_integer_ptr=(&i_cape_array_integer as *const C::ICapeArrayInteger).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayIntegerOut::new(&mut i_cape_array_integer_ptr); //CapeArrayIntegerOut from *mut C::ICapeArrayInteger
assert_eq!(a.as_vec(), vec![9,10,2]);
Source§

impl CapeArrayIntegerProviderOut for CapeArrayIntegerVec

Source§

fn as_cape_array_integer_out(&mut self) -> ICapeArrayInteger

Convert to ICapeArrayInteger

Returns a mutable reference to the ICapeArrayInteger interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayIntegerVec::from_slice(&[9,10,2]);
let i_cape_array_integer=arr.as_cape_array_integer_out();
let mut i_cape_array_integer_ptr=(&i_cape_array_integer as *const C::ICapeArrayInteger).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayIntegerOut::new(&mut i_cape_array_integer_ptr); //CapeArrayIntegerOut from *mut C::ICapeArrayInteger
assert_eq!(a.as_vec(), vec![9,10,2]);
Source§

impl<T: CapeArrayIntegerProviderIn> PartialEq<T> for CapeArrayIntegerVec

Source§

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

Partial equality

Checks if the CapeArrayIntegerVec is equal to another CapeArrayIntegerProviderIn.

§Arguments
  • other - The other CapeArrayIntegerProviderIn to compare with
§Examples
use cobia::*;
use cobia::prelude::*;
let arr1 = cobia::CapeArrayIntegerVec::from_slice(&[2,4]);
let arr2 = cobia::CapeArrayIntegerVec::from_slice(&[2,4]);
let arr3 = cobia::CapeArrayIntegerVec::from_slice(&[2,3,4]);
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.