Scala Array函数整理

Array

  • Scala 语言中提供的数组是用来存储固定大小的同类型元素。
  • 若长度固定则使用Array,若长度可能有变化则使用ArrayBuffer;如果你需要在 Array 和 ArrayBuffer 之间转换,那么分别调用 toBuffer()和 toArray()方法即可。

一、声明数组

        scala中Array声明格式如下:

var a:Array[String] = new Array[String](3)

var b = Array[Int](3)

二、定义数组

var arr = Array('a','b','c')

        在数组中我们可以通过索引来访问每个元素(下标从0开始

scala> arr(0)
res0: Int = 1

三、函数整理

下面列出Array中的所有函数:

!=              distinct          indices              prefixLength        take
##              drop              init                 product             takeRight
+               dropRight         inits                reduce              takeWhile
++              dropWhile         intersect            reduceLeft          to
++:             elemManifest      isDefinedAt          reduceLeftOption    toArray
+:              elemTag           isEmpty              reduceOption        toBuffer
->              endsWith          isInstanceOf         reduceRight         toIndexedSeq
/:              ensuring          isTraversableAgain   reduceRightOption   toIterable
:+              eq                iterator             repr                toIterator
:\              equals            last                 reverse             toList
==              exists            lastIndexOf          reverseIterator     toMap
addString       filter            lastIndexOfSlice     reverseMap          toSeq
aggregate       filterNot         lastIndexWhere       runWith             toSet
andThen         find              lastOption           sameElements        toStream
apply           flatMap           length               scan                toString
applyOrElse     flatten           lengthCompare        scanLeft            toTraversable
array           fold              lift                 scanRight           toVector
asInstanceOf    foldLeft          map                  segmentLength       transform
canEqual        foldRight         max                  seq                 transpose
clone           forall            maxBy                size                union
collect         foreach           min                  slice               unzip
collectFirst    formatted         minBy                sliding             unzip3
combinations    genericBuilder    mkString             sortBy              update
companion       getClass          ne                   sortWith            updated
compose         groupBy           nonEmpty             sorted              view
contains        grouped           notify               span                wait
containsSlice   hasDefiniteSize   notifyAll            splitAt             withFilter
copyToArray     hashCode          orElse               startsWith          zip
copyToBuffer    head              padTo                stringPrefix        zipAll
corresponds     headOption        par                  sum                 zipWithIndex
count           indexOf           partition            synchronized        →
deep            indexOfSlice      patch                tail
diff            indexWhere        permutations         tails

下面我们通过使用函数来体验下它们的用法:

!=

        比较两个数组的地址是否一致,不一致则为true;

scala> var a1 = Array(1,2,3)
a1: Array[Int] = Array(1, 2, 3)

scala> var a2 = a1.clone
a2: Array[Int] = Array(1, 2, 3)

scala> a1 != a2
res3: Boolean = true

++

        将两个数组合并为一个新数组,新数组包含两个数组的所有元素;

scala> var a1 = Array(1,2,3)
a1: Array[Int] = Array(1, 2, 3)

scala> var a2 = Array("curry","paul","jack")
a2: Array[String] = Array(curry, paul, jack)

scala> a1 ++ a2
res12: Array[Any] = Array(1, 2, 3, curry, paul, jack)

++:

        与++类似,但是右边的数组类型决定了最终返回数组的类型

scala> var a1:Array[Byte] = Array(1,2,3)
a1: Array[Byte] = Array(1, 2, 3)

scala> var a2:Array[Int] = Array(1,2,3)
a2: Array[Int] = Array(1, 2, 3)

scala> a1 ++:a2
res17: Array[AnyVal] = Array(1, 2, 3, 1, 2, 3)

+:

        在数组头部追加元素并返回一个新的数组

scala> a2
res18: Array[Int] = Array(1, 2, 3)

scala> 4+:a2
res19: Array[Int] = Array(4, 1, 2, 3)

/:

        从左向右对元素使用相同的操作(返回类型和数组内元素类型一致,过期用foldLeft代替);

scala> a2
res18: Array[Int] = Array(1, 2, 3)

scala> (10/:a2)(_+_)
<console>:13: warning: method /: in trait TraversableOnce is deprecated (since 2.12.10): Use foldLeft instead of /:
       (10/:a2)(_+_)
          ^
res22: Int = 16

:\

        逆序对数组中的元素采用相同的操作(返回类型和数组内元素类型一致,过期用foldRight代替);

scala> a2
res18: Array[Int] = Array(1, 2, 3)

scala> (a2:\10)(_+_)
<console>:13: warning: method :\ in trait TraversableOnce is deprecated (since 2.12.10): Use foldRight instead of :\
       (a2:\10)(_+_)
          ^
res24: Int = 16

==

        比较两个数组的地址是否一致,一致为true,否则false;与!=相反;


addString

        将数组拼接为字符串;

import scala.collection.mutable.StringBuilder
	var builder =new mutable.StringBuilder()
	var a1 = Array.range(1,10)
	a1.addString(builder,"[",",","]")
	println(builder)
[1,2,3,4,5,6,7,8,9]

aggregate

        聚合计算,aggregate 是柯里化方法,参数是两个方法

  • arr.aggregate(initValue)(mapCal,reduceCal)
    • map端聚合mapCal生效,不走reduce端reduceCal失效
  • arr.par.aggregate(initValue)(mapCal,reduceCal)
    • par产生分区,mapCal->reduceCal
val add = (x:Int,y:Int) => {
	var z = x+y
	println(s"$x + $y = $z")
	z
}

val red = (x:Int,y:Int) =>{
	var z = x-y
	println(s"$x -$y = $z")
	z
}

var lst = new ListBuffer[Int]
for (elem <- 1 to 8) {
	lst.append(Random.nextInt(30))
}
println(lst.aggregate(0)(add, red))
println("-------------------")
println(lst.par.aggregate(0)(add, red))
0 + 13 = 13
13 + 22 = 35
35 + 28 = 63
63 + 23 = 86
86 + 18 = 104
104 + 26 = 130
130 + 26 = 156
156 + 5 = 161
161
-------------------
0 + 26 = 26
0 + 13 = 13
0 + 23 = 23
0 + 28 = 28
0 + 22 = 22
0 + 5 = 5
13 -22 = -9
0 + 18 = 18
0 + 26 = 26
28 -23 = 5
26 -5 = 21
-9 -5 = -14
18 -26 = -8
-8 -21 = -29
-14 --29 = 15
15

andThen

        def f = f1 andThen f2     =>    先调用f1,再调用f2

        f1和f2只有【一个参数】且类型相同,f1的输出为f2的输入

a.addThen(x=>{}) => PartialFunction[Int,c] 

a.andThen(x=>if(x%2==0) x})(0) =>如果下标0位为偶数则输出该数,否则Unit:()
val add = (x:Int) => {
  var z = x+7
  println(s"$x + 7 = $z")
  z
}

val minus=(x:Int) =>{
  var z = x-3
  println(s"$x - 3 = $z")
  z
}

def am = add  andThen  minus

println(am(3))
3 + 7 = 10
10 - 3 = 7
7

apply

        根据索引取元素;

  • T t = arr.apply(index)
var a = Array(1,2,3,10,13,21);
println(a.apply(2))
3

applyOrElse

        T t = a.applyOrElse(index,{item:Int=>DEFAULT VALUE})

  • 根据下标取数据元素,如果越界,则返回默认值
  • 第二个参数为偏函数
var a = Array(1,2,3,10,13,21);
println(a.applyOrElse(20,{ i:Int => "NONE" }))
println(a.applyOrElse(0,{ i: Int => "NONE"}))	
NONE
1

canEqual

        两个集合之间是否可以比较(地址一致比较的用equals.元素比较是否一致用sameElements);

scala> a1
res25: Array[Byte] = Array(1, 2, 3)

scala> a2
res26: Array[Int] = Array(1, 2, 3)

scala> a1.canEqual(a2)
res27: Boolean = true

charAt(index)

        根据索引取字符,只能用于字符数组

scala> var a3 = Array('a','b','c','d')
a3: Array[Char] = Array(a, b, c, d)

scala> a3.charAt(2)
res5: Char = c

clone

        【浅克隆】一个数组的副本

  • 若数组的类型为AnyRef,则副本中存储的是对象引用
var a1 = Array.range(1,5)
var a2 = a1.clone

collect

        a1.collect(PartialFunction)      =>    返回类型为Array

var arr = Array(11,35,9,22,3,16,18,21,36)
arr.collect({case i if (i%2==0)=>i}).foreach(println)
22
16
18
36

collectFirst

        a1.collectFirst(PartialFunction)      =>    返回类型为Option

var arr = Array(11,35,9,22,3,16,18,21,36)
arr.collectFirst({case i if(i%2==0)=>i}).foreach(println)
22

combinations

        排序组合,不考虑顺序;

var a3 = Array('a','b','c')
a3.combinations(2).foreach(x={x.foreach(print);println()})
ab
ac
bc

compose

        def f = f1 andThen f2 先调用f2,在调用f1

val add = (x:Int) => {
  var z = x+7
  println(s"$x + 7 = $z")
  z
}

val minus=(x:Int) =>{
  var z = x-3
  println(s"$x - 3 = $z")
  z
}

def mcm = add compose mul
println(mcm(2))
3 - 3 = 0
0 + 7 = 7
7

contains(n)

        判断集合中是否包含元素n

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
scala> arr.contains(20)
res7: Boolean = false

containsSlice(GenSeq)

        判断判断序列中是否包含子序列,子序列必须【有序】的【连续】的出现才返回true;

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.containsSlice(Array(5,6,7))
res8: Boolean = true

copyToArray

        copyToArray(Array[,destStartPos[,destLen]])      =>     将数组中的元素从开始下标位置开始将数量为目标长度的元素全部拷贝至目标数组,长度参数不加默认将开始位置后的全部元素拷贝至目标数组;

scala> val a = Array('a','c','e')
a: Array[Char] = Array(a, c, e)	

scala> val b:Array[Char] = new Array(5)
b: Array[Char] = Array(?, ?, ?, ?, ?)

scala> a.copyToArray(b)

scala> b
res15: Array[Char] = Array(a, c, e, ?, ?)

scala> val b:Array[Char] = new Array(5)
b: Array[Char] = Array(?, ?, ?, ?, ?)

scala> a.copyToArray(b,2)

scala> b
res24: Array[Char] = Array(?, ?, a, c, e)

scala> val b:Array[Char] = new Array(5)
b: Array[Char] = Array(?, ?, ?, ?, ?)

