Permalink
Browse files

Require firstKey and lastKey on IntMap to be tail recursive.

  • Loading branch information...
1 parent 1e69a0b commit e3b7b5f9be5316fbf7c41599e377daceac4c26e8 @mt2309 mt2309 committed Mar 1, 2013
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/library/scala/collection/immutable/IntMap.scala
@@ -12,6 +12,7 @@ package immutable
import scala.collection.generic.{ CanBuildFrom, BitOperations }
import scala.collection.mutable.{ Builder, MapBuilder }
+import scala.annotation.tailrec
/** Utility class for integer maps.
* @author David MacIver
@@ -427,6 +428,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
/**
* The entry with the lowest key value considered in unsigned order.
*/
+ @tailrec
final def firstKey: Int = this match {
case Bin(_, _, l, r) => l.firstKey
case Tip(k, v) => k
@@ -436,6 +438,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
/**
* The entry with the highest key value considered in unsigned order.
*/
+ @tailrec
final def lastKey: Int = this match {
case Bin(_, _, l, r) => r.lastKey
case Tip(k, v) => k

0 comments on commit e3b7b5f

Please sign in to comment.