Struct hexagon_map::HexagonMap

source ·
pub struct HexagonMap<T> { /* private fields */ }
Expand description

A sparse hexagon map, if your map size will grow, or most areas will be blank, this is a better choice.

Implementations§

source§

impl<T> HexagonMap<T>

source

pub fn action_field( &self, start: AxialPoint, action: f64 ) -> ActionFieldSolver<'_, T>

Set the passable function.

Arguments
  • passable: A function that returns true if the point is passable.

returns: PathFinder

Examples
source§

impl<T> HexagonMap<T>

source

pub fn path_finder( &self, start: &AxialPoint, end: &AxialPoint ) -> PathFinder<'_, T>

Set the passable function.

Arguments
  • passable: A function that returns true if the point is passable.

returns: PathFinder

Examples
source§

impl<T: Default> HexagonMap<T>

source

pub fn circle(diameter: usize) -> Self

source

pub fn rhombus(width: usize, height: usize) -> Self

source

pub fn width_first(rows: usize, columns: usize, odd_left: bool) -> Self

Create a width first hexagon map.

Arguments
  • width: row count
  • height: column count
  • odd_left: Fill the extra line at left if width is odd.

returns: HexagonMap

Examples
let map = HexagonMap::<u8>::width_first(5, 5, true);
assert_eq!(map.count_points(), 10)
source

pub fn height_first(rows: usize, columns: usize, odd_up: bool) -> Self

source§

impl<T> HexagonMap<T>

source

pub fn get_point(&self, point: AxialPoint) -> Option<&T>

Get the value at a point, if it exists.

source

pub fn add_point(&mut self, point: AxialPoint, value: T) -> Option<T>

Add a point to the map, if it already exists, return the old value.

source

pub fn mut_point(&mut self, point: AxialPoint) -> Option<&mut T>

Get a mutable reference to a point, if it exists.

source

pub fn remove_point(&mut self, point: AxialPoint) -> Option<T>

Remove a point from the map, if it exists, return the old value.

source

pub fn count_points(&self) -> usize

Count all defined points in the map.

source

pub fn nearby_points(&self, from: &AxialPoint) -> Vec<AxialPoint>

Find at most 6 points that are exists and adjacent to a point.

source

pub fn around_points( &self, from: &AxialPoint, distance: usize ) -> Vec<AxialPoint>

Find all points that are within a certain distance of a point.

source

pub fn points(&self) -> impl Iterator<Item = &AxialPoint>

Trait Implementations§

source§

impl<'i, T> IntoIterator for &'i HexagonMap<T>

§

type Item = (&'i AxialPoint, &'i T)

The type of the elements being iterated over.
§

type IntoIter = Iter<'i, AxialPoint, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for HexagonMap<T>where T: RefUnwindSafe,

§

impl<T> Send for HexagonMap<T>where T: Send,

§

impl<T> Sync for HexagonMap<T>where T: Sync,

§

impl<T> Unpin for HexagonMap<T>

§

impl<T> UnwindSafe for HexagonMap<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.