// 
// Decompiled by Procyon v0.6.0
// 

package it.unimi.dsi.fastutil.objects;

import java.util.Collection;
import java.util.Set;
import java.util.function.IntBinaryOperator;
import it.unimi.dsi.fastutil.chars.CharBinaryOperator;
import java.util.function.BiFunction;
import it.unimi.dsi.fastutil.SafeMath;
import java.util.Objects;
import java.util.function.ToIntFunction;
import java.util.function.Consumer;
import java.util.function.BiConsumer;
import it.unimi.dsi.fastutil.chars.CharCollection;
import java.util.Map;

public interface Object2CharMap<K> extends Object2CharFunction<K>, Map<K, Character>
{
    int size();
    
    default void clear() {
        throw new UnsupportedOperationException();
    }
    
    void defaultReturnValue(final char p0);
    
    char defaultReturnValue();
    
    ObjectSet<Entry<K>> object2CharEntrySet();
    
    @Deprecated
    default ObjectSet<Map.Entry<K, Character>> entrySet() {
        return (ObjectSet<Map.Entry<K, Character>>)this.object2CharEntrySet();
    }
    
    @Deprecated
    default Character put(final K key, final Character value) {
        return super.put(key, value);
    }
    
    @Deprecated
    default Character get(final Object key) {
        return super.get(key);
    }
    
    @Deprecated
    default Character remove(final Object key) {
        return super.remove(key);
    }
    
    ObjectSet<K> keySet();
    
    CharCollection values();
    
    boolean containsKey(final Object p0);
    
    boolean containsValue(final char p0);
    
    @Deprecated
    default boolean containsValue(final Object value) {
        return value != null && this.containsValue((char)value);
    }
    
    default void forEach(final BiConsumer<? super K, ? super Character> consumer) {
        final ObjectSet<Entry<K>> entrySet = this.object2CharEntrySet();
        final Consumer<Entry<K>> wrappingConsumer = entry -> consumer.accept(entry.getKey(), entry.getCharValue());
        if (entrySet instanceof FastEntrySet) {
            ((FastEntrySet)entrySet).fastForEach(wrappingConsumer);
        }
        else {
            entrySet.forEach(wrappingConsumer);
        }
    }
    
    default char getOrDefault(final Object key, final char defaultValue) {
        final char v;
        return ((v = this.getChar(key)) != this.defaultReturnValue() || this.containsKey(key)) ? v : defaultValue;
    }
    
    @Deprecated
    default Character getOrDefault(final Object key, final Character defaultValue) {
        return super.getOrDefault(key, defaultValue);
    }
    
    default char putIfAbsent(final K key, final char value) {
        final char v = this.getChar(key);
        final char drv = this.defaultReturnValue();
        if (v != drv || this.containsKey(key)) {
            return v;
        }
        this.put(key, value);
        return drv;
    }
    
    default boolean remove(final Object key, final char value) {
        final char curValue = this.getChar(key);
        if (curValue != value || (curValue == this.defaultReturnValue() && !this.containsKey(key))) {
            return false;
        }
        this.removeChar(key);
        return true;
    }
    
    default boolean replace(final K key, final char oldValue, final char newValue) {
        final char curValue = this.getChar(key);
        if (curValue != oldValue || (curValue == this.defaultReturnValue() && !this.containsKey(key))) {
            return false;
        }
        this.put(key, newValue);
        return true;
    }
    
    default char replace(final K key, final char value) {
        return this.containsKey(key) ? this.put(key, value) : this.defaultReturnValue();
    }
    
    default char computeIfAbsent(final K key, final ToIntFunction<? super K> mappingFunction) {
        Objects.requireNonNull(mappingFunction);
        final char v = this.getChar(key);
        if (v != this.defaultReturnValue() || this.containsKey(key)) {
            return v;
        }
        final char newValue = SafeMath.safeIntToChar(mappingFunction.applyAsInt(key));
        this.put(key, newValue);
        return newValue;
    }
    
    @Deprecated
    default char computeCharIfAbsent(final K key, final ToIntFunction<? super K> mappingFunction) {
        return this.computeIfAbsent(key, mappingFunction);
    }
    
