Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Require firstKey and lastKey on IntMap to be tail recursive.

  • Loading branch information...
commit e3b7b5f9be5316fbf7c41599e377daceac4c26e8 1 parent 1e69a0b
@mt2309 mt2309 authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  src/library/scala/collection/immutable/IntMap.scala
View
3  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
Please sign in to comment.
Something went wrong with that request. Please try again.