Created
March 26, 2014 15:21
-
-
Save mariuszklinger/9785861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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