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

com.koloboke.collect.impl.hash.LHashParallelKVObjObjMapFactoryImpl Maven / Gradle / Ivy

Go to download

Carefully designed and efficient extension of the Java Collections Framework with primitive specializations and more, built for Java 8 (Implementation)

The newest version!
/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.koloboke.collect.impl.hash;

import com.koloboke.collect.*;
import com.koloboke.collect.hash.*;
import com.koloboke.collect.map.hash.*;

import javax.annotation.Nonnull;


public final class LHashParallelKVObjObjMapFactoryImpl
        extends LHashParallelKVObjObjMapFactoryGO {

    

    

    
    
    

    
    
    

    /** For ServiceLoader */
    public LHashParallelKVObjObjMapFactoryImpl() {
        this(HashConfig.getDefault(), 10
            , false
            );
    }

    

    

    

    LHashParallelKVObjObjMapFactoryImpl(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
        super(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
    }

    @Override
    HashObjObjMapFactory thisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
        return new LHashParallelKVObjObjMapFactoryImpl(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
    }

    @Override
    HashObjObjMapFactory qHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
        return new QHashParallelKVObjObjMapFactoryImpl(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
    }
    @Override
    HashObjObjMapFactory lHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
        return new LHashParallelKVObjObjMapFactoryImpl(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
    }

    @SuppressWarnings("unchecked")
    @Override
    @Nonnull
    public HashObjObjMapFactory withKeyEquivalence(
            @Nonnull Equivalence keyEquivalence) {
        if (keyEquivalence.equals(Equivalence.defaultEquality())) {
            return (HashObjObjMapFactory) this;
        }
        return new WithCustomKeyEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                (Equivalence) keyEquivalence);
    }

    @SuppressWarnings("unchecked")
    @Override
    @Nonnull
    public HashObjObjMapFactory withValueEquivalence(
            @Nonnull Equivalence valueEquivalence) {
        if (valueEquivalence.equals(Equivalence.defaultEquality())) {
            return (HashObjObjMapFactory) this;
        }
        return new WithCustomValueEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                (Equivalence) valueEquivalence);
    }

    static class WithCustomKeyEquivalence
            extends LHashParallelKVObjObjMapFactoryGO {

        private final Equivalence keyEquivalence;

        WithCustomKeyEquivalence(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            , Equivalence keyEquivalence) {
            super(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
            this.keyEquivalence = keyEquivalence;
        }

        @Override
        @Nonnull
        public Equivalence getKeyEquivalence() {
            return keyEquivalence;
        }

        @Override
         MutableLHashParallelKVObjObjMapGO
        uninitializedMutableMap() {
            MutableLHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
                    new MutableLHashParallelKVObjObjMap.WithCustomKeyEquivalence();
            map.keyEquivalence = keyEquivalence;
            return map;
        }
        @Override
         UpdatableLHashParallelKVObjObjMapGO
        uninitializedUpdatableMap() {
            UpdatableLHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
                    new UpdatableLHashParallelKVObjObjMap.WithCustomKeyEquivalence();
            map.keyEquivalence = keyEquivalence;
            return map;
        }
        @Override
         ImmutableLHashParallelKVObjObjMapGO
        uninitializedImmutableMap() {
            ImmutableLHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
                    new ImmutableLHashParallelKVObjObjMap.WithCustomKeyEquivalence();
            map.keyEquivalence = keyEquivalence;
            return map;
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withKeyEquivalence(
                @Nonnull Equivalence keyEquivalence) {
            if (keyEquivalence.equals(Equivalence.defaultEquality()))
                return new LHashParallelKVObjObjMapFactoryImpl(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed());
            if (keyEquivalence.equals(this.keyEquivalence)) {
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomKeyEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    (Equivalence) keyEquivalence);
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withValueEquivalence(
                @Nonnull Equivalence valueEquivalence) {
            if (valueEquivalence.equals(Equivalence.defaultEquality())) {
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    keyEquivalence, (Equivalence) valueEquivalence);
        }

        @Override
        HashObjObjMapFactory thisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new WithCustomKeyEquivalence(hashConf, defaultExpectedSize, isNullKeyAllowed
            , keyEquivalence);
        }

        @Override
        HashObjObjMapFactory qHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new QHashParallelKVObjObjMapFactoryImpl.WithCustomKeyEquivalence(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , keyEquivalence);
        }
        @Override
        HashObjObjMapFactory lHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new LHashParallelKVObjObjMapFactoryImpl.WithCustomKeyEquivalence(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , keyEquivalence);
        }
    }

    static final class WithCustomValueEquivalence
            extends LHashParallelKVObjObjMapFactoryGO {

        private final Equivalence valueEquivalence;
        WithCustomValueEquivalence(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ,
                Equivalence valueEquivalence) {
            super(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
            this.valueEquivalence = valueEquivalence;
        }

        @Override
        @Nonnull
        public Equivalence getValueEquivalence() {
            return valueEquivalence;
        }

        @Override
         MutableLHashParallelKVObjObjMapGO
        uninitializedMutableMap() {
            MutableLHashParallelKVObjObjMap.WithCustomValueEquivalence map =
                    new MutableLHashParallelKVObjObjMap.WithCustomValueEquivalence();
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        @Override
         UpdatableLHashParallelKVObjObjMapGO
        uninitializedUpdatableMap() {
            UpdatableLHashParallelKVObjObjMap.WithCustomValueEquivalence map =
                    new UpdatableLHashParallelKVObjObjMap.WithCustomValueEquivalence();
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        @Override
         ImmutableLHashParallelKVObjObjMapGO
        uninitializedImmutableMap() {
            ImmutableLHashParallelKVObjObjMap.WithCustomValueEquivalence map =
                    new ImmutableLHashParallelKVObjObjMap.WithCustomValueEquivalence();
            map.valueEquivalence = valueEquivalence;
            return map;
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withKeyEquivalence(
                @Nonnull Equivalence keyEquivalence) {
            if (keyEquivalence.equals(Equivalence.defaultEquality())) {
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    (Equivalence) keyEquivalence, valueEquivalence);
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withValueEquivalence(
                @Nonnull Equivalence valueEquivalence) {
            if (valueEquivalence.equals(Equivalence.defaultEquality()))
                return new LHashParallelKVObjObjMapFactoryImpl(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed());
            if (valueEquivalence.equals(this.valueEquivalence))
                return (HashObjObjMapFactory) this;
            return new WithCustomValueEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    (Equivalence) valueEquivalence);
        }

        @Override
        HashObjObjMapFactory thisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new WithCustomValueEquivalence(hashConf, defaultExpectedSize, isNullKeyAllowed
            ,
                    valueEquivalence);
        }

        @Override
        HashObjObjMapFactory qHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new QHashParallelKVObjObjMapFactoryImpl.WithCustomValueEquivalence(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , valueEquivalence);
        }
        @Override
        HashObjObjMapFactory lHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new LHashParallelKVObjObjMapFactoryImpl.WithCustomValueEquivalence(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , valueEquivalence);
        }
    }

    static final class WithCustomEquivalences
            extends LHashParallelKVObjObjMapFactoryGO {
        private final Equivalence keyEquivalence;
        private final Equivalence valueEquivalence;

        WithCustomEquivalences(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ,
                Equivalence keyEquivalence, Equivalence valueEquivalence) {
            super(hashConf, defaultExpectedSize, isNullKeyAllowed
            );
            this.keyEquivalence = keyEquivalence;
            this.valueEquivalence = valueEquivalence;
        }

        @Override
        @Nonnull
        public Equivalence getKeyEquivalence() {
            return keyEquivalence;
        }

        @Override
        @Nonnull
        public Equivalence getValueEquivalence() {
            return valueEquivalence;
        }

        @Override
         MutableLHashParallelKVObjObjMapGO
        uninitializedMutableMap() {
            MutableLHashParallelKVObjObjMap.WithCustomEquivalences map =
                    new MutableLHashParallelKVObjObjMap.WithCustomEquivalences();
            map.keyEquivalence = keyEquivalence;
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        @Override
         UpdatableLHashParallelKVObjObjMapGO
        uninitializedUpdatableMap() {
            UpdatableLHashParallelKVObjObjMap.WithCustomEquivalences map =
                    new UpdatableLHashParallelKVObjObjMap.WithCustomEquivalences();
            map.keyEquivalence = keyEquivalence;
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        @Override
         ImmutableLHashParallelKVObjObjMapGO
        uninitializedImmutableMap() {
            ImmutableLHashParallelKVObjObjMap.WithCustomEquivalences map =
                    new ImmutableLHashParallelKVObjObjMap.WithCustomEquivalences();
            map.keyEquivalence = keyEquivalence;
            map.valueEquivalence = valueEquivalence;
            return map;
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withKeyEquivalence(
                @Nonnull Equivalence keyEquivalence) {
            if (keyEquivalence.equals(Equivalence.defaultEquality()))
                return new WithCustomValueEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                        valueEquivalence);
            if (keyEquivalence.equals(this.keyEquivalence)) {
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    (Equivalence) keyEquivalence, valueEquivalence);
        }

        @SuppressWarnings("unchecked")
        @Override
        @Nonnull
        public HashObjObjMapFactory withValueEquivalence(
                @Nonnull Equivalence valueEquivalence) {
            if (valueEquivalence.equals(Equivalence.defaultEquality()))
                return new WithCustomKeyEquivalence(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(), keyEquivalence);
            if (valueEquivalence.equals(this.valueEquivalence)) {
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(getHashConfig(), getDefaultExpectedSize()
        , isNullKeyAllowed(),
                    keyEquivalence, (Equivalence) valueEquivalence);
        }

        @Override
        HashObjObjMapFactory thisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new WithCustomEquivalences(hashConf, defaultExpectedSize, isNullKeyAllowed
            ,
                    keyEquivalence, valueEquivalence);
        }

        @Override
        HashObjObjMapFactory qHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new QHashParallelKVObjObjMapFactoryImpl.WithCustomEquivalences(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , keyEquivalence, valueEquivalence);
        }
        @Override
        HashObjObjMapFactory lHashLikeThisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
            ) {
            return new LHashParallelKVObjObjMapFactoryImpl.WithCustomEquivalences(
                    hashConf, defaultExpectedSize, isNullKeyAllowed
            , keyEquivalence, valueEquivalence);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy