#array #layout #binary-search-tree #sorting #bfs #aka #layer

eytzinger

This crate implements the "eytzinger" (aka BFS) array layout

4 stable releases

Uses old Rust 2015

1.1.1 Mar 3, 2021
1.0.1 Nov 18, 2017
1.0.0 Nov 15, 2017

#1727 in Data structures

Download history 1/week @ 2024-07-20 102/week @ 2024-07-27 76/week @ 2024-08-03 38/week @ 2024-08-10 1/week @ 2024-08-17 95/week @ 2024-08-31 5/week @ 2024-09-07 48/week @ 2024-09-14 199/week @ 2024-09-21 20/week @ 2024-09-28 1/week @ 2024-10-05 26/week @ 2024-10-12 18/week @ 2024-10-19 25/week @ 2024-10-26 31/week @ 2024-11-02

100 downloads per month
Used in eytzinger-map

MIT license

27KB
448 lines

This crate implements the "eytzinger" (aka BFS) array layout where a binary search tree is stored by layer (instead of as a sorted array). This can have significant performance benefits (see Khuong, Paul-Virak, and Pat Morin. "Array layouts for comparison-based searching.").

Usage

use eytzinger::SliceExt;
let mut data = [0, 1, 2, 3, 4, 5, 6];
data.eytzingerize(&mut eytzinger::permutation::InplacePermutator);
assert_eq!(data, [3, 1, 5, 0, 2, 4, 6]);
assert_eq!(data.eytzinger_search(&5), Some(2));
assert_eq!(data.eytzinger_search_by(|x| x.cmp(&6)), Some(6));

Dependencies

~10KB