A data structure for maintaining a list of pages keyed by Morton order (also known as z-order or interleaving).
//Create a 2D page store having a capacity of (1<<4) == 16var pageStore = 2 4//Add a pagepageStore//Retrieve a pagevar x = pageStoreconsole//Remove the pagepageStore//Try pulling the page out (returns null now)console
npm install morton-page
var createPageStore =
Creates a z-order page store.
dimensionis the dimension of the pages
log_sizeis the log base 2 of the number of buckets in the store
shiftis the number of bits to shift each page by before indexing (default:
keyis the property of each page to use for the index (default:
Returns An instance of a
MortonPageStore class specialized for the given input parameters.
Adds a page to the store
pageis an object with a field called
keywhich is an array of coordinates representing the identifier of the page in the store.
Retrieves the page with the given key from the page store
i0, i1, ...is the name of the page
Returns The page with the key
i0, i1, ... if it is in the store, or
Removes the page with the given key from the store.
i0, i1, ...is the key of the page
Basically it is faster and does not require creating any string objects. All of the methods in this class require 0 allocations and thus will not trigger garbage collection events.
(c) 2013 Mikola Lysenko. MIT License