Struct hkArrayBase

Source
#[repr(C)]
pub struct hkArrayBase<T, A: SelflessAllocator = TESGlobalAlloc> { /* private fields */ }
Expand description

Represents a base class for a dynamic array of type T.

Implementations§

Source§

impl<T, A> hkArrayBase<T, A>

Source

pub const fn new() -> Self

Source

pub const fn as_ptr(&self) -> *mut T

Returns a raw pointer to the array data.

  • Equivalent C++ method: data
Source

pub const fn len(&self) -> usize

Returns the size of the array.

Not bytes_count. Return N of T * N

Source

pub const fn capacity(&self) -> i32

Returns the current capacity of the array.

Source

pub const fn is_empty(&self) -> bool

Checks whether the array is empty.

Source

pub fn with_capacity(capacity: i32) -> Self

Source

pub fn reserve(&mut self, new_capacity: i32)

Reserves memory for the array to hold new capacity elements.

§Panics
Source

pub fn push(&mut self, value: T)

Pushes a new element to the end of the array.

  • Equivalent C++ method: push_back
Source

pub const fn pop(&mut self) -> Option<T>

Removes the last element from the array and returns it, or None if it’s empty.

Source

pub const fn get(&self, index: usize) -> Option<&T>

Returns a reference to the element at the given index, if it exists.

Source

pub const fn get_mut(&mut self, index: usize) -> Option<&mut T>

Returns a mutable reference to the element at the given index, if it exists.

Source

pub fn clear(&mut self)

Clears the array, removing all elements but preserving the capacity.

Source

pub const fn iter(&self) -> hkArrayRefIterator<'_, T, A>

Source

pub const fn as_slice(&self) -> &[T]

Source

pub const fn as_mut_slice(&mut self) -> &mut [T]

Source

pub fn contains(&self, value: &T) -> bool
where T: PartialEq,

Checks if the array contains the given element.

Returns true if the element is present in the array, and false otherwise.

§Examples
use commonlibsse_ng::re::hkArray::hkArrayBase;
use stdx::alloc::Global;

let mut array = hkArrayBase::<i32, Global>::with_capacity(10);
array.push(1);
array.push(2);
assert!(array.contains(&1));
assert!(!array.contains(&3));
Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Retains only the elements that satisfy the predicate.

This method takes a closure that accepts an element of the array and returns a boolean. Elements for which the closure returns true will be kept, while elements for which it returns false will be removed.

§Examples
use commonlibsse_ng::re::hkArray::hkArrayBase;
use stdx::alloc::Global;

let mut array = hkArrayBase::<i32, Global>::with_capacity(10);
array.push(1);
array.push(2);
array.push(3);
array.retain(|&x| x > 1);
assert_eq!(array.len(), 2);
assert!(array.contains(&2));
assert!(array.contains(&3));
Source

pub fn drain<R>(&mut self, range: R) -> hkArrayDrain<'_, T, A>
where R: RangeBounds<usize>,

Removes a range of elements from the array, returning them as a vector.

This method removes the elements within the specified range and returns them as a Vec<T>. The range must be within the bounds of the array.

§Examples
use commonlibsse_ng::re::hkArray::hkArrayBase;
use stdx::alloc::Global;

let mut array = hkArrayBase::<i32, Global>::with_capacity(10);
array.push(1);
array.push(2);
array.push(3);
array.push(4);
array.push(5);
let drained = array.drain(0..2);
assert_eq!(drained.collect::<Vec<_>>(), vec![1, 2]);
assert_eq!(array.len(), 3);
assert_eq!(array[0], 3);
assert_eq!(array[1], 4);
assert_eq!(array[2], 5);
§Panics

Panics if the range is out of bounds.

Source§

impl<T, A> hkArrayBase<T, A>
where T: Clone, A: SelflessAllocator,

Source

pub fn resize(&mut self, new_len: i32, value: T)

Resizes the array to hold a_count elements.

§Panics

Trait Implementations§

Source§

impl<T: Clone, A: SelflessAllocator> Clone for hkArrayBase<T, A>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, A: SelflessAllocator> Debug for hkArrayBase<T, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, A> Default for hkArrayBase<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, A> Drop for hkArrayBase<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, A> Extend<T> for hkArrayBase<T, A>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T: Hash, A: SelflessAllocator> Hash for hkArrayBase<T, A>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, A> Index<usize> for hkArrayBase<T, A>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, A> IndexMut<usize> for hkArrayBase<T, A>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T, A> IntoIterator for &'a hkArrayBase<T, A>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = hkArrayRefIterator<'a, T, A>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, A> IntoIterator for &'a mut hkArrayBase<T, A>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = hkArrayIterMut<'a, T, A>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, A> IntoIterator for hkArrayBase<T, A>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = hkArrayIterator<T, A>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: Ord, A: SelflessAllocator> Ord for hkArrayBase<T, A>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, A: SelflessAllocator> PartialEq for hkArrayBase<T, A>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd, A: SelflessAllocator> PartialOrd for hkArrayBase<T, A>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq, A: SelflessAllocator> Eq for hkArrayBase<T, A>

Source§

impl<T: Send, A> Send for hkArrayBase<T, A>

Source§

impl<T: Sync, A> Sync for hkArrayBase<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for hkArrayBase<T, A>

§

impl<T, A> RefUnwindSafe for hkArrayBase<T, A>

§

impl<T, A> Unpin for hkArrayBase<T, A>
where A: Unpin,

§

impl<T, A> UnwindSafe for hkArrayBase<T, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more