|
@@ -1,13 +1,14 @@
|
1
|
1
|
package com.dmdirc.ktirc.model
|
2
|
2
|
|
3
|
3
|
import com.dmdirc.ktirc.io.CaseMapping
|
|
4
|
+import java.util.*
|
4
|
5
|
|
5
|
6
|
/**
|
6
|
7
|
* Provides a case-insensitive mapping from a String to some value, according to the provided [CaseMapping].
|
7
|
8
|
*/
|
8
|
9
|
abstract class CaseInsensitiveMap<T>(private val caseMappingProvider: () -> CaseMapping, private val nameOf: (T) -> String) : Iterable<T> {
|
9
|
10
|
|
10
|
|
- private val values = HashSet<T>()
|
|
11
|
+ private val values = Collections.synchronizedSet(HashSet<T>())
|
11
|
12
|
|
12
|
13
|
/** Gets the value of the given key, if present. */
|
13
|
14
|
operator fun get(name: String) = values.find { caseMappingProvider().areEquivalent(nameOf(it), name) }
|