本文整理汇总了Scala中java.util.LinkedList类的典型用法代码示例。如果您正苦于以下问题:Scala LinkedList类的具体用法?Scala LinkedList怎么用?Scala LinkedList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkedList类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Macrowave
//设置package包名称以及导入依赖的类
package com.github.zenpie.macrowave.internal
import java.util.LinkedList
import com.github.zenpie.macrowave.internal.scanner.FiniteAutomaton
import com.github.zenpie.macrowave.internal.parser.{RuleValidation, SetComputation, SymbolString}
import scala.reflect.macros.whitebox
class Macrowave(val c: whitebox.Context) extends AnyRef
with MacroUtils
with scanner.RuleParser
with parser.RuleParser {
import c.universe._
def transformGrammars(annottees: Tree*): c.Tree = {
val typedAnnottees = annottees map (c.typecheck(_, silent = false))
val grammars = typedAnnottees map {
case tree @ q"""$mods class $cname(...$ctors) extends $superclasses { ..$stms }""" =>
val grammar = new Grammar(c)
val stmList = new LinkedList[Tree]()
stms.foreach(stm => stmList.add(stm))
scannerRulesFromStatements(grammar, stmList)
parserRulesFromStatements(grammar, stmList)
RuleValidation.validateParserRules(grammar)
val dfa = FiniteAutomaton.generate(grammar)
SymbolString.fromGrammar(grammar)
SetComputation.calculateFirstAndFollowSets(grammar)
q"""$mods class $cname(...$ctors) extends $superclasses {}"""
case x =>
c.abort(x.pos, "Element annotated with 'grammar' is no Grammar!")
}
q"{..$grammars}"
}
}
开发者ID:zen-pie,项目名称:macrowave,代码行数:43,代码来源:Macrowave.scala
示例2: LinkedListOps
//设置package包名称以及导入依赖的类
package com.github.zenpie.macrowave
import java.util.LinkedList
package object internal {
private[internal] implicit class LinkedListOps[T](list: LinkedList[T]) {
def popsome(pf: PartialFunction[T, Unit]): Unit = {
val iter = list.iterator()
while (iter.hasNext) iter.next() match {
case elem if pf isDefinedAt elem =>
pf(elem)
iter.remove()
case _ =>
()
}
}
def forsome(pf: PartialFunction[T, Unit]): Unit = {
val iter = list.iterator()
while (iter.hasNext) iter.next() match {
case elem if pf isDefinedAt elem =>
pf(elem)
case _ =>
()
}
}
}
}
开发者ID:zen-pie,项目名称:macrowave,代码行数:33,代码来源:package.scala
注:本文中的java.util.LinkedList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论