src/sets.rs

branch
dev
changeset 155
45d03cf92c23
parent 133
2b13f8a0c8ba
child 163
b4a47e8e80d1
equal deleted inserted replaced
154:03f34ba55685 155:45d03cf92c23
1 /*! 1 /*!
2 This module provides various sets and traits for them. 2 This module provides various sets and traits for them.
3 */ 3 */
4 4
5 use crate::euclidean::Euclidean; 5 use crate::euclidean::Euclidean;
6 use crate::instance::{Instance, Space}; 6 use crate::instance::{BasicDecomposition, Instance, Space};
7 use crate::loc::Loc; 7 use crate::loc::Loc;
8 use crate::types::*; 8 use crate::types::*;
9 use serde::Serialize; 9 use serde::Serialize;
10 use std::ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive}; 10 use std::ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive};
11 11
49 macro_rules! impl_ranges { 49 macro_rules! impl_ranges {
50 ($($range:ident),*) => { $( 50 ($($range:ident),*) => { $(
51 impl<U,Idx> Set<U> for $range<Idx> 51 impl<U,Idx> Set<U> for $range<Idx>
52 where 52 where
53 Idx : PartialOrd<U>, 53 Idx : PartialOrd<U>,
54 U : PartialOrd<Idx> + Space, 54 U : PartialOrd<Idx> + Space<Decomp=BasicDecomposition> + Clone,
55 Idx : PartialOrd 55 Idx : PartialOrd
56 { 56 {
57 #[inline] 57 #[inline]
58 fn contains<I : Instance<U>>(&self, item : I) -> bool { 58 fn contains<I : Instance<U>>(&self, item : I) -> bool {
59 item.eval(|x| $range::contains(&self, x)) 59 item.eval(|x| $range::contains(&self, x))
83 A: Euclidean<F>, 83 A: Euclidean<F>,
84 F: Float, 84 F: Float,
85 { 85 {
86 #[inline] 86 #[inline]
87 pub fn new(orthogonal: A, offset: F) -> Self { 87 pub fn new(orthogonal: A, offset: F) -> Self {
88 Halfspace { 88 Halfspace { orthogonal: orthogonal, offset: offset }
89 orthogonal: orthogonal,
90 offset: offset,
91 }
92 } 89 }
93 } 90 }
94 91
95 /// Trait for generating a halfspace spanned by another set `Self` of elements of type `U`. 92 /// Trait for generating a halfspace spanned by another set `Self` of elements of type `U`.
96 pub trait SpannedHalfspace<F> 93 pub trait SpannedHalfspace<F>

mercurial