来自 计算机编程 2019-12-04 16:28 的文章
当前位置: 澳门威尼斯人平台 > 计算机编程 > 正文

java中具体集合

ArrayList 一种可以动态增长和缩减的索引序列

1.ArrayList   可以动态增长和缩减的索引序列

原文地址

LinkedList 一种可以在任何位置进行高效地插入和删除操作的有序序列

2.LinkedList 可以在任何位置高效插入和删除错左的有序序列

本文内容

  • 并行数组(Parallel Array)
  • 并行向量(Parallel Vector)
  • 并行范围(Parallel Range)
  • 并行哈希表(Parallel Hash Tables)
  • 并行散列 Tries(Parallel Hash Tries)
  • 并行并发 Tries(Parallel Concurrent Tries)
  • 参考资料

ArrayDeque  一种用循环数组实现的双端队列

3.HashSet  没有重复元素的无序集合

并行数组(Parallel Array)


一个 ParArray 序列包含线性、连续的元素数组。这意味着,通过修改底层数组,可以高效地访问和修改元素。因此,反序元素也很高效。并行数组跟数组一样也是固定大小的。

scala> val pa = scala.collection.parallel.mutable.ParArray.tabulate(1000)(x =>2*

 x +1)

pa: scala.collection.parallel.mutable.ParArray[Int] = ParArray(1, 3, 5, 7, 9, 11

, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51

, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91

, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 12

5, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 15

7, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 18

9, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 22

1, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 25

3, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 28

5, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315,...

 

scala> pa reduce(_+_)

res0: Int = 1000000

 

scala> pa map(x=>(x-1)/2)

res1: scala.collection.parallel.mutable.ParArray[Int] = ParArray(0, 1, 2, 3, 4,

5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 2

6, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 4

6, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 6

6, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 8

6, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,

105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,

121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,

137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,

153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 16...

 

scala>

HashSet 一种没有重复元素的无序集合

4.TreeSet   有序集

并行向量(Parallel Vector)


一个 ParVector 是一个不可变序列,具有低常量因子对数的访问(low-constant factor logarithmic access )和更新时间。

scala> val pv = scala.collection.parallel.immutable.ParVector.tabulate(1000)(x =

> x)

pv: scala.collection.parallel.immutable.ParVector[Int] = ParVector(0, 1, 2, 3, 4

, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,

 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,

 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,

 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,

 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104

, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120

, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136

, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152

, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, ...

 

scala> pv filter (_ %2==0)

res2: scala.collection.parallel.immutable.ParVector[Int] = ParVector(0, 2, 4, 6,

 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46,

48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86,

88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 1

22, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 1

54, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 1

86, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 2

18, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 2

50, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 2

82, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312...

 

scala>

TreeSet 一种有序集

5.HashMap  键值对关联的数据结构

并行范围(Parallel Range)


一个 ParRange 是一个有序的等差整数数列(an ordered sequence of elements equally spaced apart)。并行范围(parallel range)的创建与顺序范围类似(sequential Range)。

scala> 1 to 3 par

warning: there were 1 feature warning(s); re-run with -feature for details

res3: scala.collection.parallel.immutable.ParRange = ParRange(1, 2, 3)

 

scala> 15 to 5 by -2 par

warning: there were 1 feature warning(s); re-run with -feature for details

res4: scala.collection.parallel.immutable.ParRange = ParRange(15, 13, 11, 9, 7,

5)

 

scala>

本文由澳门威尼斯人平台发布于计算机编程,转载请注明出处:java中具体集合

关键词: