本文整理汇总了Scala中scala.annotation.elidable类的典型用法代码示例。如果您正苦于以下问题:Scala elidable类的具体用法?Scala elidable怎么用?Scala elidable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了elidable类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: SimpleLogger
//设置package包名称以及导入依赖的类
package me.mmcoulombe.aad
import scala.annotation.elidable
import scala.annotation.elidable._
import scala.scalajs.js.Date
object SimpleLogger {
@elidable(FINEST)
def trace(msg: String): Unit =
println(s"TRACE [${new Date()}: $msg")
@elidable(FINE)
def debug(msg: String): Unit =
println(s"DEBUG [${new Date()}: $msg")
@elidable(INFO)
def info(msg: String): Unit =
println(s"INFO [${new Date()}: $msg")
}
示例2: log
//设置package包名称以及导入依赖的类
package de.sciss.imperfect
import java.awt.image.BufferedImage
import java.text.SimpleDateFormat
import java.util.{Date, Locale}
import scala.annotation.elidable
import scala.annotation.elidable.CONFIG
package object mesh {
var showLog = true
private[this] val logHeader = new SimpleDateFormat("[d MMM yyyy, HH:mm''ss.SSS] 'imperfect' - ", Locale.US)
final val NominalWidth = 1920
final val NominalHeight = 1080
final val VisibleWidth = 3840
final val VisibleHeight = 540
final val OffScreenImg = new BufferedImage(VisibleWidth, VisibleHeight, BufferedImage.TYPE_BYTE_GRAY)
final val OffScreenG = OffScreenImg.createGraphics()
@elidable(CONFIG) def log(what: => String): Unit =
if (showLog) Console.out.println(s"${logHeader.format(new Date())}$what")
def warn(s: String): Unit =
Console.err.println(s"Warning: $s")
}
示例3: log
//设置package包名称以及导入依赖的类
package de.sciss.imperfect
import java.awt.Color
import java.awt.image.BufferedImage
import java.text.SimpleDateFormat
import java.util.{Date, Locale}
import scala.annotation.elidable
import scala.annotation.elidable.CONFIG
package object hough {
var showLog = true
private[this] val logHeader = new SimpleDateFormat("[d MMM yyyy, HH:mm''ss.SSS] 'imperfect' - ", Locale.US)
final val NominalWidth = 1920
final val NominalHeight = 1080
final val VisibleWidth = 3840
final val VisibleHeight = 540
// final val OffScreenImg = new BufferedImage(VisibleWidth, VisibleHeight, BufferedImage.TYPE_BYTE_GRAY)
final val OffScreenImg = new BufferedImage(VisibleWidth, VisibleHeight, BufferedImage.TYPE_INT_ARGB)
final val OffScreenG = {
val res = OffScreenImg.createGraphics()
res.setColor(Color.black)
res.fillRect(0, 0, VisibleWidth, VisibleHeight)
res
}
@elidable(CONFIG) def log(what: => String): Unit =
if (showLog) Console.out.println(s"${logHeader.format(new Date())}$what")
def warn(s: String): Unit =
Console.err.println(s"Warning: $s")
}
示例4: Common
//设置package包名称以及导入依赖的类
package swim.app
import scala.annotation.elidable
import scala.annotation.elidable.ASSERTION
import fuel.func.RunExperiment
import fuel.util.IApp
import swim.Grammar
import swim.Tests
import swim.tree.ConstantProviderUniformI
import swim.tree.GPMoves
import swim.tree.Op
import swim.tree.SimpleGP
import fuel.util.Options
import fuel.util.Rng
import fuel.util.CollectorStdout
import fuel.func.BestSoFar
import fuel.core.StatePop
import fuel.util.Collector
object Common {
def getPassedTestsRatio(bsf: BestSoFar[Op, Int], totalTests: Int)(s: StatePop[(Op, Int)])(implicit coll: Collector) = {
// Computes ratio of passed tests for a best of run.
val (op, e) = bsf.bestSoFar.get
val ratio = if (e <= 0) 1.0 else (totalTests - e).toDouble / totalTests.toDouble
coll.setResult("best.passedTestsRatio", ratio)
s
}
}
object BooleanProblemFromCSV extends App {
val defaultOpts = Options('maxGenerations -> 20, 'populationSize -> 100, 'csvFile -> "booleanEx1.csv", 'parEval -> false )
implicit val opt = if (this.args.size == 0) defaultOpts else Options(this.args)
implicit val rng = Rng(opt)
implicit val coll = CollectorStdout(opt)
val fname = opt.getOption("csvFile").get
val tests = Tests.fromCSVfile[Double](fname, Tests.str2double)
assume(tests.nonEmpty)
val numVars = tests(0).input.size
println("Number of input variables: " + numVars)
// instruction set:
val instrSet = FloatingPointDomain.instructionSet(opt.paramString("instructions", "default")) +
(0 -> List(ConstantProviderUniformI(0, numVars - 1))) // input variables
val grammar = Grammar.fromSingleTypeInstructions(instrSet)
val domain = FloatingPointDomain(numVars)
// fitness function:
def eval(s: Op) = tests.count(t => domain(s)(t._1) != t._2)
val gp = new SimpleGP(GPMoves(grammar, SimpleGP.defaultFeasible), eval, SimpleGP.correctDiscrete) {
override def epilogue = super.epilogue andThen Common.getPassedTestsRatio(bsf, tests.size)
}
// launch the GP run
RunExperiment(gp)
}
示例5: Exercise03
//设置package包名称以及导入依赖的类
package forimpatient.chapter15
import scala.annotation.elidable
import scala.annotation.elidable.CONFIG
import scala.annotation.meta.{beanGetter, beanSetter}
import scala.beans.BeanProperty
object Exercise03 extends App {
println("Chapter 15 Exercise 03")
val annotated = new BeanAnnotated
annotated.setB("Hello")
println(annotated.b)
println(annotated.getB)
annotated.setA(3)
println(annotated.getA)
class BeanAnnotated {
@(deprecated @beanSetter)("Use scala setter instead", "1.1") @BeanProperty var a: Int = 0
@(elidable @beanGetter)(CONFIG) @BeanProperty var b: String = ""
}
}