Skip to content

Commit

Permalink
updated the docs to include the zosdit data-structures
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Jan 28, 2024
1 parent 5c5be38 commit 23f9738
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.7.1"
authors = ["James Forster <james.forsterer@gmail.com>"]
edition = "2021"
description = """
This crate provides NoditMap and NoditSet, Non-Overlapping Discrete
This crate provides NoditMap, NoditSet and ZosditMap, Discrete
Interval Tree data-structures, which are based off BTreeMap.
"""
documentation = "https://docs.rs/nodit"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img src="logo.png" alt="nodit_logo" width="350">
</p>

This crate provides [`NoditMap`] and [`NoditSet`], Non-Overlapping Discrete
This crate provides [`NoditMap`], [`NoditSet`] and [`ZosditMap`], Discrete
Interval Tree data-structures, which are based off [`BTreeMap`].

`no_std` is supported and should work with the default features.
Expand Down Expand Up @@ -364,4 +364,5 @@ topic area, beware my biases when reading:
[`num_bigint`]: https://docs.rs/num-bigint
[`get_key_value_at_point()`]: https://docs.rs/nodit/latest/nodit/nodit/struct.NoditMap.html#method.get_key_value_at_point
[`NoditMap`]: https://docs.rs/nodit/latest/nodit/map/struct.NoditMap.html
[`ZosditMap`]: https://docs.rs/nodit/latest/zosdit/map/struct.ZosditMap.html
[`NoditSet`]: https://docs.rs/nodit/latest/nodit/set/struct.NoditSet.html
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with nodit. If not, see <https://www.gnu.org/licenses/>.
*/

//! This crate provides [`NoditMap`] and [`NoditSet`], Non-Overlapping Discrete
//! This crate provides [`NoditMap`], [`NoditSet`] and [`ZosditMap`], Discrete
//! Interval Tree data-structures, which are based off [`BTreeMap`].
//!
//! `no_std` is supported and should work with the default features.
Expand Down Expand Up @@ -372,6 +372,7 @@ along with nodit. If not, see <https://www.gnu.org/licenses/>.
//! [`num_bigint`]: https://docs.rs/num-bigint
//! [`get_key_value_at_point()`]: https://docs.rs/nodit/latest/nodit/nodit/struct.NoditMap.html#method.get_key_value_at_point
//! [`NoditMap`]: https://docs.rs/nodit/latest/nodit/map/struct.NoditMap.html
//! [`ZosditMap`]: https://docs.rs/nodit/latest/zosdit/map/struct.ZosditMap.html
//! [`NoditSet`]: https://docs.rs/nodit/latest/nodit/set/struct.NoditSet.html
#![allow(clippy::tabs_in_doc_comments)]
Expand Down
10 changes: 5 additions & 5 deletions src/nodit/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ mod tests {
map.insert_strict(inside_interval, ()).unwrap();

let mut expected_overlapping = Vec::new();
if overlaps(overlap_interval, inside_interval) {
if overlap_interval.overlaps(&inside_interval) {
expected_overlapping.push(inside_interval);
}

Expand Down Expand Up @@ -1651,10 +1651,10 @@ mod tests {
map.insert_strict(inside_interval2, ()).unwrap();

let mut expected_overlapping = Vec::new();
if overlaps(overlap_interval, inside_interval1) {
if overlap_interval.overlaps(&inside_interval1) {
expected_overlapping.push(inside_interval1);
}
if overlaps(overlap_interval, inside_interval2) {
if overlap_interval.overlaps(&inside_interval2) {
expected_overlapping.push(inside_interval2);
}
//make our expected_overlapping the correct order
Expand Down Expand Up @@ -2118,7 +2118,7 @@ mod tests {
fn overlaps_tests() {
for interval1 in all_valid_test_bounds() {
for interval2 in all_valid_test_bounds() {
let our_answer = overlaps(interval1, interval2);
let our_answer = interval1.overlaps(&interval2);

let mathematical_definition_of_overlap =
NUMBERS_DOMAIN.iter().any(|x| {
Expand Down Expand Up @@ -2245,7 +2245,7 @@ mod tests {
let mut output = Vec::new();
for test_bounds1 in all_valid_test_bounds() {
for test_bounds2 in all_valid_test_bounds() {
if !overlaps(test_bounds1, test_bounds2) {
if !test_bounds1.overlaps(&test_bounds2) {
output.push((test_bounds1, test_bounds2));
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/nodit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! A module containing the `nodit` data-structures.
//!
//! `nodit` stands for Non-Overlapping Discrete Interval Tree.
pub mod map;
pub mod set;
5 changes: 5 additions & 0 deletions src/zosdit/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use alloc::vec::Vec;
use core::cmp::Ordering;
use core::fmt;
use core::marker::PhantomData;
#[cfg(doc)]
use crate::NoditMap;

use btree_monstrousity::btree_map::SearchBoundCustom;
use btree_monstrousity::BTreeMap;
Expand All @@ -28,6 +30,9 @@ type ValueStore<V> = SmallVec<[V; 2]>;
/// A Zero Overlap Sequential Discrete Interval Tree Map Data-Structure based off [`BTreeMap`] and
/// [`SmallVec`]
///
/// See the `zosdit` module documentation for a more detailed explanation of how this
/// data-structure works.
///
/// `I` is the generic type parameter for the [`Ord`] type the `K`
/// type is a interval over.
///
Expand Down
28 changes: 28 additions & 0 deletions src/zosdit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
//! A module containing the `zosdit` data-structures.
//!
//! `zosdit` stands for Zero-Overlap Sequential Discrete Interval Tree.
//!
//! These data-structures are very similar to the `nodit` data-structures, except where in `zosdit`
//! no overlapping at all is allowed within the data-structure, `zosdit` is slightly more relaxed
//! in that you are allowed overlaps as long as they are "zero-overlaps".
//!
//! ## Zero-Overlap
//!
//! In this crate, zero-overlap is the term used to describe when intervals have zero-width
//! overlap, for example the intervals `0..=4` and `4..=10` overlap since they both contain the
//! point `4`, however, they are also deemed to have zero-overlap as the width of their
//! intersection (4..=4) is zero (4 - 4 = 0).
//!
//! However, there is another restriction to our definition of zero-overlap, and that is that
//! singular intervals (like 4..=4) cannot be completely inside other intervals. For example,
//! (4..=8) and (6..=6) despite having zero-width intersection are deemed to still not be classed
//! as having zero-overlap.
//!
//! These two restrictions then give natural zero-overlap sequences of intervals such as [`0..=4`,
//! `4..=4`, `4..=4`, `4..=4`, `4..=6`, `6..=10`]. This is where the sequential part comes in as
//! when inserting a new interval into the data-structure those three `4..=4` intervals are
//! inserted to the back of the same intervals (if using `insert_strict_back()`).
//!
//! The main use-case for these data-structures at the moment is for time-traversal of a graph. So
//! if you wanted to describe the time-taken when walking along a graph with perhaps some
//! zero-sized and some non-zero-sized edges losslessly and efficiently then this is the sort of
//! data-structure you might want to use.
pub mod map;

0 comments on commit 23f9738

Please sign in to comment.