Util

object Util
Source
__.scala
class java.lang.Object
trait scala.Matchable
class Any

Member

opaque type ByteCount

Byte Size

ByteCount is an opaque Long value, used to indicate something like "File size" or "memory allocation", whatever is counted in bytes

Source
ByteCount.scala
abstract class EnumCompanion[A <: scala.reflect.Enum] extends Idx[A]

EnumCompanion is a type to be extended by all enum companion objects to integrate them with Scalqa containers.

This is a recommended step, which might not be nessesasy in simple cases

 enum Direction:
   case Up,Down,Left,Right

 object Direction extends EnumCompanion[Direction]

 Direction.stream.tp

 // Output
 Stream(Up, Down, Left, Right)
Source
EnumCompanion.scala
opaque type Percent

Percent is an opaque Double value

Percent can be created with method constructors on primitives

 3.Percent.tp     // Prints: 3.0%
 3.14.Percent.tp  // Prints: 3.14%
Source
Percent.scala
trait TwoWayFunction[A, B] extends A => B

Bi-Directional Function

TwoWayFunction allows to convert value to some type and back

It is used in two way binded collections

  val intToChar: TwoWayFunction[Int,Char] = TwoWayFunction(i => ('A' + i).toChar, _ - 'A')

  val list:  Idx.M[Int] = Stream(0, 2, 4).toBuffer
  val view:  Idx.M[Char] = list.mutableMapView(intToChar)

  list.stream.tp     // Prints Stream(0, 2, 4)
  view.stream.tp     // Prints Stream(A, C, E)

  view(1) = 'Z' // Note, only second collection is updated, but both are changed

  list.stream.tp     // Prints Stream(0, 25, 4)
  view.stream.tp     // Prints Stream(A, Z, E)
Source
TwoWayFunction.scala
trait TwoWayFunction[A, B] extends A => B

Bi-Directional Function

TwoWayFunction allows to convert value to some type and back

It is used in two way binded collections

  val intToChar: TwoWayFunction[Int,Char] = TwoWayFunction(i => ('A' + i).toChar, _ - 'A')

  val list:  Idx.M[Int] = Stream(0, 2, 4).toBuffer
  val view:  Idx.M[Char] = list.mutableMapView(intToChar)

  list.stream.tp     // Prints Stream(0, 2, 4)
  view.stream.tp     // Prints Stream(A, C, E)

  view(1) = 'Z' // Note, only second collection is updated, but both are changed

  list.stream.tp     // Prints Stream(0, 25, 4)
  view.stream.tp     // Prints Stream(A, Z, E)
Source
TwoWayFunction.scala