summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/IntMap.scala
diff options
context:
space:
mode:
authorDavid MacIver <david.maciver@gmail.com>2008-10-27 15:24:43 +0000
committerDavid MacIver <david.maciver@gmail.com>2008-10-27 15:24:43 +0000
commitcc97afe49feb585819abf0b5ae6fc25c34e349df (patch)
treea3d45670f0bcfd4ba95cf93d27a055a9a408f740 /src/library/scala/collection/immutable/IntMap.scala
parentea3a4fe4c8db32d2dc16d1ff442081d4d76ca97f (diff)
downloadscala-cc97afe49feb585819abf0b5ae6fc25c34e349df.tar.gz
scala-cc97afe49feb585819abf0b5ae6fc25c34e349df.tar.bz2
scala-cc97afe49feb585819abf0b5ae6fc25c34e349df.zip
Added firstKey and lastKey to IntMap.
Diffstat (limited to 'src/library/scala/collection/immutable/IntMap.scala')
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index c7ebab3f65..33bbccfb96 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -369,5 +369,24 @@ sealed abstract class IntMap[+T] extends scala.collection.immutable.Map[Int, T]{
case (that : IntMap[_]) => this.unionWith[S](that.asInstanceOf[IntMap[S]], (key, x, y) => y);
case that => that.foldLeft(this : IntMap[S])({case (m, (x, y)) => m.update(x, y)});
}
+
+
+ /**
+ * The entry with the lowest key value considered in unsigned order.
+ */
+ final def firstKey : Int = this match {
+ case Bin(_, _, l, r) => l.firstKey;
+ case Tip(k, v) => k;
+ case Nil => error("Empty set")
+ }
+
+ /**
+ * The entry with the highest key value considered in unsigned order.
+ */
+ final def lastKey : Int = this match {
+ case Bin(_, _, l, r) => r.lastKey;
+ case Tip(k, v) => k;
+ case Nil => error("Empty set")
+ }
}