com.koloboke.collect.impl.hash.DHashByteSetFactorySO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of koloboke-impl-jdk6-7 Show documentation
Show all versions of koloboke-impl-jdk6-7 Show documentation
Carefully designed and efficient extension of the Java Collections Framework with primitive specializations and more, built for Java 6 or 7 (Implementation)
The newest version!
/* with
DHash|QHash|LHash hash
byte|char|short|int|long|float|double elem
*/
/*
* 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.ByteCollection;
import com.koloboke.collect.hash.*;
import com.koloboke.collect.set.hash.HashByteSetFactory;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Set;
public abstract class DHashByteSetFactorySO
extends ByteDHashFactory
/* if !(float|double elem) && !(LHash hash) *//* endif */
implements HashByteSetFactory {
DHashByteSetFactorySO(HashConfig hashConf, int defaultExpectedSize
/* if !(float|double elem) */, byte lower, byte upper/* endif */) {
super(hashConf, defaultExpectedSize/* if !(float|double elem) */, lower, upper/* endif */);
}
/* if !(float|double elem) && !(LHash hash) */
@Override
MutableDHashByteSetGO createNewMutable(int expectedSize, byte free, byte removed) {
MutableDHashByteSet set = new MutableDHashByteSet();
set.init(configWrapper, expectedSize, free, removed);
return set;
}
/* endif */
/* with Mutable|Updatable|Immutable mutability */
MutableDHashByteSetGO uninitializedMutableSet() {
return new MutableDHashByteSet();
}
/* endwith */
/* with Mutable|Updatable mutability */
@Override
@Nonnull
public MutableDHashByteSetGO newMutableSet(int expectedSize) {
/* if float|double elem */
MutableDHashByteSetGO set = new MutableDHashByteSet();
set.init(configWrapper, expectedSize);
return set;
/* elif !(float|double elem) && !(LHash hash) && Mutable mutability */
return newMutableHash(expectedSize);
/* elif LHash hash || Updatable mutability */
MutableDHashByteSetGO set = new MutableDHashByteSet();
set.init(configWrapper, expectedSize, getFree());
return set;
/* endif */
}
/* if Updatable mutability */
@Override
@Nonnull
public MutableDHashByteSetGO newMutableSet(Iterable elements, int expectedSize) {
if (elements instanceof ByteCollection) {
if (elements instanceof SeparateKVByteDHash) {
SeparateKVByteDHash hash = (SeparateKVByteDHash) elements;
if (hash.hashConfig().equals(hashConf)) {
MutableDHashByteSet set = new MutableDHashByteSet();
set.copy(hash);
return set;
}
}
int size = elements instanceof Set ? ((Set) elements).size() : expectedSize;
MutableDHashByteSetGO set = newMutableSet(size);
set.addAll((Collection) elements);
return set;
} else {
int size = elements instanceof Set ? ((Set) elements).size() : expectedSize;
MutableDHashByteSetGO set = newMutableSet(size);
for (byte e : elements) {
set.add(e);
}
return set;
}
}
/* endif */
/* endwith */
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy