export class Interval { private _min = 0 ; private _max = 0 ; public constructor ( min = 0 , max = 0 ) { this . _min = Math . min ( min , max ) ; this . _max = max ; } public intersect ( interval ) { return new Interval ( Math . max ( interval . min ( ) , this . min ( ) ) , Math . min ( interval . max ( ) , this . max ( ) ) ) ; } public contains ( point ) { return this . min ( ) <= point && point <= this . max ( ) ; } public contigous ( interval ) { return this . contains ( interval . min ( ) ) || this . contains ( interval . max ( ) ) ; } public expandWith ( interval ) { this . _min = Math . min ( this . _min , interval . _min ) ; this . _max = Math . max ( this . _max , interval . _max ) ; } public min ( ) { return this . _min ; } public max ( ) { return this . _max ; } public size ( ) { return this . max ( ) - this . min ( ) ; } public empty ( ) { return this . max ( ) === this . min ( ) ; } }