Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Hex_Lattice< Storage, Boundary > Class Template Reference

Hexagonal lattice with axial accessors over a 2D storage. More...

#include <tpl_ca_hex_lattice.H>

Inheritance diagram for Aleph::CA::Hex_Lattice< Storage, Boundary >:
[legend]
Collaboration diagram for Aleph::CA::Hex_Lattice< Storage, Boundary >:
[legend]

Public Types

using base_type = Lattice< Storage, Boundary >
 
using state_type = typename base_type::state_type
 
using coord_type = typename base_type::coord_type
 
using extents_type = typename base_type::extents_type
 
- Public Types inherited from Aleph::CA::Lattice< Storage, Boundary >
using storage_type = Storage
 
using boundary_type = Boundary
 
using state_type = typename Storage::state_type
 
using coord_type = typename Storage::coord_type
 
using extents_type = typename Storage::extents_type
 

Public Member Functions

ca_size_t rows () const noexcept
 < inherit constructors
 
ca_size_t cols () const noexcept
 Number of columns per row (axis 1, the q axis).
 
state_type at_axial (Hex_Axial a) const
 
void set_axial (Hex_Axial a, const state_type &v)
 Write cell value at axial coords (q, r) (strict).
 
state_type at_axial_safe (Hex_Axial a) const
 Boundary-aware read at axial coords.
 
state_type at_offset_even_r (Hex_Offset o) const
 Convenience: read using the even-r offset convention.
 
void set_offset_even_r (Hex_Offset o, const state_type &v)
 Convenience: write using the even-r offset convention.
 
- Public Member Functions inherited from Aleph::CA::Lattice< Storage, Boundary >
 Lattice ()=default
 Construct an empty lattice (no cells allocated).
 
 Lattice (const extents_type &extents, const state_type &init=state_type{})
 Construct a lattice with the given extents and initial value.
 
 Lattice (Storage &&s) noexcept(std::is_nothrow_move_constructible_v< Storage >)
 Wrap an existing storage by move.
 
ca_size_t size () const noexcept
 
ca_size_t size (std::size_t d) const
 
const extents_type & extents () const noexcept
 
state_type at (const coord_type &c) const
 Strict access: throws if c is out of range.
 
void set (const coord_type &c, const state_type &v)
 Strict write: throws if c is out of range.
 
state_type at_safe (coord_type c) const
 Boundary-aware read.
 
const Storage & storage () const noexcept
 Direct read access to the underlying storage (read-only).
 
Storage & storage () noexcept
 Direct read-write access to the underlying storage.
 
void fill (const state_type &value)
 Set every cell to value.
 
void swap (Lattice &other) noexcept(noexcept(store_.swap(other.store_)))
 O(1) swap.
 

Static Public Attributes

static constexpr std::size_t rank = base_type::rank
 
- Static Public Attributes inherited from Aleph::CA::Lattice< Storage, Boundary >
static constexpr std::size_t rank = Storage::rank
 

Additional Inherited Members

- Static Public Member Functions inherited from Aleph::CA::Lattice< Storage, Boundary >
static constexpr std::size_t dimension () noexcept
 

Detailed Description

template<typename Storage, typename Boundary = OpenBoundary>
class Aleph::CA::Hex_Lattice< Storage, Boundary >

Hexagonal lattice with axial accessors over a 2D storage.

Inherits the full Lattice API (so the generic engine and Hex_Neighborhood work unchanged) and adds axial/offset helpers that translate the user's hex coords into the underlying (r, q) storage layout.

Coord convention: coord = {r, q} (axis 0 is row, axis 1 is column). The strict at / set of the base class continue to consume coord_type, so the generic engine can iterate row-major exactly as it does for any rectangular lattice.

Template Parameters
Storagestorage type (rank 2) satisfying LatticeLike.
Boundaryboundary tag, default OpenBoundary.

Definition at line 261 of file tpl_ca_hex_lattice.H.

Member Typedef Documentation

◆ base_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Hex_Lattice< Storage, Boundary >::base_type = Lattice<Storage, Boundary>

Definition at line 266 of file tpl_ca_hex_lattice.H.

◆ coord_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Hex_Lattice< Storage, Boundary >::coord_type = typename base_type::coord_type

Definition at line 268 of file tpl_ca_hex_lattice.H.

◆ extents_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Hex_Lattice< Storage, Boundary >::extents_type = typename base_type::extents_type

Definition at line 269 of file tpl_ca_hex_lattice.H.

◆ state_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Hex_Lattice< Storage, Boundary >::state_type = typename base_type::state_type

Definition at line 267 of file tpl_ca_hex_lattice.H.

Member Function Documentation

◆ at_axial()

template<typename Storage , typename Boundary = OpenBoundary>
state_type Aleph::CA::Hex_Lattice< Storage, Boundary >::at_axial ( Hex_Axial  a) const
inline
Returns
cell value at axial coords (q, r) (strict).

Definition at line 281 of file tpl_ca_hex_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::at(), Aleph::CA::Hex_Axial::q, and Aleph::CA::Hex_Axial::r.

Referenced by Aleph::CA::Hex_Lattice< Storage, Boundary >::at_offset_even_r().

◆ at_axial_safe()

template<typename Storage , typename Boundary = OpenBoundary>
state_type Aleph::CA::Hex_Lattice< Storage, Boundary >::at_axial_safe ( Hex_Axial  a) const
inline

Boundary-aware read at axial coords.

Definition at line 293 of file tpl_ca_hex_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::at_safe(), Aleph::CA::Hex_Axial::q, and Aleph::CA::Hex_Axial::r.

◆ at_offset_even_r()

template<typename Storage , typename Boundary = OpenBoundary>
state_type Aleph::CA::Hex_Lattice< Storage, Boundary >::at_offset_even_r ( Hex_Offset  o) const
inline

Convenience: read using the even-r offset convention.

Definition at line 299 of file tpl_ca_hex_lattice.H.

References Aleph::CA::Hex_Lattice< Storage, Boundary >::at_axial(), Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::offset_to_axial_even_r().

◆ cols()

template<typename Storage , typename Boundary = OpenBoundary>
ca_size_t Aleph::CA::Hex_Lattice< Storage, Boundary >::cols ( ) const
inlinenoexcept

Number of columns per row (axis 1, the q axis).

Definition at line 278 of file tpl_ca_hex_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::size().

◆ rows()

template<typename Storage , typename Boundary = OpenBoundary>
ca_size_t Aleph::CA::Hex_Lattice< Storage, Boundary >::rows ( ) const
inlinenoexcept

< inherit constructors

Number of rows (axis 0, the r axis).

Definition at line 275 of file tpl_ca_hex_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::size().

◆ set_axial()

template<typename Storage , typename Boundary = OpenBoundary>
void Aleph::CA::Hex_Lattice< Storage, Boundary >::set_axial ( Hex_Axial  a,
const state_type &  v 
)
inline

◆ set_offset_even_r()

template<typename Storage , typename Boundary = OpenBoundary>
void Aleph::CA::Hex_Lattice< Storage, Boundary >::set_offset_even_r ( Hex_Offset  o,
const state_type &  v 
)
inline

Convenience: write using the even-r offset convention.

Definition at line 305 of file tpl_ca_hex_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::offset_to_axial_even_r(), and Aleph::CA::Hex_Lattice< Storage, Boundary >::set_axial().

Referenced by TEST().

Member Data Documentation

◆ rank

template<typename Storage , typename Boundary = OpenBoundary>
constexpr std::size_t Aleph::CA::Hex_Lattice< Storage, Boundary >::rank = base_type::rank
staticconstexpr

Definition at line 270 of file tpl_ca_hex_lattice.H.


The documentation for this class was generated from the following file: