Skip to content

Commit

Permalink
Name boolean arguments in src/library.
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym authored and paulp committed Mar 5, 2013
1 parent a8d60a6 commit 9179c88
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/library/scala/Array.scala
Expand Up @@ -399,7 +399,7 @@ object Array extends FallbackArrayBuilding {
def range(start: Int, end: Int, step: Int): Array[Int] = {
if (step == 0) throw new IllegalArgumentException("zero step")
val b = newBuilder[Int]
b.sizeHint(immutable.Range.count(start, end, step, false))
b.sizeHint(immutable.Range.count(start, end, step, isInclusive = false))

var i = start
while (if (step < 0) end < i else i < end) {
Expand Down
10 changes: 5 additions & 5 deletions src/library/scala/collection/SeqLike.scala
Expand Up @@ -335,7 +335,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
if (from > l) -1
else if (tl < 1) clippedFrom
else if (l < tl) -1
else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, true)
else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, forward = true)
}
else {
var i = from
Expand Down Expand Up @@ -372,7 +372,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
if (end < 0) -1
else if (tl < 1) clippedL
else if (l < tl) -1
else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, false)
else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, forward = false)
}

/** Tests whether this $coll contains a given sequence as a slice.
Expand Down Expand Up @@ -778,7 +778,7 @@ object SeqLike {
case _ =>
// We had better not index into S directly!
val iter = S.iterator.drop(m0)
val Wopt = kmpOptimizeWord(W, n0, n1, true)
val Wopt = kmpOptimizeWord(W, n0, n1, forward = true)
val T = kmpJumpTable(Wopt, n1-n0)
val cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind
var largest = 0
Expand Down Expand Up @@ -851,7 +851,7 @@ object SeqLike {
else if (s1 - s0 < t1 - t0) -1 // Source is too short to find target
else {
// Nontrivial search
val ans = kmpSearch(source, s0, s1, target, t0, t1, true)
val ans = kmpSearch(source, s0, s1, target, t0, t1, forward = true)
if (ans < 0) ans else ans - math.min(slen, sourceOffset)
}
}
Expand Down Expand Up @@ -883,7 +883,7 @@ object SeqLike {
else if (fixed_s1 - s0 < t1 - t0) -1 // Source is too short to find target
else {
// Nontrivial search
val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, false)
val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, forward = false)
if (ans < 0) ans else ans - s0
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/library/scala/collection/concurrent/TrieMap.scala
Expand Up @@ -41,7 +41,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
@tailrec private def GCAS_Complete(m: MainNode[K, V], ct: TrieMap[K, V]): MainNode[K, V] = if (m eq null) null else {
// complete the GCAS
val prev = /*READ*/m.prev
val ctr = ct.readRoot(true)
val ctr = ct.readRoot(abort = true)

