Optimization of Index
This commit is contained in:
parent
f0079cb6c8
commit
eff7aeaf5c
1 changed files with 5 additions and 3 deletions
|
|
@ -157,6 +157,7 @@ class Index[K <: AnyRef,V <: AnyRef : Manifest] {
|
|||
|
||||
private val Naught = Array[V]() //Nil for Arrays
|
||||
private val container = new ConcurrentHashMap[K, JSet[V]]
|
||||
private val emptySet = new ConcurrentSkipListSet[V]
|
||||
|
||||
def put(key: K, value: V) {
|
||||
|
||||
|
|
@ -213,9 +214,10 @@ class Index[K <: AnyRef,V <: AnyRef : Manifest] {
|
|||
val set = container get key
|
||||
if (set ne null) {
|
||||
set.synchronized {
|
||||
set remove value
|
||||
if (set.isEmpty)
|
||||
container remove key
|
||||
if (set.remove(value)) {
|
||||
if (set.isEmpty)
|
||||
container.remove(key,emptySet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue