Skip to content

Commit 0202987

Browse files
authored
Merge pull request #1167 from rkoeninger/collection-diagrams
Collection diagrams
2 parents b5f35db + 70199b9 commit 0202987

13 files changed

+1131
-28
lines changed

_ja/overviews/collections/overview.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,19 @@ Scala のコレクションは、体系的に可変および不変コレクシ
5353
次の図は `scala.collection` パッケージ内の全てのコレクションを示す。
5454
これらはすべて、高レベルの抽象クラスやトレイトで一般に可変と不変の両方の実装を持っている。
5555

56-
[<img src="{{ site.baseurl }}/resources/images/collections.png" width="550">]({{ site.baseurl }}/resources/images/collections.png)
56+
[![General collection hierarchy][1]][1]
5757

5858
次の図は `scala.collection.immutable` パッケージ内の全てのコレクションを示す。
5959

60-
[<img src="{{ site.baseurl }}/resources/images/collections.immutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.immutable.png)
60+
[![Immutable collection hierarchy][2]][2]
6161

6262
そして、次の図は `scala.collection.mutable` パッケージ内の全てのコレクションを示す。
6363

64-
[<img src="{{ site.baseurl }}/resources/images/collections.mutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.mutable.png)
64+
[![Mutable collection hierarchy][3]][3]
6565

66-
(以上三つ全ての図は decodified.com の Matthias によって生成された。)
66+
図の伝説:
67+
68+
[![Graph legend][4]][4]
6769

6870
## コレクションAPIの概要
6971

@@ -102,3 +104,9 @@ Scala のコレクションは、体系的に可変および不変コレクシ
102104
唯一の例外は、可変コレクションにのみ存在する `Buffer` トレイトだ。
103105

104106
これより、これらのクラスを一つずつ見ていく。
107+
108+
109+
[1]: /resources/images/tour/collections-diagram.svg
110+
[2]: /resources/images/tour/collections-immutable-diagram.svg
111+
[3]: /resources/images/tour/collections-mutable-diagram.svg
112+
[4]: /resources/images/tour/collections-legend-diagram.svg

_overviews/FAQ/collections.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ collections, which was introduced with Scala 2.9. I'll talk about them in the
3939
next section. The hierarchy described in this section refers _exclusively to
4040
non-parallel collections_.
4141

42-
The following image shows the non-specific hierarchy introduced with Scala 2.8:
43-
![General collection hierarchy][5]
42+
The following image shows the non-specific hierarchy as of Scala 2.10:
43+
44+
[![General collection hierarchy][5]][5]
4445

4546
All elements shown are traits. In the other two hierarchies there are also
4647
classes directly inheriting the traits as well as classes which can be _viewed
4748
as_ belonging in that hierarchy through implicit conversion to wrapper classes.
4849
The legend for these graphs can be found after them.
4950

5051
Graph for immutable hierarchy:
51-
<img src="http://i.stack.imgur.com/2fjoA.png" width="600px" />
52+
53+
[![Immutable collection hierarchy][10]][10]
5254

5355
Graph for mutable hierarchy:
54-
<a href="http://i.stack.imgur.com/Dsptl.png"><img src="http://i.stack.imgur.com/Dsptl.png" width="600px" /></a>
56+
57+
[![Mutable collection hierarchy][11]][11]
5558

5659
Legend:
5760

58-
![Graph legend][8]
61+
[![Graph legend][8]][8]
5962

6063
Here's an abbreviated ASCII depiction of the collection hierarchy, for those who can't see the images.
6164

@@ -67,9 +70,11 @@ Here's an abbreviated ASCII depiction of the collection hierarchy, for those who
6770
+------------------+--------------------+
6871
Map Set Seq
6972
| | |
70-
| +----+----+ +-----+------+
71-
Sorted Map SortedSet BitSet Buffer Vector LinearSeq
72-
73+
| | +------+-------+
74+
SortedMap SortedSet Buffer Vector LinearSeq
75+
|
76+
|
77+
BitSet
7378

7479
## Parallel Collections
7580

@@ -282,13 +287,12 @@ it. Also available are some traits with further refinements, such as
282287

283288
* `Set` -- A set is a collection that includes at most one of any object.
284289

285-
* `BitSet` -- A set of integers stored as a bitset.
286-
* `immutable.BitSet`
287-
* `mutable.BitSet`
288-
289290
* `SortedSet` -- A set whose elements are ordered.
290291
* `immutable.SortedSet`
292+
* `immutable.BitSet` -- A set of integers stored as a bitset.
291293
* `immutable.TreeSet` -- An implementation of a `SortedSet` based on a tree.
294+
* `mutable.SortedSet`
295+
* `mutable.BitSet` -- A set of integers stored as a bitset.
292296

293297
* `SetProxy` -- A `Proxy` for a `Set`.
294298

@@ -372,8 +376,10 @@ Overflow.
372376
[2]: http://docs.scala-lang.org/overviews/core/architecture-of-scala-collections.html
373377
[3]: http://www.scala-lang.org/sid/3
374378
[4]: https://github.com/sirthias/scala-collections-charts/downloads
375-
[5]: http://i.stack.imgur.com/bSVyA.png
379+
[5]: /resources/images/tour/collections-diagram.svg
376380
[6]: http://i.stack.imgur.com/2fjoA.png
377381
[7]: http://i.stack.imgur.com/Dsptl.png
378-
[8]: http://i.stack.imgur.com/szWUr.png
382+
[8]: /resources/images/tour/collections-legend-diagram.svg
379383
[9]: http://stackoverflow.com/q/1722137/53013
384+
[10]: /resources/images/tour/collections-immutable-diagram.svg
385+
[11]: /resources/images/tour/collections-mutable-diagram.svg

_overviews/collections/overview.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,19 @@ The following figure shows all collections in package
100100
`scala.collection`. These are all high-level abstract classes or traits, which
101101
generally have mutable as well as immutable implementations.
102102

103-
[<img src="{{ site.baseurl }}/resources/images/collections.png" width="550">]({{ site.baseurl }}/resources/images/collections.png)
103+
[![General collection hierarchy][1]][1]
104104

105105
The following figure shows all collections in package `scala.collection.immutable`.
106106

107-
[<img src="{{ site.baseurl }}/resources/images/collections.immutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.immutable.png)
107+
[![Immutable collection hierarchy][2]][2]
108108

109109
And the following figure shows all collections in package `scala.collection.mutable`.
110110

111-
[<img src="{{ site.baseurl }}/resources/images/collections.mutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.mutable.png)
111+
[![Mutable collection hierarchy][3]][3]
112112

113-
(All three figures were generated by Matthias at decodified.com).
113+
Legend:
114+
115+
[![Graph legend][4]][4]
114116

115117
## An Overview of the Collections API ##
116118

@@ -144,3 +146,9 @@ This behavior which is implemented everywhere in the collections libraries is ca
144146
Most of the classes in the collections hierarchy exist in three variants: root, mutable, and immutable. The only exception is the Buffer trait which only exists as a mutable collection.
145147

146148
In the following, we will review these classes one by one.
149+
150+
151+
[1]: /resources/images/tour/collections-diagram.svg
152+
[2]: /resources/images/tour/collections-immutable-diagram.svg
153+
[3]: /resources/images/tour/collections-mutable-diagram.svg
154+
[4]: /resources/images/tour/collections-legend-diagram.svg

_zh-cn/overviews/collections/overview.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@ Scala 集合类系统地区分了可变的和不可变的集合。可变集合
4545

4646
下面的图表显示了`scala.collection`包中所有的集合类。这些都是高级抽象类或特性,它们通常具备和不可变实现一样的可变实现。
4747

48-
[<img src="{{ site.baseurl }}/resources/images/collections.png" width="550">]({{ site.baseurl }}/resources/images/collections.png)
48+
[![General collection hierarchy][1]][1]
4949

5050
下面的图表显示scala.collection.immutable中的所有集合类。
5151

52-
[<img src="{{ site.baseurl }}/resources/images/collections.immutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.immutable.png)
52+
[![Immutable collection hierarchy][2]][2]
5353

5454
下面的图表显示scala.collection.mutable中的所有集合类。
5555

56-
[<img src="{{ site.baseurl }}/resources/images/collections.mutable.png" width="550">]({{ site.baseurl }}/resources/images/collections.mutable.png)
56+
[![Mutable collection hierarchy][3]][3]
5757

58-
(以上三个图表由Matthias生成, 来自decodified.com)。
58+
图传奇:
59+
60+
[![Graph legend][4]][4]
5961

6062
## 集合API概述
6163

@@ -89,3 +91,9 @@ Traversable类提供了所有集合支持的API,同时,对于特殊类型也
8991
大多数类在集合树中存在这于三种变体:root, mutable 和immutable。唯一的例外是缓冲区特征,它仅在于mutable集合。
9092

9193
下面我们将一个个的回顾这些类。
94+
95+
96+
[1]: /resources/images/tour/collections-diagram.svg
97+
[2]: /resources/images/tour/collections-immutable-diagram.svg
98+
[3]: /resources/images/tour/collections-mutable-diagram.svg
99+
[4]: /resources/images/tour/collections-legend-diagram.svg

resources/images/tour/Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
all: unified-types\
2+
type-casting\
3+
collections\
4+
collections-immutable\
5+
collections-mutable\
6+
collections-legend
17
unified-types:
2-
dot -Tsvg unified-types-diagram.dot -o unified-types-diagram.svg
8+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
39
type-casting:
4-
dot -Tsvg type-casting-diagram.dot -o type-casting-diagram.svg
10+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
11+
collections:
12+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
13+
collections-immutable:
14+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
15+
collections-mutable:
16+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
17+
collections-legend:
18+
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
digraph Collections {
2+
edge [
3+
color="#7F7F7F"
4+
];
5+
node [
6+
shape="box",
7+
style="rounded, filled",
8+
fontcolor="#FFFFFF",
9+
color="#6DC6E6"
10+
];
11+
rankdir="TB";
12+
13+
Traversable -> Iterable;
14+
Iterable -> Seq;
15+
Iterable -> Set;
16+
Iterable -> Map;
17+
Seq -> IndexedSeq;
18+
Seq -> LinearSeq;
19+
Set -> SortedSet;
20+
SortedSet -> BitSet;
21+
Map -> SortedMap;
22+
}
Lines changed: 108 additions & 0 deletions
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
digraph ImmutableCollections {
2+
edge [
3+
color="#7F7F7F"
4+
];
5+
node [
6+
shape="box",
7+
style="rounded, filled",
8+
fontcolor="#FFFFFF",
9+
color="#6DC6E6"
10+
];
11+
rankdir="TB";
12+
13+
HashSet [color="#4A5659"];
14+
TreeSet [color="#4A5659"];
15+
ListSet [color="#4A5659"];
16+
HashMap [color="#4A5659"];
17+
TreeMap [color="#4A5659"];
18+
ListMap [color="#4A5659"];
19+
Vector [color="#4A5659"];
20+
NumericRange [color="#4A5659"];
21+
String [color="#4A5659"];
22+
Range [color="#4A5659"];
23+
List [color="#4A5659"];
24+
Stack [color="#4A5659"];
25+
Stream [color="#4A5659"];
26+
Queue [color="#4A5659"];
27+
28+
Traversable -> Iterable [penwidth="4"];
29+
Iterable -> Set;
30+
Iterable -> Seq [penwidth="4"];
31+
Iterable -> Map;
32+
Set -> SortedSet;
33+
Set -> HashSet [penwidth="4"];
34+
Set -> ListSet;
35+
SortedSet -> BitSet;
36+
SortedSet -> TreeSet;
37+
Seq -> IndexedSeq;
38+
Seq -> LinearSeq [penwidth="4"];
39+
IndexedSeq -> Vector [penwidth="4"];
40+
IndexedSeq -> NumericRange;
41+
IndexedSeq -> Range;
42+
IndexedSeq -> String [style="dashed"];
43+
LinearSeq -> List [penwidth="4"];
44+
LinearSeq -> Stack;
45+
LinearSeq -> Stream;
46+
LinearSeq -> Queue;
47+
Map -> HashMap [penwidth="4"];
48+
Map -> ListMap;
49+
Map -> SortedMap;
50+
SortedMap -> TreeMap;
51+
52+
{rank=same; Seq; TreeMap}
53+
}

0 commit comments

Comments
 (0)