Skip to content

Commit

Permalink
Merge pull request #57 from ripytide/interval_naming
Browse files Browse the repository at this point in the history
"range" -> "interval" naming + crate name change to `nodit`
  • Loading branch information
ripytide committed Jan 2, 2024
2 parents e58ec9d + 94e5bdc commit e0c680b
Show file tree
Hide file tree
Showing 11 changed files with 1,028 additions and 1,018 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
documentation for use by end-users, #56
- `insert_overwrite()` now returns the cut entries, #51
- Renamed `gaps()` to `gaps_trimmed()` and added a `gaps_untrimmed()` method
- Mass replaced renamed from the word "range" to the word "interval" all code
items, docs.
- The crate has been renamed from `discrete_range_map` to `nodit`
- The `DiscreteRangeMap` is now `NoditMap` and the `DiscreteRangeSet` is now
`NoditSet`

### Fixed

Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[package]
name = "discrete_range_map"
name = "nodit"
version = "0.6.2"
authors = ["James Forster <james.forsterer@gmail.com>"]
edition = "2021"
description = """
This crate provides DiscreteRangeMap and DiscreteRangeSet, Data
Structures for storing non-overlapping discrete intervals based off
BTreeMap.
This crate provides NoditMap and NoditSet, Non-Overlapping Discrete
Interval Tree data-structures, which are based off BTreeMap.
"""
documentation = "https://docs.rs/discrete_range_map"
documentation = "https://docs.rs/nodit"
readme = "README.md"
homepage = "https://github.com/ripytide/discrete_range_map"
repository = "https://github.com/ripytide/discrete_range_map"
homepage = "https://github.com/ripytide/nodit"
repository = "https://github.com/ripytide/nodit"
license = "AGPL-3.0-or-later"
keywords = ["data-structures", "map", "data", "library"]
categories = ["data-structures"]
Expand Down
76 changes: 42 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
# discrete_range_map
# nodit

[![License](https://img.shields.io/github/license/ripytide/discrete_range_map)](https://www.gnu.org/licenses/agpl-3.0.en.html)
[![Docs](https://docs.rs/discrete_range_map/badge.svg)](https://docs.rs/discrete_range_map)
[![Maintained](https://img.shields.io/maintenance/yes/2023)](https://github.com/ripytide)
[![Crates.io](https://img.shields.io/crates/v/discrete_range_map)](https://crates.io/crates/discrete_range_map)
[![License](https://img.shields.io/github/license/ripytide/nodit)](https://www.gnu.org/licenses/agpl-3.0.en.html)
[![Docs](https://docs.rs/nodit/badge.svg)](https://docs.rs/nodit)
[![Maintained](https://img.shields.io/maintenance/yes/2024)](https://github.com/ripytide)
[![Crates.io](https://img.shields.io/crates/v/nodit)](https://crates.io/crates/nodit)

<p align="center">
<img src="logo.png" alt="discrete_range_map_logo" width="350">
<img src="logo.png" alt="nodit_logo" width="350">
</p>

This crate provides [`DiscreteRangeMap`] and [`DiscreteRangeSet`],
Data Structures for storing non-overlapping discrete intervals based
off [`BTreeMap`].
This crate provides [`NoditMap`] and [`NoditSet`], Non-Overlapping Discrete
Interval Tree data-structures, which are based off [`BTreeMap`].

`no_std` is supported and should work with the default features.

## `Copy` is partially required

Due to implementation complications with non-`Copy` types the
datastructures currently require both the range type and the points the
data-structures currently require both the range type and the points the
ranges are over to be `Copy`. However, the value type used when using
the [`DiscreteRangeMap`] does not have to be `Copy`. In fact the only
the [`NoditMap`] does not have to be `Copy`. In fact the only
required traits on the value type are sometimes `Clone` or `Eq` but only
for some methods so if in doubt check a methods trait bounds.

## Example using an Inclusive-Exclusive range

```rust
use discrete_range_map::inclusive_interval::ie;
use discrete_range_map::DiscreteRangeMap;
use nodit::interval::ie;
use nodit::NoditMap;

let mut map = DiscreteRangeMap::new();
let mut map = NoditMap::new();

map.insert_strict(ie(0, 5), true);
map.insert_strict(ie(5, 10), false);
Expand All @@ -45,9 +44,9 @@ assert_eq!(map.contains_point(5), true);
```rust
use std::ops::{Bound, RangeBounds};

use discrete_range_map::inclusive_interval::ie;
use discrete_range_map::{
DiscreteFinite, DiscreteRangeMap, InclusiveInterval,
use nodit::interval::ie;
use nodit::{
DiscreteFinite, NoditMap, InclusiveInterval,
InclusiveRange,
};

Expand Down Expand Up @@ -75,9 +74,9 @@ impl InclusiveRange<i8> for Reservation {
}
}

// Second, we need to implement From<InclusiveInterval<i8>>
impl From<InclusiveInterval<i8>> for Reservation {
fn from(value: InclusiveInterval<i8>) -> Self {
// Second, we need to implement From<Interval<i8>>
impl From<Interval<i8>> for Reservation {
fn from(value: Interval<i8>) -> Self {
if value.end == i8::MAX {
Reservation::Infinite(value.start)
} else {
Expand All @@ -89,8 +88,8 @@ impl From<InclusiveInterval<i8>> for Reservation {
}
}

// Next we can create a custom typed DiscreteRangeMap
let reservation_map = DiscreteRangeMap::from_slice_strict([
// Next we can create a custom typed NoditMap
let reservation_map = NoditMap::from_slice_strict([
(Reservation::Finite(10, 20), "Ferris".to_string()),
(Reservation::Infinite(21), "Corro".to_string()),
])
Expand Down Expand Up @@ -149,7 +148,7 @@ as this:
```rust
use std::cmp::Ordering;

use discrete_range_map::DiscreteFinite;
use nodit::DiscreteFinite;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum WithInfinity<T> {
Expand Down Expand Up @@ -227,19 +226,19 @@ where
// Infinity is encountered such as when it might be
// returned by `get_entry_at_point()`, for example:

use discrete_range_map::{DiscreteRangeMap, InclusiveInterval};
use nodit::{NoditMap, Interval};

let map: DiscreteRangeMap<
let map: NoditMap<
WithInfinity<u8>,
InclusiveInterval<WithInfinity<u8>>,
Interval<WithInfinity<u8>>,
bool,
> = DiscreteRangeMap::new();
> = NoditMap::new();

let mut gap = map.get_entry_at_point(WithInfinity::Finite(4));

assert_eq!(
gap,
Err(InclusiveInterval {
Err(Interval {
start: WithInfinity::Finite(0),
end: WithInfinity::Infinity,
})
Expand Down Expand Up @@ -297,11 +296,20 @@ Lots of my inspiration came from the [`rangemap`] crate.
The BTreeMap implementation ([`btree_monstrousity`]) used under the
hood was inspired and forked from the [`copse`] crate.

## Name Change

This crate was previously named [`range_bounds_map`] it was renamed
## Name Changes
This crate was later named [`range_bounds_map`] it was renamed
around about 2023-04-24 due to it no longer being an accurate name.

This crate was previously named [`range_bounds_map`] it was renamed to
[`discrete_range_map`] around about 2023-04-24 due to the old name no longer
being very accurate.

This crate was then renamed again on 2023-01-02 from [`discrete_range_map`] to
[`nodit`] due to a change to prefer the word "interval" over "range" whenever
possible for consistency. Hopefully, even if the library undergoes more changes
the shorter and more abstract name may be able to be kept even if it loses its
acronym of Non-Overlapping Discrete Interval Tree.

## Similar Crates

Here are some relevant crates I found whilst searching around the
Expand Down Expand Up @@ -363,6 +371,6 @@ topic area, beware my biases when reading:
[`range_bounds_map`]: https://docs.rs/range_bounds_map
[`bigint`]: https://docs.rs/num-bigint/latest/num_bigint/struct.BigInt.html
[`num_bigint`]: https://docs.rs/num-bigint
[`get_entry_at_point()`]: https://docs.rs/discrete_range_map/latest/discrete_range_map/discrete_range_map/struct.DiscreteRangeMap.html#method.get_entry_at_point
[`DiscreteRangeMap`]: https://docs.rs/discrete_range_map/latest/discrete_range_map/discrete_range_map/struct.DiscreteRangeMap.html#
[`DiscreteRangeSet`]: https://docs.rs/discrete_range_map/latest/discrete_range_map/discrete_range_set/struct.DiscreteRangeSet.html#
[`get_entry_at_point()`]: https://docs.rs/nodit/latest/nodit/nodit/struct.NoditMap.html#method.get_entry_at_point
[`NoditMap`]: https://docs.rs/nodit/latest/nodit/nodit/struct.NoditMap.html#
[`NoditSet`]: https://docs.rs/nodit/latest/nodit/discrete_interval_set/struct.NoditSet.html#
8 changes: 4 additions & 4 deletions src/discrete_finite.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
Copyright 2022,2023 James Forster
This file is part of discrete_range_map.
This file is part of nodit.
discrete_range_map is free software: you can redistribute it and/or
nodit is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
discrete_range_map is distributed in the hope that it will be useful,
nodit is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with discrete_range_map. If not, see <https://www.gnu.org/licenses/>.
along with nodit. If not, see <https://www.gnu.org/licenses/>.
*/

//! A module containing the [`DiscreteFinite`] trait and trait impls for the
Expand Down
Loading

0 comments on commit e0c680b

Please sign in to comment.