scala> a.copyToArray(b,2,1)

scala> b
res26: Array[Char] = Array(?, ?, a, ?, ?)

copyToBuffer(Buffer)

        将数组中的所有元素拷贝至Buffer中;

import scala.collection.mutable.ArrayBuffer
	var arr = new ArrayBuffer[Int]()
	var arr1 = Array(1,2,3)
	arr1.copyToBuffer(arr)
	arr.foreach(println)
1
2
3

corresponds

        a1.corresponds(a2)((x,y)=>Boolean)

  • a1和a2的长度相等,且a1和a2同一位置的元素必须符合条件;
scala> var arr1 = Array(1,2,3,4)
arr1: Array[Int] = Array(1, 2, 3, 4)

scala> var arr2 =Array(1,2,3,4)
arr2: Array[Int] = Array(1, 2, 3, 4)

scala> var arr3 =Array(3,4,4,4)
arr3: Array[Int] = Array(3, 4, 4, 4)

scala> arr1.corresponds(arr2)(_==_)
res9: Boolean = true

scala> arr1.corresponds(arr2)(_>_)
res10: Boolean = false

scala> arr1.corresponds(arr3)(_<_) 
res11: Boolean = false

count((x=>Boolean)

        count((x=>Boolean)     =>    统计符合条件的元素数量;

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.count(_%2==0)
res27: Int = 7

scala> arr.count(x=>x>=5 && x<=20)
res28: Int = 11

diff(array)

        a1.diff(a2)    =>    返回a1不在a2中的元素;

scala> var a1 = Array(1,2,3,4,5,6,7)
a1: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)

scala> var a2 = Array(2,3,4,5)
a2: Array[Int] = Array(2, 3, 4, 5)

scala> a1.diff(a2)
res31: Array[Int] = Array(1, 6, 7)

distinct

        数组去重;

scala> var arr = Array(1,2,1,3,2,3,4,5,1,2)
arr: Array[Int] = Array(1, 2, 1, 3, 2, 3, 4, 5, 1, 2)

scala> arr.distinct
res12: Array[Int] = Array(1, 2, 3, 4, 5)

endsWith

        判断数组是否以某个Array结尾(对应startsWith);

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.endsWith(Array(13,14,15))
res4: Boolean = true

scala> arr.endsWith(Array(13,14,1))
res5: Boolean = false

filter(p: (T) ⇒ Boolean)

        过滤集合内符合条件的元素,返回一个新的数组;

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.filter(_%2==0)
res10: Array[Int] = Array(2, 4, 6, 8, 10, 12, 14)

scala> arr.filter(_%2!=0)
res11: Array[Int] = Array(1, 3, 5, 7, 9, 11, 13, 15)

filterNot(p: (T) ⇒ Boolean)

        过滤集合内不符合条件的元素,返回一个新的数组;

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.filterNot(_%2==0)
res12: Array[Int] = Array(1, 3, 5, 7, 9, 11, 13, 15)

find(p: (T) ⇒ Boolean): Option[T]

        返回第一个符合条件的元素,没有为NONE(option类型);

scala> res10.find(_>10)
res13: Option[Int] = Some(12)

scala> res10.find(_>20)
res14: Option[Int] = None

flatten

        将二维数组的所有元素合并在一起,形成一个一维数组返回;

scala> var a2 = Array(Array(1,3,5),Array(2,4,6))
a2: Array[Array[Int]] = Array(Array(1, 3, 5), Array(2, 4, 6))

scala> a2.flatten
res18: Array[Int] = Array(1, 3, 5, 2, 4, 6)

flatMap[B](f: (A) ⇒ GenTraversableOnce[B]): Array[B]

        对当前序列的每个元素进行操作,结果放入新序列返回,参数要求是GenTraversableOnce及其子类;

scala> a2.flatMap(x=>x.map(x=>(x,1)))
res21: Array[(Int, Int)] = Array((1,1), (3,1), (5,1), (2,1), (4,1), (6,1))

scala> a2.flatMap(x=>x.map(x=>(if(x%2==0) "even" else "odd",1)))
res22: Array[(String, Int)] = Array((odd,1), (odd,1), (odd,1), (even,1), (even,1), (even,1))

fold()

  • 对序列中的每个元素进行二元运算,把初始值顺序和每个元素相加,把得到的结果与下一个元素进行运算
  • 和aggregate有类似的语义,但是aggregate把初始值与每个元素相加,但结果不参与下一步运算
val add = (x:Int,y:Int) =>{
val z= x+y
	println(s"$x+$y = $z")
	z
}
var arr= Array(13,9,6,8,4)
println(arr.par.fold(0)(add))
println("-------------------------------")
println(arr.grouped(2).map(x => x.fold(0)(add)).fold(0)(add))
0+13 = 13
0+4 = 4
0+8 = 8
0+9 = 9
0+6 = 6
13+9 = 22
8+4 = 12
6+12 = 18
22+18 = 40
40
-------------------------------
0+13 = 13
13+9 = 22
0+22 = 22
0+6 = 6
6+8 = 14
22+14 = 36
0+4 = 4
36+4 = 40
40

foldLeft()

        从左向右对数组元素使用相同的操作;

var arr= Array(1,2,3,4,5)
println(arr.foldLeft(10)((x, y) => {
  println(s"$x\t$y"); x + y
}))
10	1
11	2
13	3
16	4
20	5
25

foldRight()

        从右向左对数组元素使用相同的操作;

var arr= Array(1,2,3,4,5)
println(arr.foldRight(10)((x, y) => {
  println(s"$x\t$y"); x + y
}))
5	10
4	15
3	19
2	22
1	24
25

forall(p:Type=>U):Unit

        集合中的元素是否都满足条件;如果序列为空,返回true

scala> var arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.forall(_.isInstanceOf[Int])
res0: Boolean = true

scala> arr.forall(_%2==0)
res1: Boolean = false

foreach(p:Type=>U):Unit

        对数组遍历进行p操作;

scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)

