import { Grid } from './Grid'; import { Hexagon } from './Hexagon'; export class HexagonalGrid extends Grid { constructor(hashfn: (key: V) => number = Hexagon.hash, equalfn: (lhs: V, rhs: V) => boolean = Hexagon.equal, vertices?: ArrayLike | Iterable) { super(hashfn, equalfn, vertices); } neighbors(v: V, visitfn: (u: V, distance: number, grid: HexagonalGrid) => void) { const length = Hexagon.directions.length; for (let i = 0; i < length; i++) { const d = Hexagon.directions[i]; const u = v.plus(d) as V; if (!this.has(u)) continue; visitfn(u, d.manhattanLength(), this); } } }