本文整理汇总了Scala中scala.collection.SortedSet类的典型用法代码示例。如果您正苦于以下问题:Scala SortedSet类的具体用法?Scala SortedSet怎么用?Scala SortedSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SortedSet类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: ResultReader
//设置package包名称以及导入依赖的类
package org.perftester.results
import ammonite.ops.{Path, read}
import org.perftester.TestConfig
import scala.collection.SortedSet
object ResultReader {
private val totalOrSingle = Set(ResultType.SINGLE.toString,ResultType.TOTAL.toString)
def readResults(testConfig: TestConfig, file : Path, iterations:Int): RunResult = {
val lines = read.lines! file
val asValues = lines.map(_.split(',').toList)
val dataLines = asValues.filter( value =>
value(0) == "data" && totalOrSingle(value(4)) )
val rows = dataLines.map { row =>
PhaseResults(
// data,
row(1).toInt, // iteration id
row(2).toInt, // phaseId
row(3), // phaseName
ResultType.withName(row(4)), // type
row(5).toInt, // id
row(6), // comment
row(7).toDouble, // wallClockTimeMs,
row(8).toDouble, // idleTimeMs,
row(9).toDouble, // cpuTimeMs,
row(10).toDouble, // userTimeMS
row(11).toDouble, // allocatedMB
row(12).toDouble, // retainedMB
row(13).toDouble// gcTimeMs
)
}
val alIterations = SortedSet((1 to iterations).toList :_*)
val phases = rows.groupBy(_.phaseName).keySet
RunResult(testConfig,rows, alIterations, phases)
}
}
开发者ID:rorygraves,项目名称:perf_tester,代码行数:41,代码来源:ResultReader.scala
示例2: SysMLTokens
//设置package包名称以及导入依赖的类
package specific.sysml.parser
import de.dfki.cps.specific.ocl.parser.OclTokens
import scala.collection.SortedSet
import scala.util.parsing.combinator.token.Tokens
import scala.util.parsing.input.Positional
object SysMLTokens {
type Token = OclTokens.Token
type Delimiter = OclTokens.Delimiter
case class SysmlComment(chars: String) extends Token with Positional
sealed trait Indentation extends Token { val n: Int; val chars = "" }
object Indentation {
case object None extends Indentation { val n = 0 }
case class Tabs(n: Int) extends Indentation {
override def toString = s"$n tabs"
}
case class Spaces(n: Int) extends Indentation {
override def toString = s"$n spaces"
}
}
sealed trait IndentationToken extends Token { val chars = "" }
case object SEPARATOR extends IndentationToken {
override def toString = "end of line"
}
case object INDENT extends IndentationToken {
override def toString = "start of indented block"
}
case object DEDENT extends IndentationToken {
override def toString = "end of indented block"
}
case class UNMATCHED_DEDENT(indentation: Indentation) extends IndentationToken {
override def toString = s"unmatched dedentation (no previous line was indented with $indentation)"
}
case class INCONSISTENT_INDENTATION(before: Indentation, now: Indentation) extends IndentationToken {
override def toString = s"inconsistent indentation (started with $before and continued with $now)"
}
case class MIXED_INDENTATION(start: Indentation) extends IndentationToken {
override def toString = start match {
case Indentation.Spaces(n) => s"mixed indentation characters in one line (tab afer $n spaces)"
case Indentation.Tabs(n) => s"mixed indentation characters in one line (space afer $n tabs)"
case Indentation.None => sys.error("invalid indentation state")
}
}
val delimiters = OclTokens.delimiters ++ SortedSet[Delimiter](
ELIPSIS, HASH, LEFT_ARROW, TILDE
) (Ordering.by[Delimiter,(Int,String)](k => (k.chars.length, k.chars)).reverse)
case object ELIPSIS extends Delimiter("..")
case object HASH extends Delimiter("#")
case object LEFT_ARROW extends Delimiter("<-")
case object TILDE extends Delimiter("~")
}
开发者ID:DFKI-CPS,项目名称:specific-sysml,代码行数:61,代码来源:SysMLTokens.scala
示例3: BridgePlayer
//设置package包名称以及导入依赖的类
package com.growse.bridgetree
import com.growse.bridgetree.Player.Player
import com.growse.bridgetree.Suit.Suit
import com.typesafe.scalalogging.LazyLogging
import scala.collection.parallel.mutable.ParMap
import scala.collection.{SortedSet, mutable}
class BridgePlayer(cards: mutable.LinkedHashSet[Card], trumpSuit: Suit = null) extends LazyLogging {
if (cards == null) {
throw new IllegalArgumentException("Deck should not be null")
}
val cardsPerHand = cards.size / Player.values.size
val rootTrieNode: BridgeTrieNode = new BridgeTrieNode()
def PlayCard(hands: mutable.Map[Player, SortedSet[Card]], playerToPlay: Player, recursionLevel: Int, parentTrieNode: BridgeTrieNode): Unit = {
val actualPlayerToPlay = parentTrieNode.getNextPlayer
// Work out if were starting a new trick and if so, who won the last one.
if (parentTrieNode.getLastTrick.isDefined && parentTrieNode.getThisUnfinishedTrick.isEmpty) {
logger.debug(s"Looks like Player $actualPlayerToPlay won the last trick: ${parentTrieNode.getLastTrick.get}")
}
if (hands(actualPlayerToPlay).nonEmpty) {
hands(actualPlayerToPlay).foreach(card => {
logger.debug(s"Seeing if player $actualPlayerToPlay can play $card ($recursionLevel)")
if (
parentTrieNode.cardNumberPlayed % 4 == 0 // We're the first to play this trick
|| !hands(actualPlayerToPlay).exists(card => card.suit == parentTrieNode.getThisUnfinishedTrick.get.head.card.get.suit) // We can't follow suit
|| parentTrieNode.getThisUnfinishedTrick.get.head.card.get.suit == card.suit // We can follow suit, and this card follows suit
) {
//Play the card
logger.debug(s"Player $actualPlayerToPlay plays $card")
val newHands = hands.clone()
newHands(actualPlayerToPlay) = hands(actualPlayerToPlay).-(card)
val trieNode = new BridgeTrieNode(trumpSuit, Some(card), Some(parentTrieNode), Some(actualPlayerToPlay))
parentTrieNode.children.+=(trieNode)
PlayCard(newHands, Player.NextPlayer(actualPlayerToPlay), recursionLevel + 1, trieNode)
} else {
logger.debug(s"Player $actualPlayerToPlay cannot play $card")
}
})
} else {
assert(parentTrieNode.getPlayOrder.size == cardsPerHand * Player.values.size)
logger.debug(s"Final PlaySeq: ${parentTrieNode.toString}. NS won ${parentTrieNode.getNSTricksWon}")
}
}
}
开发者ID:growse,项目名称:BridgeTree,代码行数:53,代码来源:BridgePlayer.scala
示例4: DispatcherMessage
//设置package包名称以及导入依赖的类
package com.gilazaria.subsearch.core.subdomainscanner
import akka.actor.ActorRef
import com.gilazaria.subsearch.model.Record
import scala.collection.SortedSet
import scala.util.Try
trait Message
object DispatcherMessage extends Message {
case object ResumeScanning
case object PauseScanning
case object NotifyOnCompletion
case object AvailableForScan
case class PriorityScanSubdomain(subdomain: String)
case class CompletedScan(subdomain: String, resolver: String)
case class FailedScan(subdomain: String, resolver: String)
}
object ScannerMessage extends Message {
case object ScanAvailable
case class Scan(subdomain: String, resolver: String, attempt: Int)
case class ScanComplete(records: Try[SortedSet[Record]], subdomain: String, resolver: String)
case class ScanFailed(cause: Throwable, subdomain: String, resolver: String, attempt: Int)
}
object ListenerMessage extends Message {
case object PausingScanning
case object ResumedScanning
case object NotEnoughResolvers
case class FoundSubdomain(subdomain: String, records: SortedSet[Record])
case class LastScan(subdomain: String, requestsSoFar: Int, totalRequests: Int)
case class TaskCompleted(master: Option[ActorRef])
case class TaskFailed(master: Option[ActorRef])
case class ScanTimeout(subdomain: String, resolver: String, attempt: Int)
case class BlacklistedResolver(resolver: String)
}
开发者ID:gavia,项目名称:subsearch,代码行数:42,代码来源:Message.scala
示例5: AuthoritativeScanner
//设置package包名称以及导入依赖的类
package com.gilazaria.subsearch.core
import com.gilazaria.subsearch.output.Logger
import com.gilazaria.subsearch.connection.{DNSLookupImpl, DNSLookup}
import com.gilazaria.subsearch.model.{Record, RecordType}
import scala.concurrent.{ExecutionContext, Future}
import scala.collection.SortedSet
class AuthoritativeScanner private[core] (private val logger: Logger, private val lookup: DNSLookup)(implicit ec: ExecutionContext) {
def performLookupOnHostname(hostname: String, resolver: String): Future[Set[String]] = {
logger.logAuthoritativeScanStarted()
dataFromQuery(hostname, resolver, RecordType.NS)
.flatMap(nameservers => ipsForNameServers(nameservers, resolver))
.map(printAuthoritativeNameServers)
}
private[core] def ipsForNameServers(nameServers: Set[String], resolver: String): Future[Set[String]] = {
Future
.sequence(nameServers.map(ns => dataFromQuery(ns, resolver, RecordType.A)))
.map(_.flatten)
}
private[core] def dataFromQuery(hostname: String, resolver: String, recordType: RecordType): Future[Set[String]] = {
Future {
lookup
.performQueryOfType(hostname, resolver, recordType)
.getOrElse(SortedSet.empty[Record])
.map(_.data)
.toSet
}
}
private[core] def printAuthoritativeNameServers(nameServers: Set[String]) = {
nameServers.foreach(logger.logAuthoritativeNameServer)
logger.logAuthoritativeScanCompleted()
nameServers
}
}
object AuthoritativeScanner {
def create(logger: Logger)(implicit ec: ExecutionContext): AuthoritativeScanner =
new AuthoritativeScanner(logger, DNSLookupImpl.create())
}
开发者ID:gavia,项目名称:subsearch,代码行数:46,代码来源:AuthoritativeScanner.scala
注:本文中的scala.collection.SortedSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论