scala> a.foreach(x=>println(x*10))
10
20
30
40

groupBy(x:T=>K)=>Map[K, Array[T]]

        按照函数x对数组进行分组,返回类型为Map[K, Array[T]] ;

scala> val a = Array(1,2,3,4)
a: Array[Int] = Array(1, 2, 3, 4)

scala> val b = a.groupBy(x=> x match {
     | case x if (x<3) => "small"
     | case _ => "big"
     | })
b: scala.collection.immutable.Map[String,Array[Int]] = Map(small -> Array(1, 2), big -> Array(3, 4))

grouped(size:Int): collection.Iterator[Array[T]]

        按数量n进行分组,每组数组有n个元素,如果不足n,则单独作为一个数组结束;

scala> val a = Array(1,2,3,4,5,6,7)
a: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)

scala> a.grouped(3)
res3: Iterator[Array[Int]] = <iterator>

scala> a.grouped(3).toList
res5: List[Array[Int]] = List(Array(1, 2, 3), Array(4, 5, 6), Array(7))

hasDefiniteSize:Boolean

        判断数组是否有固定长度;

scala> var arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.hasDefiniteSize
res2: Boolean = true

scala> arr.toStream
res3: scala.collection.immutable.Stream[Int] = Stream(1, ?)

scala> arr.toStream.hasDefiniteSize
res4: Boolean = false

head:T

        返回集合中第一个元素,没有系统报错;

scala> var arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.head
res5: Int = 1

headOption: Option[T]

        返回数组的第一个元素,返回类型为Some,没有返回None;

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.headOption
res16: Option[Int] = Some(1)

scala> var arr:Array[Int]= Array()
arr: Array[Int] = Array()

scala> arr.headOption
res18: Option[Int] = None

indexOf(elem: T): Int

        返回元素在集合中第一次出现的索引位置,没有为-1;

indexOf(elem: T, from: Int): Int

        返回elem在序列中的索引,可以指定从某个索引处(from)开始查找,找到第一个就返回

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.indexOf(5)
res19: Int = 4

scala> a2.indexOf(5,2)
res20: Int = 4

scala> a2.indexOf(5,6)
res21: Int = -1

indexOfSlice(GenSeq)

        返回集合中子序列的索引;

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.indexOfSlice(Array(3,4))
res22: Int = 2

indexWhere(p:B=>Boolean)

        返回第一个满足条件的元素的下标;

indexWhere(p: (T) ⇒ Boolean, from: Int): Int

        从from索引位置开始,返回第一个满足条件的元素的下标;

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.indexWhere(_>6)
res23: Int = 6

scala> a2.indexWhere(_>1)
res24: Int = 1

scala> a2.indexWhere(_>=6,4)
res25: Int = 5

indices: collection.immutable.Range

        返回当前集合的索引集合

scala> a2.indices
res26: scala.collection.immutable.Range = Range 0 until 9

init: Array[T]

        返回当前序列中不包含最后一个元素的序列

scala> arr.init
res9: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8)

inits: collection.Iterator[Array[T]]

        但会一个迭代器,对序列进行init迭代;

scala> res10.init
res11: Array[Int] = Array(1, 2, 3, 4, 5, 6)

scala> res11.inits
res12: Iterator[Array[Int]] = <iterator>

scala> res11.inits.foreach(x=>{x.foreach(print);println})
123456
12345
1234
123
12
1

intersect(that: collection.Seq[T]): Array[T]

        返回两个数组的交集;

scala> a
res9: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)

scala> a2
res10: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.intersect(a)
res11: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)

isDefinedAt(idx: Int): Boolean

        判断序列中是否存在指定索引;

scala> a
res12: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)

scala> a.isDefinedAt(5)
res13: Boolean = true

scala> a.isDefinedAt(11)
res14: Boolean = false

isEmpty: Boolean

        判断当前序列是否为空;

scala> a.isEmpty
res16: Boolean = false

iterator: collection.Iterator[T]

        对序列中的每个元素产生一个 iterator;

scala> val a = Array(1, 2, 3, 4, 5)
a: Array[Int] = Array(1, 2, 3, 4, 5)

scala> val b = a.iterator
b: Iterator[Int] = <iterator>

scala> a.iterator.foreach(println)
1
2
3
4
5

last:A

        返回集合中最后元素,没有系统报错;

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.last
res6: Int = 9

lastIndexOf(elem: T): Int

        取得序列中最后一个等于 elem 的元素的位置;

lastIndexOf(elem: T, end: Int): Int

        取得序列中最后一个等于 elem 的元素的位置,可以指定在 end 之前(包括)的元素中查找

scala> a2
res23: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.lastIndexOf(4)
res26: Int = 3

