diff options
author | Michael Thorpe <mt2309@ic.ac.uk> | 2013-03-01 13:58:05 +0000 |
---|---|---|
committer | Michael Thorpe <mt2309@ic.ac.uk> | 2013-03-02 14:05:32 +0000 |
commit | e3b7b5f9be5316fbf7c41599e377daceac4c26e8 (patch) | |
tree | f296d3abe12fca66293a25e97d701cb83269b789 /src/library/scala/collection/immutable/IntMap.scala | |
parent | 1e69a0b67a184ca9d0b205a407e34cf85d11372c (diff) | |
download | scala-e3b7b5f9be5316fbf7c41599e377daceac4c26e8.tar.gz scala-e3b7b5f9be5316fbf7c41599e377daceac4c26e8.tar.bz2 scala-e3b7b5f9be5316fbf7c41599e377daceac4c26e8.zip |
Require firstKey and lastKey on IntMap to be tail recursive.
Diffstat (limited to 'src/library/scala/collection/immutable/IntMap.scala')
-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 ab1faf363e..457d46a0eb 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 @@ -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 |