summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-03-05 08:14:32 -0800
committerPaul Phillips <paulp@improving.org>2013-03-05 08:14:32 -0800
commit80e29e580cbfc93633e730f4a185b6efcd526568 (patch)
tree25208335d9b83be535aee883033991fcd9236357 /src/library
parent106539a52632e90fe3445e70c8f550d60af11af6 (diff)
parente3b7b5f9be5316fbf7c41599e377daceac4c26e8 (diff)
downloadscala-80e29e580cbfc93633e730f4a185b6efcd526568.tar.gz
scala-80e29e580cbfc93633e730f4a185b6efcd526568.tar.bz2
scala-80e29e580cbfc93633e730f4a185b6efcd526568.zip
Merge pull request #2183 from mt2309/tailrec-intmap
Require firstKey and lastKey on IntMap tail-recursive.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index 83356b4932..07e2ddaae2 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/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
@@ -429,6 +430,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
@@ -438,6 +440,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