scala> a2.lastIndexOf(4,6)
res27: Int = 3

scala> a2.lastIndexOf(6,2)
res29: Int = -1

lastIndexOfSlice(GenSeq[,endIndex])

        返回子序列在结束下标位置前最后一次出现的位置;

scala> a2
res23: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> val a = Array(5,6,7)
a: Array[Int] = Array(5, 6, 7)

scala> a2.lastIndexOfSlice(a)
res35: Int = 4

scala> a2.lastIndexOfSlice(a,8)
res32: Int = 4

scala> a2.lastIndexOfSlice(a,3)
res37: Int = -1

lastIndexWhere(p: (T) ⇒ Boolean): Int

        返回当前序列中最后一个满足条件 p 的元素的索引;

lastIndexWhere(p: (T) ⇒ Boolean, end: Int): Int

        返回当前序列中最后一个满足条件 p 的元素的索引,可以指定在 end 之前(包括)的元素中查找;


lastOption: Option[T]

        返回数据的最后一个元素,返回类型为Some,没有返回None;

scala> var a2 = Array.range(1,10)
a2: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.lastOption
res19: Option[Int] = Some(9)

scala> var arr:Array[Int]= Array()
arr: Array[Int] = Array()

scala> arr.lastOption
res20: Option[Int] = None

length:Int

        返回当前数组中元素的数量;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.length
res0: Int = 9

map[B](f: (A) ⇒ B): Array[B]

        对数组中的元素按照函数f进行操作;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.map(x=>(x,1))
res1: Array[(Int, Int)] = Array((1,1), (2,1), (3,1), (4,1), (5,1), (6,1), (7,1), (8,1), (9,1))

scala> arr.map(x=>x*10)
res2: Array[Int] = Array(10, 20, 30, 40, 50, 60, 70, 80, 90)

max :A

        返回数组中的最大值;

scala> val arr = Array("a","b","我","c")
arr: Array[String] = Array(a, b,, c)

scala> arr.max
res3: String = 我

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.max
res4: Int = 9

maxBy[B](f: (A) ⇒ B):A

        返回满足条件的第一个值;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.maxBy(x=>x>3)
res5: Int = 4

min:A

        返回数组中的最小值;

scala> val arr = Array("a","b","我","c")
arr: Array[String] = Array(a, b,, c)

scala> arr.min
res6: String = a

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.min
res7: Int = 1

minBy[B](f: (A) ⇒ B):A

        返回不满足条件的第一个值

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.minBy(x=>x<3)
res8: Int = 3

mkString:String

        将数组中的所有元素组合为字符串;

scala> val arr1=Array((1,2),(2,3))
arr1: Array[(Int, Int)] = Array((1,2), (2,3))

scala> arr1.mkString
res9: String = (1,2)(2,3)

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.mkString
res10: String = 123456789

mkString(sep: String): String

        将数组中的所有元素组合为字符串以sep为分隔符组合为字符串;

scala> val arr1=Array((1,2),(2,3))
arr1: Array[(Int, Int)] = Array((1,2), (2,3))

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr1.mkString(",")
res11: String = (1,2),(2,3)

scala> arr.mkString(",")
res12: String = 1,2,3,4,5,6,7,8,9

mkString(start: String, sep: String, end: String): String

        将数组中的所有元素组合为字符串以start开头、以sep为分隔符、以end结尾组合为字符串;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.mkString("[",",","]")
res13: String = [1,2,3,4,5,6,7,8,9]

nonEmpty: Boolean

        判断数组不为空;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.nonEmpty
res15: Boolean = true

par: ParArray[T]

         返回一个并行序列ParArray[T],内容不可更改,相当于hashcode partitioner,便于多线程执行;

scala> arr
res16: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.par
res17: scala.collection.parallel.mutable.ParArray[Int] = ParArray(1, 2, 3, 4, 5, 6, 7, 8, 9)

partition(p: (T) ⇒ Boolean): (Array[T], Array[T])

         将序列拆成满足和不满足的两个序列;

scala> arr
res16: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.partition(x=>x%2==0)
res21: (Array[Int], Array[Int]) = (Array(2, 4, 6, 8),Array(1, 3, 5, 7, 9))

patch(from: Int, that: GenSeq[A], replaced: Int): Array[A]

         从序列的from位置起,后面的replaced个元素由子系列that替换

scala> a2
res48: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.patch(2,Array('a','b'),0)
res49: Array[AnyVal] = Array(1, 2, a, b, 3, 4, 5, 6, 7, 8, 9)

scala> a2.patch(2,Array('a','b'),1)
res50: Array[AnyVal] = Array(1, 2, a, b, 4, 5, 6, 7, 8, 9)

scala> var i:Array[Int] = Array()
i: Array[Int] = Array()

scala> a2.patch(2,i,1)
res51: Array[Int] = Array(1, 2, 4, 5, 6, 7, 8, 9)

permutations: collection.Iterator[Array[T]]

        所有元素不同顺序的排列;

scala> var a3 = Array('a','b','c')
a3: Array[Char] = Array(a, b, c)

scala> a3.permutations
res31: Iterator[Array[Char]] = <iterator>

scala> a3.permutations.foreach(x=>println(x.mkString("")))
abc
acb
bac
bca
cab
cba

prefixLength(p: (T) ⇒ Boolean): Int

        返回序列中满足条件的元素数量

  • 如果第一个元素就不满足返回0
  • 到第一个不满足条件的元素为止
