Skip to content

Collection diagrams #1167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions _ja/overviews/collections/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ Scala のコレクションは、体系的に可変および不変コレクシ
次の図は `scala.collection` パッケージ内の全てのコレクションを示す。
これらはすべて、高レベルの抽象クラスやトレイトで一般に可変と不変の両方の実装を持っている。

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

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

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

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

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

(以上三つ全ての図は decodified.com の Matthias によって生成された。)
図の伝説:

[![Graph legend][4]][4]

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

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

これより、これらのクラスを一つずつ見ていく。


[1]: /resources/images/tour/collections-diagram.svg
[2]: /resources/images/tour/collections-immutable-diagram.svg
[3]: /resources/images/tour/collections-mutable-diagram.svg
[4]: /resources/images/tour/collections-legend-diagram.svg
34 changes: 20 additions & 14 deletions _overviews/FAQ/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ collections, which was introduced with Scala 2.9. I'll talk about them in the
next section. The hierarchy described in this section refers _exclusively to
non-parallel collections_.

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

[![General collection hierarchy][5]][5]

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

Graph for immutable hierarchy:
<img src="http://i.stack.imgur.com/2fjoA.png" width="600px" />

[![Immutable collection hierarchy][10]][10]

Graph for mutable hierarchy:
<a href="http://i.stack.imgur.com/Dsptl.png"><img src="http://i.stack.imgur.com/Dsptl.png" width="600px" /></a>

[![Mutable collection hierarchy][11]][11]

Legend:

![Graph legend][8]
[![Graph legend][8]][8]

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

Expand All @@ -67,9 +70,11 @@ Here's an abbreviated ASCII depiction of the collection hierarchy, for those who
+------------------+--------------------+
Map Set Seq
| | |
| +----+----+ +-----+------+
Sorted Map SortedSet BitSet Buffer Vector LinearSeq

| | +------+-------+
SortedMap SortedSet Buffer Vector LinearSeq
|
|
BitSet

## Parallel Collections

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

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

* `BitSet` -- A set of integers stored as a bitset.
* `immutable.BitSet`
* `mutable.BitSet`

* `SortedSet` -- A set whose elements are ordered.
* `immutable.SortedSet`
* `immutable.BitSet` -- A set of integers stored as a bitset.
* `immutable.TreeSet` -- An implementation of a `SortedSet` based on a tree.
* `mutable.SortedSet`
* `mutable.BitSet` -- A set of integers stored as a bitset.

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

Expand Down Expand Up @@ -372,8 +376,10 @@ Overflow.
[2]: http://docs.scala-lang.org/overviews/core/architecture-of-scala-collections.html
[3]: http://www.scala-lang.org/sid/3
[4]: https://github.com/sirthias/scala-collections-charts/downloads
[5]: http://i.stack.imgur.com/bSVyA.png
[5]: /resources/images/tour/collections-diagram.svg
[6]: http://i.stack.imgur.com/2fjoA.png
[7]: http://i.stack.imgur.com/Dsptl.png
[8]: http://i.stack.imgur.com/szWUr.png
[8]: /resources/images/tour/collections-legend-diagram.svg
[9]: http://stackoverflow.com/q/1722137/53013
[10]: /resources/images/tour/collections-immutable-diagram.svg
[11]: /resources/images/tour/collections-mutable-diagram.svg
16 changes: 12 additions & 4 deletions _overviews/collections/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ The following figure shows all collections in package
`scala.collection`. These are all high-level abstract classes or traits, which
generally have mutable as well as immutable implementations.

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

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

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

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

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

(All three figures were generated by Matthias at decodified.com).
Legend:

[![Graph legend][4]][4]

## An Overview of the Collections API ##

Expand Down Expand Up @@ -144,3 +146,9 @@ This behavior which is implemented everywhere in the collections libraries is ca
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.

In the following, we will review these classes one by one.


[1]: /resources/images/tour/collections-diagram.svg
[2]: /resources/images/tour/collections-immutable-diagram.svg
[3]: /resources/images/tour/collections-mutable-diagram.svg
[4]: /resources/images/tour/collections-legend-diagram.svg
16 changes: 12 additions & 4 deletions _zh-cn/overviews/collections/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ Scala 集合类系统地区分了可变的和不可变的集合。可变集合

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

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

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

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

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

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

(以上三个图表由Matthias生成, 来自decodified.com)。
图传奇:

[![Graph legend][4]][4]

## 集合API概述

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

下面我们将一个个的回顾这些类。


[1]: /resources/images/tour/collections-diagram.svg
[2]: /resources/images/tour/collections-immutable-diagram.svg
[3]: /resources/images/tour/collections-mutable-diagram.svg
[4]: /resources/images/tour/collections-legend-diagram.svg
18 changes: 16 additions & 2 deletions resources/images/tour/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
all: unified-types\
type-casting\
collections\
collections-immutable\
collections-mutable\
collections-legend
unified-types:
dot -Tsvg unified-types-diagram.dot -o unified-types-diagram.svg
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
type-casting:
dot -Tsvg type-casting-diagram.dot -o type-casting-diagram.svg
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
collections:
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
collections-immutable:
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
collections-mutable:
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
collections-legend:
dot -Tsvg $@-diagram.dot -o $@-diagram.svg
22 changes: 22 additions & 0 deletions resources/images/tour/collections-diagram.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
digraph Collections {
edge [
color="#7F7F7F"
];
node [
shape="box",
style="rounded, filled",
fontcolor="#FFFFFF",
color="#6DC6E6"
];
rankdir="TB";

Traversable -> Iterable;
Iterable -> Seq;
Iterable -> Set;
Iterable -> Map;
Seq -> IndexedSeq;
Seq -> LinearSeq;
Set -> SortedSet;
SortedSet -> BitSet;
Map -> SortedMap;
}
108 changes: 108 additions & 0 deletions resources/images/tour/collections-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions resources/images/tour/collections-immutable-diagram.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
digraph ImmutableCollections {
edge [
color="#7F7F7F"
];
node [
shape="box",
style="rounded, filled",
fontcolor="#FFFFFF",
color="#6DC6E6"
];
rankdir="TB";

HashSet [color="#4A5659"];
TreeSet [color="#4A5659"];
ListSet [color="#4A5659"];
HashMap [color="#4A5659"];
TreeMap [color="#4A5659"];
ListMap [color="#4A5659"];
Vector [color="#4A5659"];
NumericRange [color="#4A5659"];
String [color="#4A5659"];
Range [color="#4A5659"];
List [color="#4A5659"];
Stack [color="#4A5659"];
Stream [color="#4A5659"];
Queue [color="#4A5659"];

Traversable -> Iterable [penwidth="4"];
Iterable -> Set;
Iterable -> Seq [penwidth="4"];
Iterable -> Map;
Set -> SortedSet;
Set -> HashSet [penwidth="4"];
Set -> ListSet;
SortedSet -> BitSet;
SortedSet -> TreeSet;
Seq -> IndexedSeq;
Seq -> LinearSeq [penwidth="4"];
IndexedSeq -> Vector [penwidth="4"];
IndexedSeq -> NumericRange;
IndexedSeq -> Range;
IndexedSeq -> String [style="dashed"];
LinearSeq -> List [penwidth="4"];
LinearSeq -> Stack;
LinearSeq -> Stream;
LinearSeq -> Queue;
Map -> HashMap [penwidth="4"];
Map -> ListMap;
Map -> SortedMap;
SortedMap -> TreeMap;

{rank=same; Seq; TreeMap}
}
Loading