trait Range[A] extends Base[A]

Generic 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,startExclusive
  • end, endExclusive
  • and ordering, which makes 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 filter function, returning true if an element is within Range and false otherwise

Ordering
  1. Alphabetic
Inherited
  1. Range
  2. Util.Z.Range.Base
  3. scala.Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type

  1. abstract type Range[A] <: Range[A]
    Attributes
    protected
    Definition Classes
    Base

Method

  1. def all(implicit n: Numeric[A]): ~[A]

    Stream of elements

    Stream of elements

    Elements are produced from start to end using implicit math.Numeric with value 1

    Range('A','K').all.lp  // Prints ~(A, B, C, D, E, F, G, H, I, J, K)
    Definition Classes
    Range
  2. def allIntStep(step: Int)(implicit n: Numeric[A]): ~[A]

    Stream of elements with Int step

    Stream of elements with Int step

    Elements are produced from start to end using implicit math.Numeric with provided step value

    If step is negative, elements streamed from end to start

    Range('A', 'Z').allIntStep(4).lp  // Prints: ~(A, E, I, M, Q, U, Y)
    Definition Classes
    Range
  3. def allStep(step: A)(implicit n: Numeric[A]): ~[A]

    Stream of elements with step

    Stream of elements with step

    Elements are produced from start to end using implicit math.Numeric with provided step value

    If step is negative, elements streamed from end to start

    Range(1 to 20).allStep(-3).lp    // Prints: ~(20, 17, 14, 11, 8, 5, 2)
    Definition Classes
    Range
  4. def allStep(step: (A) ⇒ A): ~[A]

    Stream of elements with step

    Stream of elements with step

    Elements are produced using specified step function

    Range(1.0, 10.0).allStep(_ + 3).lp // Prints: ~(1.0, 4.0, 7.0, 10.0)
    
    Range(1.0, 10.0).allStep(_ - 2).lp // Prints: ~(10.0, 8.0, 6.0, 4.0, 2.0)
    Definition Classes
    Range
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def contains(a: A): Boolean

    Check if within

    Check if within

    Returns true if this range contains specified value

    Range(1, 9) contains 3  // Returns: true
    Definition Classes
    Range
  7. def contains(that: Range[A]): Boolean

    Check if within

    Check if within

    Returns true if this range contains that range

    Range(1, 9) contains Range(3, 7)  // Returns: true
    
    Range(1, 5) contains Range(3, 7)  // Returns: false
    Definition Classes
    Range
  8. abstract def end: A

    To value

    To value

    End value of the range

    Definition Classes
    Range
  9. def endContains(v: A, x: Boolean = false): Boolean
    Attributes
    protected
    Definition Classes
    Base
  10. abstract def endExclusive: Boolean

    Exclusive check

    Exclusive check

    If true, the end value is exclusive

    Range(10,15,true) contains 15   // Returns: false
    
    // Exclusive 15 does not contain 15
    Definition Classes
    Range
  11. def equals(arg0: Any): Boolean
    Definition Classes
    Any
  12. def extendTo(a: A): Range[A]

    Expand

    Expand

    This range is extended to contain the specified value

    Range('A','C') extendTo 'G' // Returns: A <> G
    
    Range('A','C') extendTo 'B' // Returns: A <> C
    Definition Classes
    Range
  13. def hashCode(): Int
    Definition Classes
    Any
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def join(that: Range[A]): Range[A]

    Union

    Union

    Returns range with out-most reaches of this and that

    Range('A', 'C') join Range('X', 'Z') // Returns: A <> Z
    Definition Classes
    Range
  16. abstract def make(start: A, startIn: Boolean, end: A, endIn: Boolean): Range[A]
    Attributes
    protected
    Definition Classes
    Base
  17. def map[B](m: (A) ⇒ B)(implicit s: Ordering[B]): Range[B]

    Mapped Range

    Mapped Range

    Creates range with mapped values

    Range(1, 5, true).map(_ * 100) // Creates range: 100 <>> 500
    Definition Classes
    Range
  18. abstract def ordering: Ordering[A]

    Ordering

    Ordering

    Ordering defining range

    Ordering defining type elements comparison

    Definition Classes
    Range
  19. def overlapOpt(that: Range[A]): Opt[Range[A]]

    Optional intersection

    Optional intersection

    Optionally returns common intersection of this and that

    Range(1, 6) overlapOpt Range(3, 9)  // Returns: Opt(3 <> 6)
    
    Range(1, 3) overlapOpt Range(6, 9)  // Returns: Opt.Void
    Definition Classes
    Range
  20. abstract def start: A

    From value

    From value

    Start value of the range

    Definition Classes
    Range
  21. def startContains(v: A, x: Boolean = false): Boolean
    Attributes
    protected
    Definition Classes
    Base
  22. abstract def startExclusive: Boolean

    Exclusive check

    Exclusive check

    If true, the start value is exclusive

    Range(10,true,15,false) contains 10  // Returns: false
    
    // Exclusive 10 does not contain 10
    Definition Classes
    Range
  23. def thisClass: Class[_]
    Attributes
    protected
    Definition Classes
    Base
  24. def toString(): String

    String presentation

    String presentation

    Returns String in Range format, which is for values A and B, specifies:

    • A <> B - A to B
    • A <>> B - A to B exclusive
    • A <<> B - A exclusive to B
    • A <<>> B - A exclusive to B exclusive
    Range("AA", "BB").toString // Returns AA <> BB
    Definition Classes
    Range → Any

Operator

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
Linear Supertypes
Base[A], Any
Source: Range.scala