scala> arr
res22: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.prefixLength(x=>x<3)
res23: Int = 2

scala> arr.prefixLength(x=>x>3)
res24: Int = 0

product: A

        返回序列内所有元素的乘积;

scala> val a2 = Array(1.0,2,4,5.0)
a2: Array[Double] = Array(1.0, 2.0, 4.0, 5.0)

scala> a2.product
res28: Double = 40.0

scala> arr
res29: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.product
res30: Int = 362880

reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1

        同 fold,不需要初始值;

scala> a2
res54: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2.reduce(_+_)
res55: Int = 45

scala> a2.reduce((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
1 +2 = 3
3 +3 = 6
6 +4 = 10
10 +5 = 15
15 +6 = 21
21 +7 = 28
28 +8 = 36
36 +9 = 45
res58: Int = 45

reduceLeft[B >: A](op: (B, T) ⇒ B): B

        从左向右计算;

scala> a2.reduceLeft((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
1 +2 = 3
3 +3 = 6
6 +4 = 10
10 +5 = 15
15 +6 = 21
21 +7 = 28
28 +8 = 36
36 +9 = 45
res60: Int = 45

reduceRight[B >: A](op: (T, B) ⇒ B): B

        从右向左计算;

scala> a2.reduceRight((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
8 +9 = 17
7 +17 = 24
6 +24 = 30
5 +30 = 35
4 +35 = 39
3 +39 = 42
2 +42 = 44
1 +44 = 45
res59: Int = 45

reduceOption[A1 >: A](op: (A1, A1) ⇒ A1): Option[A1]

reduceLeftOption[B >: A](op: (B, T) ⇒ B): Option[B]

reduceRightOption[B >: A](op: (T, B) ⇒ B): Option[B]

        与上面的reducef方法相同,但返回类型为Option;

scala> arr.reduceOption((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
1 +2 = 3
3 +3 = 6
6 +4 = 10
10 +5 = 15
15 +6 = 21
21 +7 = 28
28 +8 = 36
36 +9 = 45
res33: Option[Int] = Some(45)

scala> arr.reduceLeftOption((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
1 +2 = 3
3 +3 = 6
6 +4 = 10
10 +5 = 15
15 +6 = 21
21 +7 = 28
28 +8 = 36
36 +9 = 45
res34: Option[Int] = Some(45)

scala> arr.reduceRightOption((x,y)=>{var z = x+y;println(s"$x +$y = $z");z})
8 +9 = 17
7 +17 = 24
6 +24 = 30
5 +30 = 35
4 +35 = 39
3 +39 = 42
2 +42 = 44
1 +44 = 45
res35: Option[Int] = Some(45)

reverse: Array[T]

        将数组反转后返回一个新数组;

scala> arr
res36: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.reverse
res37: Array[Int] = Array(9, 8, 7, 6, 5, 4, 3, 2, 1)

reverseIterator: collection.Iterator[T]

        将数组反转后返回新数组的一个迭代器;

scala> arr
res36: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.reverse
res37: Array[Int] = Array(9, 8, 7, 6, 5, 4, 3, 2, 1)

scala> arr.reverseIterator
res38: Iterator[Int] = <iterator>

reverseMap[B](f: (A) ⇒ B): Array[B]

        将数组依次执行函数并反转返回一个新数组;相当于先执行map方法再执行reverse;

scala> arr
res36: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.reverseMap(x=>x*10)
res42: Array[Int] = Array(90, 80, 70, 60, 50, 40, 30, 20, 10)

runWith[U](f:scala.Function1[B,U])=>scala.Function1[A,scala.Boolean]

  • 调用偏函数
  • 以第二参数下标提取序列元素,作为第一参数函数的入口
    • 下标存在,且元素符合函数规则返回true
    • 下标存在,且元素不符合函数规则报异常
    • 下标不存在返回false
val pf:PartialFunction[Int,Option[String]] = (x:Int) => x match {
	case i if i%3 == 0 Some("there")
	case i if i%7 == 0 Some("seven")
	case i => None
}

pf.runWith(println)(5) => 输出 None			返回 false
pf.runWith(println)(6) => 输出 Some(three) 	返回 true

arr.runWith(x=>x match {
	case x if x%2==0 =>x
})(17)

sameElements(that: GenIterable[A]): Boolean

        判断两个序列是否值相同(长度相同,同一个索引下的值相同);

scala> arr
res44: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a2
res45: Array[Double] = Array(1.0, 2.0, 4.0, 5.0)

scala> arr.sameElements(a2)
res46: Boolean = false

scan[B >: A, That](z: B)(op: (B, B) ⇒ B)(implicit cbf: CanBuildFrom[Array[T], B, That]): That

scanLeft[B, That](z: B)(op: (B, T) ⇒ B)(implicit bf: CanBuildFrom[Array[T], B, That]): That

scanRight[B, That](z: B)(op: (T, B) ⇒ B)(implicit bf: CanBuildFrom[Array[T], B, That]): That

        用法同 fold,scan会把每一步的计算结果放到一个新的集合中返回,而 fold 返回的是单一的值;,scan与scanLeft都是从左向右执行,而scanRight从右向左执行;

scala> var arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)	

scala> arr.scan(0)(_+_)
res6: Array[Int] = Array(0, 1, 3, 6, 10, 15, 21, 28, 36, 45)

scala> arr.scanRight(0)(_+_)
res9: Array[Int] = Array(45, 44, 42, 39, 35, 30, 24, 17, 9, 0)

segmentLength(p: (T) ⇒ Boolean, from: Int): Int

        从序列的 from 处开始向后查找,所有满足 p 的连续元素的长度;

scala> var arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.segmentLength(x=>x>5,7)
res47: Int = 2

seq: collection.mutable.IndexedSeq[T]

        产生一个引用当前序列的 sequential 视图;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.seq
res0: scala.collection.mutable.IndexedSeq[Int] = WrappedArray(1, 2, 3, 4, 5, 6, 7, 8, 9)

size: Int

        返回数组内元素的数量;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.size
res1: Int = 9

slice(from: Int, until: Int): Array[T]

        截取数组从开始位置from到until位置之前的元素;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.slice(2,5)
res2: Array[Int] = Array(3, 4, 5)

sliding(size: Int): collection.Iterator[Array[T]]

        从0开始以step(默认为1)为步伐滑动,并取出从当前位置开始的size个元素;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.sliding(3).toArray
res20: Array[Array[Int]] = Array(Array(1, 2, 3), Array(2, 3, 4), Array(3, 4, 5), Array(4, 5, 6), Array(5, 6, 7), Array(6, 7, 8), Array(7, 8, 9))

sortBy[B](f: (T) ⇒ B)(implicit ord: math.Ordering[B]): Array[T]

        按指定的排序规则排序;

scala> at.sortBy(x=>x)
res31: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 9)

scala> at.sortBy(x=>(-x))
res32: Array[Int] = Array(9, 7, 6, 5, 4, 3, 2, 1)

sorted: Array[T]

        使用默认的排序规则对序列排序;

scala> var at = Array(2,5,3,6,9,7,1,4)
at: Array[Int] = Array(2, 5, 3, 6, 9, 7, 1, 4)

scala> at.sorted
res27: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 9)

sortWith(lt: (T, T) ⇒ Boolean): Array[T]

        按自定义排序方法对数组进行排序;

scala> at.sortWith(_<_)
res29: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 9)

scala> at.sortWith(_>_)
res30: Array[Int] = Array(9, 7, 6, 5, 4, 3, 2, 1)	

span(p: (T) ⇒ Boolean): (Array[T], Array[T])

        将序列拆分为两个数组;从第一个元素开始,到第一个不满足条件的元素为止,存放于第一个数组;其他元素放于第二个数组;如果第一个元素不满足,则第一个数组长度为0;

scala> at.span(_>=2)
res34: (Array[Int], Array[Int]) = (Array(2, 5, 3, 6, 9, 7),Array(1, 4))

startsWith

        判断数组是否以某个Array开头(对应endsWith);

scala> var arr = Array.range(1,16)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

scala> arr.startsWith(Array(1,2,3))
res6: Boolean = true

subSequence(start: Int, end: Int): CharSequence

        获取start~end之间的字符序列;

scala> Array('a','b','v','e','f')
res39: Array[Char] = Array(a, b, v, e, f)

scala> res39.subSequence(0,res39.length)
res40: CharSequence = abvef

scala> res39.subSequence(1,3)
res42: CharSequence = bv

sum: A

        对序列中的元素求和;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.sum
res3: Int = 45

tail: Array[T]

        返回除了当前序列除第一个元素的其它元素组成的序列;

scala> val arr = Array.range(1,10)
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> arr.tail
res7: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9)

tails: collection.Iterator[ArrayT]

        对序列进行tail迭代;

scala> arr.tails
res8: Iterator[Array[Int]] = <iterator>

scala> res10.init
res11: Array[Int] = Array(1, 2, 3, 4, 5, 6)

scala> res11.tails.foreach(x=>{x.foreach(print);println})
123456
23456
3456
456
56
6

take(n: Int): Array[T]

        返回当前序列中前 n 个元素组成的序列;

scala> var at = Array(2,5,3,6,9,7,1,4)
at: Array[Int] = Array(2, 5, 3, 6, 9, 7, 1, 4)

scala> at.take(4)
res43: Array[Int] = Array(2, 5, 3, 6)

takeRight(n: Int): Array[T]

        返回当前序列中,从右边开始,选择 n 个元素组成的序列;

scala> var at = Array(2,5,3,6,9,7,1,4)
at: Array[Int] = Array(2, 5, 3, 6, 9, 7, 1, 4)

scala> at.takeRight(3)
res44: Array[Int] = Array(7, 1, 4)

takeWhile(p: (T) ⇒ Boolean): Array[T]

        返回当前序列中,从第一个元素开始,满足条件的连续元素组成的序列;

scala> var at = Array(2,5,3,6,9,7,1,4)
at: Array[Int] = Array(2, 5, 3, 6, 9, 7, 1, 4)

scala> at.takeWhile(_>1)
res45: Array[Int] = Array(2, 5, 3, 6, 9, 7)

toArray: Array[A]

        转换成 Array 类型;


toBuffer[A1 >: A]: Buffer[A1]

        转换成 Buffer 类型;


toIndexedSeq: collection.immutable.IndexedSeq[T]

        转换成 IndexedSeq 类型;


toIterable: collection.Iterable[T]

        转换成可迭代的类型;


toIterator: collection.Iterator[T]

        同 iterator 方法;


toList: List[T]

        转换成 List 类型;


toMap[T, U]: Map[T, U]

        转换成 Map 类型,需要被转化序列中包含的元素时 Tuple2 类型数据;


toSeq: collection.Seq[T]

        转换成 Seq 类型;


toSet[B >: A]: Set[B]

        转换成 Set 类型;


toStream: collection.immutable.Stream[T]

        转换成 Stream 类型;


toVector: Vector[T]

        转换成 Vector 类型;


transpose[U](implicit asArray: (T) ⇒ Array[U]): Array[Array[U]]

        矩阵转换,二维数组行列转换;


union(that: collection.Seq[T]): Array[T]

        与 ++ 相同,将两个数组组成为一个数组;

scala> val a = Array.range(1,10)
a: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> val b = Array('a','b','c','d','e')
b: Array[Char] = Array(a, b, c, d, e)

scala> a.union(b)
res0: Array[AnyVal] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e)

unzip[T1, T2](implicit asPair: (T) ⇒ (T1, T2), ct1: ClassTag[T1], ct2: ClassTag[T2]): (Array[T1], Array[T2])

        将由包含两个元素的元祖组成的数组,每个元祖的第一个元素组成一个数组,第二个元祖组成另一个数组并返回;

scala> val a =Array((1,2),(2,3),(3,4))
a: Array[(Int, Int)] = Array((1,2), (2,3), (3,4))

scala> val b =Array((1,2),(2,3),(3,4))
b: Array[(Int, Int)] = Array((1,2), (2,3), (3,4))

scala> a.unzip
res9: (Array[Int], Array[Int]) = (Array(1, 2, 3),Array(2, 3, 4))

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])

        和unzip一样,不过unzip3适合三个元素组成元祖的数组;

scala> val b = Array((1,2,3),(2,3,4),(3,4,5))
b: Array[(Int, Int, Int)] = Array((1,2,3), (2,3,4), (3,4,5))

scala> b.unzip3
res10: (Array[Int], Array[Int], Array[Int]) = (Array(1, 2, 3),Array(2, 3, 4),Array(3, 4, 5))

update(i: Int, x: T): Unit

        将集合指定下标下的元素替换;

scala> a
res1: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> a.update(3,10)

scala> a
res3: Array[Int] = Array(1, 2, 3, 10, 5, 6, 7, 8, 9)

scala

updated(index: Int, elem: A): Array[A]

        将集合指定下标下的元素替换后返回一个新数组;

scala> a
res1: Array[Int] = Array(1, 2, 3, 10, 5, 6, 7, 8, 9)

scala> a.updated(3,12)
res5: Array[Int] = Array(1, 2, 3, 12, 5, 6, 7, 8, 9)

view(from: Int, until: Int): IndexedSeqView[T, Array[T]]

        返回 from 到 until 间的IndexedSeqView,不包括 until处的元素;

scala> a
res1: Array[Int] = Array(1, 2, 3, 10, 5, 6, 7, 8, 9)

scala> a.view(2,7)
res6: scala.collection.mutable.IndexedSeqView[Int,Array[Int]] = SeqViewS(...)

withFilter(p: (T) ⇒ Boolean): FilterMonadic[T, Array[T]]

        按条件过滤元素,返回一个集合;

scala> a
res1: Array[Int] = Array(1, 2, 3, 10, 5, 6, 7, 8, 9)

scala> a.withFilter( x => x>3)
res7: scala.collection.generic.FilterMonadic[Int,Array[Int]] = scala.collection.TraversableLike$WithFilter@4446a191

scala> a.withFilter( x => x>3).foreach(println)
10
5
6
7
8
9

zip[B](that: GenIterable[B]): Array[(A, B)]

        将两个序列对应位置上的元素组成一个pair序列;

scala> val b =Array(1,2,3,4,5)
b: Array[Int] = Array(1, 2, 3, 4, 5)

scala> val a =Array(1,2,3,4,5)
a: Array[Int] = Array(1, 2, 3, 4, 5)

scala> a.zip(b)
res12: Array[(Int, Int)] = Array((1,1), (2,2), (3,3), (4,4), (5,5))

zipAll[B](that: collection.Iterable[B], thisElem: A, thatElem: B): Array[(A, B)]

        同 zip ,但是允许两个序列长度不一样,不足的自动填充,如果当前序列端,空出的填充为 thisElem,如果 that 短,填充为 thatElem;

scala> a
res18: Array[Int] = Array(1, 2, 3, 4, 5)

scala> b
res19: Array[Int] = Array(3, 4, 5)

scala> a.zipAll(b,5,5)
res20: Array[(Int, Int)] = Array((1,3), (2,4), (3,5), (4,5), (5,5))

zipWithIndex: Array[(A, Int)]

        序列中的每个元素和它的索引组成一个序列;

scala> a
res13: Array[Int] = Array(1, 2, 3, 4, 5)

scala> a.zipWithIndex
res14: Array[(Int, Int)] = Array((1,0), (2,1), (3,2), (4,3), (5,4))

PS:如果有写错或者写的不好的地方,欢迎各位大佬在评论区留下宝贵的意见或者建议,敬上!如果这篇博客对您有帮助,希望您可以顺手帮我点个赞!不胜感谢!

原创作者:wsjslient

作者主页:https://blog.csdn.net/wsjslient


  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值