prev match {
case null =>
Expand Down Expand Up @@ -723,7 +723,7 @@ extends scala.collection.concurrent.Map[K, V]
private def RDCSS_ROOT(ov: INode[K, V], expectedmain: MainNode[K, V], nv: INode[K, V]): Boolean = {
val desc = RDCSS_Descriptor(ov, expectedmain, nv)
if (CAS_ROOT(ov, desc)) {
RDCSS_Complete(false)
RDCSS_Complete(abort = false)
/*READ*/desc.committed
} else false
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ private[collection] class TrieMapIterator[K, V](var level: Int, private var ct:
val (arr1, arr2) = stack(d).drop(stackpos(d) + 1).splitAt(rem / 2)
stack(d) = arr1
stackpos(d) = -1
val it = newIterator(level + 1, ct, false)
val it = newIterator(level + 1, ct, _mustInit = false)
it.stack(0) = arr2
it.stackpos(0) = -1
it.depth = 0
Expand Down
Expand Up @@ -216,7 +216,7 @@ extends GenericCompanion[CC] {

if (step == zero) throw new IllegalArgumentException("zero step")
val b = newBuilder[T]
b sizeHint immutable.NumericRange.count(start, end, step, false)
b sizeHint immutable.NumericRange.count(start, end, step, isInclusive = false)
var i = start
while (if (step < zero) end < i else i < end) {
b += i
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/collection/immutable/Range.scala
Expand Up @@ -332,7 +332,7 @@ object Range {
}
}
def count(start: Int, end: Int, step: Int): Int =
count(start, end, step, false)
count(start, end, step, isInclusive = false)

class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) {
// override def par = new ParRange(this)
Expand Down
34 changes: 17 additions & 17 deletions src/library/scala/collection/immutable/RedBlackTree.scala
Expand Up @@ -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
Expand All @@ -61,7 +61,7 @@ object RedBlackTree {
// right will all be greater than or equal to the lower bound. So 1 for this node plus
// count the subtrees by stripping off the bounds that we don't need any more
case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to)

}
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))
Expand Down Expand Up @@ -252,23 +252,23 @@ object RedBlackTree {
if (ordering.lt(tree.key, from)) return doFrom(tree.right, from)
val newLeft = doFrom(tree.left, from)
if (newLeft eq tree.left) tree
else if (newLeft eq null) upd(tree.right, tree.key, tree.value, false)
else if (newLeft eq null) upd(tree.right, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, tree.right)
}
private[this] def doTo[A, B](tree: Tree[A, B], to: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
if (tree eq null) return null
if (ordering.lt(to, tree.key)) return doTo(tree.left, to)
val newRight = doTo(tree.right, to)
if (newRight eq tree.right) tree
else if (newRight eq null) upd(tree.left, tree.key, tree.value, false)
else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doUntil[A, B](tree: Tree[A, B], until: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
if (tree eq null) return null
if (ordering.lteq(until, tree.key)) return doUntil(tree.left, until)
val newRight = doUntil(tree.right, until)
if (newRight eq tree.right) tree
else if (newRight eq null) upd(tree.left, tree.key, tree.value, false)
else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doRange[A, B](tree: Tree[A, B], from: A, until: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
Expand All @@ -278,8 +278,8 @@ object RedBlackTree {
val newLeft = doFrom(tree.left, from)
val newRight = doUntil(tree.right, until)
if ((newLeft eq tree.left) && (newRight eq tree.right)) tree
else if (newLeft eq null) upd(newRight, tree.key, tree.value, false)
else if (newRight eq null) upd(newLeft, tree.key, tree.value, false)
else if (newLeft eq null) upd(newRight, tree.key, tree.value, overwrite = false)
else if (newRight eq null) upd(newLeft, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, newRight)
}

Expand All @@ -290,7 +290,7 @@ object RedBlackTree {
if (n > count) return doDrop(tree.right, n - count - 1)
val newLeft = doDrop(tree.left, n)
if (newLeft eq tree.left) tree
else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, false)
else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, tree.right)
}
private[this] def doTake[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = {
Expand All @@ -300,7 +300,7 @@ object RedBlackTree {
if (n <= count) return doTake(tree.left, n)
val newRight = doTake(tree.right, n - count - 1)
if (newRight eq tree.right) tree
else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, false)
else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doSlice[A, B](tree: Tree[A, B], from: Int, until: Int): Tree[A, B] = {
Expand All @@ -311,8 +311,8 @@ object RedBlackTree {
val newLeft = doDrop(tree.left, from)
val newRight = doTake(tree.right, until - count - 1)
if ((newLeft eq tree.left) && (newRight eq tree.right)) tree
else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, false)
else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, false)
else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, overwrite = false)
else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, newRight)
}

Expand Down Expand Up @@ -501,28 +501,28 @@ object RedBlackTree {
}
private[this] var index = 0
private[this] var lookahead: Tree[A, B] = start map startFrom getOrElse findLeftMostOrPopOnEmpty(root)

/**
* Find the leftmost subtree whose key is equal to the given key, or if no such thing,
* Find the leftmost subtree whose key is equal to the given key, or if no such thing,
* the leftmost subtree with the key that would be "next" after it according
* to the ordering. Along the way build up the iterator's path stack so that "next"
* functionality works.
*/
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] =
@tailrec def find(tree: Tree[A, B]): Tree[A, B] =
if (tree eq null) popNext()
else find(
if (ordering.lteq(key, tree.key)) goLeft(tree)
else goRight(tree)
)
)
find(root)
}

private[this] def goLeft(tree: Tree[A, B]) = {
pushNext(tree)
tree.left
}

private[this] def goRight(tree: Tree[A, B]) = tree.right
}

Expand Down
4 changes: 2 additions & 2 deletions src/library/scala/collection/immutable/TreeMap.scala
Expand Up @@ -128,7 +128,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
* @param value the value to be associated with `key`
* @return a new $coll with the updated binding
*/
override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, true))
override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, overwrite = true))

/** Add a key/value pair to this map.
* @tparam B1 type of the value of the new binding, a supertype of `B`
Expand Down Expand Up @@ -168,7 +168,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
*/
def insert [B1 >: B](key: A, value: B1): TreeMap[A, B1] = {
assert(!RB.contains(tree, key))
new TreeMap(RB.update(tree, key, value, true))
new TreeMap(RB.update(tree, key, value, overwrite = true))
}

def - (key:A): TreeMap[A, B] =
Expand Down
4 changes: 2 additions & 2 deletions src/library/scala/collection/immutable/TreeSet.scala
Expand Up @@ -109,7 +109,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
* @param elem a new element to add.
* @return a new $coll containing `elem` and all the elements of this $coll.
*/
def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), false))
def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), overwrite = false))

/** A new `TreeSet` with the entry added is returned,
* assuming that elem is <em>not</em> in the TreeSet.
Expand All @@ -119,7 +119,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
*/
def insert(elem: A): TreeSet[A] = {
assert(!RB.contains(tree, elem))
newSet(RB.update(tree, elem, (), false))
newSet(RB.update(tree, elem, (), overwrite = false))
}

/** Creates a new `TreeSet` with the entry removed.
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/collection/mutable/FlatHashTable.scala
Expand Up @@ -230,7 +230,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
private def checkConsistent() {
for (i <- 0 until table.length)
if (table(i) != null && !containsElem(entryToElem(table(i))))
assert(false, i+" "+table(i)+" "+table.mkString)
assert(assertion = false, i+" "+table(i)+" "+table.mkString)
}


Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/collection/mutable/TreeSet.scala
Expand Up @@ -67,7 +67,7 @@ class TreeSet[A] private (treeRef: ObjectRef[RB.Tree[A, Null]], from: Option[A],
}

override def +=(elem: A): this.type = {
treeRef.elem = RB.update(treeRef.elem, elem, null, false)
treeRef.elem = RB.update(treeRef.elem, elem, null, overwrite = false)
this
}

Expand Down
Expand Up @@ -823,7 +823,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport })
} else setTaskSupport(seq.zip(that)(bf2seq(bf)), tasksupport)

def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, false)
def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, inclusive = false)

def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) {
val thatseq = that.asParSeq
Expand Down
Expand Up @@ -131,7 +131,7 @@ self =>

override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That]
override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That =
newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That]
newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That]
override def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[This, (U, S), That]): That =
newZippedAllTryParSeq(that, thisElem, thatElem).asInstanceOf[That]

Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/collection/parallel/ParSeqViewLike.scala
Expand Up @@ -147,7 +147,7 @@ self =>
override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = newMapped(f).asInstanceOf[That]
override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That]
override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That =
newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That]
newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That]
override def reverse: This = newReversed.asInstanceOf[This]
override def reverseMap[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = reverse.map(f)

Expand Down
Expand Up @@ -136,7 +136,7 @@ extends TrieMapIterator[K, V](lev, ct, mustInit)
}

def dup = {
val it = newIterator(0, ct, false)
val it = newIterator(0, ct, _mustInit = false)
dupTo(it)
it.iterated = this.iterated
it
Expand Down
4 changes: 2 additions & 2 deletions src/library/scala/sys/process/ProcessBuilder.scala
Expand Up @@ -305,10 +305,10 @@ object ProcessBuilder extends ProcessBuilderImpl {
protected def toSource: ProcessBuilder

/** Writes the output stream of this process to the given file. */
def #> (f: File): ProcessBuilder = toFile(f, false)
def #> (f: File): ProcessBuilder = toFile(f, append = false)

/** Appends the output stream of this process to the given file. */
def #>> (f: File): ProcessBuilder = toFile(f, true)
def #>> (f: File): ProcessBuilder = toFile(f, append = true)

/** Writes the output stream of this process to the given OutputStream. The
* argument is call-by-name, so the stream is recreated, written, and closed each
Expand Down
30 changes: 15 additions & 15 deletions src/library/scala/sys/process/ProcessBuilderImpl.scala
Expand Up @@ -69,7 +69,7 @@ private[process] trait ProcessBuilderImpl {
import io._

// spawn threads that process the input, output, and error streams using the functions defined in `io`
val inThread = Spawn(writeInput(process.getOutputStream), true)
val inThread = Spawn(writeInput(process.getOutputStream), daemon = true)
val outThread = Spawn(processOutput(process.getInputStream), daemonizeThreads)
val errorThread =
if (p.redirectErrorStream) Nil
Expand All @@ -93,26 +93,26 @@ private[process] trait ProcessBuilderImpl {
def #&&(other: ProcessBuilder): ProcessBuilder = new AndBuilder(this, other)
def ###(other: ProcessBuilder): ProcessBuilder = new SequenceBuilder(this, other)

def run(): Process = run(false)
def run(): Process = run(connectInput = false)
def run(connectInput: Boolean): Process = run(BasicIO.standard(connectInput))
def run(log: ProcessLogger): Process = run(log, false)
def run(log: ProcessLogger): Process = run(log, connectInput = false)
def run(log: ProcessLogger, connectInput: Boolean): Process = run(BasicIO(connectInput, log))

def !! = slurp(None, false)
def !!(log: ProcessLogger) = slurp(Some(log), false)
def !!< = slurp(None, true)
def !!<(log: ProcessLogger) = slurp(Some(log), true)
def !! = slurp(None, withIn = false)
def !!(log: ProcessLogger) = slurp(Some(log), withIn = false)
def !!< = slurp(None, withIn = true)
def !!<(log: ProcessLogger) = slurp(Some(log), withIn = true)

def lines: Stream[String] = lines(false, true, None)
def lines(log: ProcessLogger): Stream[String] = lines(false, true, Some(log))
def lines_! : Stream[String] = lines(false, false, None)
def lines_!(log: ProcessLogger): Stream[String] = lines(false, false, Some(log))
def lines: Stream[String] = lines(withInput = false, nonZeroException = true, None)
def lines(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = true, Some(log))
def lines_! : Stream[String] = lines(withInput = false, nonZeroException = false, None)
def lines_!(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = false, Some(log))

def ! = run(false).exitValue()
def ! = run(connectInput = false).exitValue()
def !(io: ProcessIO) = run(io).exitValue()
def !(log: ProcessLogger) = runBuffered(log, false)
def !< = run(true).exitValue()
def !<(log: ProcessLogger) = runBuffered(log, true)
def !(log: ProcessLogger) = runBuffered(log, connectInput = false)
def !< = run(connectInput = true).exitValue()
def !<(log: ProcessLogger) = runBuffered(log, connectInput = true)

/** Constructs a new builder which runs this command with all input/output threads marked
* as daemon threads. This allows the creation of a long running process while still
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/sys/process/ProcessImpl.scala
Expand Up @@ -17,7 +17,7 @@ private[process] trait ProcessImpl {

/** Runs provided code in a new Thread and returns the Thread instance. */
private[process] object Spawn {
def apply(f: => Unit): Thread = apply(f, false)
def apply(f: => Unit): Thread = apply(f, daemon = false)
def apply(f: => Unit, daemon: Boolean): Thread = {
val thread = new Thread() { override def run() = { f } }
thread.setDaemon(daemon)
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/xml/Attribute.scala
Expand Up @@ -94,7 +94,7 @@ abstract trait Attribute extends MetaData {

sb append key append '='
val sb2 = new StringBuilder()
Utility.sequenceToXML(value, TopScope, sb2, true)
Utility.sequenceToXML(value, TopScope, sb2, stripComments = true)
Utility.appendQuoted(sb2.toString, sb)
}
}

0 comments on commit 9179c88

Please sign in to comment.