pub struct CapeArrayVec<Element: Copy + Clone, InterfaceType> {
vec: Vec<Element>,
interface_type: PhantomData<InterfaceType>,
}Expand description
Vector based implementation of ICapeArray
Base class for several vector based ICapeArray implementations.
Any ICapeArray (e.g. 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, that uses std::vec::Vec as the data container.
§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]);Fields§
§vec: Vec<Element>§interface_type: PhantomData<InterfaceType>Implementations§
Source§impl<Element: Copy + Clone, InterfaceType> CapeArrayVec<Element, InterfaceType>
impl<Element: Copy + Clone, InterfaceType> CapeArrayVec<Element, InterfaceType>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new CapeArrayVec
Creates a new empty CapeArrayVec
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::new();
assert_eq!(arr.as_vec().len(), 0);Sourcepub fn as_vec(&self) -> &Vec<Element>
pub fn as_vec(&self) -> &Vec<Element>
Return a vector
Returns a reference to the vector of type T.
§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);Sourcepub fn as_mut_vec(&mut self) -> &mut Vec<Element>
pub fn as_mut_vec(&mut self) -> &mut Vec<Element>
Return a mutable vector
Returns a mutable reference to the vector of type T.
§Example
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_vec(vec![2.5,4.5]);
arr.as_mut_vec().push(6.5);
assert_eq!(arr.as_vec(), &vec![2.5,4.5,6.5]);Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Get size
Returns the size of the array.
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.size(), 2);Sourcepub fn from_slice(slice: &[Element]) -> Self
pub fn from_slice(slice: &[Element]) -> Self
Initialize from slice
Creates a new CapeArrayVec from a slice.
§Arguments
slice- A vector or array or slice of values to be converted to a CapeArrayVec - values are copied
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if empty
Returns true if the array is empty.
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::new();
assert!(arr.is_empty());Sourcepub fn from_vec(vec: Vec<Element>) -> Self
pub fn from_vec(vec: Vec<Element>) -> Self
Initialize from vector
Creates a new CapeArrayVec from a vector, taking ownwership of the data
§Arguments
vec- A vector slice of values to be converted to a CapeArrayVec
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);Source§impl CapeArrayVec<f64, ICapeArrayReal>
impl CapeArrayVec<f64, ICapeArrayReal>
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]);Source§impl CapeArrayVec<i32, ICapeArrayInteger>
impl CapeArrayVec<i32, ICapeArrayInteger>
Sourceconst VTABLE: ICapeArrayInteger_VTable
const VTABLE: ICapeArrayInteger_VTable
Interface v-table
Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut CapeInteger,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut CapeInteger, size: *mut CapeSize, )
Interface member function
Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut CapeInteger,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeInteger, ) -> CapeResult
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 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]);Sourcepub fn set<T: CapeArrayIntegerProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
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]);Source§impl CapeArrayVec<u8, ICapeArrayByte>
impl CapeArrayVec<u8, ICapeArrayByte>
Sourceconst VTABLE: ICapeArrayByte_VTable
const VTABLE: ICapeArrayByte_VTable
Interface v-table
Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut CapeByte,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut CapeByte, size: *mut CapeSize, )
Interface member function
Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut CapeByte,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeByte, ) -> CapeResult
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 0.
§Arguments
size- The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![2u8,4u8,0,0]);Sourcepub fn set<T: CapeArrayByteProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
pub fn set<T: CapeArrayByteProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>
Set the content of the byte array from any object that implements CapeArrayByteProviderIn.
§Arguments
array- An object that implements CapeArrayByteProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayByteVec::new();
let arr1 = cobia::CapeArrayByteVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);Source§impl CapeArrayVec<u32, ICapeArrayBoolean>
impl CapeArrayVec<u32, ICapeArrayBoolean>
Sourceconst VTABLE: ICapeArrayBoolean_VTable
const VTABLE: ICapeArrayBoolean_VTable
Interface v-table
Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut CapeBoolean,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut CapeBoolean, 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 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]);Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut CapeBoolean,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeBoolean, ) -> CapeResult
Interface member function
Sourcepub fn set<T: CapeArrayBooleanProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
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 CapeArrayVec<u32, ICapeArrayBoolean>
impl CapeArrayVec<u32, ICapeArrayBoolean>
Sourcepub fn from_bool_slice(slice: &[bool]) -> Self
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]);Source§impl CapeArrayVec<CapeEnumeration, ICapeArrayEnumeration>
impl CapeArrayVec<CapeEnumeration, ICapeArrayEnumeration>
Sourceconst VTABLE_RAW: ICapeArrayEnumeration_VTable
const VTABLE_RAW: ICapeArrayEnumeration_VTable
Interface v-table
Sourceextern "C" fn get_raw(
me: *mut c_void,
data: *mut *mut CapeEnumeration,
size: *mut CapeSize,
)
extern "C" fn get_raw( me: *mut c_void, data: *mut *mut CapeEnumeration, size: *mut CapeSize, )
Interface member function
Sourceextern "C" fn setsize_raw(
me: *mut c_void,
size: CapeSize,
data: *mut *mut CapeEnumeration,
) -> CapeResult
extern "C" fn setsize_raw( me: *mut c_void, size: CapeSize, data: *mut *mut CapeEnumeration, ) -> CapeResult
Interface member function
Source§impl<Element: Copy + Clone> CapeArrayVec<Element, ICapeArrayEnumeration>
impl<Element: Copy + Clone> CapeArrayVec<Element, ICapeArrayEnumeration>
Sourcepub fn resize(&mut self, size: usize, value: Element)
pub fn resize(&mut self, size: usize, value: Element)
Resize
Resize the array to the given size. If the size is larger than the current size, the new elements are set specified value.
§Arguments
size- The new size of the arrayvalue- The value to set the new elements to
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayEnumerationVec::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
arr.resize(4,cobia::CapePMCServiceType::Inproc32);
assert_eq!(arr.as_vec(), &vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64,cobia::CapePMCServiceType::Inproc32,cobia::CapePMCServiceType::Inproc32]);Trait Implementations§
Source§impl<Element: Copy + Clone, InterfacType> AsRef<[Element]> for CapeArrayVec<Element, InterfacType>
impl<Element: Copy + Clone, InterfacType> AsRef<[Element]> for CapeArrayVec<Element, InterfacType>
Source§impl<Element: Clone + Copy + Clone, InterfaceType: Clone> Clone for CapeArrayVec<Element, InterfaceType>
impl<Element: Clone + Copy + Clone, InterfaceType: Clone> Clone for CapeArrayVec<Element, InterfaceType>
Source§fn clone(&self) -> CapeArrayVec<Element, InterfaceType>
fn clone(&self) -> CapeArrayVec<Element, InterfaceType>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more