com.koloboke.collect.impl.hash.DHashSeparateKVByteShortMapFactoryImpl 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!
/* with
DHash|QHash|LHash hash
byte|char|short|int|long|float|double|obj key
short|byte|char|int|long|float|double|obj value
Separate|Parallel kv
*/
/*
* 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 DHashSeparateKVByteShortMapFactoryImpl/*<>*/
extends DHashSeparateKVByteShortMapFactoryGO/*<>*/ {
/* define p1 */
/* if obj key obj value //// elif obj key //
// elif obj value //// endif */
/* enddefine */
/* define p2 */
/* if obj key obj value //// elif obj key //// elif obj value //// endif */
/* enddefine */
/* define kAnd *//* if obj key //K, // endif *//* enddefine */
/* define p1And *//* if obj key //K2 extends K, // endif *//* enddefine */
/* define p2And *//* if obj key //K2, // endif *//* enddefine */
/* define andV *//* if obj value //, V// endif *//* enddefine */
/* define andP1 *//* if obj value //, V2 extends V// endif *//* enddefine */
/* define andP2 *//* if obj value //, V2// endif *//* enddefine */
/** For ServiceLoader */
public DHashSeparateKVByteShortMapFactoryImpl() {
this(HashConfig.getDefault(), 10
/* if obj key */, false
/* elif !(float|double key) */, Byte.MIN_VALUE, Byte.MAX_VALUE/* endif */);
}
/* define commonArgDef //
HashConfig hashConf, int defaultExpectedSize// if obj key //, boolean isNullKeyAllowed
// elif !(float|double key) //, byte lower, byte upper// endif //
// enddefine */
/* define commonArgApply //
hashConf, defaultExpectedSize// if obj key //, isNullKeyAllowed
// elif !(float|double key) //, lower, upper// endif //
// enddefine */
/* define commonArgGet //
getHashConfig(), getDefaultExpectedSize()
// if obj key //, isNullKeyAllowed()// elif !(float|double key) //
, getLowerKeyDomainBound(), getUpperKeyDomainBound()// endif //
// enddefine */
DHashSeparateKVByteShortMapFactoryImpl(/* commonArgDef */) {
super(/* commonArgApply */);
}
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgApply */);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgApply */);
}
/* endwith */
/* if obj key */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjShortMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality())) {
return (HashObjShortMapFactory/*<>*/) this;
}
return new WithCustomKeyEquivalence/*<>*/(/* commonArgGet */,
(Equivalence) keyEquivalence);
}
/* endif */
/* if !(obj value) */
@Override
@Nonnull
public HashByteShortMapFactory/*<>*/ withDefaultValue(short defaultValue) {
if (defaultValue == /* const value 0 */0)
return this;
return new WithCustomDefaultValue/*<>*/(/* commonArgGet */, defaultValue);
}
/* elif obj value */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashByteObjMapFactory/*<>*/ withValueEquivalence(
@Nonnull Equivalence super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality())) {
return (HashByteObjMapFactory/*<>*/) this;
}
return new WithCustomValueEquivalence/*<>*/(/* commonArgGet */,
(Equivalence) valueEquivalence);
}
/* endif */
/* if obj key */
static class WithCustomKeyEquivalence
extends DHashSeparateKVObjShortMapFactoryGO {
private final Equivalence keyEquivalence;
WithCustomKeyEquivalence(/* commonArgDef */, Equivalence keyEquivalence) {
super(/* commonArgApply */);
this.keyEquivalence = keyEquivalence;
}
@Override
@Nonnull
public Equivalence getKeyEquivalence() {
return keyEquivalence;
}
/* with Mutable|Updatable|Immutable mutability */
@Override
MutableDHashSeparateKVObjShortMapGO
uninitializedMutableMap() {
MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalence map =
new MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalence ();
map.keyEquivalence = keyEquivalence;
return map;
}
/* endwith */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjShortMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality()))
return new DHashSeparateKVObjShortMapFactoryImpl/*<>*/(/* commonArgGet */);
if (keyEquivalence.equals(this.keyEquivalence)) {
return (HashObjShortMapFactory/*<>*/) this;
}
return new WithCustomKeyEquivalence/*<>*/(/* commonArgGet */,
(Equivalence) keyEquivalence);
}
/* if !(obj value) */
@Override
@Nonnull
public HashObjShortMapFactory withDefaultValue(short defaultValue) {
if (defaultValue == /* const value 0 */0)
return this;
return new WithCustomKeyEquivalenceAndDefaultValue (
/* commonArgGet */, keyEquivalence, defaultValue);
}
/* elif obj value */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory/*<>*/ withValueEquivalence(
@Nonnull Equivalence super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality())) {
return (HashObjObjMapFactory/*<>*/) this;
}
return new WithCustomEquivalences/*<>*/(/* commonArgGet */,
keyEquivalence, (Equivalence) valueEquivalence);
}
/* endif */
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new WithCustomKeyEquivalence (/* commonArgApply */, keyEquivalence);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomKeyEquivalence (
/* commonArgApply */, keyEquivalence);
}
/* endwith */
}
/* endif */
/* if !(obj value) */
static final class WithCustomDefaultValue/*<>*/
extends DHashSeparateKVByteShortMapFactoryGO/*<>*/ {
private final short defaultValue;
WithCustomDefaultValue(/* commonArgDef */, short defaultValue) {
super(/* commonArgApply */);
this.defaultValue = defaultValue;
}
@Override
public short getDefaultValue() {
return defaultValue;
}
/* with Mutable|Updatable|Immutable mutability */
@Override
/*p1*/ MutableDHashSeparateKVByteShortMapGO/*p2*/ uninitializedMutableMap() {
MutableDHashSeparateKVByteShortMap.WithCustomDefaultValue/*p2*/ map =
new MutableDHashSeparateKVByteShortMap.WithCustomDefaultValue/*p2*/();
map.defaultValue = defaultValue;
return map;
}
/* endwith */
/* if obj key */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjShortMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality())) {
return (HashObjShortMapFactory/*<>*/) this;
}
return new WithCustomKeyEquivalenceAndDefaultValue/*<>*/(/* commonArgGet */,
(Equivalence) keyEquivalence, defaultValue);
}
/* endif */
@Override
@Nonnull
public HashByteShortMapFactory/*<>*/ withDefaultValue(short defaultValue) {
if (defaultValue == /* const value 0 */0)
return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgGet */);
if (defaultValue == this.defaultValue)
return this;
return new WithCustomDefaultValue/*<>*/(/* commonArgGet */, defaultValue);
}
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new WithCustomDefaultValue/*<>*/(/* commonArgApply */, defaultValue);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomDefaultValue/*<>*/(
/* commonArgApply */, defaultValue);
}
/* endwith */
}
/* elif obj value */
static final class WithCustomValueEquivalence*kAnd*/V>
extends DHashSeparateKVByteObjMapFactoryGO*kAnd*/V> {
private final Equivalence valueEquivalence;
WithCustomValueEquivalence(/* commonArgDef */,
Equivalence valueEquivalence) {
super(/* commonArgApply */);
this.valueEquivalence = valueEquivalence;
}
@Override
@Nonnull
public Equivalence getValueEquivalence() {
return valueEquivalence;
}
/* with Mutable|Updatable|Immutable mutability */
@Override
*p1And*/V2 extends V> MutableDHashSeparateKVByteObjMapGO*p2And*/V2>
uninitializedMutableMap() {
MutableDHashSeparateKVByteObjMap.WithCustomValueEquivalence*p2And*/V2> map =
new MutableDHashSeparateKVByteObjMap.WithCustomValueEquivalence*p2And*/V2>();
map.valueEquivalence = valueEquivalence;
return map;
}
/* endwith */
/* if obj key */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality())) {
return (HashObjObjMapFactory/*<>*/) this;
}
return new WithCustomEquivalences/*<>*/(/* commonArgGet */,
(Equivalence) keyEquivalence, valueEquivalence);
}
/* endif */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashByteObjMapFactory/*<>*/ withValueEquivalence(
@Nonnull Equivalence super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality()))
return new DHashSeparateKVByteObjMapFactoryImpl/*<>*/(/* commonArgGet */);
if (valueEquivalence.equals(this.valueEquivalence))
return (HashByteObjMapFactory/*<>*/) this;
return new WithCustomValueEquivalence/*<>*/(/* commonArgGet */,
(Equivalence) valueEquivalence);
}
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new WithCustomValueEquivalence*kAnd*/V>(/* commonArgApply */,
valueEquivalence);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomValueEquivalence*kAnd*/V>(
/* commonArgApply */, valueEquivalence);
}
/* endwith */
}
/* endif */
/* if obj key && !(obj value) */
static final class WithCustomKeyEquivalenceAndDefaultValue
extends DHashSeparateKVObjShortMapFactoryGO {
private final Equivalence keyEquivalence;
private final short defaultValue;
WithCustomKeyEquivalenceAndDefaultValue(/* commonArgDef */,
Equivalence keyEquivalence, short defaultValue) {
super(/* commonArgApply */);
this.keyEquivalence = keyEquivalence;
this.defaultValue = defaultValue;
}
@Override
@Nonnull
public Equivalence getKeyEquivalence() {
return keyEquivalence;
}
@Override
public short getDefaultValue() {
return defaultValue;
}
/* with Mutable|Updatable|Immutable mutability */
@Override
MutableDHashSeparateKVObjShortMapGO uninitializedMutableMap() {
MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalenceAndDefaultValue map =
new MutableDHashSeparateKVObjShortMap
.WithCustomKeyEquivalenceAndDefaultValue();
map.keyEquivalence = keyEquivalence;
map.defaultValue = defaultValue;
return map;
}
/* endwith */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjShortMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality()))
return new WithCustomDefaultValue/*<>*/(/* commonArgGet */, defaultValue);
if (keyEquivalence.equals(this.keyEquivalence)) {
return (HashObjShortMapFactory/*<>*/) this;
}
return new WithCustomKeyEquivalenceAndDefaultValue/*<>*/(
/* commonArgGet */, (Equivalence) keyEquivalence, defaultValue);
}
@Override
@Nonnull
public HashObjShortMapFactory withDefaultValue(short defaultValue) {
if (defaultValue == /* const value 0 */0)
return new WithCustomKeyEquivalence(/* commonArgGet */, keyEquivalence);
if (defaultValue == this.defaultValue)
return this;
return new WithCustomKeyEquivalenceAndDefaultValue(
/* commonArgGet */, keyEquivalence, defaultValue);
}
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new WithCustomKeyEquivalenceAndDefaultValue(/* commonArgApply */,
keyEquivalence, defaultValue);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl
.WithCustomKeyEquivalenceAndDefaultValue(/* commonArgApply */,
keyEquivalence, defaultValue);
}
/* endwith */
}
/* elif obj key obj value */
static final class WithCustomEquivalences
extends DHashSeparateKVObjObjMapFactoryGO {
private final Equivalence keyEquivalence;
private final Equivalence valueEquivalence;
WithCustomEquivalences(/* commonArgDef */,
Equivalence keyEquivalence, Equivalence valueEquivalence) {
super(/* commonArgApply */);
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
}
@Override
@Nonnull
public Equivalence getKeyEquivalence() {
return keyEquivalence;
}
@Override
@Nonnull
public Equivalence getValueEquivalence() {
return valueEquivalence;
}
/* with Mutable|Updatable|Immutable mutability */
@Override
MutableDHashSeparateKVObjObjMapGO
uninitializedMutableMap() {
MutableDHashSeparateKVObjObjMap.WithCustomEquivalences map =
new MutableDHashSeparateKVObjObjMap.WithCustomEquivalences();
map.keyEquivalence = keyEquivalence;
map.valueEquivalence = valueEquivalence;
return map;
}
/* endwith */
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory/*<>*/ withKeyEquivalence(
@Nonnull Equivalence super K> keyEquivalence) {
if (keyEquivalence.equals(Equivalence.defaultEquality()))
return new WithCustomValueEquivalence/*<>*/(/* commonArgGet */,
valueEquivalence);
if (keyEquivalence.equals(this.keyEquivalence)) {
return (HashObjObjMapFactory/*<>*/) this;
}
return new WithCustomEquivalences/*<>*/(/* commonArgGet */,
(Equivalence) keyEquivalence, valueEquivalence);
}
@SuppressWarnings("unchecked")
@Override
@Nonnull
public HashObjObjMapFactory/*<>*/ withValueEquivalence(
@Nonnull Equivalence super V> valueEquivalence) {
if (valueEquivalence.equals(Equivalence.defaultEquality()))
return new WithCustomKeyEquivalence/*<>*/(/* commonArgGet */, keyEquivalence);
if (valueEquivalence.equals(this.valueEquivalence)) {
return (HashObjObjMapFactory/*<>*/) this;
}
return new WithCustomEquivalences/*<>*/(/* commonArgGet */,
keyEquivalence, (Equivalence) valueEquivalence);
}
@Override
HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
return new WithCustomEquivalences(/* commonArgApply */,
keyEquivalence, valueEquivalence);
}
/* with DHash|QHash|LHash hash */
@Override
HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomEquivalences(
/* commonArgApply */, keyEquivalence, valueEquivalence);
}
/* endwith */
}
/* endif */
}