scala数组、集合、序列函数总结

  • Array
    • ++
    • ++:
    • +:
    • :+
    • /:
    • :\
    • addString
    • addString
    • addString
    • map
    • apply
    • array
    • addThen
    • applyOrElse
    • charAt
    • clone
    • collect
    • collectFirst
    • combinations
    • contains
    • containsSlice
    • canEqual
    • copyToArray
    • copyToBuffer
    • corresponds
    • count
    • diff
    • distinct
    • drop
    • dropRight
    • dropWhile
    • endsWith
    • startsWith
    • exists
    • filter
    • filterNot
    • flatMap
    • flatten
    • fold
    • foldLeft
    • foldRight
    • aggregate
    • forall
    • foreach
    • groupBy
    • grouped
    • hasDefiniteSize
    • head
    • tail
    • headOption
    • indexOf
    • indexOf
    • indexOfSlice
    • indexOfSlice
    • indexWhere
    • indexWhere
    • indices
    • init
    • inits
    • intersect
    • isDefinedAt
    • isEmpty
    • isTraversableAgain
    • iterator
    • last
    • lastIndexOf(elem)
    • lastIndexOf(elem, end)
    • lastIndexOfSlice(that)
    • lastIndexOfSlice(that, end)
    • lastIndexWhere
    • lastIndexWhere(p, end)
    • lastOption
    • length
    • lengthCompare
    • map
    • max
    • maxBy
    • min
    • minBy
    • mkString
    • mkString(sep)
    • mkString(start, sep, end)
    • nonEmpty
    • padTo
    • par
    • partition
    • patch
    • permutations
    • prefixLength
    • product
    • reduce
    • reduceLeft
    • reduceRight
    • reduceLeftOption
    • reduceRightOption
    • reverse
    • iterator
    • reverseIterator
    • reverseMap
    • sameElements
    • scan
    • scanLeft
    • scanRight
    • segmentLength
    • seq
    • size
    • slice
    • sliding(size)
    • sliding(size, step)
    • sortBy
    • sortWith
    • sorted
    • span
    • splitAt
    • startsWith(that)
    • startsWith(that, offset)
    • stringPrefix
    • subSequence
    • sum
    • tail
    • tails
    • take
    • takeRight
    • takeWhile
    • toArray
    • toBuffer
    • toIndexedSeq
    • toIterable
    • toIterator
    • toList
    • toMap
    • toSet
    • toStream
    • toVector
    • transpose
    • union
    • unzip
    • unzip3
    • update
    • updated
    • view
    • withFilter
    • zip
    • zipAll
    • zipWithIndex

Array

Array

数组是一种可变的、可索引的数据集合。在 Scala 中用 Array[T] 的形式来表示 。
声明数组:

scala声明数组:
写法一:简单通用var e = Array("a","b","c")
写法二:中括号表示泛型,小括号及内容表示数组的长度var a1:Array[String] = new Array[String](3)

示例:

1.读取第一个元素:
val first = e(0)2.替换第一个元素为指定值:
e(0) = 103.对数组中的所有元素进行某项操作,并生成新的数组:
val a = Array(1,2,3)
val b = a.map(_+2)		//注意_下划线代表代理参数,同一数组只能用一次,代表数组中的每个元素
结果:b: Array[Int] = Array(3, 4, 5)4.打印数组
print(a.mkString(","))
结果:1,2,3

以下案例展示结果均在dos窗口下执行

++

(同union)
定义:def ++[B](that: GenTraversableOnce[B]): Array[B]
描述:(合并集合,并返回一个新的数组,新数组包含左右两个集合对象的内容)

val k = Array(1,2,3,"a")
val e = Array("a","b","c")
k++e
结果:res24: Array[Any] = Array(1, 2, 3, a, a, b, c)
或者e.++(k) //++注意++是一个函数,所以可以通过类似java中的函数调用的方式
结果同上:res25: Array[Any] = Array(1, 2, 3, a, a, b, c)

++:

定义:def ++:[B >: A, That](that: collection.Traversable[B])(implicit bf: CanBuildFrom[Array[T], B, That]): That

描述:(功能类似++,即:冒号后面的数据类型决定整个方法返回结果的类型)

val  e = Array(1,2,3,4)
val  k = List(1,2)
e++:k 
结果:res29: List[Int] = List(1, 2, 3, 4, 1, 2)
k++:e
结果:res30: Array[Int] = Array(1, 2, 1, 2, 3, 4)

+:

定义:def +:(elem: A): Array[A]

描述:(在数组的头部位置添加元素,并返回新的对象)

val  k = Array(1,2,3,4)
24+:k 
结果:Array[Int] = Array(24,1,2,3,4)

:+

定义:def :+(elem: A): Array[A]
描述:(在数组的尾部位置添加元素,并返回新的对象)

k:+24 
结果:Array[Int] = Array(1,2,3,4,24)
注意:数组或集合一定要紧靠着:冒号的位置,否则会报错

/:

定义:def /:[B](z: B)(op: (B, T) ⇒ B): B
描述:(对数组中所有的元素从左向右遍历,进行相同的迭代操作,foldLeft 的简写)
(foldLeft的简写,左二叉树)

val y = Array(1,2,3)
(88 /: y) (_+_)
结果:Int = 94
注意:将/左边的数值依次和:右边的数组中的元素进行某项操作,示例中的左二叉树即为先用88+1,再将前者的操作结果即和与第二个元素2相加,依次累加至最后一个元素

:\

