<!doctype html>
<title>CodeMirror: Scala mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../theme/ambiance.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Scala</a>
</ul>
</div>
<article>
<h2>Scala mode</h2>
<form>
<textarea id="code" name="code">
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.collection
import generic._
import mutable.{ Builder, ListBuffer }
import annotation.{tailrec, migration, bridge}
import annotation.unchecked.{ uncheckedVariance => uV }
import parallel.ParIterable
/** A template trait for traversable collections of type `Traversable[A]`.
*
* $traversableInfo
* @define mutability
* @define traversableInfo
* This is a base trait of all kinds of $mutability Scala collections. It
* implements the behavior common to all collections, in terms of a method
* `foreach` with signature:
* {{{
* def foreach[U](f: Elem => U): Unit
* }}}
* Collection classes mixing in this trait provide a concrete
* `foreach` method which traverses all the
* elements contained in the collection, applying a given function to each.
* They also need to provide a method `newBuilder`
* which creates a builder for collections of the same kind.
*
* A traversable class might or might not have two properties: strictness
* and orderedness. Neither is represented as a type.
*
* The instances of a strict collection class have all their elements
* computed before they can be used as values. By contrast, instances of
* a non-strict collection class may defer computation of some of their
* elements until after the instance is available as a value.
* A typical example of a non-strict collection class is a
* <a href="../immutable/Stream.html" target="ContentFrame">
* `scala.collection.immutable.Stream`</a>.
* A more general class of examples are `TraversableViews`.
*
* If a collection is an instance of an ordered collection class, traversing
* its elements with `foreach` will always visit elements in the
* same order, even for different runs of the program. If the class is not
* ordered, `foreach` can visit elements in different orders for
* different runs (but it will keep the same order in the same run).'
*
* A typical example of a collection class which is not ordered is a
* `HashMap` of objects. The traversal order for hash maps will
* depend on the hash codes of its elements, and these hash codes might
* differ from one run to the next. By contrast, a `LinkedHashMap`
* is ordered because it's `foreach` method visits elements in the
* order they were inserted into the `HashMap`.
*
* @author Martin Odersky
* @version 2.8
* @since 2.8
* @tparam A the element type of the collection
* @tparam Repr the type of the actual collection containing the elements.
*
* @define Coll Traversable
* @define coll traversable collection
*/
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
with FilterMonadic[A, Repr]
with TraversableOnce[A]
with GenTraversableLike[A, Repr]
with Parallelizable[A, ParIterable[A]]
{
self =>
import Traversable.breaks._
/** The type implementing this traversable */
protected type Self = Repr
/** The collection of type $coll underlying this `TraversableLike` object.
* By default this is implemented as the `TraversableLike` object itself,
* but this can be overridden.
*/
def repr: Repr = this.asInstanceOf[Repr]
/** The underlying collection seen as an instance of `$Coll`.
* By default this is implemented as the current collection object itself,
* but this can be overridden.
*/
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
/** A conversion from collections of type `Repr` to `$Coll` objects.
* By default this is implemented as just a cast, but this can be overridden.
*/
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
/** Creates a new builder for this collection type.
*/
protected[this] def newBuilder: Builder[A, Repr]
protected[this] def parCombiner = ParIterable.newCombiner[A]
/** Applies a function `f` to all elements of this $coll.
*
* Note: this method underlies the implementation of most other bulk operations.
* It's important to implement this method in an efficient way.
*
*
* @param f the function that is applied for its side-effect to every element.
* The result of function `f` is discarded.
*
* @tparam U the type parameter describing the result of function `f`.
* This result will always be ignored. Typically `U` is `Unit`,
* but this is not necessary.
*
* @usecase def foreach(f: A => Unit): Unit
*/
def foreach[U](f: A => U): Unit
/** Tests whether this $coll is empty.
*
* @return `true` if the $coll contain no elements, `false` otherwise.
*/
def isEmpty: Boolean = {
var result = true
breakable {
for (x <- this) {
result = false
break
}
}
result
}
/** Tests whether this $coll is known to have a finite size.
* All strict collections are known to have finite size. For a non-strict collection
* such as `Stream`, the predicate returns `true` if all elements have been computed.
* It returns `false` if the stream is not yet evaluated to the end.
*
* Note: many collection methods will not work on collections of infinite sizes.
*
* @return `true` if this collection is known to have finite size, `false` otherwise.
*/
def hasDefiniteSize = true
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
b ++= thisCollection
b ++= that.seq
b.result
}
@bridge
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
++(that: GenTraversableOnce[B])(bf)
/** Concatenates this $coll with the elements of a traversable collection.
* It differs from ++ in that the right operand determines the type of the
* resulting collection rather than the left one.
*
* @param that the traversable to append.
* @tparam B the element type of the returned collection.
* @tparam That $thatinfo
* @param bf $bfinfo
* @return a new collection of type `That` which con
.whl
- 粉丝: 3958
- 资源: 4904
最新资源
- 云控系统脚本源码,批量化控制,自动化脚统源码,#Autojs
- 基于MATLAB的微网限流控制策略 在MATLAB上搭建了小型微网平台,并网电压等级为380V,两个直流电压为800V,外环采用含有washout滤波器的下垂控制,内环是基于Pi控制器的限流控制,设定
- 激光SLAM之激光雷达+IMU建图 , 工程化落地项目,涉及激光雷达+imu 多传感器融合建图,加工程应用角度的代码优化,从数据接收到闭环检测到图优化,非常完整 该与本人发布的激光SLAM
- Carsim和simulink联合仿真车轮胎侧偏刚度估计 使用的算法:递归最小二乘法RLS算法 测试的工况: 正弦工况,不同车速 估计的参数为:前轮和后轮的侧偏刚度 s函数写的代码,主流建模方式,不需
- 基于matlab的FFT滤波,可以实现对simulink模型中示波器的波形数据或者外部mat数据、csv数据进行谐波分析(FFT)和自定义频段清除,对已有数据特定频段的数据进行提取也可以 优点是滤波
- BP神经网络预测代码,多数入单输出,MATLAB程序 优化好的程序,注释清楚,可直接数据,直接运行即可 代码实现训练与测试精度分析 预测精度高,支持多输入多输出
- 台达Plc程序44个,都是设备上的程序,有变频器,通讯,伺服,过程控制,运动控制,模拟量控制,pid控制
- 风光柴储,遗传算法求解微电网各部分最优出力,适合初学者学习参考
- BCH编码 硬判决以及软判决译码 误码率曲线
- 基于卷积神经网络的,轴承故障识别 matlab代码, 请大佬指教的,准确率能到99%以上 实际上代码很多,但是主要步骤分为4个, 1 是凯斯西储大学数据集的划分, 2 是4种(连续小波变,短时傅立
- Labview自动运行程序,PLC为欧姆龙NJ,程序自动加载设置参数,可以修改保存参数,通过网口扫码,进出站,产品数据由PLC程序转移,程序标准易懂,清晰,数据可以在操作界面显示,用作参考
- MATLAB代码:基于二阶锥松弛的主动配电网故障重构及可视化 关键词:配电网 故障重构 二阶锥松弛 可视化 参考文档:《基于禁忌克隆遗传算法的配电网故障恢复重构-张利民》参考故障重构部分模型;二阶
- MATLAB代码:基于非对称纳什谈判的多微网P2P电能交易策略 关键词:纳什谈判 合作博弈 微网 电转气-碳捕集 P2P电能交易交易 参考文档:加好友获取 仿真平台:MATLAB CPLE
- Mitsubishi 三菱Q系列16轴设备 带个4个QD75运行模块,1个QJ71C24通信模块,1个QJ61BT11N 三菱CC-Link模块,多个输入输出模块 含三菱的触摸屏和CAD完整电气图
- SIEMENS 西门子伺服液压PID模板 程序包括 1整套西门子smart200 PLC程序, 2昆仑通态MCGS程序, 3东元伺服 4电气图纸. 5液压机械图 6功能说明书 7注释详细,完整项目资
- ModbusTCP助手调试工具Modbus主站调试工具ModbusMaster支持所有Modbus设备调试; 功能强大,是学习测试的必备工具; 1.界面简洁 2.数据记录功能 3.串口助手功能 4.数
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