diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-05 08:14:32 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-05 08:14:32 -0800 |
commit | 80e29e580cbfc93633e730f4a185b6efcd526568 (patch) | |
tree | 25208335d9b83be535aee883033991fcd9236357 | |
parent | 106539a52632e90fe3445e70c8f550d60af11af6 (diff) | |
parent | e3b7b5f9be5316fbf7c41599e377daceac4c26e8 (diff) | |
download | scala-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.
-rw-r--r-- | src/library/scala/collection/immutable/IntMap.scala | 3 |
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 |