pub struct VariantArray(/* private fields */);
Expand description
A reference-counted Variant
vector. Godot’s generic array data type.
Negative indices can be used to count from the right.
Implementations§
Source§impl VariantArray
impl VariantArray
Sourcepub fn new() -> VariantArray
pub fn new() -> VariantArray
Creates an empty VariantArray
.
Sourcepub fn set(&mut self, idx: i32, val: &Variant)
pub fn set(&mut self, idx: i32, val: &Variant)
Sets the value of the element at the given offset.
Sourcepub fn get_val(&mut self, idx: i32) -> Variant
pub fn get_val(&mut self, idx: i32) -> Variant
Returns a copy of the element at the given offset.
Sourcepub fn get_ref(&self, idx: i32) -> &Variant
pub fn get_ref(&self, idx: i32) -> &Variant
Returns a reference to the element at the given offset.
Sourcepub fn get_mut_ref(&mut self, idx: i32) -> &mut Variant
pub fn get_mut_ref(&mut self, idx: i32) -> &mut Variant
Returns a mutable reference to the element at the given offset.
pub fn count(&mut self, val: &Variant) -> i32
pub fn remove(&mut self, idx: i32)
pub fn erase(&mut self, val: &Variant)
Sourcepub fn push_front(&mut self, val: &Variant)
pub fn push_front(&mut self, val: &Variant)
Appends an element to the front of the array.
Sourcepub fn insert(&mut self, at: i32, val: &Variant)
pub fn insert(&mut self, at: i32, val: &Variant)
Insert a new int at a given position in the array.
Sourcepub fn find(&self, what: &Variant, from: i32) -> i32
pub fn find(&self, what: &Variant, from: i32) -> i32
Searches the array for a value and returns its index.
Pass an initial search index as the second argument.
Returns -1
if value is not found.
Sourcepub fn contains(&self, what: &Variant) -> bool
pub fn contains(&self, what: &Variant) -> bool
Returns true if the VariantArray
contains the specified value.
pub fn resize(&mut self, size: i32)
Sourcepub fn rfind(&self, what: &Variant, from: i32) -> i32
pub fn rfind(&self, what: &Variant, from: i32) -> i32
Searches the array in reverse order. Pass an initial search index as the second argument. If negative, the start index is considered relative to the end of the array.
Sourcepub fn find_last(&self, what: &Variant) -> i32
pub fn find_last(&self, what: &Variant) -> i32
Searches the array in reverse order for a value.
Returns its index or -1
if not found.