use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.
the class MapReference method equals.
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (!(obj instanceof MapReference) || myHash != ((MapReference) obj).myHash)
return false;
KeyFMap o1 = get();
KeyFMap o2 = ((MapReference) obj).get();
if (o1 == null || o2 == null)
return false;
if (o1 instanceof OneElementFMap && o2 instanceof OneElementFMap) {
OneElementFMap m1 = (OneElementFMap) o1;
OneElementFMap m2 = (OneElementFMap) o2;
return m1.getKey() == m2.getKey() && m1.getValue() == m2.getValue();
}
if (o1 instanceof PairElementsFMap && o2 instanceof PairElementsFMap) {
PairElementsFMap m1 = (PairElementsFMap) o1;
PairElementsFMap m2 = (PairElementsFMap) o2;
return m1.getKey1() == m2.getKey1() && m1.getKey2() == m2.getKey2() && m1.getValue1() == m2.getValue1() && m1.getValue2() == m2.getValue2();
}
if (o1 instanceof ArrayBackedFMap && o2 instanceof ArrayBackedFMap) {
ArrayBackedFMap m1 = (ArrayBackedFMap) o1;
ArrayBackedFMap m2 = (ArrayBackedFMap) o2;
return Arrays.equals(m1.getKeyIds(), m2.getKeyIds()) && containSameElements(m1.getValues(), m2.getValues());
}
return false;
}
use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.
the class MapReference method internUserData.
static KeyFMap internUserData(@NotNull KeyFMap map) {
if (shouldIntern(map)) {
MapReference key = new MapReference(map);
synchronized (ourCache) {
KeyFMap cached = SoftReference.dereference(ourCache.get(key));
if (cached != null)
return cached;
ourCache.put(key, key);
}
return map;
}
return map;
}
use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.
the class UserDataHolderBase method replace.
@Override
public <T> boolean replace(@NotNull Key<T> key, @Nullable T oldValue, @Nullable T newValue) {
while (true) {
KeyFMap map = getUserMap();
if (map.get(key) != oldValue) {
return false;
}
KeyFMap newMap = newValue == null ? map.minus(key) : map.plus(key, newValue);
if (newMap == map || changeUserMap(map, newMap)) {
return true;
}
}
}
use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.
the class UserDataHolderBase method getUserDataString.
@TestOnly
public String getUserDataString() {
final KeyFMap userMap = getUserMap();
final KeyFMap copyableMap = getUserData(COPYABLE_USER_MAP_KEY);
return userMap + (copyableMap == null ? "" : copyableMap.toString());
}
use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.
the class UserDataHolderBase method putUserData.
@Override
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
while (true) {
KeyFMap map = getUserMap();
KeyFMap newMap = value == null ? map.minus(key) : map.plus(key, value);
if (newMap == map || changeUserMap(map, newMap)) {
break;
}
}
}
Aggregations