diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-13 21:23:04 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-13 21:26:34 -0800 |
commit | 07ba1f8002b5f81bd3849ba38144efdabc8ef4a4 (patch) | |
tree | 6b923275bf605be045b83d15ef3da45c151e4a30 /src/library | |
parent | 39037798c94e6e862f39dacffc5e65bb08b78d6a (diff) | |
download | scala-07ba1f8002b5f81bd3849ba38144efdabc8ef4a4.tar.gz scala-07ba1f8002b5f81bd3849ba38144efdabc8ef4a4.tar.bz2 scala-07ba1f8002b5f81bd3849ba38144efdabc8ef4a4.zip |
SI-6642 Code cleanup from review of iteratorFrom
This commit is code cleanup from the review on
https://github.com/scala/scala/pull/2119
* Changes several instances of
def f[A, ]… to
def f[A]…
* Changes several instances of
def f[A](…)(implicit ordering : Ordering[A])… to
def f[A: Ordering](…)…
* Changes one instance of
x == null to
x eq null
* Changes two instances of
id + bottomid to
bottomid + id
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Enumeration.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/RedBlackTree.scala | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index e7ce21b229..d522539e83 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -254,8 +254,8 @@ abstract class Enumeration (initial: Int) extends Serializable { def contains(v: Value) = nnIds contains (v.id - bottomId) def + (value: Value) = new ValueSet(nnIds + (value.id - bottomId)) def - (value: Value) = new ValueSet(nnIds - (value.id - bottomId)) - def iterator = nnIds.iterator map (id => thisenum.apply(id + bottomId)) - override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(id + bottomId)) + def iterator = nnIds.iterator map (id => thisenum.apply(bottomId + id)) + override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(bottomId + id)) override def stringPrefix = thisenum + ".ValueSet" /** Creates a bit mask for the zero-adjusted ids in this set as a * new array of longs */ diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index d8c69f026b..1cd0128c05 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -29,8 +29,8 @@ object RedBlackTree { def isEmpty(tree: Tree[_, _]): Boolean = tree eq null - def contains[A](tree: Tree[A, _], x: A)(implicit ordering: Ordering[A]): Boolean = lookup(tree, x) ne null - def get[A, B](tree: Tree[A, B], x: A)(implicit ordering: Ordering[A]): Option[B] = lookup(tree, x) match { + def contains[A: Ordering](tree: Tree[A, _], x: A): Boolean = lookup(tree, x) ne null + def get[A: Ordering, B](tree: Tree[A, B], x: A): Option[B] = lookup(tree, x) match { case null => None case tree => Some(tree.value) } @@ -48,7 +48,7 @@ object RedBlackTree { * Count all the nodes with keys greater than or equal to the lower bound and less than the upper bound. * The two bounds are optional. */ - def countInRange[A, _](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = + def countInRange[A](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int = if (tree eq null) 0 else (from, to) match { // with no bounds use this node's count @@ -63,8 +63,8 @@ object RedBlackTree { case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to) } - def update[A, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean)(implicit ordering: Ordering[A]): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) - def delete[A, B](tree: Tree[A, B], k: A)(implicit ordering: Ordering[A]): Tree[A, B] = blacken(del(tree, k)) + def update[A: Ordering, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean): Tree[A, B1] = blacken(upd(tree, k, v, overwrite)) + def delete[A: Ordering, B](tree: Tree[A, B], k: A): Tree[A, B] = blacken(del(tree, k)) def rangeImpl[A: Ordering, B](tree: Tree[A, B], from: Option[A], until: Option[A]): Tree[A, B] = (from, until) match { case (Some(from), Some(until)) => this.range(tree, from, until) case (Some(from), None) => this.from(tree, from) @@ -110,9 +110,9 @@ object RedBlackTree { if (tree.right ne null) _foreachKey(tree.right, f) } - def iterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[(A, B)] = new EntriesIterator(tree, start) - def keysIterator[A, _](tree: Tree[A, _], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[A] = new KeysIterator(tree, start) - def valuesIterator[A, B](tree: Tree[A, B], start: Option[A] = None)(implicit ordering: Ordering[A]): Iterator[B] = new ValuesIterator(tree, start) + def iterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[(A, B)] = new EntriesIterator(tree, start) + def keysIterator[A: Ordering](tree: Tree[A, _], start: Option[A] = None): Iterator[A] = new KeysIterator(tree, start) + def valuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[B] = new ValuesIterator(tree, start) @tailrec def nth[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = { @@ -510,7 +510,7 @@ object RedBlackTree { */ private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else { @tailrec def find(tree: Tree[A, B]): Tree[A, B] = - if (tree == null) popNext + if (tree eq null) popNext else find( if (ordering.lteq(key, tree.key)) goLeft(tree) else goRight(tree) @@ -526,15 +526,15 @@ object RedBlackTree { private[this] def goRight(tree: Tree[A, B]) = tree.right } - private[this] class EntriesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, (A, B)](tree, focus) { + private[this] class EntriesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, (A, B)](tree, focus) { override def nextResult(tree: Tree[A, B]) = (tree.key, tree.value) } - private[this] class KeysIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, A](tree, focus) { + private[this] class KeysIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, A](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.key } - private[this] class ValuesIterator[A, B](tree: Tree[A, B], focus: Option[A])(implicit ordering: Ordering[A]) extends TreeIterator[A, B, B](tree, focus) { + private[this] class ValuesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, B](tree, focus) { override def nextResult(tree: Tree[A, B]) = tree.value } } |