Skip to content

Instantly share code, notes, and snippets.

@mariuszklinger
Created March 26, 2014 15:21
Show Gist options
  • Save mariuszklinger/9785861 to your computer and use it in GitHub Desktop.
Save mariuszklinger/9785861 to your computer and use it in GitHub Desktop.
import scala.collection.mutable.PriorityQueue
import scala.math.Ordering._
import scala.util.Sorting
import Implicits._
class MyType{
}
object Implicits {
//implicit objects can't be top-level ones
implicit object MyTypeQueOrdering extends Ordering[MyType] {
def compare(n1: MyType, n2: MyType) = -1
}
}
class MyTypeQue extends PriorityQueue[MyType]{
}
object Main {
def main(args: Array[String]) = {
val q = new MyTypeQue
q += new MyType
q += new MyType
q += new MyType
println(q.length)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment