devela/data/collections/vec/d2/definitions.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// devela::data::collections::vec::d2::definitions
//
//! Defines [`Vec2d`].
//
use crate::Vec;
#[doc = crate::TAG_DATA_STRUCTURE!()]
/// A 2-dimensional [`Vec`].
///
/// It is generic in respect to its elements (`T`), and storage order (`RMAJ`).
///
/// The
/// [*storage order*](https://en.wikipedia.org/wiki/Row-_and_column-major_order)
/// is row-major by default (`RMAJ = true`). It can be column-major if set to false.
///
/// ## Methods
/*
/// - Construct:
/// [`new`][Self::new],
/// [`with_cloned`][Self::with_cloned].
/// - Deconstruct:
/// [`as_slice`][Self::as_slice],
/// [`as_mut_slice`][Self::as_mut_slice],
/// [`into_array`][Self::into_array]*([`const`][Self::into_array_copy])*,
/// [`into_slice`][Self::into_slice]*(`alloc`)*,
/// [`into_vec`][Self::into_vec]*(`alloc`)*.
/// - Query:
/// [`len`][Self::len]
/// [`x_len`][Self::x_len]
/// [`y_len`][Self::y_len]
/// [`is_empty`][Self::is_empty],
/// [`contains`][Self::contains].
/// - Indexing and coordinates (for the current order):
/// - [`get_ref`][Self::get_ref]*([`uc`][Self::get_ref_unchecked])*,
/// [`get_mut`][Self::get_mut]*([`uc`][Self::get_mut_unchecked])*,
/// [`set`][Self::set]*([`uc`][Self::set_unchecked])*,
/// [`get_index`][Self::get_index]*([`uc`][Self::get_index_unchecked])*,
/// [`get_coords`][Self::get_coords]*([`uc`][Self::get_coords_unchecked])*.
/// - Indexing and coordinates (specific for the **opposite** order):
/// - row-major:
/// [`get_ref_cmaj`][Self::get_ref_cmaj]*([`uc`][Self::get_ref_cmaj_unchecked])*,
/// [`get_mut_cmaj`][Self::get_mut_cmaj]*([`uc`][Self::get_mut_cmaj_unchecked])*,
/// [`set_cmaj`][Self::set_cmaj]*([`uc`][Self::set_cmaj_unchecked])*,
/// [`get_index_cmaj`][Self::get_index_cmaj]*([`uc`][Self::get_index_cmaj_unchecked])*,
/// [`get_coords_cmaj`][Self::get_coords_cmaj]*([`uc`][Self::get_coords_cmaj_unchecked])*.
/// - column-major:
/// [`get_ref_rmaj`][Self::get_ref_rmaj]*([`uc`][Self::get_ref_rmaj_unchecked])*,
/// [`get_mut_rmaj`][Self::get_mut_rmaj]*([`uc`][Self::get_mut_rmaj_unchecked])*,
/// [`set_rmaj`][Self::set_rmaj]*([`uc`][Self::set_rmaj_unchecked])*,
/// [`get_index_rmaj`][Self::get_index_rmaj]*([`uc`][Self::get_index_rmaj_unchecked])*,
/// [`get_coords_rmaj`][Self::get_coords_rmaj]*([`uc`][Self::get_coords_rmaj_unchecked])*.
*/
#[derive(Clone, Default)]
pub struct Vec2d<T, const RMAJ: bool = true> {
pub(super) data: Vec<T>,
pub(super) rows: usize,
pub(super) cols: usize,
}