Type Alias CapeArrayRealVec

Source
pub type CapeArrayRealVec = CapeArrayVec<CapeReal, ICapeArrayReal>;
Expand description

Vector based CapeArrayRealOut implementation

ICapeArrayReal 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::CapeReal>.

§Examples

use cobia::*;

fn set_content(arr: &mut CapeArrayRealOut) {
	arr.put_array(&[4.5,6.5]).unwrap();
}
 
let mut arr = cobia::CapeArrayRealVec::from_slice(&[4.5,6.5]);
set_content(&mut CapeArrayRealOutFromProvider::from(&mut arr).as_cape_array_real_out());
assert_eq!(arr.as_vec(), &vec![4.5,6.5]);

Aliased Type§

pub struct CapeArrayRealVec {
    vec: Vec<f64>,
    interface_type: PhantomData<ICapeArrayReal>,
}

Fields§

§vec: Vec<f64>§interface_type: PhantomData<ICapeArrayReal>

Implementations§

Source§

impl CapeArrayRealVec

Source

const VTABLE: ICapeArrayReal_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeReal, 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 CapeReal::NAN.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
arr.resize(4);
assert_eq!(arr.size(), 4);
assert!(arr[2].is_nan());
Source

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

Set the content of the real array from any object that implements CapeArrayRealProviderIn.

§Arguments
  • array - An object that implements CapeArrayRealProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayRealVec::new();
let arr1 = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);
Source

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

Interface member function

Trait Implementations§

Source§

impl CapeArrayRealProviderIn for CapeArrayRealVec

Source§

fn as_cape_array_real_in(&self) -> ICapeArrayReal

Convert to ICapeArrayReal

Returns a reference to the ICapeArrayReal interface.

§Examples
use cobia::*;

fn test_content(a: &CapeArrayRealIn) {
    assert_eq!(a.as_vec(), vec![2.5,4.5]);
}
 
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
test_content(&CapeArrayRealInFromProvider::from(&arr).as_cape_array_real_in());
Source§

impl CapeArrayRealProviderOut for CapeArrayRealVec

Source§

fn as_cape_array_real_out(&mut self) -> ICapeArrayReal

Convert to ICapeArrayReal

Returns a mutable reference to the ICapeArrayReal interface.

§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
let i_cape_array_real=arr.as_cape_array_real_out();
let mut i_cape_array_real_ptr=(&i_cape_array_real as *const C::ICapeArrayReal).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayRealOut::new(&mut i_cape_array_real_ptr); //CapeArrayRealOut from *mut C::ICapeArrayReal
assert_eq!(a.as_vec(), vec![2.5,4.5]);
Source§

impl<T: CapeArrayRealProviderIn> PartialEq<T> for CapeArrayRealVec

Source§

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

Partial equality

Checks if the CapeArrayRealVec is equal to another CapeArrayRealProviderIn.

§Arguments
  • other - The other CapeArrayRealProviderIn to compare with
§Examples
use cobia::*;
use cobia::prelude::*;
let arr1 = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
let arr2 = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
let arr3 = cobia::CapeArrayRealVec::from_slice(&[2.0,4.5]);
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.