skadistats.clarity.model.state.TreeMapEntityState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarity Show documentation
Show all versions of clarity Show documentation
Clarity is an open source replay parser for Dota 2, CSGO, CS2 and Deadlock written in Java.
package skadistats.clarity.model.state;
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap;
import skadistats.clarity.model.FieldPath;
import java.util.Iterator;
public class TreeMapEntityState implements EntityState {
private final Object2ObjectAVLTreeMap state;
public TreeMapEntityState() {
state = new Object2ObjectAVLTreeMap<>();
}
private TreeMapEntityState(TreeMapEntityState other) {
state = other.state.clone();
}
@Override
public EntityState copy() {
return new TreeMapEntityState(this);
}
@Override
public boolean setValueForFieldPath(FieldPath fp, Object value) {
if (value != null) {
return state.put(fp, value) == null;
} else {
return state.remove(fp) != null;
}
}
@Override
public T getValueForFieldPath(FieldPath fp) {
return (T) state.get(fp);
}
@Override
public Iterator fieldPathIterator() {
return state.keySet().iterator();
}
}