#plane #grid2d #data-structure-2d

plane-2d

Continuous 2D data structure representing infinite 2d plane

9 releases

0.1.8 Oct 7, 2024
0.1.7 Aug 21, 2024
0.1.6 Jul 9, 2024
0.1.4 Jun 14, 2024

#515 in Data structures

Download history 113/week @ 2024-08-15 43/week @ 2024-08-22 2/week @ 2024-08-29 25/week @ 2024-09-12 17/week @ 2024-09-19 7/week @ 2024-09-26 124/week @ 2024-10-03 35/week @ 2024-10-10 2/week @ 2024-10-17

573 downloads per month

MIT/Apache

145KB
3K SLoC

Two Dimensional Plane

Models continuous, infinitely big (within integer and storage limits) 2D data structure. The purpose of this crate is to provide a data structure that is faster than a HashMap<(i32, i32), T> in specific scenarios and provides better API for working with 2D plane.

This crate will always provide a 2D data structure. The Plane<T> type is a container for all kinds of data that implement Default trait. You can use Option<T> to store optionally initialized data.

No other dependencies except for the std lib are used, besides dependencies hidden behind feature flags.

Memory layout

Uses almost exact copy of grid crate to use Grid<T> type. Stores a dense chunk of the plane in Vec<T> (Grid<T>, provided by copy of the grid crate) and HashMap<(i32, i32), T> to store cells that are out of bounds of the Grid<T>. Unlike HashMap<(i32, i32), T>, two allocations are being done.


lib.rs:

Two Dimensional Plane

Models continuous, infinitely big (within integer and storage limits) 2D data structure. The purpose of this crate is to provide a data structure that is faster than a HashMap<(i32, i32), T> in specific scenarios and provides better API for working with 2D plane.

This crate will always provide a 2D data structure. The Plane<T> type is a container for all kinds of data that implement Default trait. You can use Option<T> to store optionally initialized data.

No other dependencies except for the std lib are used, besides dependencies hidden behind feature flags.

Memory layout

Uses almost exact copy of grid crate to use Grid<T> type. Stores a dense chunk of the plane in Vec<T> (Grid<T>, provided by copy of the grid crate) and HashMap<(i32, i32), T> to store cells that are out of bounds of the Grid<T>. Unlike HashMap<(i32, i32), T>, two allocations are being done.

Dependencies

~0–1.4MB
~24K SLoC