_metadata

trait _metadata

Stream Metadata Interface

Metadata is a static knowledge about stream elements to be delivered

Metadata methods can be called many times, they do not trigger any data movements

Source
_metadata.scala
class java.lang.Object
trait scala.Matchable
class Any
trait _use
object ~

Def

inline def docTree[A]: Doc.Tree

Doc Tree description

Doc Tree description

Returns a tree describing all stream trasformations

('a' <> 'z').~
 .map(_.Int)
 .take(_ % 2 == 0)
 .docTree.tp

// Output
scalqa.lang.int.g.Stream$TakeStream$2@4ds1{raw=Int}
 scalqa.lang.char.z.stream.map$Ints@j38c{raw=Int,fromRaw=Char,size=26}
   scalqa.lang.char.Z$Stream_fromRange@gw1k{raw=Char,size=26,from=a,step=1}
Source
_metadata.scala
@scala.annotation.targetName("size_Opt")
inline def size_?[A]: Int.Opt

Optional size

Optional size

Many streams can return their current element count. If the information is not available, void option is returned

Note: If size is known, but exceeds integer range, void option is returned. For theses cases use sizeLong_?

 var s = ('a' <> 'z').~

 s.size_?.tp         // Prints Int.Opt(26)

 s = s.take(_ > 10)  // static sizing is lost

 s.size_?.tp         // Prints Int.Opt(\/)
Source
_metadata.scala
@scala.annotation.targetName("sizeLong_Opt")
inline def sizeLong_?[A]: Long.Opt

Optional long size

Optional long size

Many streams can return their current element count. If the information is not available, void option is returned

var s = (Int.min.Long <> Int.max.Long).~

s.sizeLong_?.tp    // Prints Long.Opt(4294967296)

s = s.take(_ > 10) // static sizing is lost

s.sizeLong_?.tp    // Prints Long.Opt(\/)
Source
_metadata.scala