pub struct CapeArrayObjectVec<ElementImpl, ElementInterface> {
vec: Vec<ElementImpl>,
interface_vec: Vec<ElementInterface>,
interface_ptr_vec: Vec<*mut ElementInterface>,
}Expand description
Base implementation for CapeArrayStringVec and CapeArrayValueVec
Fields§
§vec: Vec<ElementImpl>§interface_vec: Vec<ElementInterface>§interface_ptr_vec: Vec<*mut ElementInterface>Implementations§
Source§impl<ElementImpl, ElementInterface> CapeArrayObjectVec<ElementImpl, ElementInterface>
impl<ElementImpl, ElementInterface> CapeArrayObjectVec<ElementImpl, ElementInterface>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new CapeArrayObjectVec
Creates a new CapeArrayObjectVec with an empty array.
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::new();
assert_eq!(arr.as_string_vec().len(), 0);Sourcepub fn as_vec(&self) -> &Vec<ElementImpl>
pub fn as_vec(&self) -> &Vec<ElementImpl>
Return a vector
Returns a reference to the vector of ElementImpl.
§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.as_vec()[0].as_string(), "idealGasEnthalpy".to_string());Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Return size
Returns the size of the vector.
§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.size(), 2);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if empty
Returns true if the vector is empty.
§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::new();
assert!(arr.is_empty());Sourcepub fn iter(&self) -> CapeArrayObjectRefIterator<'_, ElementImpl> ⓘ
pub fn iter(&self) -> CapeArrayObjectRefIterator<'_, ElementImpl> ⓘ
Return an iterator for the array.
§Examples
use cobia::*;
fn test_iter(a: &CapeArrayStringIn) {
let mut iter = a.iter();
assert_eq!(cobia::CapeStringConstNoCase::from_string("IDEALGASENTHALPY"),iter.next().unwrap());
assert_eq!(cobia::CapeStringConstNoCase::from_string("idealgasentropy"),iter.next().unwrap());
assert!(!iter.next().is_some());
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy", "idealGasEntropy"]);
test_iter(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Source§impl CapeArrayObjectVec<CapeStringImpl, _ICapeString>
impl CapeArrayObjectVec<CapeStringImpl, _ICapeString>
Sourceconst CAPE_ARRAY_STRING_VTABLE: ICapeArrayString_VTable
const CAPE_ARRAY_STRING_VTABLE: ICapeArrayString_VTable
interface v-table
Sourcepub fn from_slice<T: AsRef<str>>(array: &[T]) -> CapeArrayStringVec
pub fn from_slice<T: AsRef<str>>(array: &[T]) -> CapeArrayStringVec
Initialize from string vector
Creates a new CapeArrayStringVec from a vector of array of strings.
§Arguments
array- A vector or array or slice of strings or string slices to be converted to a CapeArrayStringVec
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);Sourcepub fn as_string_vec(&self) -> Vec<String>
pub fn as_string_vec(&self) -> Vec<String>
Return a string vector
Returns a vector of strings from the CapeArrayStringVec.
Note that this operation comes with an overhead of string conversion.
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
let strvec = arr.as_string_vec();
assert_eq!(strvec, vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);Sourcepub fn set<T: CapeArrayStringProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
pub fn set<T: CapeArrayStringProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>
Set the content of the string array from any object that implements CapeArrayStringProviderIn.
§Arguments
array- An object that implements CapeArrayStringProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayStringVec::new();
let arr1 = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
arr.set(&arr1);
assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]); //the values have been stored on the object that implements ICapeArrayStringSourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut *mut ICapeString,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut *mut ICapeString, size: *mut CapeSize, )
interface member
Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut *mut ICapeString,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut *mut ICapeString, ) -> CapeResult
interface member
Source§impl CapeArrayObjectVec<CapeValueImpl, ICapeValue>
impl CapeArrayObjectVec<CapeValueImpl, ICapeValue>
Sourceconst CAPE_ARRAY_VALUE_VTABLE: ICapeArrayValue_VTable
const CAPE_ARRAY_VALUE_VTABLE: ICapeArrayValue_VTable
interface v-table
Sourcepub fn from_slice(array: &[CapeValueContent]) -> CapeArrayValueVec
pub fn from_slice(array: &[CapeValueContent]) -> CapeArrayValueVec
Initialize from CapeValueContent slice
Creates a new CapeArrayValueVec from or slice of CapeValueContent; note that the values will be cloned.
§Arguments
array- A slice of values to converted to a CapeArrayValueVec
§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);Sourcepub fn as_value_vec(&self) -> Vec<CapeValueContent>
pub fn as_value_vec(&self) -> Vec<CapeValueContent>
Return a value vector
Returns a vector of values from the CapeArrayValueVec.
§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
let valvec = arr.as_value_vec();
assert_eq!(valvec, vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);Sourcepub fn set<T: CapeArrayValueProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
pub fn set<T: CapeArrayValueProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>
Set the content of the value array from any object that implements CapeArrayValueProviderIn.
§Arguments
array- An object that implements CapeArrayValueProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayValueVec::new();
let mut arr1 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
arr.set(&arr1);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut *mut ICapeValue,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut *mut ICapeValue, size: *mut CapeSize, )
interface member
Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut *mut ICapeValue,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut *mut ICapeValue, ) -> CapeResult
interface member
Trait Implementations§
Source§impl<ElementImpl: Clone, ElementInterface: Clone> Clone for CapeArrayObjectVec<ElementImpl, ElementInterface>
impl<ElementImpl: Clone, ElementInterface: Clone> Clone for CapeArrayObjectVec<ElementImpl, ElementInterface>
Source§fn clone(&self) -> CapeArrayObjectVec<ElementImpl, ElementInterface>
fn clone(&self) -> CapeArrayObjectVec<ElementImpl, ElementInterface>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<ElementImpl, ElementInterface> Index<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>
impl<ElementImpl, ElementInterface> Index<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>
Source§impl<ElementImpl, ElementInterface> IndexMut<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>
impl<ElementImpl, ElementInterface> IndexMut<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>
Source§fn index_mut(&mut self, index: usize) -> &mut Self::Output
fn index_mut(&mut self, index: usize) -> &mut Self::Output
Indexing
Returns a mutable reference to the element at the given index.
§Arguments
index- The index of the element to be returned
§Examples
use cobia;
let mut arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
arr[0].set_string("idealGasHeatCapacity");
assert_eq!(arr.as_string_vec(), vec!["idealGasHeatCapacity".to_string(), "idealGasEntropy".to_string()]);