Scala中List方法

List方法总结:

1	def +(elem: A): List[A]
    前置一个元素列表
2	def ::(x: A): List[A]
    在这个列表的开头添加的元素。
3	def :::(prefix: List[A]): List[A]
    增加了一个给定列表中该列表前面的元素。
4	def ::(x: A): List[A]
    增加了一个元素x在列表的开头
5	def addString(b: StringBuilder): StringBuilder
    追加列表的一个字符串生成器的所有元素。
6	def addString(b: StringBuilder, sep: String): StringBuilder
    追加列表的使用分隔字符串一个字符串生成器的所有元素。
7	def apply(n: Int): A
    选择通过其在列表中索引的元素
8	def contains(elem: Any): Boolean
    测试该列表中是否包含一个给定值作为元素。
9	def copyToArray(xs: Array[A], start: Int, len: Int): Unit
    列表的副本元件阵列。填充给定的数组xs与此列表中最多len个元素,在位置开始。
10	def distinct: List[A]
    建立从列表中没有任何重复的元素的新列表。
11	def drop(n: Int): List[A]
    返回除了第n个的所有元素。
12	def dropRight(n: Int): List[A]
    返回除了最后的n个的元素
13	def dropWhile(p: (A) => Boolean): List[A]
    丢弃满足谓词的元素最长前缀。
14	def endsWith[B](that: Seq[B]): Boolean
    测试列表是否使用给定序列结束。
15	def equals(that: Any): Boolean
    equals方法的任意序列。比较该序列到某些其他对象。
16	def exists(p: (A) => Boolean): Boolean
    测试谓词是否持有一些列表的元素。
17	def filter(p: (A) => Boolean): List[A]
    返回列表满足谓词的所有元素。
18	def forall(p: (A) => Boolean): Boolean
    测试谓词是否持有该列表中的所有元素。
19	def foreach(f: (A) => Unit): Unit
    应用一个函数f以列表的所有元素。
20	def head: A
    选择列表的第一个元素
21	def indexOf(elem: A, from: Int): Int
    经过或在某些起始索引查找列表中的一些值第一次出现的索引。
22	def init: List[A]
    返回除了最后的所有元素
23	def intersect(that: Seq[A]): List[A]
    计算列表和另一序列之间的多重集交集。
24	def isEmpty: Boolean
    测试列表是否为空
25	def iterator: Iterator[A]
    创建一个新的迭代器中包含的可迭代对象中的所有元素
26	def last: A
    返回最后一个元素
27	def lastIndexOf(elem: A, end: Int): Int
    之前或在一个给定的最终指数查找的列表中的一些值最后一次出现的索引
28	def length: Int
    返回列表的长度
29	def map[B](f: (A) => B): List[B]
    通过应用函数以g这个列表中的所有元素构建一个新的集合
30	def max: A
    查找最大的元素
31	def min: A
    查找最小元素
32	def mkString: String
    显示列表的字符串中的所有元素
33	def mkString(sep: String): String
    显示的列表中的字符串中使用分隔串的所有元素
34	def reverse: List[A]
    返回新列表,在相反的顺序元素
35	def sorted[B >: A]: List[A]
    根据排序对列表进行排序
36	def startsWith[B](that: Seq[B], offset: Int): Boolean
    测试该列表中是否包含给定的索引处的给定的序列
37	def sum: A
    概括这个集合的元素
38	def tail: List[A]
    返回除了第一的所有元素
39	def take(n: Int): List[A]
    返回前n个元素
40	def takeRight(n: Int): List[A]
    返回最后n个元素
41	def toArray: Array[A]
    列表以一个数组变换
42	def toBuffer[B >: A]: Buffer[B]
    列表以一个可变缓冲器转换
43	def toMap[T, U]: Map[T, U]
    此列表的映射转换
44	def toSeq: Seq[A]
    列表的序列转换
45	def toSet[B >: A]: Set[B]
    列表到集合变换
46	def toString(): String
    列表转换为字符串

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值