Skip to content

Commit ce3ac4e

Browse files
committed
maps translation finished
1 parent 1eddcd7 commit ce3ac4e

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

ko/overviews/collections/maps.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ language: ko
108108
result
109109
}
110110

111-
### Synchronized Sets and Maps ###
111+
### 동기화된 집합과 맵 ###
112112

113-
To get a thread-safe mutable map, you can mix the `SynchronizedMap` trait trait into whatever particular map implementation you desire. For example, you can mix `SynchronizedMap` into `HashMap`, as shown in the code below. This example begins with an import of two traits, `Map` and `SynchronizedMap`, and one class, `HashMap`, from package `scala.collection.mutable`. The rest of the example is the definition of singleton object `MapMaker`, which declares one method, `makeMap`. The `makeMap` method declares its result type to be a mutable map of string keys to string values.
113+
쓰레드 안전한 변경 가능한 맵을 만들고 싶다면 `SynchronizedMap` 트레잇을 원하는 맵 구현에 끼워 넣으면 된다. 예를 들어 아래 코드처럼 `SynchronizedMap``HashMap`에 끼워 넣을 수 있다. 아래 예제는 두 트레잇 `Map``SynchronizedMap`, 그리고 클래스 `HashMap`을 패키지 `scala.collection.mutable`에서 임포트한다. 나머지 부분은 싱글턴 `MapMaker`를 만드는 것이다. 이 객체는 메소드 `makeMap`를 구현한다. `makeMap` 메소드는 문자열에서 문자열로 맵핑하는 동기화된 해시맵을 반환한다.
114114

115115
import scala.collection.mutable.{Map,
116116
SynchronizedMap, HashMap}
@@ -124,21 +124,21 @@ To get a thread-safe mutable map, you can mix the `SynchronizedMap` trait trait
124124
}
125125
}
126126

127-
<center>Mixing in the `SynchronizedMap` trait.</center>
127+
<center>`SynchronizedMap`트레잇 끼워 넣기</center>
128128

129-
The first statement inside the body of `makeMap` constructs a new mutable `HashMap` that mixes in the `SynchronizedMap` trait:
129+
`makeMap`의 첫 문장은 새로운 변경 가능한 `HashMap`을 만들고 `SynchronizedMap` 트레잇을 끼워 넣는다.
130130

131131
new HashMap[String, String] with
132132
SynchronizedMap[String, String]
133133

134-
Given this code, the Scala compiler will generate a synthetic subclass of `HashMap` that mixes in `SynchronizedMap`, and create (and return) an instance of it. This synthetic class will also override a method named `default`, because of this code:
134+
스칼라 컴파일러는 이 코드를 보고 `SynchronizedMap`을 끼워 넣은 `HashMap`의 하위 클래스를 만들고, 그 클래스의 인스턴스를 만든다(그리고 반환한다). 이 합성 클래스는 아래와 같이 `default`라는 메소드를 재정의한다.
135135

136136
override def default(key: String) =
137137
"Why do you want to know?"
138138

139-
If you ask a map to give you the value for a particular key, but it doesn't have a mapping for that key, you'll by default get a `NoSuchElementException`. If you define a new map class and override the `default` method, however, your new map will return the value returned by `default` when queried with a non-existent key. Thus, the synthetic `HashMap` subclass generated by the compiler from the code in the synchronized map code will return the somewhat curt response string, `"Why do you want to know?"`, when queried with a non-existent key.
139+
사용자가 맵에게 어떤 키와 연관된 값을 물어봤는데 그런 연관이 맵에 존재하지 않는다면 기본 동작은 `NoSuchElementException` 예외를 발생시키는 것이다. 하지만 새 맵 클래스를 만들면서 `default` 메소드를 재정의하면 존재하지 않는 키에 대한 질의가 들어올 때 `default` 메소드가 정의하는 값을 반환하게 된다. 따라서 컴파일러가 만든 동기화된 합성 `HashMap` 하위 클래스는 존재하지 않는 키에 대한 질의를 받으면 `"Why do you want to know?"`라는 문자열을 반환한다.
140140

141-
Because the mutable map returned by the `makeMap` method mixes in the `SynchronizedMap` trait, it can be used by multiple threads at once. Each access to the map will be synchronized. Here's an example of the map being used, by one thread, in the interpreter:
141+
`makeMap` 메소드가 반환하는 변경 가능한 맵에 `SynchronizedMap` 트레잇을 끼워 넣었기 때문에, 동시에 여러 쓰레드에서 이를 사용할 수 있다. 맵에 대한 억세스는 동기화될 것이다. 다음은 인터프리터상에서 한 쓰레드를 사용해 이 맵을 사용하는 예를 보여준다.
142142

143143
scala> val capital = MapMaker.makeMap
144144
capital: scala.collection.mutable.Map[String,String] = Map()
@@ -154,11 +154,13 @@ Because the mutable map returned by the `makeMap` method mixes in the `Synchroni
154154
scala> capital("New Zealand")
155155
res3: String = Wellington
156156

157-
You can create synchronized sets similarly to the way you create synchronized maps. For example, you could create a synchronized `HashSet` by mixing in the `SynchronizedSet` trait, like this:
157+
동기화된 맵을 만드는 것과 비슷한 방식으로 동기화된 집합도 만들 수 있다. 예를 들어 `SynchronizedSet` 트레잇을 끼워 넣으면 동기화된 `HashSet`을 만들 수 있다. 다음과 같다.
158158

159159
import scala.collection.mutable
160160
val synchroSet =
161161
new mutable.HashSet[Int] with
162162
mutable.SynchronizedSet[Int]
163163

164-
Finally, if you are thinking of using synchronized collections, you may also wish to consider the concurrent collections of `java.util.concurrent` instead.
164+
마지막으로, 어떤 상황에서 동기화된 컬렉션을 사용하는 것을 고려하게 된다면, 그 상황이 `java.util.concurrent` 컬렉션을 필요로 하는 경우는 아닌지 한번 더 생각해 보도록 하라.
165+
166+
번역: 오현석([email protected])

ko/overviews/collections/sets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,4 @@ res3: scala.collection.immutable.TreeSet[String] = TreeSet(four, one, three, two
148148

149149
따라서 크기가 작은 정수 원소를 여러개 포함하는 경우 비트집합을 사용하면 다른 집합에 비해 작은 크기로 가능하다. 비트 집합의 또 다른 잇점은 `contains`를 사용한 포함관계 검사나 `+=`, `-=` 등을 사용한 원소 추가/제거가 모두 아주 효율적이라는 점이다.
150150

151+
번역: 오현석([email protected])

ko/overviews/collections/trait-iterable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ language: ko
3939

4040
`Traversable` 트레잇의 메소드 중 이터레이터가 있는 경우에만 효율적으로 구현할 수 있는 메소드 몇 가지를 `Iterable` 트레잇에서 재정의하고 있다. 다음 표에서 이를 요약하였다.
4141

42-
### Iterable 트레잇의 연산들 ###
42+
### Iterable 트레잇의 연산 ###
4343

4444
| 사용법 | 하는일 |
4545
| ------ | ------ |

0 commit comments

Comments
 (0)