Struct gdnative_core::core_types::typed_array::TypedArray [−][src]
A reference-counted CoW typed vector using Godot's pool allocator, generic over possible element types.
This type is CoW. The Clone
implementation of this type creates a new reference without
copying the contents.
When using this type, it's generally better to perform mutations in batch using write
,
or the append
methods, as opposed to push
or set
, because the latter ones trigger
CoW behavior each time they are called.
Implementations
impl<T: Element> TypedArray<T>
[src]
pub fn new() -> Self
[src]
Creates an empty array.
pub fn from_variant_array(array: &VariantArray) -> Self
[src]
Creates from a VariantArray
by making a best effort to convert each variant.
pub fn from_vec(mut src: Vec<T>) -> Self
[src]
Creates a TypedArray
moving elements from src
.
pub fn push(&mut self, val: T)
[src]
Appends an element to the end of the array.
Calling push
triggers copy-on-write behavior. To insert a large number of elements,
consider using resize
and write
.
pub fn push_ref(&mut self, val: &T)
[src]
Appends an element to the end of the array by reference.
Calling push
triggers copy-on-write behavior. To insert a large number of elements,
consider using resize
and write
.
pub fn append(&mut self, src: &Self)
[src]
Copies and appends all values in src
to the end of the array.
pub fn append_vec(&mut self, src: &mut Vec<T>)
[src]
Moves all the elements from src
into self
, leaving src
empty.
Panics
If the resulting length would not fit in i32
.
pub fn insert(&mut self, offset: i32, val: T) -> bool
[src]
Inserts an element at the given offset and returns true
if successful.
pub fn insert_ref(&mut self, offset: i32, val: &T) -> bool
[src]
Inserts an element by reference at the given offset and returns true
if successful.
pub fn invert(&mut self)
[src]
Inverts the order of the elements in the array.
pub fn remove(&mut self, idx: i32)
[src]
Removes an element at the given offset.
pub fn resize(&mut self, size: i32)
[src]
Changes the size of the array, possibly removing elements or pushing default values.
pub fn get(&self, idx: i32) -> T
[src]
Returns a copy of the element at the given offset.
pub fn set(&mut self, idx: i32, val: T)
[src]
Sets the value of the element at the given offset.
pub fn set_ref(&mut self, idx: i32, val: &T)
[src]
Sets the value of the element at the given offset by reference.
pub fn len(&self) -> i32
[src]
Returns the number of elements in the array.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the container is empty.
pub fn read(&self) -> Read<'_, T>
[src]
Returns a RAII read access into this array.
pub fn write(&mut self) -> Write<'_, T>
[src]
Returns a RAII write access into this array. This triggers CoW once per lock, instead of once each mutation.
impl<T: Element + Copy> TypedArray<T>
[src]
pub fn from_slice(src: &[T]) -> Self
[src]
pub fn append_slice(&mut self, src: &[T])
[src]
Copies and appends all values in src
to the end of the array.
Panics
If the resulting length would not fit in i32
.
Trait Implementations
impl<T: Element> Clone for TypedArray<T>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Element + Debug> Debug for TypedArray<T>
[src]
impl<T: Element> Default for TypedArray<T>
[src]
impl<T: Element> Drop for TypedArray<T>
[src]
impl<T: Element + Eq> Eq for TypedArray<T>
[src]
impl<T: Element> Extend<T> for TypedArray<T>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<T: Element> FromIterator<T> for TypedArray<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
impl<T: Element> FromVariant for TypedArray<T>
[src]
fn from_variant(variant: &Variant) -> Result<Self, FromVariantError>
[src]
impl<T: Element> NewRef for TypedArray<T>
[src]
impl<T: Element + PartialEq> PartialEq<TypedArray<T>> for TypedArray<T>
[src]
impl<T: Element> ToVariant for TypedArray<T>
[src]
fn to_variant(&self) -> Variant
[src]
impl<T: Element + Eq> ToVariantEq for TypedArray<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for TypedArray<T> where
<T as Element>::SysArray: RefUnwindSafe,
[src]
<T as Element>::SysArray: RefUnwindSafe,
impl<T> Send for TypedArray<T> where
<T as Element>::SysArray: Send,
[src]
<T as Element>::SysArray: Send,
impl<T> Sync for TypedArray<T> where
<T as Element>::SysArray: Sync,
[src]
<T as Element>::SysArray: Sync,
impl<T> Unpin for TypedArray<T> where
<T as Element>::SysArray: Unpin,
[src]
<T as Element>::SysArray: Unpin,
impl<T> UnwindSafe for TypedArray<T> where
<T as Element>::SysArray: UnwindSafe,
[src]
<T as Element>::SysArray: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> OwnedToVariant for T where
T: ToVariant,
[src]
T: ToVariant,
pub fn owned_to_variant(Self) -> Variant
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,