![JAR search and dependency download from the Maven repository](/logo.png)
io.timeandspace.smoothie.SmoothieMapWithCustomValueEquivalence Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smoothie-map Show documentation
Show all versions of smoothie-map Show documentation
Map implementation with low footprint and no latency spikes
/*
* Copyright (C) The SmoothieMap 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 io.timeandspace.smoothie;
import io.timeandspace.collect.Equivalence;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.function.Supplier;
import java.util.function.ToLongFunction;
import static io.timeandspace.smoothie.ObjectSize.classSizeInBytes;
/**
* The logic of this class is the same as of {@link SmoothieMapWithCustomKeyAndValueEquivalences}.
* These classes should be updated in parallel.
*/
final class SmoothieMapWithCustomValueEquivalence extends SmoothieMap {
private static final long SIZE_IN_BYTES =
classSizeInBytes(SmoothieMapWithCustomValueEquivalence.class);
private final Equivalence valueEquivalence;
SmoothieMapWithCustomValueEquivalence(SmoothieMapBuilder builder) {
super(builder);
valueEquivalence = builder.valueEquivalence();
}
@Override
boolean valuesEqual(Object queriedValue, V internalValue) {
//noinspection unchecked
return valueEquivalence.equivalent((V) queriedValue, internalValue);
}
@Override
public Equivalence valueEquivalence() {
return valueEquivalence;
}
@Override
int valueHashCodeForAggregateHashCodes(Object value) {
//noinspection unchecked
return valueEquivalence.hash((V) value);
}
/** Doesn't account for {@link #valueEquivalence}. */
@Override
long smoothieMapClassSizeInBytes() {
return SIZE_IN_BYTES;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy