Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/clike
File: scala.html
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
[500] Fix | Delete
val b = newBuilder
[501] Fix | Delete
if (until <= from) b.result
[502] Fix | Delete
else {
[503] Fix | Delete
b.sizeHintBounded(until - from, this)
[504] Fix | Delete
sliceInternal(from, until, b)
[505] Fix | Delete
}
[506] Fix | Delete
}
[507] Fix | Delete
[508] Fix | Delete
def takeWhile(p: A => Boolean): Repr = {
[509] Fix | Delete
val b = newBuilder
[510] Fix | Delete
breakable {
[511] Fix | Delete
for (x <- this) {
[512] Fix | Delete
if (!p(x)) break
[513] Fix | Delete
b += x
[514] Fix | Delete
}
[515] Fix | Delete
}
[516] Fix | Delete
b.result
[517] Fix | Delete
}
[518] Fix | Delete
[519] Fix | Delete
def dropWhile(p: A => Boolean): Repr = {
[520] Fix | Delete
val b = newBuilder
[521] Fix | Delete
var go = false
[522] Fix | Delete
for (x <- this) {
[523] Fix | Delete
if (!p(x)) go = true
[524] Fix | Delete
if (go) b += x
[525] Fix | Delete
}
[526] Fix | Delete
b.result
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
def span(p: A => Boolean): (Repr, Repr) = {
[530] Fix | Delete
val l, r = newBuilder
[531] Fix | Delete
var toLeft = true
[532] Fix | Delete
for (x <- this) {
[533] Fix | Delete
toLeft = toLeft && p(x)
[534] Fix | Delete
(if (toLeft) l else r) += x
[535] Fix | Delete
}
[536] Fix | Delete
(l.result, r.result)
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
def splitAt(n: Int): (Repr, Repr) = {
[540] Fix | Delete
val l, r = newBuilder
[541] Fix | Delete
l.sizeHintBounded(n, this)
[542] Fix | Delete
if (n >= 0) r.sizeHint(this, -n)
[543] Fix | Delete
var i = 0
[544] Fix | Delete
for (x <- this) {
[545] Fix | Delete
(if (i < n) l else r) += x
[546] Fix | Delete
i += 1
[547] Fix | Delete
}
[548] Fix | Delete
(l.result, r.result)
[549] Fix | Delete
}
[550] Fix | Delete
[551] Fix | Delete
/** Iterates over the tails of this $coll. The first value will be this
[552] Fix | Delete
* $coll and the final one will be an empty $coll, with the intervening
[553] Fix | Delete
* values the results of successive applications of `tail`.
[554] Fix | Delete
*
[555] Fix | Delete
* @return an iterator over all the tails of this $coll
[556] Fix | Delete
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
[557] Fix | Delete
*/
[558] Fix | Delete
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
[559] Fix | Delete
[560] Fix | Delete
/** Iterates over the inits of this $coll. The first value will be this
[561] Fix | Delete
* $coll and the final one will be an empty $coll, with the intervening
[562] Fix | Delete
* values the results of successive applications of `init`.
[563] Fix | Delete
*
[564] Fix | Delete
* @return an iterator over all the inits of this $coll
[565] Fix | Delete
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
[566] Fix | Delete
*/
[567] Fix | Delete
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
[568] Fix | Delete
[569] Fix | Delete
/** Copies elements of this $coll to an array.
[570] Fix | Delete
* Fills the given array `xs` with at most `len` elements of
[571] Fix | Delete
* this $coll, starting at position `start`.
[572] Fix | Delete
* Copying will stop once either the end of the current $coll is reached,
[573] Fix | Delete
* or the end of the array is reached, or `len` elements have been copied.
[574] Fix | Delete
*
[575] Fix | Delete
* $willNotTerminateInf
[576] Fix | Delete
*
[577] Fix | Delete
* @param xs the array to fill.
[578] Fix | Delete
* @param start the starting index.
[579] Fix | Delete
* @param len the maximal number of elements to copy.
[580] Fix | Delete
* @tparam B the type of the elements of the array.
[581] Fix | Delete
*
[582] Fix | Delete
*
[583] Fix | Delete
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
[584] Fix | Delete
*/
[585] Fix | Delete
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
[586] Fix | Delete
var i = start
[587] Fix | Delete
val end = (start + len) min xs.length
[588] Fix | Delete
breakable {
[589] Fix | Delete
for (x <- this) {
[590] Fix | Delete
if (i >= end) break
[591] Fix | Delete
xs(i) = x
[592] Fix | Delete
i += 1
[593] Fix | Delete
}
[594] Fix | Delete
}
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
def toTraversable: Traversable[A] = thisCollection
[598] Fix | Delete
def toIterator: Iterator[A] = toStream.iterator
[599] Fix | Delete
def toStream: Stream[A] = toBuffer.toStream
[600] Fix | Delete
[601] Fix | Delete
/** Converts this $coll to a string.
[602] Fix | Delete
*
[603] Fix | Delete
* @return a string representation of this collection. By default this
[604] Fix | Delete
* string consists of the `stringPrefix` of this $coll,
[605] Fix | Delete
* followed by all elements separated by commas and enclosed in parentheses.
[606] Fix | Delete
*/
[607] Fix | Delete
override def toString = mkString(stringPrefix + "(", ", ", ")")
[608] Fix | Delete
[609] Fix | Delete
/** Defines the prefix of this object's `toString` representation.
[610] Fix | Delete
*
[611] Fix | Delete
* @return a string representation which starts the result of `toString`
[612] Fix | Delete
* applied to this $coll. By default the string prefix is the
[613] Fix | Delete
* simple name of the collection class $coll.
[614] Fix | Delete
*/
[615] Fix | Delete
def stringPrefix : String = {
[616] Fix | Delete
var string = repr.asInstanceOf[AnyRef].getClass.getName
[617] Fix | Delete
val idx1 = string.lastIndexOf('.' : Int)
[618] Fix | Delete
if (idx1 != -1) string = string.substring(idx1 + 1)
[619] Fix | Delete
val idx2 = string.indexOf('$')
[620] Fix | Delete
if (idx2 != -1) string = string.substring(0, idx2)
[621] Fix | Delete
string
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
/** Creates a non-strict view of this $coll.
[625] Fix | Delete
*
[626] Fix | Delete
* @return a non-strict view of this $coll.
[627] Fix | Delete
*/
[628] Fix | Delete
def view = new TraversableView[A, Repr] {
[629] Fix | Delete
protected lazy val underlying = self.repr
[630] Fix | Delete
override def foreach[U](f: A => U) = self foreach f
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
/** Creates a non-strict view of a slice of this $coll.
[634] Fix | Delete
*
[635] Fix | Delete
* Note: the difference between `view` and `slice` is that `view` produces
[636] Fix | Delete
* a view of the current $coll, whereas `slice` produces a new $coll.
[637] Fix | Delete
*
[638] Fix | Delete
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
[639] Fix | Delete
* $orderDependent
[640] Fix | Delete
*
[641] Fix | Delete
* @param from the index of the first element of the view
[642] Fix | Delete
* @param until the index of the element following the view
[643] Fix | Delete
* @return a non-strict view of a slice of this $coll, starting at index `from`
[644] Fix | Delete
* and extending up to (but not including) index `until`.
[645] Fix | Delete
*/
[646] Fix | Delete
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
[647] Fix | Delete
[648] Fix | Delete
/** Creates a non-strict filter of this $coll.
[649] Fix | Delete
*
[650] Fix | Delete
* Note: the difference between `c filter p` and `c withFilter p` is that
[651] Fix | Delete
* the former creates a new collection, whereas the latter only
[652] Fix | Delete
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
[653] Fix | Delete
* and `withFilter` operations.
[654] Fix | Delete
* $orderDependent
[655] Fix | Delete
*
[656] Fix | Delete
* @param p the predicate used to test elements.
[657] Fix | Delete
* @return an object of class `WithFilter`, which supports
[658] Fix | Delete
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
[659] Fix | Delete
* All these operations apply to those elements of this $coll which
[660] Fix | Delete
* satisfy the predicate `p`.
[661] Fix | Delete
*/
[662] Fix | Delete
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
[663] Fix | Delete
[664] Fix | Delete
/** A class supporting filtered operations. Instances of this class are
[665] Fix | Delete
* returned by method `withFilter`.
[666] Fix | Delete
*/
[667] Fix | Delete
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
[668] Fix | Delete
[669] Fix | Delete
/** Builds a new collection by applying a function to all elements of the
[670] Fix | Delete
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
[671] Fix | Delete
*
[672] Fix | Delete
* @param f the function to apply to each element.
[673] Fix | Delete
* @tparam B the element type of the returned collection.
[674] Fix | Delete
* @tparam That $thatinfo
[675] Fix | Delete
* @param bf $bfinfo
[676] Fix | Delete
* @return a new collection of type `That` resulting from applying
[677] Fix | Delete
* the given function `f` to each element of the outer $coll
[678] Fix | Delete
* that satisfies predicate `p` and collecting the results.
[679] Fix | Delete
*
[680] Fix | Delete
* @usecase def map[B](f: A => B): $Coll[B]
[681] Fix | Delete
*
[682] Fix | Delete
* @return a new $coll resulting from applying the given function
[683] Fix | Delete
* `f` to each element of the outer $coll that satisfies
[684] Fix | Delete
* predicate `p` and collecting the results.
[685] Fix | Delete
*/
[686] Fix | Delete
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
[687] Fix | Delete
val b = bf(repr)
[688] Fix | Delete
for (x <- self)
[689] Fix | Delete
if (p(x)) b += f(x)
[690] Fix | Delete
b.result
[691] Fix | Delete
}
[692] Fix | Delete
[693] Fix | Delete
/** Builds a new collection by applying a function to all elements of the
[694] Fix | Delete
* outer $coll containing this `WithFilter` instance that satisfy
[695] Fix | Delete
* predicate `p` and concatenating the results.
[696] Fix | Delete
*
[697] Fix | Delete
* @param f the function to apply to each element.
[698] Fix | Delete
* @tparam B the element type of the returned collection.
[699] Fix | Delete
* @tparam That $thatinfo
[700] Fix | Delete
* @param bf $bfinfo
[701] Fix | Delete
* @return a new collection of type `That` resulting from applying
[702] Fix | Delete
* the given collection-valued function `f` to each element
[703] Fix | Delete
* of the outer $coll that satisfies predicate `p` and
[704] Fix | Delete
* concatenating the results.
[705] Fix | Delete
*
[706] Fix | Delete
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
[707] Fix | Delete
*
[708] Fix | Delete
* @return a new $coll resulting from applying the given collection-valued function
[709] Fix | Delete
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
[710] Fix | Delete
*/
[711] Fix | Delete
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
[712] Fix | Delete
val b = bf(repr)
[713] Fix | Delete
for (x <- self)
[714] Fix | Delete
if (p(x)) b ++= f(x).seq
[715] Fix | Delete
b.result
[716] Fix | Delete
}
[717] Fix | Delete
[718] Fix | Delete
/** Applies a function `f` to all elements of the outer $coll containing
[719] Fix | Delete
* this `WithFilter` instance that satisfy predicate `p`.
[720] Fix | Delete
*
[721] Fix | Delete
* @param f the function that is applied for its side-effect to every element.
[722] Fix | Delete
* The result of function `f` is discarded.
[723] Fix | Delete
*
[724] Fix | Delete
* @tparam U the type parameter describing the result of function `f`.
[725] Fix | Delete
* This result will always be ignored. Typically `U` is `Unit`,
[726] Fix | Delete
* but this is not necessary.
[727] Fix | Delete
*
[728] Fix | Delete
* @usecase def foreach(f: A => Unit): Unit
[729] Fix | Delete
*/
[730] Fix | Delete
def foreach[U](f: A => U): Unit =
[731] Fix | Delete
for (x <- self)
[732] Fix | Delete
if (p(x)) f(x)
[733] Fix | Delete
[734] Fix | Delete
/** Further refines the filter for this $coll.
[735] Fix | Delete
*
[736] Fix | Delete
* @param q the predicate used to test elements.
[737] Fix | Delete
* @return an object of class `WithFilter`, which supports
[738] Fix | Delete
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
[739] Fix | Delete
* All these operations apply to those elements of this $coll which
[740] Fix | Delete
* satisfy the predicate `q` in addition to the predicate `p`.
[741] Fix | Delete
*/
[742] Fix | Delete
def withFilter(q: A => Boolean): WithFilter =
[743] Fix | Delete
new WithFilter(x => p(x) && q(x))
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
// A helper for tails and inits.
[747] Fix | Delete
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
[748] Fix | Delete
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
[749] Fix | Delete
it ++ Iterator(Nil) map (newBuilder ++= _ result)
[750] Fix | Delete
}
[751] Fix | Delete
}
[752] Fix | Delete
[753] Fix | Delete
[754] Fix | Delete
</textarea>
[755] Fix | Delete
</form>
[756] Fix | Delete
[757] Fix | Delete
<script>
[758] Fix | Delete
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
[759] Fix | Delete
lineNumbers: true,
[760] Fix | Delete
matchBrackets: true,
[761] Fix | Delete
theme: "ambiance",
[762] Fix | Delete
mode: "text/x-scala"
[763] Fix | Delete
});
[764] Fix | Delete
</script>
[765] Fix | Delete
</article>
[766] Fix | Delete
[767] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function