本文整理汇总了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}"
}
}
示例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 _ =>
()
}
}
}
}