trait Range[A] extends Base[A]
- Alphabetic
- Range
- Util.Z.Range.Base
- scala.Any
- Hide All
- Show All
- Public
- All
Method
-
def
all(implicit n: Numeric[A]): ~[A]
Stream of elements
Stream of elements
Elements are produced from
start
toend
using implicit math.Numeric with value 1Range('A','K').all.lp // Prints ~(A, B, C, D, E, F, G, H, I, J, K)
- Definition Classes
- Range
-
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
toend
using implicit math.Numeric with providedstep
valueIf
step
is negative, elements streamed fromend
tostart
Range('A', 'Z').allIntStep(4).lp // Prints: ~(A, E, I, M, Q, U, Y)
- Definition Classes
- Range
-
def
allStep(step: A)(implicit n: Numeric[A]): ~[A]
Stream of elements with step
Stream of elements with step
Elements are produced from
start
toend
using implicit math.Numeric with providedstep
valueIf
step
is negative, elements streamed fromend
tostart
Range(1 to 20).allStep(-3).lp // Prints: ~(20, 17, 14, 11, 8, 5, 2)
- Definition Classes
- Range
-
def
allStep(step: (A) ⇒ A): ~[A]
Stream of elements with step
Stream of elements with step
Elements are produced using specified
step
functionRange(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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
contains(a: A): Boolean
Check if within
Check if within
Returns true if
this
range contains specified valueRange(1, 9) contains 3 // Returns: true
- Definition Classes
- Range
-
def
contains(that: Range[A]): Boolean
Check if within
Check if within
Returns true if
this
range containsthat
rangeRange(1, 9) contains Range(3, 7) // Returns: true Range(1, 5) contains Range(3, 7) // Returns: false
- Definition Classes
- Range
-
abstract
def
end: A
To value
To value
End value of the range
- Definition Classes
- Range
-
def
endContains(v: A, x: Boolean = false): Boolean
- Attributes
- protected
- Definition Classes
- Base
-
abstract
def
endExclusive: Boolean
Exclusive check
Exclusive check
If true, the
end
value is exclusiveRange(10,15,true) contains 15 // Returns: false // Exclusive 15 does not contain 15
- Definition Classes
- Range
-
def
equals(arg0: Any): Boolean
- Definition Classes
- Any
-
def
extendTo(a: A): Range[A]
Expand
Expand
This
range is extended to contain the specified valueRange('A','C') extendTo 'G' // Returns: A <> G Range('A','C') extendTo 'B' // Returns: A <> C
- Definition Classes
- Range
-
def
hashCode(): Int
- Definition Classes
- Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
join(that: Range[A]): Range[A]
Union
Union
Returns range with out-most reaches of
this
andthat
Range('A', 'C') join Range('X', 'Z') // Returns: A <> Z
- Definition Classes
- Range
-
abstract
def
make(start: A, startIn: Boolean, end: A, endIn: Boolean): Range[A]
- Attributes
- protected
- Definition Classes
- Base
-
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
-
abstract
def
ordering: Ordering[A]
Ordering
Ordering
Ordering defining range
Ordering defining type elements comparison
- Definition Classes
- Range
-
def
overlapOpt(that: Range[A]): Opt[Range[A]]
Optional intersection
Optional intersection
Optionally returns common intersection of
this
andthat
Range(1, 6) overlapOpt Range(3, 9) // Returns: Opt(3 <> 6) Range(1, 3) overlapOpt Range(6, 9) // Returns: Opt.Void
- Definition Classes
- Range
-
abstract
def
start: A
From value
From value
Start value of the range
- Definition Classes
- Range
-
def
startContains(v: A, x: Boolean = false): Boolean
- Attributes
- protected
- Definition Classes
- Base
-
abstract
def
startExclusive: Boolean
Exclusive check
Exclusive check
If true, the
start
value is exclusiveRange(10,true,15,false) contains 10 // Returns: false // Exclusive 10 does not contain 10
- Definition Classes
- Range
-
def
thisClass: Class[_]
- Attributes
- protected
- Definition Classes
- Base
-
def
toString(): String
String presentation
String presentation
Returns String in Range format, which is for values A and B, specifies:
A <> B
- A to BA <>> B
- A to B exclusiveA <<> B
- A exclusive to BA <<>> B
- A exclusive to B exclusive
Range("AA", "BB").toString // Returns AA <> BB
- Definition Classes
- Range → Any
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
ordering
, which makes the above meaningfulRange 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 andfalse
otherwise