All Downloads are FREE. Search and download functionalities are using the official Maven repository.

skadistats.clarity.model.state.TreeMapEntityState Maven / Gradle / Ivy

Go to download

Clarity is an open source replay parser for Dota 2, CSGO, CS2 and Deadlock written in Java.

There is a newer version: 3.1.1
Show newest version
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();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy