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
impl CapeArrayRealVec
Sourceconst VTABLE: ICapeArrayReal_VTable
const VTABLE: ICapeArrayReal_VTable
Interface v-table
Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut CapeReal,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut CapeReal, size: *mut CapeSize, )
Interface member function
Sourcepub fn resize(&mut self, size: usize)
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());Sourcepub fn set<T: CapeArrayRealProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
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]);Trait Implementations§
Source§impl CapeArrayRealProviderIn for CapeArrayRealVec
impl CapeArrayRealProviderIn for CapeArrayRealVec
Source§fn as_cape_array_real_in(&self) -> ICapeArrayReal
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
impl CapeArrayRealProviderOut for CapeArrayRealVec
Source§fn as_cape_array_real_out(&mut self) -> ICapeArrayReal
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
impl<T: CapeArrayRealProviderIn> PartialEq<T> for CapeArrayRealVec
Source§fn eq(&self, other: &T) -> bool
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);