everythings working and I'm starting to re-add functionality

This commit is contained in:
ripytide
2023-04-02 20:25:05 +01:00
parent 2c6eda2db8
commit b5ca8ad92c
6 changed files with 55 additions and 24 deletions
Generated
+2 -2
View File
@@ -10,9 +10,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "btree_monstousity"
version = "0.0.3"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1bcfb39dbdc98ba2984b575608c94a871f111960a813a23e88b0ac3d62fd274"
checksum = "a596671a3fb8cd1899005c5cdc5ce442fe4d0153abbe12917171f7d435831563"
dependencies = [
"cfg-if",
"rustversion",
+1 -1
View File
@@ -21,7 +21,7 @@ serde = {version = "1.0.148", features = ["derive"]}
itertools = "0.10.5"
labels = "0.0.2"
pretty_assertions = "1.3.0"
btree_monstousity = "0.0.3"
btree_monstousity = "0.0.4"
[dev-dependencies]
ordered-float = "3.4.0"
+1
View File
@@ -0,0 +1 @@
use std::ops::RangeBounds;
+2 -2
View File
@@ -34,9 +34,9 @@ where
B: Ord,
{
if bound_ord < BoundOrd::start(range_bounds.start_bound()) {
Ordering::Greater
} else if bound_ord > BoundOrd::end(range_bounds.end_bound()) {
Ordering::Less
} else if bound_ord > BoundOrd::end(range_bounds.end_bound()) {
Ordering::Greater
} else {
Ordering::Equal
}
+1
View File
@@ -231,6 +231,7 @@ pub(crate) mod bound_ord;
pub(crate) mod helpers;
pub mod range_bounds_map;
pub mod delete_me;
//pub mod range_bounds_set;
pub mod try_from_bounds;
+48 -19
View File
@@ -17,6 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with range_bounds_map. If not, see <https://www.gnu.org/licenses/>.
*/
use std::cmp::Ordering;
use std::fmt::{self, Debug};
use std::iter::once;
use std::marker::PhantomData;
@@ -358,7 +359,20 @@ where
range_bounds: K,
value: V,
) -> Result<(), OverlapError> {
todo!()
if self.overlaps((range_bounds.start_bound(), range_bounds.end_bound()))
{
return Err(OverlapError);
}
let double_comp = |inner_range_bounds: &K, new_range_bounds: &K| {
let retult = BoundOrd::start(new_range_bounds.start_bound())
.cmp(&BoundOrd::start(inner_range_bounds.start_bound()));
retult
};
self.inner.insert(range_bounds, value, double_comp);
return Ok(());
}
/// Returns `true` if the given `RangeBounds` overlaps any of the
@@ -390,7 +404,7 @@ where
where
Q: RangeBounds<I>,
{
todo!()
self.overlapping(range_bounds).next().is_some()
}
/// Returns an iterator over every (`RangeBounds`, `Value`) entry
@@ -430,18 +444,8 @@ where
where
Q: RangeBounds<I>,
{
let lower_comp = |inner_range_bounds: &K| {
cmp_range_bounds_with_bound_ord(
inner_range_bounds,
BoundOrd::start(range_bounds.start_bound()),
)
};
let upper_comp = |inner_range_bounds: &K| {
cmp_range_bounds_with_bound_ord(
inner_range_bounds,
BoundOrd::end(range_bounds.end_bound()),
)
};
let lower_comp = comp_start(range_bounds.start_bound());
let upper_comp = comp_end(range_bounds.end_bound());
let lower_bound = SearchBoundCustom::Included;
let upper_bound = SearchBoundCustom::Included;
@@ -471,7 +475,7 @@ where
/// ```
#[trivial]
pub fn get_at_point(&self, point: &I) -> Option<&V> {
todo!()
self.get_entry_at_point(point).map(|(key, value)| value)
}
/// Returns `true` if the map contains a `RangeBounds` that
@@ -494,7 +498,7 @@ where
/// ```
#[trivial]
pub fn contains_point(&self, point: &I) -> bool {
todo!()
self.get_entry_at_point(point).is_some()
}
/// Returns a mutable reference to the `Value` corresponding to
@@ -514,8 +518,8 @@ where
/// assert_eq!(map.get_at_point(&1), Some(&true));
/// ```
#[tested]
pub fn get_at_point_mut(&mut self, point: I) -> Option<&mut V> {
todo!()
pub fn get_at_point_mut(&mut self, point: &I) -> Option<&mut V> {
self.inner.get_mut(comp_start(Bound::Included(point)))
}
/// Returns an (`RangeBounds`, `Value`) entry corresponding to the
@@ -538,7 +542,7 @@ where
/// ```
#[trivial]
pub fn get_entry_at_point(&self, point: &I) -> Option<(&K, &V)> {
todo!()
self.inner.get_key_value(comp_start(Bound::Included(point)))
}
/// Returns an iterator over every (`RangeBounds`, `Value`) entry
@@ -1647,3 +1651,28 @@ where
todo!()
}
}
fn comp_start<I, K>(bound: Bound<&I>) -> impl FnMut(&K) -> Ordering + '_
where
I: Ord,
K: RangeBounds<I>,
{
move |inner_range_bounds: &K| {
cmp_range_bounds_with_bound_ord(
inner_range_bounds,
BoundOrd::start(bound),
)
}
}
fn comp_end<I, K>(bound: Bound<&I>) -> impl FnMut(&K) -> Ordering + '_
where
I: Ord,
K: RangeBounds<I>,
{
move |inner_range_bounds: &K| {
cmp_range_bounds_with_bound_ord(
inner_range_bounds,
BoundOrd::end(bound),
)
}
}