|
|
@@ -17,7 +17,6 @@ import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.SortedMap;
|
|
|
import java.util.SortedSet;
|
|
|
-import java.util.function.Consumer;
|
|
|
import java.util.function.Supplier;
|
|
|
import java.util.stream.Stream;
|
|
|
import net.ranides.assira.collection.maps.ASortedMap;
|
|
|
@@ -65,34 +64,29 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
protected <T> IndexComparator<V, T> mindex(String name) {
|
|
|
return name2mindex.get(name);
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
protected Comparator<V> sindex(String name) {
|
|
|
return name2sindex.get(name);
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void update(V value, Consumer<? super V> consumer) {
|
|
|
- remove(value);
|
|
|
- consumer.accept(value);
|
|
|
- put(value);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void remove(V value) {
|
|
|
for(SortedSet<V> index : cindexes.values()) {
|
|
|
- $remove(index, value);
|
|
|
+ CIndexTreeMap.this.iremove(index, value);
|
|
|
}
|
|
|
for(SortedMap<Object,V> index : mindexes.values()) {
|
|
|
- CIndexTreeMap.this.$remove(index, value);
|
|
|
+ iremove(index, value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void $remove(SortedSet<V> set, V value) {
|
|
|
+ private void iremove(SortedSet<V> set, V value) {
|
|
|
Comparator<? super V> c = set.comparator();
|
|
|
Iterator<V> i = set.headSet(value).iterator();
|
|
|
while(i.hasNext()) {
|
|
|
@@ -107,7 +101,7 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void $remove(SortedMap<Object,V> map, V value) {
|
|
|
+ private void iremove(SortedMap<Object,V> map, V value) {
|
|
|
Comparator<Object> c = CompareUtils.comparator();
|
|
|
Iterator<Entry<Object,V>> i = map.headMap(value).entrySet().iterator();
|
|
|
while(i.hasNext()) {
|
|
|
@@ -122,8 +116,9 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
- protected void update() {
|
|
|
+ public void updateAll() {
|
|
|
List<V> items = new ArrayList<>(values());
|
|
|
for(SortedSet<V> index : cindexes.values()) {
|
|
|
index.clear();
|
|
|
@@ -145,6 +140,7 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
return new CHQuery();
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public void put(V value) {
|
|
|
for(SortedSet<V> index : cindexes.values()) {
|
|
|
@@ -171,7 +167,7 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
return cindexes.values().iterator().next();
|
|
|
}
|
|
|
|
|
|
- private Object after(ASortedMap<Object, V> map, Object value) {
|
|
|
+ private static Object after(ASortedMap<Object, ?> map, Object value) {
|
|
|
Comparator<Object> cmp = CompareUtils.comparator();
|
|
|
Iterator<Object> i = map.keySet().iterator(value);
|
|
|
while(i.hasNext()) {
|
|
|
@@ -183,11 +179,11 @@ public class CIndexTreeMap<V> extends AIndexMap<V> {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private V after(ASortedSet<V> set, V value) {
|
|
|
- Comparator<? super V> cmp = set.comparator();
|
|
|
- Iterator<V> i = set.iterator(value);
|
|
|
+ private static <T> T after(ASortedSet<T> set, T value) {
|
|
|
+ Comparator<? super T> cmp = set.comparator();
|
|
|
+ Iterator<T> i = set.iterator(value);
|
|
|
while(i.hasNext()) {
|
|
|
- V next = i.next();
|
|
|
+ T next = i.next();
|
|
|
if(cmp.compare(value, next)!=0) {
|
|
|
return next;
|
|
|
}
|