定义:def :[B](z: B)(op: (T, B) ⇒ B): B
描述:(对数组中所有的元素从右向左遍历,进行相同的迭代操作,`foldRight 的简写)
(foldRight的简写,右二叉树)

val y = Array(1,2,3)
(88 /: y) (_+_)
结果:Int = 94
注意:单个数值与数组中的元素进行操作的顺序为从右往左

addString

定义:def addString(b: StringBuilder): StringBuilder
描述:(将数组k的元素拼接成字符串的形式添加到StringBuilder中)

val  k = Array(5,6,7,8)
val g = new StringBuilder
k.addString(g)
结果:StringBuilder = 5678

addString

定义:def addString(b: StringBuilder, sep: String): StringBuilder
描述:(同上,每个元素以sep分隔符分开)

val  k = Array(5,6,7,8)
val g = new StringBuilder
k.addString(g,",")
结果:StringBuilder = 5,6,7,8

addString

定义:def addString(b: StringBuilder, start: String, sep: String, end: String):
描述:(同上,在首位各加上一个字符串,并指定sep分隔符)

val  k = Array(5,6,7,8)
val g = new StringBuilder
k.addString(g,"{",",","}")
结果:StringBuilder = {5,6,7,8}

map

定义:def map[B](f: (A) ⇒ B): Array[B]
描述:(类似与java中的增强型for循环,将数组中的每个元素进行某项操作,必须加表 达式或者自定义函数)

val  k = Array(5,6,7,8)
k.map(x=>x+2)
结果:res44: Array[Int] = Array(7,8,9,10)或者这样写:y map(x=>x+2)
结果同上或写成y.map(abc)
结果同上或
val k = Array(1,2,3,"a")
k
结果:Array[Any] = Array(1, 2, 3, a)
Array数组的泛型为Any类型:
k.map(_+"")
结果:Array[String] = Array(1, 2, 3, a)
将Array数组的泛型转为了String类型

apply

定义:def apply(i: Int): T
描述:(取出指定索引处的元素;可以是数组,也可以是集合)

val k=Array(1,2,3)
k.array(0)
结果:Int = 1

array

定义:def array(i: Int): T
描述:(取出数组中指定索引处的元素,只可以是Array)

val g = Array(2,3,4,"a")
g.array(3)
结果: Any = a注意:array()只适用于数组Array,其他类型的会报错;而apply适用于数组或者集合;或者直接用变量名(索引)直接取出对应元素 

addThen

applyOrElse

charAt

定义:def charAt(index: Int): Char
描述:(取出字符数组指定索引所对应的元素,仅限字符数组)
获取index索引处的字符,这个方法会执行一个隐式的转换,将Array[T]转换为 ArrayCharSequence,只有当T为char类型时,这个转换才会发生。

var h = Array('a','b','c')
h.charAt(0)
结果: Char = a

clone

定义:def clone(): Array[T]
描述:(创建一个副本,浅拷贝,拷贝的是对象的引用,深拷贝是拷贝对象本身,并在堆中生成一个相同的对象)

scala> var a=Array(1,2,3)
a: Array[Int] = Array(1, 2, 3)scala> var b=Array(1,2,3,a)
b: Array[Any] = Array(1, 2, 3, Array(1, 2, 3))scala> var c=b.clone
c: Array[Any] = Array(1, 2, 3, Array(1, 2, 3))scala> a(1)=4scala> a
res41: Array[Int] = Array(1, 4, 3)scala> b
res42: Array[Any] = Array(1, 2, 3, Array(1, 4, 3))scala> c
res43: Array[Any] = Array(1, 2, 3, Array(1, 4, 3))
由上例可知,clone是浅拷贝,当对象改变时,拷贝的对象的引用即地址并未发生改变,指向的是原来的对象,
但此时对象已发生改变,因而拷贝后的数据也随之改变

collect

定义:def collect[B](pf: PartialFunction[A, B]): Array[B]
描述:(通过执行一个并行计算(偏函数),得到一个新的数组对象)

偏函数:只能与collect、collectFirst函数连用
例1:
scala> val a =Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)
scala> val func:PartialFunction[Int,Int] = {| case x if x%2==0 => x+2| case x => x+1| }
func: PartialFunction[Int,Int] = <function1>调用调用collect函数,将偏函数以参数的形式传入
scala> a.collect(func)
res8: Array[Int] = Array(2, 4, 4, 6)2:
scala> val func:PartialFunction[Int,Int] = {#_下划线代表代理参数,一个对象只能用一次| case x if x%2==0 => x+2| case _ => 1
scala> a.collect(func)
res8:  Array[Int] = Array(1, 4, 1, 6) //数组a中的为偶数的元素+2,其他元素都变为13:
scala> val func:PartialFunction[Int,Int] = {| case x if x%2==0 => x+2| }
func: PartialFunction[Int,Int] = <function1>scala> a.collect(func)
res9: Array[Int] = Array(4, 6)  //除了偏函数内部满足条件的数据,其他的全部去除

collectFirst

定义:def collectFirst[B](pf: PartialFunction[T, B]): Option[B]
描述:(在序列中查找第一个符合偏函数定义的元素,并执行偏函数计算)
例:

scala> val func:PartialFunction[Int,Int] = {| case x if x%2==0 => x+2| }
func: PartialFunction[Int,Int] = <function1>scala> a.collect(func)
res9: Array[Int] = Array(4, 6)
scala> a.collectFirst(func).get
结果:res11: Int = 4

combinations

定义:def combinations(n: Int): collection.Iterator[Array[T]]
描述:(将数组中的元素通过参数设定,设定参数为n,就将n个元素两两组合起来,不考虑顺序)
排列组合,这个排列组合会选出所有包含字符不一样的组合,对于 “abc”、“cba”,只选择一个,参数n表示序列长度,就是几个字符为一组

例:
scala> var a = Array(1,2,3,4)
scala> var b = a.combinations(2)
res15: Iterator[Array[Int]] = non-empty iteratorscala> b.foreach(x=>println(x.mkString(","))) //将数组a中的元素两两结合为一组,并以分隔符,逗号为每个分组元素之间的分隔符
1,2
1,3
1,4
2,3
2,4
3,4

contains

定义:def contains[A1 >: A](elem: A1): Boolean
描述:(判断序列中是否包含指定元素)

例:
scala> var a = Array(1,2,3,4)
scala> a.contains
contains   containsSlicescala> a.contains(5)
res17: Boolean = falsescala> a.contains(3)
res18: Boolean = true

containsSlice

定义:def containsSlice[B](that: GenSeq[B]): Boolean
描述:(判断当前序列中是否包含另一个序列,并且两个序列中的元素顺序要保持一致)

例:
scala> val c=Array(1,2,3,4,5)
c: Array[Int] = Array(1, 2, 3, 4, 5)scala> val d=Array(3,4)
d: Array[Int] = Array(3, 4)scala> c.containsSlice(d)
res23: Boolean = true

canEqual

定义:def canEqual(that: Any): Boolean
描述:(判断两个对象是否可以进行比较)

例:
val a = List(1,2,3,4)
val b = Array("a","b","c")
a.canEqual(b)
结果:ture

copyToArray

定义:def copyToArray(xs: Array[A]): Unit
描述:(将当前数组元素复制到另一个数组中)

例:
val a = Array(1,2,3)
val b = new Array[Int](5)
用法一:
a.copyToArray(b)
结果:res54: Array[Int] = Array(1, 2, 3, 0, 0)

用法二:
定义:copyToArray(xs: Array[A], start: Int): Unit
描述:(将当前数组元素复制到另一个数组中,从新数组的start位置开始将源数组全部拷贝)

a.copyToArray(b,1)
结果:res56: Array[Int] = Array(0, 1, 2, 3, 0)

用法三:
定义:copyToArray(xs: Array[A], start: Int, len: Int): Unit(将数组a拷贝到数组b中,从b中下标为2的位置开始,拷贝a数组中两个元素)

a.copyToArray(b,2,2)
结果:res58: Array[Int] = Array(0, 0, 1, 2, 0)

copyToBuffer

定义:def copyToBuffer[B >: A](dest: Buffer[B]): Unit
描述:(将数组中的元素拷贝到Buffer中)
例:

首先得先导包:
import scala.collection.mutable.ArrayBufferscala> val a = Array(1,2,3)
scala> var d = new ArrayBuffer[Int]()
d: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer()scala> a.copyToBuffer(d)scala> d
res6: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer(1, 2, 3)

corresponds

定义:def corresponds[B](that: GenSeq[B])(p: (T, B) ⇒ Boolean): Boolean
描述:判断两个序列长度以及对应位置元素是否符合某个条件。如果两个序列具有相同的元素数量并且p(x, y)=true,返回结果为true

例:
scala> a
res7: List[Int] = List(1, 2, 3)scala> b
res8: List[Int] = List(2, 3)scala> a.corresponds(b) (_<_)
res9: Boolean = falsescala> val c = List(1,2,3)
c: List[Int] = List(1, 2, 3)scala> a.corresponds(c)(_==_)
res10: Boolean = true

count

定义:def count(p: (T) ⇒ Boolean): Int (统计符合条件的元素个数)
描述:(p:代表的是参数,即数组中的元素,T代表的是数组的泛型,即元素的数据类型,Boolean代表的是表达式返回结果的类型)

1:求数组中是偶数的元素的个数
val a = Array(1,2,3)
a.count(x=>x%2==0)
res65: Int = 12:求数组中含“o”的元素的个数
scala> val e=Array("hello","world","hadoop")
e: Array[String] = Array(hello, world, hadoop)scala> e.countdef count(p: String => Boolean): Intscala> e.count(x=>x.contains("o"))  //判断数组中含o字符的元素的个数
res13: Int = 3scala> e.count(x=>x.indexOf("o") > -1)
res16: Int = 3

diff

定义:def diff(that: collection.Seq[T]): Array[T]
描述:计算当前数组与另一个数组的不同。将当前数组中没有在另一个数组中出现的元素返回

例:
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> val b = Array(2,4,6,8)
b: Array[Int] = Array(2, 4, 6, 8)scala> a.diff(b)
res66: Array[Int] = Array(1, 3)

distinct

定义:def distinct: Array[T]
描述: (去除当前集合中重复的元素,只保留一个)

例:
scala> val a = Array(1,2,2,3)
a: Array[Int] = Array(1, 2, 2, 3)scala> a.distinct
res67: Array[Int] = Array(1, 2, 3)

drop

定义:def drop(n: Int): Array[T]
描述: (将当前数组中前 n 个元素去除后,作为一个新序列返回)

例:
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.drop(3)  //去除前3个元素
res68: Array[Int] = Array(4)

dropRight

定义:def dropRight(n: Int): Array[T]
描述:(功能同 drop,去掉尾部的 n 个元素,即从后往前去除n个元素)

例:
scala> a
res69: Array[Int] = Array(1, 2, 3, 4)scala> a.dropRight(3)
res70: Array[Int] = Array(1)

dropWhile

定义:def dropWhile(p: (T) ⇒ Boolean): Array[T]
描述:去除当前数组中符合条件的元素,这个需要一个条件,就是从当前数组的第一个元素起,就要满足条件,直到碰到第一个不满足条件的元素结束(即使后面还有符合条件的元素),否则返回整个数组

1:当数组中的元素满足条件时scala> val a = Array(3,4,7,2)
a: Array[Int] = Array(3, 4, 7, 2)scala> a.dropWhile(x=>x>2)
res71: Array[Int] = Array(2)2:当数组中的第一个元素就不满足条件时,直接返回整个数组
scala> a.dropWhile(x=>x>3)
res73: Array[Int] = Array(3, 4, 7, 2)

endsWith

定义:def endsWith[B](that: GenSeq[B]): Boolean
描述: (判断数组是否以某个序列结尾,注意参数必须为序列,为单值会报错)

例:
scala> val a = Array(2,4,6,8)
a: Array[Int] = Array(2, 4, 6, 8)scala> a.endsWith(8)   //注意:此处参数为单值会报错
<console>:14: error: type mismatch;found   : Int(8)required: scala.collection.GenSeq[?]a.endsWith(8)^scala> val b = Array(6,8)
b: Array[Int] = Array(6, 8)scala> a.endsWith(b)
res75: Boolean = true

startsWith

定义:def startsWith[B](that: GenSeq[B]): Boolean
描述:(判断数组是否以某个序列开头,注意参数必须为序列,为单值会报错)

例:
scala> val a = Array(2,4,6,8)
a: Array[Int] = Array(2, 4, 6, 8)scala> a.endsWith(8)   //注意:此处参数为单值会报错
<console>:14: error: type mismatch;found   : Int(8)required: scala.collection.GenSeq[?]a.endsWith(8)^scala> val b = Array(6,8)
b: Array[Int] = Array(2, 4)scala> a.startsWith(b)
res75: Boolean = true

exists

定义:def exists(p: (T) ⇒ Boolean): Boolean
描述: (判断当前数组是否包含符合条件的元素)

例:
scala> val a = Array(2,4,4,6)
a: Array[Int] = Array(2, 4, 4, 6)scala> a.exists(x=> x==4)
res78: Boolean = truescala> a.exists(x=> x>1)
res79: Boolean = truescala> a.exists(x=> x>10)
res81: Boolean = false

filter

定义:def filter(p: (T) ⇒ Boolean): Array[T]
描述: (取得当前数组中符合条件的元素,组成新的数组返回)

例:
scala> val a = Array(1,2,3,4,5)
a: Array[Int] = Array(1, 2, 3, 4, 5)scala> a.map(x=> if (x>2) x)
res82: Array[AnyVal] = Array((), (), 3, 4, 5)scala> a.filter(_>2)
res83: Array[Int] = Array(3, 4, 5)scala> a.filter(x=> x>2)
res84: Array[Int] = Array(3, 4, 5)

filterNot

定义:def filterNot(p: (T) ⇒ Boolean): Array[T]
描述:(保留不符合条件的元素,组成新的数组返回)

例:
scala> a.filterNot(x=>x>2)
res85: Array[Int] = Array(1, 2)## 38.find 
定义:def find(p: (T)Boolean): Option[T]
描述: (查找第一个符合条件的元素)
例:
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.find(x=>x>2)
res86: Option[Int] = Some(3)scala> a.find(x=>x>2).get    //要想得到对应元素的类型,必须再加上.get
res87: Int = 3

flatMap

定义:def flatMap[B](f: (A) ⇒ GenTraversableOnce[B]): Array[B]
描述:对当前序列的每个元素进行操作,结果放入新序列返回,参数要求是GenTraversableOnce及其子类

例:
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.flatMap(x=> 1 to x)
res88: Array[Int] = Array(1, 1, 2, 1, 2, 3, 1, 2, 3, 4)解释:(x=> 1 to x)表示,从1开始,依次取出11,12,13,14的元素,并将所有取出的元素放入到新的序列中返回scala>scala> a.flatMap(x=> 2 to x)
res89: Array[Int] = Array(2, 2, 3, 2, 3, 4)scala> a.flatMap(x=> 3 to x)
res90: Array[Int] = Array(3, 3, 4)

flatten

定义:def flatten[U](implicit asTrav: (T) ⇒ collection.Traversable[U], m: ClassTag[U]): Array[U]
描述:降维;将二维数组的所有元素联合在一起,形成一个一维数组返回

例:
scala> val g = List(List(1,2,3),List(4,5))
g: List[List[Int]] = List(List(1, 2, 3), List(4, 5))scala> g.flat
flatMap   flattenscala> g.flatten   //二维降一维
res41: List[Int] = List(1, 2, 3, 4, 5)scala> val g = List(List(List(1,2,3),List(4,5)),List(List(5,6),List(7,8)))
g: List[List[List[Int]]] = List(List(List(1, 2, 3), List(4, 5)), List(List(5, 6), List(7, 8)))scala> g.flatten.flatten //三维降二维;注意三维数组中如果同时出现不同维度的数组,则不能使用该函数
res42: List[Int] = List(1, 2, 3, 4, 5, 5, 6, 7, 8)

fold

定义:def fold[A1 >: A](z: A1)(op: (A1, A1) ⇒ A1): A1
描述:对序列中的每个元素进行二元运算,和aggregate有类似的语义,但执行过程有所不同

例: (类似  /: )
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.fold(5)(_+_)
res93: Int = 15

foldLeft

定义:def foldLeft[B](z: B)(op: (B, T) ⇒ B): B
描述:从左到右计算,简写方式:def /:[B](z: B)(op: (B, T) ⇒ B): B

例:(简写: /: 左二叉树)
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.foldLeft(5)(_+_)
res93: Int = 15scala> (5/:a)(_+_)    //简写
res95: Int = 15

foldRight

定义:def foldRight[B](z: B)(op: (B, T) ⇒ B): B
描述:从右到左计算,简写方式:def :[B](z: B)(op: (T, B) ⇒ B): B

例:(简写: :/ 右二叉树)
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.foldRight(5)(_+_)
res93: Int = 15scala> (5/:a)(_+_)   //简写
res97: Int = 15

aggregate

定义:def aggregate[B](z: ⇒ B)(seqop: (B, T) ⇒ B, combop: (B, B) ⇒ B): B
描述:聚合计算,aggregate是柯里化方法,参数是两个方法,为了方便理解,我们把aggregate的两个参数,分别封装成两个方法,并把计算过程打印出来

例:scala> def mapper(m:Int,n:Int):Int = { //自定义mapper函数| return m+n| }
mapper: (m: Int, n: Int)Intscala> def reduce(m:Int,n:Int):Int = {  //自定义reduce函数| return m+n| }
reduce: (m: Int, n: Int)Intscala> a
res103: Array[Int] = Array(1, 2, 3, 4)scala> a.par.aggregate(5)(mapper,reduce)  //将两个自定义函数作为参数传入
res106: Int = 30scala> a.par.aggregate(5)(_+_)    //简写/** 计算过程seq_exp=5+3seq_exp=5+2seq_exp=5+4seq_exp=5+1com_exp=6+7com_exp=8+9com_exp=13+17c:30*/解释:首先调用第一个mapper函数,将参数5分别和数组a中的参数进行相加,注意,此时是经过分区的,所以相加的顺序由于节点不同,顺序也不同;再将mapper函数各个分区操作的结果带入到reduce函数中,再进行分区计算,最后将各个分区操作结果进行combine汇总

forall

定义:def forall(p: (T) ⇒ Boolean): Boolean
描述:(判断数组中的每个元素是否都满足条件,如果都满足,则返回true,否则返回false)

例:
scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)scala> a.forall(x=> x>0)
res107: Boolean = truescala> a.forall(_ > 0)
res112: Boolean = truescala> a.forall(x=> x>1)
res108: Boolean = false

foreach

定义:def foreach(f: (A) ⇒ Unit): Unit
描述: (遍历数组中的元素,并进行操作,最后返回操作后的数组)

例:
scala> a.foreach(println)
1
2
3
4scala> a.foreach(x=> println(x))
1
2
3
4scala> a.foreach(println(_))
1
2
3
4

==============================================

groupBy

(按条件分组,返回的是一个hashmap)
定义:def groupBy[K](f: (T) ⇒ K): Map[K, Array[T]]
描述:根据条件分组,条件由 f 匹配,返回值是Map类型,每个key对应一个序列


例:
scala> val a = Array(1,2,3,4,5,6)
a: Array[Int] = Array(1, 2, 3, 4, 5, 6)//按照奇数偶数对数组元素进行分配,从而返回两个元祖即:Map[String,Array[Int]]
scala> a.groupBy(x=> x match{| case x if x%2==0 => "ou"| case _ => "ji"| })
res174: scala.collection.immutable.Map[String,Array[Int]] = Map(ou -> Array(2, 4, 6), ji -> Array(1, 3, 5))//通过迭代器遍历输出
scala> res174.iterator.foreach(x=> println(x._1,x._2)) //没有将元祖的元素转化为字符串,输出了一串地址
(ou,[I@1c3545c)
(ji,[I@49335860)scala> res174.iterator.foreach(x=> println(x._1,x._2.mkString(","))) //正确写法
(ou,2,4,6)
(ji,1,3,5)

grouped

定义:def grouped(size: Int): collection.Iterator[Array[T]]
描述:根据指定数量对数组元素进行分组,规定每组有 size 数量个元素,返回一个集合

例:
scala> a
res181: Array[Int] = Array(1, 2, 3, 4, 5, 6)scala> a.grouped(3)
res182: Iterator[Array[Int]] = non-empty iteratorscala> a.grouped(3).toList
res183: List[Array[Int]] = List(Array(1, 2, 3), Array(4, 5, 6))scala> a.grouped(3).toArray
res184: Array[Array[Int]] = Array(Array(1, 2, 3), Array(4, 5, 6))scala> a.grouped(2).toArray
res185: Array[Array[Int]] = Array(Array(1, 2), Array(3, 4), Array(5, 6))

hasDefiniteSize

定义:def hasDefiniteSize: Boolean
描述:判断序列是否是有限长度,如果是则返回true,如果是流stream数据,则返回false

例:
scala> a.hasDefiniteSize
res187: Boolean = true

head

定义:def head: T
描述:返回序列的第一个元素,如果序列为空,将报错

:
scala> a
res190: Array[Int] = Array(1, 2, 3, 4)scala> a.head
res191: Int = 1scala> val p:Array[Int] = Array[Int]()  //定义一个Int类型的空数组
p: Array[Int] = Array()scala> p.head
java.util.NoSuchElementException: next on empty iteratorat scala.collection.Iterator$$anon$2.next(Iterator.scala:39)at scala.collection.Iterator$$anon$2.next(Iterator.scala:37)at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:63)at scala.collection.IterableLike$class.head(IterableLike.scala:107)at scala.collection.mutable.ArrayOps$ofInt.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:234)at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:126)at scala.collection.mutable.ArrayOps$ofInt.head(ArrayOps.scala:234)... 32 elided

tail

定义:def tail: Array[T]
描述:返回当前序列中不包含第一个元素的序列;即这里的tail函数返回的是除了head第一个元素之外的所有元素

例:
scala> a
res198: Array[Int] = Array(1, 2, 3, 4)scala> a.tail
res199: Array[Int] = Array(2, 3, 4)

headOption

定义:def headOption: Option[T]
描述:返回序列的第一个元素的 Option 类型对象,如果序列为空,则返回 None,防止为空序列报错

例:
scala> a
res193: Array[Int] = Array(1, 2, 3, 4)scala> a.headOption
res194: Option[Int] = Some(1)   //Option类型只有两种情况,无值的时候为None,有值的时候为Somescala> a.headOption.get
res195: Int = 1scala> p
res196: Array[Int] = Array()scala> p.headOption
res197: Option[Int] = None

indexOf

定义:def indexOf(elem: T): Int
描述:返回元素 elem 在序列中第一次出现的索引,并且找到一个就返回

例:
scala> a++:Array(2,5,7,3)
res209: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3)scala> val c = res209
c: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3)scala> c
res210: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3)scala> c.indexOf(2)
res211: Int = 1  		//只返回该元素第一次出现的索引scala> c.indexOf(3)
res212: Int = 2			//同上

indexOf

定义:def indexOf(elem: T, from: Int): Int
描述:从指定索引 from(包括from) 开始查找,返回元素 elem 在序列中第一次出现的索引


例:
scala> c
res213: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3)scala> c.indexOf(3,1)
res214: Int = 2scala> c.indexOf(3,2)
res215: Int = 2scala> c.indexOf(3,3)
res216: Int = 7

indexOfSlice

定义:def indexOfSlice[B >: A](that: GenSeq[B]): Int
描述:检测当前序列中是否包含序列 that,并返回第一次出现该序列的索引,如果不包含序列that,则返回-1

例:
scala> c++:Array(4)
res220: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> val c = res220
c: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c
res222: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.indexOfSlice(Array(3,4))
res223: Int = 2scala> c.indexOfSlice(Array(4,2))
res224: Int = 3scala> c.indexOfSlice(Array(1,3,5))
res225: Int = -1				//如果当前序列中不包含序列that,则返回-1

indexOfSlice

定义:def indexOfSlice[B >: A](that: GenSeq[B], from: Int): Int
描述:指定从索引 from 开始查找,判断当前序列中是否包含另一个序列 that,如果包含则返回第一次出现该序列的索引,不包含则返回-1

例:
scala> c
res226: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.index
indexOf   indexOfSlice   indexWherescala> c.indexOfSlice(Array(3,4),1)
res227: Int = 2scala> c.indexOfSlice(Array(3,4),3)
res228: Int = 7

indexWhere

定义:def indexWhere(p: (T) ⇒ Boolean): Int
描述:返回当前序列中第一个满足条件 p 的元素对应的索引

例:
scala> c
res230: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.indexWhere(_>5)
res231: Int = 6scala> c.indexWhere(x=> x%2==0)
res232: Int = 1

indexWhere

定义:def indexWhere(p: (T) ⇒ Boolean, from: Int): Int
描述:返回当前序列中第一个满足条件 p 的元素的索引,指定从索引 from 开始查找

例:
scala> c
res233: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.indexWhere(_>3,1)
res235: Int = 3scala> c.indexWhere(_>3,4)
res236: Int = 5

indices

定义:def indices: collection.immutable.Range
描述:返回当前序列索引集合

例:
scala> c
res237: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.indices
res238: scala.collection.immutable.Range = Range(0, 1, 2, 3, 4, 5, 6, 7, 8)

init

定义:def init: Array[T]
描述:返回当前序列中不包含最后一个元素的序列

例:
scala> c
res237: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.init
res239: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3)

inits

(对序列进行循环init去除最后一个元素,并将每一次init的结果遍历一次,直至序列为空)
定义:def inits: collection.Iterator[Array[T]]
描述:对集合中的元素进行 init 迭代操作,该操作的返回值中, 第一个值是当前序列的副本,最后一个值为空,每一步都进行 init 操作,上一步的结果作为下一步的操作对象

例:
scala> c
res240: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.inits
res241: Iterator[Array[Int]] = non-empty iterator  //需要用迭代器对结果进行遍历scala> c.inits.toItera
toIterable   toIteratorscala> c.inits.toItera
toIterable   toIteratorscala> c
res242: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.inits
res243: Iterator[Array[Int]] = non-empty iteratorscala> c.inits.foreach(x=> println(x.mkString(","))) //遍历结果并打印序列
1,2,3,4,2,5,7,3,4
1,2,3,4,2,5,7,3
1,2,3,4,2,5,7
1,2,3,4,2,5
1,2,3,4,2
1,2,3,4
1,2,3
1,2
1

intersect

(取并集:++ 取差集: diff)
定义:def intersect(that: collection.Seq[T]): Array[T]
描述:取两个集合的交集

例:
scala> c
res249: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> val d = Array(1,2,3,4)
d: Array[Int] = Array(1, 2, 3, 4)scala> c.intersect(d)
res247: Array[Int] = Array(1, 2, 3, 4)scala> d.intersect(c)
res248: Array[Int] = Array(1, 2, 3, 4)

isDefinedAt

定义:def isDefinedAt(idx: Int): Boolean
描述:判断序列中是否存在指定索引

例:
scala> c
res250: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.isDefinedAt(8)
res251: Boolean = truescala> c.isDefinedAt(9)
res252: Boolean = false

isEmpty

定义:def isEmpty: Boolean
描述:判断序列是否为空

例:
scala> c
res253: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)

scala> c.isEmpty
res254: Boolean = false

scala> val h:Array[Int] = ArrayInt //定义一个空数组
h: Array[Int] = Array()

scala> h.isEmpty
res256: Boolean = true

isTraversableAgain

定义:def isTraversableAgain: Boolean
描述:判断序列是否可以反复遍历,该方法是 GenTraversableOnce 中的方法,对于 Traversables 一般返回 true,对于 Iterators 返回 false(Iterators只能遍历一次),除非被复写

例:
scala> c
res257: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.isTraversableAgain
res258: Boolean = truescala> c.inits			
res259: Iterator[Array[Int]] = non-empty iteratorscala> c.inits.isTraversableAgain   //对于 Iterators 返回 false
res260: Boolean = false

iterator

定义:def iterator: collection.Iterator[T]
描述:生成当前序列的迭代器

例:
scala> a.groupBy(x=> x match{| case x if x%2==0 => "ou"| case _ => "ji"| })
res174: scala.collection.immutable.Map[String,Array[Int]] = Map(ou -> Array(2, 4, 6), ji -> Array(1, 3, 5))scala> res174.iterator
res264: Iterator[(String, Array[Int])] = non-empty iteratorscala> res174.iterator.foreach(x=> println(x._1,x._2)) //遍历打印的元祖中的元素需要转成字符串再打印,否则会出现地址
(ou,[I@21e3eb5)
(ji,[I@3229b87d)scala> res174.iterator.foreach(x=> println(x._1,x._2.mkString(",")))  //x代表元祖;(x._1,x._2)  代表元祖的取值方式
(ou,2,4,6)
(ji,1,3,5)

last

定义:def last: T
描述:返回序列的最后一个元素,如果序列为空,将引发错误,如果是空数组但不要报错,则需用到lastOption

例:
scala> c
res267: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.last
res268: Int = 4

lastIndexOf(elem)

定义:def lastIndexOf(elem: T): Int
描述:返回元素 elem 在序列中最后一次出现的索引

例:
scala> c
res269: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndex
lastIndexOf   lastIndexOfSlice   lastIndexWherescala> c.lastIndexOf(3)
res270: Int = 7scala> c.lastIndexOf(4)
res271: Int = 8

lastIndexOf(elem, end)

定义:def lastIndexOf(elem: T, end: Int): Int
描述:返回元素 elem 在序列中最后一次出现的索引,指定在索引 end 之前(包括)的元素中查找

例:
scala> c
res269: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndex
lastIndexOf   lastIndexOfSlice   lastIndexWherescala> c.lastIndexOf(4,3)
res272: Int = 3scala> c.lastIndexOf(4,4)
res273: Int = 3scala> c.lastIndexOf(4,8)
res274: Int = 8scala> c.lastIndexOf(4,9) //没有索引9,但是只要是end之前的索引出现指定elem,都会返回该elem的索引
res276: Int = 8scala> c.lastIndexOf(4,0)     //索引0之前没有元素,所以结果返回-1
res275: Int = -1

lastIndexOfSlice(that)

定义:def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int
描述:判断当前序列中是否包含序列 that,如果有则返回最后一次出现该序列的索引,不包含则返回-1

例:
scala> c
res278: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndex
lastIndexOf   lastIndexOfSlice   lastIndexWherescala> c.lastIndexOfSlice(Array(2,3,4))
res279: Int = 1scala> c.lastIndexOfSlice(Array(2,8,9))
res280: Int = -1

lastIndexOfSlice(that, end)

定义:def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int
描述:在指定索引 end 之前(包括)的元素中开始查找,判断当前序列中是否包含序列 that,如果有则返回最后一次出现该序列的索引,没有则返回-1

例:
scala> c
res278: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndexOfSlice(Array(2,3,4),1)
res281: Int = 1scala> c.lastIndexOfSlice(Array(2,3,4),0)
res283: Int = -1scala> c.lastIndexOfSlice(Array(2,5,7),2)
res284: Int = -1scala> c.lastIndexOfSlice(Array(2,5,7),4)
res285: Int = 4

lastIndexWhere

定义:ef lastIndexWhere(p: (T) ⇒ Boolean): Int
描述:返回当前序列中最后一个满足条件 p 的元素的索引,如果没有满足条件的元素,则返回-1

例:
scala> c
res286: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndex
lastIndexOf   lastIndexOfSlice   lastIndexWherescala> c.lastIndexWhere(_>3)
res287: Int = 8scala> c.lastIndexWhere(_>7)
res288: Int = -1scala> c.lastIndexWhere(x=> x%2!=0)
res289: Int = 7

lastIndexWhere(p, end)

定义:def lastIndexWhere(p: (T) ⇒ Boolean, end: Int): Int
描述:在指定索引 end 之前(包括end)的元素中,查找并返回当前序列中最后一个满足条件 p 的元素的索引

例:
scala> c
res286: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastIndexWhere(x=> x%2!=0,7)
res290: Int = 7scala> c.lastIndexWhere(x=> x%2!=0,6)
res291: Int = 6

lastOption

定义:def lastOption: Option[T]
描述:返回序列的最后一个元素的 Option 类型对象,如果序列为空,则返回 None

例:
scala> c
res292: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.lastOption
res293: Option[Int] = Some(4)scala> c.lastOption.get
res294: Int = 4scala> h
res295: Array[Int] = Array()scala> h.lastOption
res296: Option[Int] = None

length

定义:def length: Int
描述:返回序列元素个数

例:
scala> c
res297: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.length
res298: Int = 9scala> c.size
res299: Int = 9scala> c:+null
res300: Array[Any] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4, null)scala> res300.length
res301: Int = 10scala> res300.size
res302: Int = 10

lengthCompare

定义:def lengthCompare(len: Int): Int
描述:比较序列的长度和参数 len,返回序列的长度 - len

例:
scala> c
res303: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)//返回序列的长度 = c.length - 传入的参数len
scala> c.lengthCompare(3)     
res304: Int = 6scala> c.lengthCompare(9)
res305: Int = 0scala> c.lengthCompare(10)
res306: Int = -1

map

定义:def map[B](f: (A) ⇒ B): Array[B]
描述:对序列中的元素进行 f 操作,返回生成的新序列

例:
scala> c
res317: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> val d = c.map(x=> x+2)
d: Array[Int] = Array(3, 4, 5, 6, 4, 7, 9, 5, 6)scala> d
res318: Array[Int] = Array(3, 4, 5, 6, 4, 7, 9, 5, 6)scala> d.foreach(x=> println(x))   //对新序列进行遍历
3
4
5
6
4
7
9
5
6

max

定义:def max: A
描述:返回序列中最大的元素

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.max
res325: Int = 7

maxBy

定义:def maxBy[B](f: (A) ⇒ B): A
描述:返回序列中符合条件的第一个元素

例:
scala> c
res326: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.maxBy(x=> x>5)
res327: Int = 7scala> c.maxBy(x=> x>2)
res328: Int = 3

min

定义:def max: A
描述:返回序列中最小的元素

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.min
res329: Int = 1

minBy

定义:def minBy[B](f: (A) ⇒ B): A
描述:返回序列中不符合条件的第一个元素

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.minBy(x=> x>5)
res330: Int = 1scala> c.minBy(x=> x>2)
res331: Int = 1

mkString

定义:def mkString: String
描述:将序列中所有元素拼接成一个字符串

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.mkString
res332: String = 123425734

mkString(sep)

定义:def mkString: String
描述:将序列中所有元素拼接成一个字符串,以 sep 作为元素间的分隔符

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.mkString(",")
res333: String = 1,2,3,4,2,5,7,3,4

mkString(start, sep, end)

定义:def mkString(start: String, sep: String, end: String): String
描述:将序列中所有元素拼接成一个字符串,以 start 开头,以 sep 作为元素间的分隔符,以 end 结尾

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.mkString("{",",","}")
res334: String = {1,2,3,4,2,5,7,3,4}

nonEmpty

定义:def nonEmpty: Boolean
描述:判断序列是否不为空

例:
scala> c
res324: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.nonEmpty
res335: Boolean = truescala> val h:Array[Int] = Array[Int]()		//定义一个空数组
h: Array[Int] = Array() 	
scala> h.nonEmpty
res337: Boolean = false

padTo

定义:def padTo(len: Int, elem: A): Array[A]
描述:填充序列,如果当前序列长度小于 len,那么新产生的序列长度是 len,多出的几个位值填充 elem,如果当前序列大于等于 len ,则返回当前序列

:
scala> c
res338: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.padTo(10,null)			//需要长度为10的数组,空出的位置用null填充
res340: Array[Any] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4, null)

par

定义:def par: ParArray[T]
描述:返回一个并行实现,产生的并行序列不能被修改

例:
scala> c
res338: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.par
res341: scala.collection.parallel.mutable.ParArray[Int] = ParArray(1, 2, 3, 4, 2, 5, 7, 3, 4)//尝试将c.par生成的并行序列的长度扩成10,但是会报错
scala> c.par.padTo(10,null)
java.lang.UnsupportedOperationExceptionat scala.collection.parallel.immutable.Repetition.seq(package.scala:23)at scala.collection.parallel.immutable.Repetition.seq(package.scala:19)at scala.collection.parallel.ParSeqLike$class.patch(ParSeqLike.scala:222)at scala.collection.parallel.mutable.ParArray.patch(ParArray.scala:56)at scala.collection.parallel.ParSeqLike$class.padTo(ParSeqLike.scala:256)at scala.collection.parallel.mutable.ParArray.padTo(ParArray.scala:56)... 32 elided

partition

定义:def partition(p: (T) ⇒ Boolean): (Array[T], Array[T])
描述:按条件将序列拆分成两个数组,满足条件的放到第一个数组,其余的放到第二个数组,返回的是包含这两个数组的元组

例:
scala> c
res345: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.partition(x=> x>4)			//也可以通过groupBy进行分区
res346: (Array[Int], Array[Int]) = (Array(5, 7),Array(1, 2, 3, 4, 2, 3, 4))

patch

定义:def patch(from: Int, that: GenSeq[A], replaced: Int): Array[A]
描述:批量替换,从原序列的 from 处开始,后面的 replaced 个元素,将被替换成序列 that
简单来说,就是从原序列的from索引处开始,用新的序列去替换原序列from(包括from)索引后面n个元素

例:
scala> c
res353: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.patch(3,Array(6,6,6),3)
res356: Array[Int] = Array(1, 2, 3, 6, 6, 6, 7, 3, 4)   //从索引3开始,用新的序列替换调索引3以3之后的3个元素scala> c.patch(3,Array(6,6,6),2)
res357: Array[Int] = Array(1, 2, 3, 6, 6, 6, 5, 7, 3, 4) //从索引3开始,用新的序列替换调索引3以3之后的2个元素

permutations

定义:def permutations: collection.Iterator[Array[T]]
描述:permutations 表示排列,这个排列组合会选出所有排列顺序不同的字符组合,permutations 与 combinations 不同的是,相同的组合考虑排列,对于 “abc”、“cba”,视为不同的组合

例:
//	permutations 考虑到同一序列内的元素之间的排列顺序而combinations只考虑组合序列的内容是否相同,不考虑内容的排列顺序scala> val m = Array(1,2,3)
m: Array[Int] = Array(1, 2, 3)
scala> m.permutations.toList   //排列组合的方式有3*2*1即6种,考虑内容间的排列顺序
res367: List[Array[Int]] = List(Array(1, 2, 3), Array(1, 3, 2), Array(2, 1, 3), Array(2, 3, 1), Array(3, 1, 2), Array(3, 2, 1))scala> m.combinations(3).toList		//combinations将三个元素组合的方式只有一种,只考虑内容相同,忽略排列顺序
res369: List[Array[Int]] = List(Array(1, 2, 3))

prefixLength

定义:def prefixLength(p: (T) ⇒ Boolean): Int
描述:给定一个条件 p,返回第一个符合p条件的序列的长度,如果第一个元素就不满足条件,则直接返回0

例:
scala> c
res370: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.prefixLength(_<3)
res371: Int = 2				//只返回第一个符合条件元素值小于3的序列Array(1,2)的长度,即2

product

定义:def product: A
描述:返回所有元素乘积的值

例:
scala> c
res377: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.product
res378: Int = 20160		//返回所有元素的乘积scala> val f = Array('a',1,2)
f: Array[Int] = Array(97, 1, 2)	//当序列中字符时,会自动隐式转化为asc码
scala> f.product
res382: Int = 194

reduce

定义:def reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1
描述:同 fold,不需要初始值

例:
//reduce 无需提供初始值,直接从左向右将元素两两相加,再将前者的和作为参数和后面的元素相加,依次累加
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.reduce(_+_)
res383: Int = 31//fold 必须提供初始值
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.fold(2)(_+_)    //必须提供一个初始值,类似aggregate语法
res385: Int = 33

reduceLeft

定义:def reduceLeft[B >: A](op: (B, T) ⇒ B): B
描述:同 foldLeft,从左向右计算,不需要初始值

例:
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.reduceLeft(_+_)
res386: Int = 31

reduceRight

定义:def reduceRight[B >: A](op: (B, T) ⇒ B): B
描述:同 foldRight,从右向左计算,不需要初始值

例:
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.reduceRight(_+_)
res387: Int = 31

reduceLeftOption

定义:def reduceLeftOption[B >: A](op: (B, T) ⇒ B): Option[B]
描述:同 reduceLeft,返回 Option

例:
//序列不为空
scala> c.reduceLeftOption(_+_)
res388: Option[Int] = Some(31)	//Some代表Option有值,None代表无值scala> c.reduceLeftOption(_+_).get	//获取的结果与对应的值相匹配
res389: Int = 31//序列为空,返回None
scala> h
res390: Array[Int] = Array()scala> h.reduceLeft
reduceLeft   reduceLeftOptionscala> h.reduceLeftOption(_+_)
res391: Option[Int] = None

reduceRightOption

定义:def reduceRightOption[B >: A](op: (T, B) ⇒ B): Option[B]
描述:同 reduceRight,返回 Option

例:
scala> c.reduceRightOption(_+_)
res393: Option[Int] = Some(31)scala> c.reduceRightOption(_+_).get
res394: Int = 31

reverse

定义:def reverse: Array[T]
描述:反转序列

例:
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.reverse
res395: Array[Int] = Array(4, 3, 7, 5, 2, 4, 3, 2, 1)
scala> println(c.reverse.mkString(","))	//打印数组
4,3,7,5,2,4,3,2,1

iterator

定义:def iterator: collection.Iterator[T]
对序列中的每个元素产生一个 iterator

例:
scala> c
res379: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.iterator.foreach(println)
1
2
3
4
2
5
7
3
4

reverseIterator

定义:def reverseIterator: collection.Iterator[T]
描述:生成反向迭代器

例:
scala> c.reverseIterator.foreach(println)
4
3
7
5
2
4
3
2
1

reverseMap

定义:def reverseMap[B](f: (A) ⇒ B): Array[B]
描述:同 map,序列的顺序倒置

例:
scala> c
res402: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
scala> c.reverseMap(x=> x*2)
res403: Array[Int] = Array(8, 6, 14, 10, 4, 8, 6, 4, 2)
scala> println(res403.mkString(","))	//打印序列
8,6,14,10,4,8,6,4,2

sameElements

定义:def sameElements(that: GenIterable[A]): Boolean
描述:判断两个序列是否顺序和对应位置上的元素都一样,两个序列的长度必须一致,否则结果为false

例:
scala> c
res406: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sameElements(Array(1,2,3))
res407: Boolean = falsescala> c.sameElements(Array(1,2,3,4,2,5,7,3,4))
res408: Boolean = true

scan

定义:def scan[B >: A, That](z: B)(op: (B, B) ⇒ B)(implicit cbf: CanBuildFrom[Array[T], B, That]): That
描述:同 fold,scan 会把每一步的计算结果放到一个新的集合中返回,而 fold 返回的是最后的结果

例:
scala> c
res409: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.scan(2)(_+_)
res410: Array[Int] = Array(2, 3, 5, 8, 12, 14, 19, 26, 29, 33)scala> c.fold(2)(_+_)	//直接返回最终累加的结果,对应scan函数生成的序列的最后一个元素
res411: Int = 33

scanLeft

定义:def scanLeft[B, That](z: B)(op: (B, T) ⇒ B)(implicit bf: CanBuildFrom[Array[T], B, That]): That
描述:同 foldLeft,从左向右计算,每一步的计算结果放到一个新的集合中返回

例:
scala> c.scanLeft(2)(_+_)
res412: Array[Int] = Array(2, 3, 5, 8, 12, 14, 19, 26, 29, 33)

scanRight

定义:def scanRight[B, That](z: B)(op: (T, B) ⇒ B)(implicit bf: CanBuildFrom[Array[T], B, That]): That
描述:同 foldRight,从右向左计算,每一步的计算结果放到(从右向左放)一个新的集合中返回

例:
scala> c.scanRight(2)(_+_)
res413: Array[Int] = Array(33, 32, 30, 27, 23, 21, 16, 9, 6, 2)

segmentLength

定义:def segmentLength(p: (T) ⇒ Boolean, from: Int): Int
描述:从序列的 from 开始向后查找,返回满足条件 p 的连续元素的长度,只返回第一个

例:
scala> c
res414: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.segmentLength(x=>x<4,0) //从索引0开始找小于4的元素,返回组成序列的长度为3
res415: Int = 3scala> c.segmentLength(x=>x<4,1) //从索引1开始找小于4的元素,返回组成序列的长度为2
res416: Int = 2scala> c.segmentLength(x=>x<4,4) //从索引4开始找小于4的元素,返回组成序列的长度为1
res417: Int = 1scala> c.segmentLength(x=>x>1,0) //从索引0开始找大于的元素,返回组成序列的长度为0,即没有符合条件的元素
res418: Int = 0

seq

定义:def seq: collection.mutable.IndexedSeq[T]
描述:产生一个引用当前序列的 sequential 视图

例:
scala> c
res420: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.seq		//将数组转成seq集合
res421: scala.collection.mutable.IndexedSeq[Int] = WrappedArray(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.seq.foreach(println) //遍历打印seq集合
1
2
3
4
2
5
7
3
4

size

定义:def size: Int
描述:返回序列元素个数,同 length

例:
scala> val e = Array(1,2,3)
scala> e.size
res134: Int = 3scala> e.length
res134: Int = 3scala> val k = Array(1,2,3,null,null)
k: Array[Any] = Array(1, 2, 3, null, null)scala> k.size
res135: Int = 5scala> k.length
res136: Int = 5

slice

定义:def slice(from: Int, until: Int): Array[T]
描述:返回当前序列中从 from 到 until 之间的序列,不包括 until 处的元素(左闭右开)

例:
scala> c
res423: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.slice(3,5)
res424: Array[Int] = Array(4, 2)

sliding(size)

定义:def sliding(size: Int): collection.Iterator[Array[T]]
描述:按照顺序从左向右一个一个滑动,从第一个元素开始,每个元素和它后面的 size - 1 个元素组成一个数组(数组长度为3),最终组成一个新的集合返回,当剩余元素个数不够 size 时,则结束

例:
scala> c
res433: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sliding(3).toList
res434: List[Array[Int]] = List(Array(1, 2, 3), Array(2, 3, 4), Array(3, 4, 2), Array(4, 2, 5), Array(2, 5, 7), Array(5, 7, 3), Array(7, 3, 4))

sliding(size, step)

定义:def sliding(size: Int): collection.Iterator[Array[T]]
描述:按照顺序从左向右移动step个滑动,从第一个元素开始,每个元素和它后面的 size - 1 个元素组成一个数组,最终组成一个新的集合返回,当剩余元素个数不够 size 时,剩余的元素组成一组。
该方法可以设置步长 step,每一组元素组合完后,下一组从上一组起始元素位置 + step 后的位置处开始

例:
scala> c
res436: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sliding(3,2).toList
res437: List[Array[Int]] = List(Array(1, 2, 3), Array(3, 4, 2), Array(2, 5, 7), Array(7, 3, 4))

sortBy

定义:def sortBy[B](f: (T) ⇒ B)(implicit ord: math.Ordering[B]): Array[T]
描述:按指定的排序规则对序列排序

例:
//正序
scala> c
res440: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sortBy(x=>x)
res441: Array[Int] = Array(1, 2, 2, 3, 3, 4, 4, 5, 7)//逆序
scala> c.sortBy(x=> -x)
res442: Array[Int] = Array(7, 5, 4, 4, 3, 3, 2, 2, 1)scala> c.sortBy(x=>(-x))
res443: Array[Int] = Array(7, 5, 4, 4, 3, 3, 2, 2, 1)

sortWith

定义:def sortWith(lt: (T, T) ⇒ Boolean): Array[T]
描述:自定义排序方法 对序列排序

例:
scala> val j = Array(3, 2, 1, 1, 2, 3, 1, 2, 3)
j: Array[Int] = Array(3, 2, 1, 1, 2, 3, 1, 2, 3)scala> j.sortWith(_.compareTo(_)>0)  //逆序;元素值大的在前
res427: Array[Int] = Array(3, 3, 3, 2, 2, 2, 1, 1, 1)scala> j.sortWith(_.compareTo(_)<0)	//正序;元素值小的在前
res428: Array[Int] = Array(1, 1, 1, 2, 2, 2, 3, 3, 3)

sorted

定义:def sorted[B >: A](implicit ord: math.Ordering[B]): Array[T]]
描述:使用默认的排序规则对序列排序

例:
scala> c
res444: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sorted
res445: Array[Int] = Array(1, 2, 2, 3, 3, 4, 4, 5, 7)

span

定义:def span(p: (T) ⇒ Boolean): (Array[T], Array[T])
描述:将序列拆分成两个数组,从第一个元素开始,直到第一个不满足条件的元素为止,
其中的元素放到第一个数组,其余的放到第二个数组,返回的是包含这两个数组的元组

例:scala> c
res450: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.span(x=> x<4)
res451: (Array[Int], Array[Int]) = (Array(1, 2, 3),Array(4, 2, 5, 7, 3, 4))

splitAt

定义:def splitAt(n: Int): (Array[T], Array[T])
描述:从指定位置开始,把序列拆分成两个数组(该指定位置的元素划分到第二个数组中)
即以下标分割,并且分割的那个下标包含在右边的数组中

例:scala> c
res460: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.splitAt(3)
res461: (Array[Int], Array[Int]) = (Array(1, 2, 3),Array(4, 2, 5, 7, 3, 4))

startsWith(that)

定义:def startsWith[B](that: GenSeq[B]): Boolean
描述:判断序列是否以某个序列开始

例:
scala> c
res463: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.startsWith(Array(1,2))
res464: Boolean = truescala> c.startsWith(Array(1,3))
res465: Boolean = false

startsWith(that, offset)

定义:def startsWith[B](that: GenSeq[B], offset: Int): Boolean
描述:判断序列从指定偏移处(指定索引的位置)是否以某个序列开始

例:
scala> c
res466: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.startsWith(Array(2,3),1)
res467: Boolean = truescala> c.startsWith(Array(4,2,5),3)
res468: Boolean = truescala> c.startsWith(Array(4,7),3)
res469: Boolean = false

stringPrefix

定义:def stringPrefix: String
描述:返回 toString 结果的前缀

例:
scala> c
res470: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.stringPrefix
res471: String = [I

subSequence

定义:def subSequence(start: Int, end: Int): CharSequence
描述:返回 start 和 end 间的字符序列,不包含 end 处的元素(左闭右开;只适用于字符数组)

例:
scala> val e = Array('a','b','c')
ee: Array[Char] = Array(a, b, c)scala> e.subSequence(1,3)  //只适用于字符数组
res472: CharSequence = bcscala> e.subSequence(1,2)
res473: CharSequence = b

sum

定义:def sum: A
描述:序列求和,元素需为 Numeric[T] 类型;结果同reduce函数调用结果


例:
scala> c
res473: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.sum
res474: Int = 31

tail

定义:def tail: Array[T]
描述:返回当前序列中不包含第一个元素的序列;与init相反,init去除最后一个元素

例:
scala> c
res475: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.tail
res476: Array[Int] = Array(2, 3, 4, 2, 5, 7, 3, 4)

tails

定义:def tails: collection.Iterator[Array[T]]
描述:同 inits,每一步都进行 tail 操作,直到null为止,并返回每一步tail操作的数组,最终返回一个集合

例:
scala> val c = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)
c: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.tails
res0: Iterator[Array[Int]] = non-empty iteratorscala> c.tails.foreach(x=> println(x.mkString(",")))
1,2,3,4,2,5,7,3,4
2,3,4,2,5,7,3,4
3,4,2,5,7,3,4
4,2,5,7,3,4
2,5,7,3,4
5,7,3,4
7,3,4
3,4
4

take

定义:def take(n: Int): Array[T]
描述:返回当前序列中,前 n 个元素组成的序列(默认从左向右返回)

例:
scala> c
res481: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.take(4)
res482: Array[Int] = Array(1, 2, 3, 4)

takeRight

定义:def takeRight(n: Int): Array[T]
描述:返回当前序列中,从右边开始,后 n 个元素组成的序列

例:
scala> c
res483: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.takeRight(4)
res484: Array[Int] = Array(5, 7, 3, 4)//取出中间的元素
scala> e.take(8).takeRight(7)   
res169: Array[Int] = Array(2)
//通用写法取中间元素
scala> e.take(e.size-1).takeRight(e.size-2)   
res170: Array[Int] = Array(2)

takeWhile

定义:def takeWhile(p: (T) ⇒ Boolean): Array[T]
描述:返回当前序列中,从第一个元素开始,满足条件的连续元素组成的序列

例:
scala> c
res485: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.takeWhile(x=> x<4)
res487: Array[Int] = Array(1, 2, 3)

toArray

定义:def toArray: Array[A]
描述:将序列转换成 Array 类型

例:
scala> val k = List(1,2,3)
k: List[Int] = List(1, 2, 3)scala> k.toArray
res527: Array[Int] = Array(1, 2, 3)

toBuffer

定义:def toBuffer[A1 >: A]: Buffer[A1]
描述:将序列转换成 Buffer 类型

例:
scala> val k = List(1,2,3)
k: List[Int] = List(1, 2, 3)
scala> k.toBuffer
res528: scala.collection.mutable.Buffer[Int] = ArrayBuffer(1, 2, 3)  //mutable代表可以改变的Buffer类型的集合

toIndexedSeq

定义:def toIndexedSeq: collection.immutable.IndexedSeq[T]
描述:将序列转换成 IndexedSeq 类型

例:
scala> c
res529: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.toIndexedSeq
res530: scala.collection.immutable.IndexedSeq[Int] = Vector(1, 2, 3, 4, 2, 5, 7, 3, 4)

toIterable

定义:def toIterable: collection.Iterable[T]
描述:将序列转换成可迭代的类型

例:
scala> x
res107: Array[Int] = Array(3, 4, 5, 6)scala> x.toIterable.foreach(println)
3
4
5
6

toIterator

定义:def toIterator: collection.Iterator[T]
描述:将序列转换成迭代器,同 iterator 方法

例:
scala> c
res534: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.toIterator
res535: Iterator[Int] = non-empty iterator

toList

定义:def toList: List[T]
描述:将序列转换成 List 类型

例:
scala> c
res536: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.toList
res537: List[Int] = List(1, 2, 3, 4, 2, 5, 7, 3, 4)

toMap

定义:def toMap[T, U]: Map[T, U]
描述:将序列转转换成 Map 类型,需要被转化序列中包含的元素是 Tuple2(元祖,最对支持22个) 类型

例:
scala> e
res8: Array[Int] = Array(1, 2, 3, 4, 5)scala> e.map((_,1))			//通过map遍历操作,将每个元素与1组成一个个元祖(最对支持22个),并转成map
res9: Array[(Int, Int)] = Array((1,1), (2,1), (3,1), (4,1), (5,1))	scala> e.map((_,1)).toMap
res10: scala.collection.immutable.Map[Int,Int] = Map(5 -> 1, 1 -> 1, 2 -> 1, 3 -> 1, 4 -> 1)

132.toSeq
定义:def toSeq: collection.Seq[T]
描述:将序列转换成 Seq 类型(元素有序)

例:
scala> c
res541: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.toSeq
res542: Seq[Int] = WrappedArray(1, 2, 3, 4, 2, 5, 7, 3, 4)

toSet

定义:def toSet[B >: A]: Set[B]
描述:将序列转换成 Set 类型

例:
scala> c
res543: Array[Int] = Array(1, 2, 3, 4, 2, 5, 7, 3, 4)scala> c.toSet
res544: scala.collection.immutable.Set[Int] = Set(5, 1, 2, 7, 3, 4)  //set去除重复的元素,且是无序的

toStream

定义:def toStream: collection.immutable.Stream[T]
描述:将序列转换成 Stream 类型

例:
scala> h
res117: Array[Int] = Array(1, 2, 3, 4, 5)scala> h.toStream
res118: scala.collection.immutable.Stream[Int] = Stream(1, ?) //类似于懒匹配,通俗来说就是你要取的时候,我才给你返回scala> h.toStream.toStream(1)
res119: Int = 2scala> h.toStream.toStream(2)
res120: Int = 3

toVector

定义:def toVector: Vector[T]
描述:将序列转换成 Vector 类型

transpose

定义:def transpose[U](implicit asArray: (T) ⇒ Array[U]): Array[Array[U]]
描述:矩阵转置,二维数组行列转换

1:每个一维数组中的元素个数相同
scala> val t = Array(Array(1,2,3),Array(4,5,6),Array(7,8,9))
//打印结果
scala> t.foreach(x=> println(x.mkString(",")))
1,2,3
4,5,6
7,8,9//转置:
scala> t.transpose
res124: Array[Array[Int]] = Array(Array(1, 4, 7), Array(2, 5, 8), Array(3, 6, 9))
//打印结果
scala> t.transpose.foreach(x=> println(x.mkString(",")))
1,4,7
2,5,8
3,6,92:一维数组中的元素个数不同(在二维数组的第一个一维数组的个数大于其他一维数组个数的前提下,是可以转置的)
scala> val t = Array(Array(1,2,3),Array(4,5),Array(7,8,9))
t: Array[Array[Int]] = Array(Array(1, 2, 3), Array(4, 5), Array(7, 8, 9))scala> t.foreach(x=> println(x.mkString(",")))
1,2,3
4,5
7,8,9scala> t.transpose
res137: Array[Array[Int]] = Array(Array(1, 4, 7), Array(2, 5, 8), Array(3, 9))scala> t.transpose.foreach(x=> println(x.mkString(",")))
1,4,7
2,5,8
3,9

union

定义:def union(that: collection.Seq[T]): Array[T]
描述:合并两个序列,功能同 ++

例:
scala> val v = Array(1,2,3)
v: Array[Int] = Array(1, 2, 3)scala> val b = Array(4,5,6)
b: Array[Int] = Array(4, 5, 6)scala> v.union(b)
res131: Array[Int] = Array(1, 2, 3, 4, 5, 6)

unzip

(类似transpose)
定义:def unzip[T1, T2](implicit asPair: (T) ⇒ (T1, T2), ct1: ClassTag[T1], ct2: ClassTag[T2]): (Array[T1], Array[T2])
描述:将含有两个二元组的数组,每个元组的第一个元素组成一个数组,第二个元素组成一个数组,返回包含这两个数组的元组

例:
//情况1:
scala> val v = Array(("a","b"),(1,2))
v: Array[(Any, Any)] = Array((a,b), (1,2))
scala> v.unzip
res140: (Array[Any], Array[Any]) = (Array(a, 1),Array(b, 2))scala> val v = Array(("a","b"),(1,2),(7,8))
v: Array[(Any, Any)] = Array((a,b), (1,2), (7,8))
scala> v.unzip
res141: (Array[Any], Array[Any]) = (Array(a, 1, 7),Array(b, 2, 8))//情况2:(与transpose不同的是,元祖内的元素个数不同,调用该函数会报错)
scala> val v = Array(("a","b"),(1,2),(7))
v: Array[Any] = Array((a,b), (1,2), 7)scala> v.unzip
<console>:16: error: No implicit view available from Any => (T1, T2).v.unzipscala> val v = Array(("a"),(1),(7))
v: Array[Any] = Array(a, 1, 7)scala> v.unzip
<console>:16: error: No implicit view available from Any => (T1, T2).v.unzip#补充:元祖的元素个数最大允许为22个
scala> val m = (1,2,3,4,"a",3,4,7,56,53,1,3,4,3,4,3,7,8,5,4,3,3,5)
<console>:1: error: too many elements for tuple: 23, allowed: 22
val m = (1,2,3,4,"a",3,4,7,56,53,1,3,4,3,4,3,7,8,5,4,3,3,5)

unzip3

定义:def unzip3[T1, T2, T3](implicit asTriple: (T) ⇒ (T1, T2, T3), ct1: ClassTag[T1], ct2: ClassTag[T2], ct3: ClassTag[T3]): (Array[T1], Array[T2], Array[T3])
描述:将含有三个三元组的数组,每个元组的第一个元素组成一个数组,第二个元素组成一个数组,第三个元素组成一个数组,返回包含这三个数组的元组

例:
scala> val v = Array(("a","b","c"),(1,2,3),(7,8,9))
v: Array[(Any, Any, Any)] = Array((a,b,c), (1,2,3), (7,8,9))scala> v.unzip3
res144: (Array[Any], Array[Any], Array[Any]) = (Array(a, 1, 7),Array(b, 2, 8),Array(c, 3, 9))

update

定义:def update(i: Int, x: T): Unit
描述:将序列中 i 索引处的元素更新为 x

例:
scala> val a = Array(1,2,3,4,5)
a: Array[Int] = Array(1, 2, 3, 4, 5)scala> a.update(2,100)
scala> a
res158: Array[Int] = Array(1, 2, 100, 4, 5) //完全修改了a数组的原值//update功能等同于 a(2)=100

updated

定义:def updated(index: Int, elem: A): Array[A]
描述:将序列中 i 索引处的元素更新为 x,并返回替换后的数组

例:
scala> a
res159: Array[Int] = Array(1, 2, 100, 4, 5)scala> a.updated(2,3)
res160: Array[Int] = Array(1, 2, 3, 4, 5)scala> a
res161: Array[Int] = Array(1, 2, 100, 4, 5)  
//与update不同的是,updated并没有修改掉数组a的原值,返回的是相当于修改后的a的一个副本

view

定义:def view(from: Int, until: Int): IndexedSeqView[T, Array[T]]
描述:返回当前序列中从 from 到 until 之间的序列,不包括 until 处的元素(左闭右开)

例:
scala> a
res162: Array[Int] = Array(1, 2, 100, 4, 5)scala> a.view(1,3)
res163: scala.collection.mutable.IndexedSeqView[Int,Array[Int]] = SeqViewS(...)scala> a.view(1,3).toArray
res164: Array[Int] = Array(2, 100)

withFilter

定义:def withFilter(p: (T) ⇒ Boolean): FilterMonadic[T, Array[T]]
描述:根据条件 p 过滤元素

例:
scala> a
res165: Array[Int] = Array(1, 2, 100, 4, 5)scala> a.withFilter(_>3).map(x=>x)
res168: Array[Int] = Array(100, 4, 5)

zip

定义:def zip[B](that: GenIterable[B]): Array[(A, B)]
描述:将两个序列对应位置上的元素组成一个元组数组,两个序列长度必须相同

例:
scala> a
res169: Array[Int] = Array(1, 2, 100, 4)scala> val b = Array(3,5,7,9)
b: Array[Int] = Array(3, 5, 7, 9)scala> a.zip(b)
res170: Array[(Int, Int)] = Array((1,3), (2,5), (100,7), (4,9))

zipAll

定义:def zipAll[B](that: collection.Iterable[B], thisElem: A, thatElem: B): Array[(A, B)]
描述:同 zip ,但是允许两个序列长度不同,不足的自动填充,如果当前序列短,不足的元素填充为 thisElem,如果 that 序列短,填充为 thatElem

例:
scala> a
res169: Array[Int] = Array(1, 2, 100, 4, 5)
scala> val b = Array(3,5)
b: Array[Int] = Array(3, 5)scala> a.zipAll(b,0,1)
res172: Array[(Int, Int)] = Array((1,3), (2,5), (100,1), (4,1), (5,1))

zipWithIndex

定义:def zipWithIndex: Array[(A, Int)]
描述:序列中的每个元素和它的索引组成一个元组数组

例:
scala> a
res173: Array[Int] = Array(1, 2, 100, 4, 5)scala> a.zipWithIndex
res174: Array[(Int, Int)] = Array((1,0), (2,1), (100,2), (4,3), (5,4))
查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 预测GDP应用:Numpy 线性回归+Matplotlib 作图

    预测GDP应用&#xff1a;Numpy 线性回归Matplotlib 作图 需求 通过2000&#xff5e;2019年中美两国的GDP数据&#xff0c;预测后续几年GDP的发展趋势&#xff1a; 读取.csv文件&#xff0c;并将字符串调整为浮点型进行二阶线性回归模拟支持数据可视化保命声明&#xff1a;用…...

    2024/4/3 20:13:51
  2. 多因素登录工具

    多因素登录工具 推荐两个工具&#xff0c;一个是微软 Authenticator&#xff0c;另一个是谷歌 Authenticator。 谷歌认证器5.1&#xff08;Google Authenticator&#xff09; 从天翼云盘下载&#xff1a;https://cloud.189.cn/t/aU7zmiM7Nzma 访问码&#xff1a;3blc 微软认…...

    2024/4/14 0:31:18
  3. pom.xml中可配置化使用两个同级别的jar包

    1、一个pom中&#xff0c;在不同的环境中使用不同的两个同级别包&#xff0c;可以使用下面的方式进行。 <profiles><profile><id>areaA</id><activation><property><name>repoVersion</name><value>areaA</value>…...

    2024/4/21 20:46:47
  4. thymeleaf中th:text和th:utext的区别

    text不会解析html utext会解析html...

    2024/4/1 17:28:30
  5. Spring AOP使用:自定义注解、通知(简单使用和原理了解)

    后续我会陆陆续续更新Spring的一些介绍、应用、以及原理的文档。大家如果觉得对自己有用就点个关注吧。 文中描述如有问题&#xff0c;欢迎留言指证。 引言 本文中的例子我尽量写的简单&#xff0c;避免一些我平时查资料时一些例子中出现的大量无用代码&#xff0c;产生让人阅读…...

    2024/4/1 17:28:28
  6. linux环境编程-进程控制

    前面文章我们介绍了PCB&#xff08;进程控制块&#xff09;&#xff0c;进程和并发的概念&#xff0c;今天我们来介绍一下进程的控制原语&#xff08;说白了就是怎么用进程&#xff09; 在介绍之前我们先来个视频了解一下博主&#xff1a; 白嫖者vsup主好&#xff0c;和大家认…...

    2024/4/1 5:46:21
  7. MyBatis源码剖析(1)配置文件的加载

    自此开启MyBatis源码分析&#xff0c;理解大神的架构&#xff0c;写在开头&#xff0c;以此纪念&#xff0c;2020年9月12日08:53:34 一、MyBatis的简单使用 1. 配置文件 主配置文件mybatis_config.xml以及从配置文件db.properties&#xff0c;其中db.properties为数据连接的…...

    2024/4/20 13:45:04
  8. 前端进阶攻略之ES6中反射和代理

    前端进阶攻略之ES6中反射和代理 在学习ES6中反射和代理之前&#xff0c;先要明白属性描述符和存储器属性的原理&#xff0c;然后理解反射和代理的原理就会非常的简单。 一.属性描述符 在ES5之前&#xff0c;JavaScript语言本身并没有提供可以直接检测属性特性的方法&#xff…...

    2024/4/17 2:00:47
  9. 字节流字节数组复制文本文件案例

    package cn.itcast_02;import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException;/** * 需求&#xff1a;C:\\a.txt内容复制到D:\\b.txt中* * 数据源&#xff1a;* C:\\a.txt---读取数据---FileInputStream* 目的地&#xff1b;* …...

    2024/4/24 1:00:35
  10. P2882 [USACO07MAR]Face The Right Way G 【贪心 + 差分】

    题目描述 Farmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facing backward, though, and he needs them all to face forward to make his life perfect. Fortunately, FJ recentl…...

    2024/4/28 5:31:38
  11. 21小红书真题

    21小红书真题...

    2024/4/29 0:42:01
  12. 2020-9-12

    //严蔚敏《数据结构》的ADT和算法的C实现 //链式线性表的一些算法实现 #include<iostream> using namespace std; #define ElemType double typedef struct Lnode//线性表的存储结构之一&#xff08;链式存储结构&#xff09; {ElemType data;struct Lnode* next; }LNode…...

    2024/4/1 17:18:47
  13. 栈入门

    https://www.csdn.net/gather_25/MtTakg1sNjE0OTAtYmxvZwO0O0OO0O0O.html栈入门 0x10相关知识 0x11寄存器 32位x86架构下的寄存器可以被简单的分为通用寄存器和特殊寄存器&#xff0c;通用寄存器在大部分汇编指令下是可以任意使用的&#xff0c;而特殊寄存器只能被特定的汇编…...

    2024/4/17 5:50:48
  14. 成功解决Adams与MATLAB交互时Adams model file does not exist问题

    Content4 The ADAMS/Control environment5 Interfacing ADAMS with MATLAB错误提示检查路径问题&#xff0c;在Matlab Simulink仿真时找不到相应的Adams文件是因为当前MATLAB 路径没有在保存Adams文件的路径里面。 4 The ADAMS/Control environment First,I follow TP1_AMORO…...

    2024/4/1 4:53:29
  15. VSCode插件安装完成后的配置二

    VSCode插件安装完成后的配置二 该配置适合喜欢使用单引号的用户&#xff0c;该配置使用后ctrls将没有以前自动格式化的效果&#xff0c;但当你使用shiftaltd时会实现配置里的效果&#xff0c;优先使用单引号&#xff0c;而不是像配置一那样变为双引号其他效果跟上个配置一样。…...

    2024/4/28 12:30:29
  16. Leecode-29. 两数相除(超详细,Java提交中速度超过100%)

    题目描述 给定两个整数&#xff0c;被除数 dividend 和除数 divisor。将两数相除&#xff0c;要求不使用乘法、除法和 mod 运算符。 返回被除数 dividend 除以除数 divisor 得到的商。 整数除法的结果应当截去&#xff08;truncate&#xff09;其小数部分&#xff0c;例如&a…...

    2024/4/29 7:12:01
  17. 【新版】2020微软AZ-104上线|AZ-103停用|Azure系统管理员认证已更新

    2020微软AZ-104上线|AZ-103停用 更多视频请见B站&#xff08;同名&#xff09;...

    2024/4/6 5:52:26
  18. AcWing 95. 费解的开关

    题意&#xff1a; 给定一个5X5的灯阵&#xff0c;1表示灯亮着&#xff0c;0表示灯灭了&#xff0c;每次操作可以选择一盏灯并改变他的状态和他周围灯的状态&#xff08;周围&#xff1a;上下左右&#xff09;然后问你最少多少次能够使所有灯都变成亮着的状态&#xff0c;如果次…...

    2024/4/1 17:18:40
  19. Chrome浏览器打开Axure设置

    如果你在用浏览器打开Axure时&#xff0c;出现下图界面&#xff0c;那请继续往下阅读&#xff0c;帮你解决问题~ 如下图步骤操作&#xff0c;清晰明了解决问题 步骤一 步骤二 步骤三 先下载&#xff0c;把解压后的文件夹放在Axure根目录下&#xff0c;然后如图操作。 插件…...

    2024/4/30 5:45:05
  20. BinaryTree二叉树

    一 algorithm算法 在这里插入代码片package MyBinaryTree;public class MyBinaryTree<T extends Comparable> {private Node root;private int count;private Object[] arrayData;private int index;public void add(Comparable<T> data) {if(null data) {throw …...

    2024/5/3 5:54:23

最新文章

  1. ubuntu修改/etc/resolve.conf总是被重置

    ubuntu修改/etc/resolve.conf总是被重置 其实处理来很简单&#xff0c;根据英文提示删除/etc/resolve.conf,那是一个软链接&#xff0c;重新创建/etc/resolve.conf rm /etc/resolve.conf vi /etc/resolve.conf 添加nameserver 223.5.5.5...

    2024/5/3 23:26:28
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 2024免费Mac苹果解压压缩包软件BetterZip5

    在2024年&#xff0c;对于Mac电脑用户来说&#xff0c;如果你想要无需解压就能快速查看压缩文档的内容&#xff0c;BetterZip是一个极佳的选择。这款软件不仅支持多种格式的压缩和解压&#xff0c;如zip、rar、7z、tar等&#xff0c;还具备丰富的功能和设置&#xff0c;包括预览…...

    2024/5/2 2:34:06
  4. C#,简单,精巧,实用的文件夹时间整理工具FolderTime

    点击下载本文软件&#xff08;5积分&#xff09;&#xff1a; https://download.csdn.net/download/beijinghorn/89071073https://download.csdn.net/download/beijinghorn/89071073 百度网盘&#xff08;不需积分&#xff09;&#xff1a; https://pan.baidu.com/s/1FwCsSz…...

    2024/5/1 13:50:22
  5. 416. 分割等和子集问题(动态规划)

    题目 题解 class Solution:def canPartition(self, nums: List[int]) -> bool:# badcaseif not nums:return True# 不能被2整除if sum(nums) % 2 ! 0:return False# 状态定义&#xff1a;dp[i][j]表示当背包容量为j&#xff0c;用前i个物品是否正好可以将背包填满&#xff…...

    2024/5/3 11:50:27
  6. 【Java】ExcelWriter自适应宽度工具类(支持中文)

    工具类 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;/*** Excel工具类** author xiaoming* date 2023/11/17 10:40*/ public class ExcelUti…...

    2024/5/2 16:04:58
  7. Spring cloud负载均衡@LoadBalanced LoadBalancerClient

    LoadBalance vs Ribbon 由于Spring cloud2020之后移除了Ribbon&#xff0c;直接使用Spring Cloud LoadBalancer作为客户端负载均衡组件&#xff0c;我们讨论Spring负载均衡以Spring Cloud2020之后版本为主&#xff0c;学习Spring Cloud LoadBalance&#xff0c;暂不讨论Ribbon…...

    2024/5/2 23:55:17
  8. TSINGSEE青犀AI智能分析+视频监控工业园区周界安全防范方案

    一、背景需求分析 在工业产业园、化工园或生产制造园区中&#xff0c;周界防范意义重大&#xff0c;对园区的安全起到重要的作用。常规的安防方式是采用人员巡查&#xff0c;人力投入成本大而且效率低。周界一旦被破坏或入侵&#xff0c;会影响园区人员和资产安全&#xff0c;…...

    2024/5/3 16:00:51
  9. VB.net WebBrowser网页元素抓取分析方法

    在用WebBrowser编程实现网页操作自动化时&#xff0c;常要分析网页Html&#xff0c;例如网页在加载数据时&#xff0c;常会显示“系统处理中&#xff0c;请稍候..”&#xff0c;我们需要在数据加载完成后才能继续下一步操作&#xff0c;如何抓取这个信息的网页html元素变化&…...

    2024/5/3 11:10:49
  10. 【Objective-C】Objective-C汇总

    方法定义 参考&#xff1a;https://www.yiibai.com/objective_c/objective_c_functions.html Objective-C编程语言中方法定义的一般形式如下 - (return_type) method_name:( argumentType1 )argumentName1 joiningArgument2:( argumentType2 )argumentName2 ... joiningArgu…...

    2024/5/3 21:22:01
  11. 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】

    &#x1f468;‍&#x1f4bb;博客主页&#xff1a;花无缺 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! 本文由 花无缺 原创 收录于专栏 【洛谷算法题】 文章目录 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】&#x1f30f;题目描述&#x1f30f;输入格…...

    2024/5/3 23:17:01
  12. 【ES6.0】- 扩展运算符(...)

    【ES6.0】- 扩展运算符... 文章目录 【ES6.0】- 扩展运算符...一、概述二、拷贝数组对象三、合并操作四、参数传递五、数组去重六、字符串转字符数组七、NodeList转数组八、解构变量九、打印日志十、总结 一、概述 **扩展运算符(...)**允许一个表达式在期望多个参数&#xff0…...

    2024/5/2 23:47:43
  13. 摩根看好的前智能硬件头部品牌双11交易数据极度异常!——是模式创新还是饮鸩止渴?

    文 | 螳螂观察 作者 | 李燃 双11狂欢已落下帷幕&#xff0c;各大品牌纷纷晒出优异的成绩单&#xff0c;摩根士丹利投资的智能硬件头部品牌凯迪仕也不例外。然而有爆料称&#xff0c;在自媒体平台发布霸榜各大榜单喜讯的凯迪仕智能锁&#xff0c;多个平台数据都表现出极度异常…...

    2024/5/3 13:26:06
  14. Go语言常用命令详解(二)

    文章目录 前言常用命令go bug示例参数说明 go doc示例参数说明 go env示例 go fix示例 go fmt示例 go generate示例 总结写在最后 前言 接着上一篇继续介绍Go语言的常用命令 常用命令 以下是一些常用的Go命令&#xff0c;这些命令可以帮助您在Go开发中进行编译、测试、运行和…...

    2024/5/3 1:55:15
  15. 用欧拉路径判断图同构推出reverse合法性:1116T4

    http://cplusoj.com/d/senior/p/SS231116D 假设我们要把 a a a 变成 b b b&#xff0c;我们在 a i a_i ai​ 和 a i 1 a_{i1} ai1​ 之间连边&#xff0c; b b b 同理&#xff0c;则 a a a 能变成 b b b 的充要条件是两图 A , B A,B A,B 同构。 必要性显然&#xff0…...

    2024/5/2 9:47:28
  16. 【NGINX--1】基础知识

    1、在 Debian/Ubuntu 上安装 NGINX 在 Debian 或 Ubuntu 机器上安装 NGINX 开源版。 更新已配置源的软件包信息&#xff0c;并安装一些有助于配置官方 NGINX 软件包仓库的软件包&#xff1a; apt-get update apt install -y curl gnupg2 ca-certificates lsb-release debian-…...

    2024/5/3 16:23:03
  17. Hive默认分割符、存储格式与数据压缩

    目录 1、Hive默认分割符2、Hive存储格式3、Hive数据压缩 1、Hive默认分割符 Hive创建表时指定的行受限&#xff08;ROW FORMAT&#xff09;配置标准HQL为&#xff1a; ... ROW FORMAT DELIMITED FIELDS TERMINATED BY \u0001 COLLECTION ITEMS TERMINATED BY , MAP KEYS TERMI…...

    2024/5/3 1:55:09
  18. 【论文阅读】MAG:一种用于航天器遥测数据中有效异常检测的新方法

    文章目录 摘要1 引言2 问题描述3 拟议框架4 所提出方法的细节A.数据预处理B.变量相关分析C.MAG模型D.异常分数 5 实验A.数据集和性能指标B.实验设置与平台C.结果和比较 6 结论 摘要 异常检测是保证航天器稳定性的关键。在航天器运行过程中&#xff0c;传感器和控制器产生大量周…...

    2024/5/2 8:37:00
  19. --max-old-space-size=8192报错

    vue项目运行时&#xff0c;如果经常运行慢&#xff0c;崩溃停止服务&#xff0c;报如下错误 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 因为在 Node 中&#xff0c;通过JavaScript使用内存时只能使用部分内存&#xff08;64位系统&…...

    2024/5/3 14:57:24
  20. 基于深度学习的恶意软件检测

    恶意软件是指恶意软件犯罪者用来感染个人计算机或整个组织的网络的软件。 它利用目标系统漏洞&#xff0c;例如可以被劫持的合法软件&#xff08;例如浏览器或 Web 应用程序插件&#xff09;中的错误。 恶意软件渗透可能会造成灾难性的后果&#xff0c;包括数据被盗、勒索或网…...

    2024/5/2 9:47:25
  21. JS原型对象prototype

    让我简单的为大家介绍一下原型对象prototype吧&#xff01; 使用原型实现方法共享 1.构造函数通过原型分配的函数是所有对象所 共享的。 2.JavaScript 规定&#xff0c;每一个构造函数都有一个 prototype 属性&#xff0c;指向另一个对象&#xff0c;所以我们也称为原型对象…...

    2024/5/2 23:47:16
  22. C++中只能有一个实例的单例类

    C中只能有一个实例的单例类 前面讨论的 President 类很不错&#xff0c;但存在一个缺陷&#xff1a;无法禁止通过实例化多个对象来创建多名总统&#xff1a; President One, Two, Three; 由于复制构造函数是私有的&#xff0c;其中每个对象都是不可复制的&#xff0c;但您的目…...

    2024/5/3 22:03:11
  23. python django 小程序图书借阅源码

    开发工具&#xff1a; PyCharm&#xff0c;mysql5.7&#xff0c;微信开发者工具 技术说明&#xff1a; python django html 小程序 功能介绍&#xff1a; 用户端&#xff1a; 登录注册&#xff08;含授权登录&#xff09; 首页显示搜索图书&#xff0c;轮播图&#xff0…...

    2024/5/3 7:43:42
  24. 电子学会C/C++编程等级考试2022年03月(一级)真题解析

    C/C++等级考试(1~8级)全部真题・点这里 第1题:双精度浮点数的输入输出 输入一个双精度浮点数,保留8位小数,输出这个浮点数。 时间限制:1000 内存限制:65536输入 只有一行,一个双精度浮点数。输出 一行,保留8位小数的浮点数。样例输入 3.1415926535798932样例输出 3.1…...

    2024/5/3 1:54:59
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57