[−][src]Struct gdnative::prelude::TypedArray
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> TypedArray<T> where
T: Element,
[src]
T: Element,
pub fn new() -> TypedArray<T>
[src]
Creates an empty array.
pub fn from_variant_array(array: &VariantArray<Shared>) -> TypedArray<T>
[src]
Creates from a VariantArray
by making a best effort to convert each variant.
pub fn from_vec(src: Vec<T>) -> TypedArray<T>
[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: &TypedArray<T>)
[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) -> Aligned<ReadGuard<'_, T>>
[src]
Returns a RAII read access into this array.
pub fn write(&mut self) -> Aligned<WriteGuard<'_, T>>
[src]
Returns a RAII write access into this array. This triggers CoW once per lock, instead of once each mutation.
impl<T> TypedArray<T> where
T: Element + Copy,
[src]
T: Element + Copy,
pub fn from_slice(src: &[T]) -> TypedArray<T>
[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> Clone for TypedArray<T> where
T: Element,
[src]
T: Element,
fn clone(&self) -> TypedArray<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for TypedArray<T> where
T: Element + Debug,
[src]
T: Element + Debug,
impl<T> Default for TypedArray<T> where
T: Element,
[src]
T: Element,
fn default() -> TypedArray<T>
[src]
impl<T> Drop for TypedArray<T> where
T: Element,
[src]
T: Element,
impl<T> Eq for TypedArray<T> where
T: Element + Eq,
[src]
T: Element + Eq,
impl Export for TypedArray<Color>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(_hint: Option<<TypedArray<Color> as Export>::Hint>) -> ExportInfo
[src]
impl Export for TypedArray<Vector3D<f32, UnknownUnit>>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(
_hint: Option<<TypedArray<Vector3D<f32, UnknownUnit>> as Export>::Hint>
) -> ExportInfo
[src]
_hint: Option<<TypedArray<Vector3D<f32, UnknownUnit>> as Export>::Hint>
) -> ExportInfo
impl Export for TypedArray<u8>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(_hint: Option<<TypedArray<u8> as Export>::Hint>) -> ExportInfo
[src]
impl Export for TypedArray<f32>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(_hint: Option<<TypedArray<f32> as Export>::Hint>) -> ExportInfo
[src]
impl Export for TypedArray<Vector2D<f32, UnknownUnit>>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(
_hint: Option<<TypedArray<Vector2D<f32, UnknownUnit>> as Export>::Hint>
) -> ExportInfo
[src]
_hint: Option<<TypedArray<Vector2D<f32, UnknownUnit>> as Export>::Hint>
) -> ExportInfo
impl Export for TypedArray<i32>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(_hint: Option<<TypedArray<i32> as Export>::Hint>) -> ExportInfo
[src]
impl Export for TypedArray<GodotString>
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(
_hint: Option<<TypedArray<GodotString> as Export>::Hint>
) -> ExportInfo
[src]
_hint: Option<<TypedArray<GodotString> as Export>::Hint>
) -> ExportInfo
impl<T> Extend<T> for TypedArray<T> where
T: Element,
[src]
T: Element,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T> FromIterator<T> for TypedArray<T> where
T: Element,
[src]
T: Element,
fn from_iter<I>(iter: I) -> TypedArray<T> where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
impl<T> FromVariant for TypedArray<T> where
T: Element,
[src]
T: Element,
fn from_variant(variant: &Variant) -> Result<TypedArray<T>, FromVariantError>
[src]
impl<T> NewRef for TypedArray<T> where
T: Element,
[src]
T: Element,
fn new_ref(&self) -> TypedArray<T>
[src]
Creates a new reference to this reference-counted instance.
impl<T> PartialEq<TypedArray<T>> for TypedArray<T> where
T: Element + PartialEq<T>,
[src]
T: Element + PartialEq<T>,
fn eq(&self, other: &TypedArray<T>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> ToVariant for TypedArray<T> where
T: Element,
[src]
T: Element,
fn to_variant(&self) -> Variant
[src]
impl<T> ToVariantEq for TypedArray<T> where
T: Element + Eq,
[src]
T: Element + Eq,
Auto Trait Implementations
impl<T> RefUnwindSafe for TypedArray<T> where
<T as Element>::SysArray: RefUnwindSafe,
<T as Element>::SysArray: RefUnwindSafe,
impl<T> Send for TypedArray<T> where
<T as Element>::SysArray: Send,
<T as Element>::SysArray: Send,
impl<T> Sync for TypedArray<T> where
<T as Element>::SysArray: Sync,
<T as Element>::SysArray: Sync,
impl<T> Unpin for TypedArray<T> where
<T as Element>::SysArray: Unpin,
<T as Element>::SysArray: Unpin,
impl<T> UnwindSafe for TypedArray<T> where
<T as Element>::SysArray: UnwindSafe,
<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,
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,
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,