• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala elidable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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")
} 
开发者ID:mmcoulombe,项目名称:poc-aad,代码行数:21,代码来源:SimpleLogger.scala


示例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")
} 
开发者ID:Sciss,项目名称:ImperfectReconstruction,代码行数:28,代码来源:package.scala


示例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")
} 
开发者ID:Sciss,项目名称:ImperfectHough,代码行数:35,代码来源:package.scala


示例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)
} 
开发者ID:kkrawiec,项目名称:swim,代码行数:61,代码来源:ExamplesCSV.scala


示例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 = ""
  }
} 
开发者ID:Kiryna,项目名称:Scala-for-the-Impatient,代码行数:24,代码来源:Exercise03.scala



注:本文中的scala.annotation.elidable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Consumer类代码示例发布时间:2022-05-23
下一篇:
Scala SecuredErrorHandler类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap