pub struct DataArray {
pub data_ref: usize,
}
Expand description
Represents an array of type ndata.Data
.
Fields
data_ref: usize
The pointer to the array in the array heap.
Implementations
sourceimpl DataArray
impl DataArray
sourcepub fn init() -> ((usize, usize), (usize, usize))
pub fn init() -> ((usize, usize), (usize, usize))
Initialize global storage of arrays. Call only once at startup.
sourcepub fn mirror(q: (usize, usize), r: (usize, usize))
pub fn mirror(q: (usize, usize), r: (usize, usize))
Mirror global storage of arrays from another process. Call only once at startup.
sourcepub fn from_string(s: &str) -> DataArray
pub fn from_string(s: &str) -> DataArray
Create a new DataArray from a JSON string.
sourcepub fn duplicate(&self) -> DataArray
pub fn duplicate(&self) -> DataArray
Returns a new DataArray
that points to the same underlying array instance.
sourcepub fn shallow_copy(self) -> DataArray
pub fn shallow_copy(self) -> DataArray
Returns a new DataArray
that points to a new array instance, which contains the
same underlying data as the original.
sourcepub fn deep_copy(&self) -> DataArray
pub fn deep_copy(&self) -> DataArray
Returns a new DataArray
that points to a new array instance, which contains a
recursively deep copy of the original underlying data.
sourcepub fn push_unique(&self, b: Data) -> bool
pub fn push_unique(&self, b: Data) -> bool
Push data if not already in array
sourcepub fn remove_data(&self, b: Data) -> bool
pub fn remove_data(&self, b: Data) -> bool
Returns the index of a Data in the array
sourcepub fn get_property(&self, id: usize) -> Data
pub fn get_property(&self, id: usize) -> Data
Returns the indexed value from the array
sourcepub fn get_string(&self, id: usize) -> String
pub fn get_string(&self, id: usize) -> String
Returns the indexed value from the array as a String
sourcepub fn get_array(&self, id: usize) -> DataArray
pub fn get_array(&self, id: usize) -> DataArray
Returns the indexed value from the array as a DataArray
sourcepub fn get_object(&self, id: usize) -> DataObject
pub fn get_object(&self, id: usize) -> DataObject
Returns the indexed value from the array as a DataObject
sourcepub fn get_bytes(&self, id: usize) -> DataBytes
pub fn get_bytes(&self, id: usize) -> DataBytes
Returns the indexed value from the array as a DataBytes
sourcepub fn push_property(&mut self, data: Data)
pub fn push_property(&mut self, data: Data)
Append the given value to the end of the array
sourcepub fn push_float(&mut self, val: f64)
pub fn push_float(&mut self, val: f64)
Append the given f64
to the end of the array
sourcepub fn push_object(&mut self, o: DataObject)
pub fn push_object(&mut self, o: DataObject)
Append the given DataObject
to the end of the array
pub fn push_list(&mut self, a: DataArray)
push_array
insteadsourcepub fn push_array(&mut self, a: DataArray)
pub fn push_array(&mut self, a: DataArray)
Append the given DataArray
to the end of the array
sourcepub fn push_bytes(&mut self, a: DataBytes)
pub fn push_bytes(&mut self, a: DataBytes)
Append the given DataBytes
to the end of the array
sourcepub fn set_property(&mut self, id: usize, data: Data)
pub fn set_property(&mut self, id: usize, data: Data)
Replace the indexed value in the array
sourcepub fn put_str(&mut self, id: usize, val: &str)
pub fn put_str(&mut self, id: usize, val: &str)
Replace the indexed value in the array with the given String
.
sourcepub fn put_bool(&mut self, id: usize, val: bool)
pub fn put_bool(&mut self, id: usize, val: bool)
Replace the indexed value in the array with the given bool
.
sourcepub fn put_i64(&mut self, id: usize, val: i64)
pub fn put_i64(&mut self, id: usize, val: i64)
Replace the indexed value in the array with the given i64
.
sourcepub fn put_float(&mut self, id: usize, val: f64)
pub fn put_float(&mut self, id: usize, val: f64)
Replace the indexed value in the array with the given f64
.
sourcepub fn put_object(&mut self, id: usize, o: DataObject)
pub fn put_object(&mut self, id: usize, o: DataObject)
Replace the indexed value in the array with the given DataObject
.
sourcepub fn put_array(&mut self, id: usize, a: DataArray)
pub fn put_array(&mut self, id: usize, a: DataArray)
Replace the indexed value in the array with the given DataArray
.
sourcepub fn put_bytes(&mut self, id: usize, a: DataBytes)
pub fn put_bytes(&mut self, id: usize, a: DataBytes)
Replace the indexed value in the array with the given DataBytes
.
sourcepub fn remove_property(&mut self, id: usize)
pub fn remove_property(&mut self, id: usize)
Remove the indexed value from the array
sourcepub fn delete(
aheap: &mut Heap<Vec<Data>>,
data_ref: usize,
oheap: &mut Heap<HashMap<String, Data>>
)
pub fn delete(
aheap: &mut Heap<Vec<Data>>,
data_ref: usize,
oheap: &mut Heap<HashMap<String, Data>>
)
DO NOT USE
Reduces the reference count for this array by one, as well as the reference counts of any
objects, arrays, or byte buffers contained in this array. This function should only be used
externally by DataObject::gc()
.
sourcepub fn print_heap()
pub fn print_heap()
Prints the arrays currently stored in the heap