10000 Merge pull request #59 from axel22/gh-pages · soc-mirror/scala.github.com@e264d4c · GitHub
[go: up one dir, main page]

Skip to content

Commit e264d4c

Browse files
committed
Merge pull request scala#59 from axel22/gh-pages
Rename Ctrie to ConcurrentTrieMap
2 parents 6c12403 + c4056eb commit e264d4c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

overviews/parallel-collections/concrete-parallel-collections.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ Parallel hash tries can be converted back and forth to sequential hash tries by
8282

8383
## Parallel Ctries
8484

85-
A [mutable.Ctrie](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/mutable/Ctrie.html) is a concurrent thread-safe map, whereas a [mutable.ParCtrie](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/parallel/mutable/ParCtrie.html) is its parallel counterpart. While most concurrent data structures do not guarantee consistent traversal if the the data structure is modified during traversal, Ctries guarantee that updates are only visible in the next iteration. This means that you can mutate the concurrent trie while traversing it, like in the following example which outputs square roots of number from 1 to 99:
85+
A [mutable.ConcurrentTrieMap](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/mutable/ConcurrentTrieMap.html) is a concurrent thread-safe map, whereas a [mutable.ParConcurrentTrieMap](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/parallel/mutable/ParConcurrentTrieMap.html) is its parallel counterpart. While most concurrent data structures do not guarantee consistent traversal if the the data structure is modified during traversal, Ctries guarantee that updates are only visible in the next iteration. This means that you can mutate the concurrent trie while traversing it, like in the following example which outputs square roots of number from 1 to 99:
8686

87-
scala> val numbers = scala.collection.parallel.mutable.ParCtrie((1 until 100) zip (1 until 100): _*) map { case (k, v) => (k.toDouble, v.toDouble) }
88-
numbers: scala.collection.parallel.mutable.ParCtrie[Double,Double] = ParCtrie(0.0 -> 0.0, 42.0 -> 42.0, 70.0 -> 70.0, 2.0 -> 2.0,...
87+
scala> val numbers = scala.collection.parallel.mutable.ParConcurrentTrieMap((1 until 100) zip (1 until 100): _*) map { case (k, v) => (k.toDouble, v.toDouble) }
88+
numbers: scala.collection.parallel.mutable.ParConcurrentTrieMap[Double,Double] = ParCtrie(0.0 -> 0.0, 42.0 -> 42.0, 70.0 -> 70.0, 2.0 -> 2.0,...
8989
scala> while (numbers.nonEmpty) {
9090
| numbers foreach { case (num, sqrt) =>
9191
| val nsqrt = 0.5 * (sqrt + num / sqrt)

overviews/parallel-collections/ctries.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ are removed from the map.
3131

3232
// prepare the list
3333
val entries = (1 until length) map { num => Entry(num.toDouble) }
34-
val results = ParCtrie()
34+
val results = ParConcurrentTrieMap()
3535
for (e <- entries) results += ((e.num, e))
3636

3737
// compute square roots
@@ -66,8 +66,8 @@ until either it finds some path to the target or there are no more nodes to expa
6666

6767
// open list - the nodefront
6868
// closed list - nodes already processed
69-
val open = ParCtrie[Node, Parent]()
70-
val closed = ParCtrie[Node, Parent]()
69+
val open = ParConcurrentTrieMap[Node, Parent]()
70+
val closed = ParConcurrentTrieMap[Node, Parent]()
7171

7272
// add a couple of starting positions
7373
open((0, 0)) = null

0 commit comments

Comments
 (0)
0