
LinearRange object
Prototype for LinearRange objects SyntaxTo create an empty LinearRange: var linear_range = new LinearRange(); To create a LinearRange contains integers from start to start+length excluded (i.e. [start, start+length) integers): var linear_range = new LinearRange(start, length); To create a copy of a LinearRange: var linear_range2 = new LinearRange (linear_range1); Parametersstart, length. Integers. start and length of the range to
create Property Ofnone. Implemented InECMerge 2.1 DescriptionLinearRange objects represents an interval in
integers' space for which you provide a start and a length. It
lets you compute intersections, containment tests and other
useful operations. Properties
Methodscontains ExamplesExample 1.Creating a LinearRange containing integers from 5 to 9 (excluded). var linear_range = new LinearRange (5, 4); See Also
Method containsSyntaxfunction contains (range) Parametersrange. LinearRange object.
Range that we test to know if it is contained by this
object. Method OfLinearRange object. Implemented InECMerge 2.1 DescriptionReturns true if the tested range is actually contained in this object. A range is considered contained inside another object:
ExamplesExample 1.Logs whether a range is contained by another (true in this case): log (LinearRange (100, 10).contains (LinearRange (105, 5))); See Also
Method emptySyntaxfunction empty ( ) Parametersnone. Method OfLinearRange object Implemented InECMerge 2.1 DescriptionSets length and start to 0 (zero). See Also
Method enlarge_to_containSyntaxfunction enlarge_to_contain (range) Parametersrange. LinearRange object.
Range that we to include in this object. Method OfLinearRange object. Implemented InECMerge 2.1 DescriptionModifies this object such that all the integers in range are also included in this object. ExamplesExample 1.Enlarges a range with another then logs the result: var range = LinearRange (25, 50); which prints: start=23, length=52 See Also
Method intersectionSyntaxfunction intersection (range) Parametersrange. LinearRange object. Range for which we want to compute the intersection with this object. Method OfLinearRange object. Implemented InECMerge 2.1 DescriptionComputes the intersection between this object and range and returns the result as a LinearRange object. ExamplesExample 1.Intersects a range with another then logs the result: var range = LinearRange (25, 50).intersection
(LinearRange (23, 40)); which prints: start=25, length=38 See Also
Method orderSyntaxfunction order ( ) Parametersnone. Method OfLinearRange object. Implemented InECMerge 2.1 DescriptionEnsures that start is before or equal to end (and as such that length is positive or zero). ExamplesExample 1.Reorders a range with negative length then logs the result: var range = LinearRange (25, 50); which prints: start=25, length=50 See Also

