<commit_before>use super::{Interval, IntervalEnd, IntervalCollisionObject};
use collision::Collidable;
use ::geometry::*;

#[derive(Debug, Clone)]
pub struct IntervalCollection {
    pub start: IntervalEnd,
    pub end: IntervalEnd,
    intervals: Vec<Interval>
}

impl IntervalCollection {
    const ERRORMARGIN: f64 = 0.0001;

    pub fn new(start: IntervalEnd, end: IntervalEnd, intervals: Vec<Interval>) -> Self {
        Self {
            start,
            end,
            intervals
        }
    }

    fn relative_error_margin(&self) -> f64 {
        Self::ERRORMARGIN * (self.end.value() - self.start.value())
    }

    fn get_starts(&self) -> Vec<IntervalEnd> {
        self.intervals.iter().map(|end| { end.get_start().clone() }).collect()
    }

    fn get_ends(&self) -> Vec<IntervalEnd> {
        self.intervals.iter().map(|end| { end.get_end().clone() }).collect()
    }

    pub fn get_start_end_interval(&self) -> Interval {
        Interval::new(self.start, self.end)
    }

    pub fn invert(&self) -> IntervalCollection {
        let mut inv_intervals: Vec<Interval> = Vec::new();

        let start_included = self.start.equals(&self.intervals[0].get_start(), self.relative_error_margin());
        if !start_included {
            let first_interval = Interval::new(self.start, self.intervals[0].get_start());<commit_msg>Add full interval helper function<commit_after>use super::{Interval, IntervalEnd, IntervalCollisionObject};
use collision::Collidable;
use ::geometry::*;
use std::f64::consts::PI;

#[derive(Debug, Clone)]
pub struct IntervalCollection {
    pub start: IntervalEnd,
    pub end: IntervalEnd,
    intervals: Vec<Interval>
}

impl IntervalCollection {
    const ERRORMARGIN: f64 = 0.0001;

    pub fn new(start: IntervalEnd, end: IntervalEnd, intervals: Vec<Interval>) -> Self {
        Self {
            start,
            end,
            intervals
        }
    }

    pub fn full_interval() -> Self {
        IntervalCollection::new(
            IntervalEnd::Closed(-PI),  
            IntervalEnd::Closed(PI),
            vec![Interval::new_closed(-PI, PI)])
    }

    fn relative_error_margin(&self) -> f64 {
        Self::ERRORMARGIN * (self.end.value() - self.start.value())
    }

    fn get_starts(&self) -> Vec<IntervalEnd> {
        self.intervals.iter().map(|end| { end.get_start().clone() }).collect()
    }

    fn get_ends(&self) -> Vec<IntervalEnd> {
        self.intervals.iter().map(|end| { end.get_end().clone() }).collect()
    }

    pub fn get_start_end_interval(&self) -> Interval {
        Interval::new(self.start, self.end)
    }

    pub fn invert(&self) -> IntervalCollection {
        let mut inv_intervals: Vec<Interval> = Vec::new();

        let start_included = self.start.equals(&self.intervals[0].get_start(), self.relative_error_margin());
        if !start_included {
            let first_interval = Interval::new(self.start, self.intervals[0].get_start());
{'fraction_non_alphanumeric': 0.14654879292757567, 'fraction_numerical': 0.008160489629377763, 'mean_word_length': 2.9279038718291055, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3728879', 'n_tokens_mistral': 943, 'n_tokens_neox': 907, 'n_words': 180}