    default char computeIfAbsent(final K key, final Object2CharFunction<? super K> mappingFunction) {
        Objects.requireNonNull(mappingFunction);
        final char v = this.getChar(key);
        final char drv = this.defaultReturnValue();
        if (v != drv || this.containsKey(key)) {
            return v;
        }
        if (!mappingFunction.containsKey(key)) {
            return drv;
        }
        final char newValue = mappingFunction.getChar(key);
        this.put(key, newValue);
        return newValue;
    }
    
    @Deprecated
    default char computeCharIfAbsentPartial(final K key, final Object2CharFunction<? super K> mappingFunction) {
        return this.computeIfAbsent(key, mappingFunction);
    }
    
    default char computeCharIfPresent(final K key, final BiFunction<? super K, ? super Character, ? extends Character> remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        final char oldValue = this.getChar(key);
        final char drv = this.defaultReturnValue();
        if (oldValue == drv && !this.containsKey(key)) {
            return drv;
        }
        final Character newValue = (Character)remappingFunction.apply(key, oldValue);
        if (newValue == null) {
            this.removeChar(key);
            return drv;
        }
        final char newVal = newValue;
        this.put(key, newVal);
        return newVal;
    }
    
    default char computeChar(final K key, final BiFunction<? super K, ? super Character, ? extends Character> remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        final char oldValue = this.getChar(key);
        final char drv = this.defaultReturnValue();
        final boolean contained = oldValue != drv || this.containsKey(key);
        final Character newValue = (Character)remappingFunction.apply(key, contained ? Character.valueOf(oldValue) : null);
        if (newValue == null) {
            if (contained) {
                this.removeChar(key);
            }
            return drv;
        }
        final char newVal = newValue;
        this.put(key, newVal);
        return newVal;
    }
    
    default char merge(final K key, final char value, final BiFunction<? super Character, ? super Character, ? extends Character> remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        final char oldValue = this.getChar(key);
        final char drv = this.defaultReturnValue();
        char newValue;
        if (oldValue != drv || this.containsKey(key)) {
            final Character mergedValue = (Character)remappingFunction.apply(oldValue, value);
            if (mergedValue == null) {
                this.removeChar(key);
                return drv;
            }
            newValue = mergedValue;
        }
        else {
            newValue = value;
        }
        this.put(key, newValue);
        return newValue;
    }
    
    default char mergeChar(final K key, final char value, final CharBinaryOperator remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        final char oldValue = this.getChar(key);
        final char drv = this.defaultReturnValue();
        final char newValue = (oldValue != drv || this.containsKey(key)) ? remappingFunction.apply(oldValue, value) : value;
        this.put(key, newValue);
        return newValue;
    }
    
    default char mergeChar(final K key, final char value, final IntBinaryOperator remappingFunction) {
        return this.mergeChar(key, value, (remappingFunction instanceof CharBinaryOperator) ? ((CharBinaryOperator)remappingFunction) : ((x, y) -> SafeMath.safeIntToChar(remappingFunction.applyAsInt(x, y))));
    }
    
    @Deprecated
    default char mergeChar(final K key, final char value, final BiFunction<? super Character, ? super Character, ? extends Character> remappingFunction) {
        return this.merge(key, value, remappingFunction);
    }
    
    @Deprecated
    default Character putIfAbsent(final K key, final Character value) {
        return super.putIfAbsent(key, value);
    }
    
    @Deprecated
    default boolean remove(final Object key, final Object value) {
        return super.remove(key, value);
    }
    
    @Deprecated
    default boolean replace(final K key, final Character oldValue, final Character newValue) {
        return super.replace(key, oldValue, newValue);
    }
    
    @Deprecated
    default Character replace(final K key, final Character value) {
        return super.replace(key, value);
    }
    
    @Deprecated
    default Character merge(final K key, final Character value, final BiFunction<? super Character, ? super Character, ? extends Character> remappingFunction) {
        return super.merge(key, value, remappingFunction);
    }
    
    public interface FastEntrySet<K> extends ObjectSet<Entry<K>>
    {
        ObjectIterator<Entry<K>> fastIterator();
        
        default void fastForEach(final Consumer<? super Entry<K>> consumer) {
            this.forEach(consumer);
        }
    }
    
    public interface Entry<K> extends Map.Entry<K, Character>
    {
        char getCharValue();
        
        char setValue(final char p0);
        
        @Deprecated
        default Character getValue() {
            return this.getCharValue();
        }
        
        @Deprecated
        default Character setValue(final Character value) {
            return this.setValue((char)value);
        }
    }
}
