<>

abstract class Range[A] extends Able.Contain[A]

Value Range

Scala provided range structures (Range and NumericRange) are implemented more as collections and this class is designed to close this void focusing on generic range operations

Range is defined with the following defs:

  • start
  • end,
  • and ordering, which mks the above meaningful

Range has a notion that an element can be within the range, i.e. between start and end, or outside

Note. Range is implicitly converted to a let function, returning true if an element is within Range and false otherwise

Companion
object
Source
__.scala
trait Able.Contain[A]
class Object
trait Matchable
class Any
class Byte.G.<>[A]
class Char.G.<>[A]
class Double.G.<>[A]
class Float.G.<>[A]
class Int.G.<>[A]
class Long.G.<>[A]
class Short.G.<>[A]
class <>.X.Base[A, THIS]
class Period

Def

def contains(v: <>[A]): Boolean

Check if within

Check if within

Returns true if this range contains specified range

 (1 <> 9) contains (3 <> 7)  // Returns: true

 (1 <> 5) contains (3 <> 7)  // Returns: false
Source
__.scala
def contains(v: A): Boolean

Check if within

Check if within

Returns true if this range contains specified value

 (1 <> 9) contains 3  // Returns: true
Source
__.scala
def end: A

To value

To value

End value of the range

Source
__.scala
def endIsIn: Boolean

Inclusive check

Inclusive check

If true, the end value is inclusive

 (10 <>> 15) contains 15   // Returns: false

 // Exclusive 15 does not contain 15
Source
__.scala
override def equals(v: Any): Boolean
Definition Classes
Any
Source
__.scala
def isEmpty: Boolean
Source
__.scala
def join(v: A): THIS_TYPE

Extend to

Extend to

This range is extended to contain the specified value

 'A' <> 'C' extendTo 'G' // Returns: A <> G

 'A' <> 'C' extendTo 'B' // Returns: A <> C
Source
__.scala
def join(v: <>[A]): THIS_TYPE

Union

Union

Returns range with out-most reaches of this and specified

 'A' <> 'C' join 'X' <> 'Z' // Returns: A <> Z
Source
__.scala
def ordering: Ordering[A]

Ordering

Ordering

Ordering defining range

Ordering defining type elements comparison

Source
__.scala
@targetName("overlap_Opt")
def overlap_?(r: <>[A]): Opt[THIS_TYPE]

Optional intersection

Optional intersection

Optionally returns common intersection of this and that

 1 <> 6 overlap_? 3 <> 9  // Returns: ?(3 <> 6)

 1 <> 3 overlap_? 6 <> 9  // Returns: \/
Source
__.scala
def overlaps(r: <>[A]): Boolean
Source
__.scala
inline def raw[RAW <: Raw[A]](using inline s: Shape.OfRange.Tag.Raw[A, RAW]): RAW
Source
__.scala
def start: A

From value

From value

Start value of the range

Source
__.scala
def step_~(f: A => A): ~[A]
Source
__.scala
def step_~(step: Int)(using Able.Sequence[A]): ~[A]
Source
__.scala

Extension

@targetName("stream")
def ~: ~[A]
Extension method from Range
Source
__.scala
def convert: <>[B]
Extension method from Range
Source
__.scala