- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
implict objects for providing lower/ upper integer bounds for Int, Long?
Mon, 2011-06-06, 16:30
hi,
is there any object (MinMax in the example) that provides the maximum positive values for integers (Int, Long)? like
object MyColl {
def empty[ A : Ordering : MinMax ] : MyColl[ A ] = new Impl[ A ]
private class Impl[ @specialized( Int, Long ) A ]( implicit ord: Ordering[ A ], minMax: MinMax[ A ]) {
def smallerThanMax( a: A ) : Boolean = ord.lt( a, minMax.max )
}
}
trait MyColl[ @specialized( Int, Long ) A ] {
def smallerThanMax( a: A ) : Boolean
}
so that minMax.min for Int gives Int.MinValue and for Long gives Long.MinValue, and minMax.max gives Int.MaxValue and Long.MaxValue respectively?
i see that Numeric has `one`, and `zero`, so i was wondering if something like `maxValue` and `minValue` also exist somewhere for integer types, preferably with implicits already set up?
thanks, -sciss-