com.koloboke.collect.impl.hash.QHashParallelKVObjObjMapFactoryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of koloboke-impl-jdk8 Show documentation
Show all versions of koloboke-impl-jdk8 Show documentation
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 QHashParallelKVObjObjMapFactoryImpl
extends QHashParallelKVObjObjMapFactoryGO {
/** For ServiceLoader */
public QHashParallelKVObjObjMapFactoryImpl() {
this(HashConfig.getDefault(), 10
, false
);
}
QHashParallelKVObjObjMapFactoryImpl(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
) {
super(hashConf, defaultExpectedSize, isNullKeyAllowed
);
}
@Override
HashObjObjMapFactory thisWith(HashConfig hashConf, int defaultExpectedSize, boolean isNullKeyAllowed
) {
return new QHashParallelKVObjObjMapFactoryImpl(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 super K> 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 super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality())) {
return (HashObjObjMapFactory) this;
}
return new WithCustomValueEquivalence(getHashConfig(), getDefaultExpectedSize()
, isNullKeyAllowed(),
(Equivalence) valueEquivalence);
}
static class WithCustomKeyEquivalence
extends QHashParallelKVObjObjMapFactoryGO {
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
MutableQHashParallelKVObjObjMapGO
uninitializedMutableMap() {
MutableQHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
new MutableQHashParallelKVObjObjMap.WithCustomKeyEquivalence();
map.keyEquivalence = keyEquivalence;
return map;
}
@Override
UpdatableQHashParallelKVObjObjMapGO
uninitializedUpdatableMap() {
UpdatableQHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
new UpdatableQHashParallelKVObjObjMap.WithCustomKeyEquivalence();
map.keyEquivalence = keyEquivalence;
return map;
}
@Override
ImmutableQHashParallelKVObjObjMapGO
uninitializedImmutableMap() {
ImmutableQHashParallelKVObjObjMap.WithCustomKeyEquivalence map =
new ImmutableQHashParallelKVObjObjMap.WithCustomKeyEquivalence();
map.keyEquivalence = keyEquivalence;
return map;
}
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality()))
return new QHashParallelKVObjObjMapFactoryImpl(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 super V> 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 QHashParallelKVObjObjMapFactoryGO {
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
MutableQHashParallelKVObjObjMapGO
uninitializedMutableMap() {
MutableQHashParallelKVObjObjMap.WithCustomValueEquivalence map =
new MutableQHashParallelKVObjObjMap.WithCustomValueEquivalence();
map.valueEquivalence = valueEquivalence;
return map;
}
@Override
UpdatableQHashParallelKVObjObjMapGO
uninitializedUpdatableMap() {
UpdatableQHashParallelKVObjObjMap.WithCustomValueEquivalence map =
new UpdatableQHashParallelKVObjObjMap.WithCustomValueEquivalence();
map.valueEquivalence = valueEquivalence;
return map;
}
@Override
ImmutableQHashParallelKVObjObjMapGO
uninitializedImmutableMap() {
ImmutableQHashParallelKVObjObjMap.WithCustomValueEquivalence map =
new ImmutableQHashParallelKVObjObjMap.WithCustomValueEquivalence();
map.valueEquivalence = valueEquivalence;
return map;
}
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory withKeyEquivalence(
@Nonnull Equivalence super K> 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 super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality()))
return new QHashParallelKVObjObjMapFactoryImpl(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 QHashParallelKVObjObjMapFactoryGO {
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
MutableQHashParallelKVObjObjMapGO
uninitializedMutableMap() {
MutableQHashParallelKVObjObjMap.WithCustomEquivalences map =
new MutableQHashParallelKVObjObjMap.WithCustomEquivalences();
map.keyEquivalence = keyEquivalence;
map.valueEquivalence = valueEquivalence;
return map;
}
@Override
UpdatableQHashParallelKVObjObjMapGO
uninitializedUpdatableMap() {
UpdatableQHashParallelKVObjObjMap.WithCustomEquivalences map =
new UpdatableQHashParallelKVObjObjMap.WithCustomEquivalences();
map.keyEquivalence = keyEquivalence;
map.valueEquivalence = valueEquivalence;
return map;
}
@Override
ImmutableQHashParallelKVObjObjMapGO
uninitializedImmutableMap() {
ImmutableQHashParallelKVObjObjMap.WithCustomEquivalences map =
new ImmutableQHashParallelKVObjObjMap.WithCustomEquivalences();
map.keyEquivalence = keyEquivalence;
map.valueEquivalence = valueEquivalence;
return map;
}
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory withKeyEquivalence(
@Nonnull Equivalence super K> 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 super V> 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);
}
}
}