Merged branches hopefully
This commit is contained in:
commit
aa580c1772
|
@ -5,6 +5,10 @@
|
|||
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
|
||||
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
||||
- Fixed: putIfAbsent now replaces defaultValues
|
||||
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
||||
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
||||
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
|
||||
- Breaking Change: Function classes now use the "apply/applyAs/test" format from Java itself, instead of the "get" format. This cleans up a lot of things. But will break existing function class implementations
|
||||
|
||||
### Version 0.7.0
|
||||
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@ configurations {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.1.4'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
||||
|
|
|
@ -52,6 +52,11 @@ public enum ClassType
|
|||
return classType;
|
||||
}
|
||||
|
||||
public String getClassPath()
|
||||
{
|
||||
return this == OBJECT ? "Object" : classType;
|
||||
}
|
||||
|
||||
public String getClassType(boolean value)
|
||||
{
|
||||
return value && this == OBJECT ? "V" : classType;
|
||||
|
@ -128,6 +133,12 @@ public enum ClassType
|
|||
}
|
||||
}
|
||||
|
||||
public String getApply(ClassType other) {
|
||||
if(other == BOOLEAN) return "test";
|
||||
if(other == ClassType.OBJECT) return "apply";
|
||||
return "applyAs"+other.getFileType();
|
||||
}
|
||||
|
||||
public String getEquals(boolean not)
|
||||
{
|
||||
switch(this)
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
package speiger.src.builder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import speiger.src.builder.mappers.IMapper;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ModulePackage
|
||||
{
|
||||
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
||||
public static final ClassType[] TYPE = ClassType.values();
|
||||
final ClassType keyType;
|
||||
final ClassType valueType;
|
||||
Set<String> blocked = new HashSet<>();
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
Map<String, String> splitters = new HashMap<>();
|
||||
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||
List<IMapper> mappers = new ArrayList<>();
|
||||
Set<String> flags = new LinkedHashSet<>();
|
||||
Set<String> globalFlags;
|
||||
BiConsumer<String, RequiredType> requirements = VOID;
|
||||
|
||||
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
||||
this.globalFlags = globalFlags;
|
||||
this.keyType = keyType;
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
requirements = VOID;
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
||||
}
|
||||
|
||||
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public boolean isSame() {
|
||||
return keyType == valueType;
|
||||
}
|
||||
|
||||
public boolean isEnumValid() {
|
||||
return keyType == ClassType.OBJECT;
|
||||
}
|
||||
|
||||
public ClassType getKeyType() {
|
||||
return keyType;
|
||||
}
|
||||
|
||||
public ClassType getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void addFlag(String flag) {
|
||||
flags.add(flag);
|
||||
}
|
||||
|
||||
public void addGlobalFlag(String flag) {
|
||||
globalFlags.add(flag);
|
||||
}
|
||||
|
||||
public void addRequirement(String fileName, RequiredType type) {
|
||||
requirements.accept(fileName, type);
|
||||
}
|
||||
|
||||
public void addMapper(IMapper mapper) {
|
||||
mappers.add(mapper);
|
||||
}
|
||||
|
||||
public void addBlockedFilter(Predicate<String> filter) {
|
||||
blockedFilters.add(filter);
|
||||
}
|
||||
|
||||
public void addBlockedFiles(String... names) {
|
||||
blocked.addAll(Arrays.asList(names));
|
||||
}
|
||||
|
||||
public void addSplitter(String fileName, String splitter) {
|
||||
splitters.put(fileName, splitter);
|
||||
}
|
||||
|
||||
public void addRemapper(String fileName, String actualName) {
|
||||
nameRemapper.put(fileName, actualName);
|
||||
}
|
||||
|
||||
public void process(String fileName, Consumer<TemplateProcess> result) {
|
||||
if(isBlocked(fileName)) return;
|
||||
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
||||
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
||||
TemplateProcess process = new TemplateProcess(newName+".java");
|
||||
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
||||
process.addFlags(flags);
|
||||
process.addFlags(globalFlags);
|
||||
process.addMappers(mappers);
|
||||
result.accept(process);
|
||||
}
|
||||
|
||||
private boolean isBlocked(String fileName) {
|
||||
if(blocked.contains(fileName)) return true;
|
||||
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||
if(blockedFilters.get(i).test(fileName)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||
List<ModulePackage> list = new ArrayList<>();
|
||||
for(ClassType key : TYPE) {
|
||||
for(ClassType value : TYPE) {
|
||||
list.add(new ModulePackage(globalFlags, key, value));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private int sort(String key, String value) {
|
||||
if(value.contains(key)) return 1;
|
||||
else if(key.contains(value)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
class PathBuilder implements UnaryOperator<Path> {
|
||||
String before;
|
||||
|
||||
public PathBuilder(String before) {
|
||||
this.before = before;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path apply(Path t) {
|
||||
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -16,25 +15,35 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import speiger.src.builder.modules.AsyncModule;
|
||||
import speiger.src.builder.modules.BaseModule;
|
||||
import speiger.src.builder.modules.CollectionModule;
|
||||
import speiger.src.builder.modules.FunctionModule;
|
||||
import speiger.src.builder.modules.JavaModule;
|
||||
import speiger.src.builder.modules.ListModule;
|
||||
import speiger.src.builder.modules.MapModule;
|
||||
import speiger.src.builder.modules.PairModule;
|
||||
import speiger.src.builder.modules.PrioQueueModule;
|
||||
import speiger.src.builder.modules.SetModule;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
import speiger.src.builder.processor.TemplateProcessor;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
{
|
||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
||||
EnumMap<ClassType, List<Predicate<String>>> blockedPredicate = new EnumMap<>(ClassType.class);
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
Map<String, String> biRequired = new HashMap<>();
|
||||
Set<String> enumRequired = new HashSet<>();
|
||||
public static final ClassType[] TYPE = ClassType.values();
|
||||
List<GlobalVariables> variables = new ArrayList<>();
|
||||
List<GlobalVariables> biVariables = new ArrayList<>();
|
||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
||||
boolean special = false;
|
||||
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||
private static final int LOAD = 0x2; //If Configs should be loaded
|
||||
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
||||
private static final int SAVE = 0x4; //if the configuration should be created
|
||||
Set<String> globalFlags = new HashSet<>();
|
||||
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||
List<ModulePackage> biPackages = new ArrayList<>();
|
||||
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||
Map<String, RequiredType> requirements = new HashMap<>();
|
||||
SettingsManager manager = new SettingsManager();
|
||||
int flags;
|
||||
|
||||
public PrimitiveCollectionsBuilder()
|
||||
{
|
||||
|
@ -56,17 +65,26 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
private PrimitiveCollectionsBuilder setSpecial() {
|
||||
special = true;
|
||||
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
if((flags & ANTI_SAVE) != 0) {
|
||||
this.flags &= ~SAVE;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTests(boolean silent) {
|
||||
return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/tests/templates/"), Paths.get("src/test/java/speiger/src/tests/"), Paths.get("src/builder/resources/speiger/assets/tests/")).setSpecial();
|
||||
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/tests/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent) {
|
||||
return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/testers/templates/"), Paths.get("src/test/java/speiger/src/testers/"), Paths.get("src/builder/resources/speiger/assets/testers/")).setSpecial();
|
||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/testers/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +108,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
@Override
|
||||
protected void afterFinish()
|
||||
{
|
||||
if(!special && getVersion() > 8)
|
||||
if((flags & SPECIAL) == 0 && getVersion() > 8)
|
||||
{
|
||||
Path basePath = Paths.get("src/main/java");
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
||||
|
@ -104,171 +122,77 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
}
|
||||
}
|
||||
|
||||
public List<BaseModule> createModules()
|
||||
{
|
||||
List<BaseModule> modules = new ArrayList<>();
|
||||
modules.add(JavaModule.INSTANCE);
|
||||
modules.add(FunctionModule.INSTANCE);
|
||||
modules.add(CollectionModule.INSTANCE);
|
||||
modules.add(PrioQueueModule.INSTANCE);
|
||||
modules.add(ListModule.INSTANCE);
|
||||
modules.add(SetModule.INSTANCE);
|
||||
modules.add(MapModule.INSTANCE);
|
||||
modules.add(PairModule.INSTANCE);
|
||||
modules.add(AsyncModule.INSTANCE);
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
variables.clear();
|
||||
for(ClassType clzType : TYPE)
|
||||
{
|
||||
for(ClassType subType : TYPE)
|
||||
{
|
||||
create(clzType, subType);
|
||||
}
|
||||
}
|
||||
enumRequired.add("EnumMap");
|
||||
enumRequired.add("LinkedEnumMap");
|
||||
biRequired.put("BiConsumer", "");
|
||||
biRequired.put("UnaryOperator", "");
|
||||
biRequired.put("Pair", "");
|
||||
biRequired.put("MutablePair", "");
|
||||
biRequired.put("ImmutablePair", "");
|
||||
addBiClass("Function", "Maps", "Map", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "AbstractMap", "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
nameRemapper.put("BiConsumer", "%sConsumer");
|
||||
nameRemapper.put("IArray", "I%sArray");
|
||||
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
||||
nameRemapper.put("AbstractCollection", "Abstract%sCollection");
|
||||
nameRemapper.put("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
||||
nameRemapper.put("AbstractSet", "Abstract%sSet");
|
||||
nameRemapper.put("AbstractList", "Abstract%sList");
|
||||
nameRemapper.put("EnumMap", "Enum2%sMap");
|
||||
nameRemapper.put("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||
nameRemapper.put("ImmutableList", "Immutable%sList");
|
||||
nameRemapper.put("CopyOnWriteList", "CopyOnWrite%sArrayList");
|
||||
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
|
||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||
addBlockage(ClassType.BOOLEAN, "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
|
||||
//UnitTesters
|
||||
nameRemapper.put("AbstractIteratorTester", "Abstract%sIteratorTester");
|
||||
nameRemapper.put("MinimalCollection", "Minimal%sCollection");
|
||||
nameRemapper.put("MinimalSet", "Minimal%sSet");
|
||||
nameRemapper.put("TestCollectionGenerator", "Test%sCollectionGenerator");
|
||||
nameRemapper.put("TestQueueGenerator", "Test%sQueueGenerator");
|
||||
nameRemapper.put("TestListGenerator", "Test%sListGenerator");
|
||||
nameRemapper.put("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
||||
nameRemapper.put("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
||||
nameRemapper.put("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
||||
nameRemapper.put("TestSetGenerator", "Test%sSetGenerator");
|
||||
nameRemapper.put("AbstractContainerTester", "Abstract%sContainerTester");
|
||||
nameRemapper.put("AbstractCollectionTester", "Abstract%sCollectionTester");
|
||||
nameRemapper.put("AbstractQueueTester", "Abstract%sQueueTester");
|
||||
nameRemapper.put("AbstractListTester", "Abstract%sListTester");
|
||||
nameRemapper.put("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
||||
nameRemapper.put("AbstractSetTester", "Abstract%sSetTester");
|
||||
nameRemapper.put("SimpleTestGenerator", "Simple%sTestGenerator");
|
||||
nameRemapper.put("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
||||
nameRemapper.put("TestMapGenerator", "Test%sMapGenerator");
|
||||
nameRemapper.put("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||
nameRemapper.put("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||
nameRemapper.put("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||
nameRemapper.put("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||
nameRemapper.put("AbstractMapTester", "Abstract%sMapTester");
|
||||
nameRemapper.put("TestMap", "Test%sMap");
|
||||
biRequired.put("PairTester", "");
|
||||
|
||||
addBiClass("TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "OrderedMapTestSuiteBuilder", "MapTests", "MapConstructorTests", "TestMap");
|
||||
addBiClass("MapAddToTester", "MapSubFromTester", "MapClearTester", "MapComputeIfAbsentTester", "MapComputeIfPresentTester", "MapComputeTester", "MapCopyTester", "MapContainsTester", "MapContainsKeyTester", "MapContainsValueTester", "MapCreatorTester", "MapEntrySetTester",
|
||||
"MapEqualsTester", "MapForEachTester", "MapGetOrDefaultTester", "MapGetTester", "MapHashCodeTester", "MapIsEmptyTester", "MapMergeTester", "MapMergeBulkTester", "MapPutAllArrayTester", "MapPutAllTester", "MapPutIfAbsentTester", "MapPutTester",
|
||||
"MapRemoveEntryTester", "MapRemoveOrDefaultTester", "MapRemoveTester", "MapReplaceAllTester", "MapReplaceEntryTester", "MapReplaceTester", "MapSizeTester", "MapSupplyIfAbsentTester", "MapToStringTester",
|
||||
"NavigableMapNavigationTester", "SortedMapNavigationTester", "OrderedMapNavigationTester", "OrderedMapMoveTester", "MapConstructorTester");
|
||||
|
||||
addBlockage(ClassType.OBJECT, "CollectionStreamTester", "ListFillBufferTester");
|
||||
addBlockage(ClassType.BOOLEAN, "TestOrderedSetGenerator", "TestSortedSetGenerator", "TestNavigableSetGenerator", "CollectionRemoveIfTester", "CollectionStreamTester", "ListFillBufferTester", "ListReplaceAllTester", "NavigableSetNavigationTester", "SetTests", "MapConstructorTests", "TestMap", "QueueTests");
|
||||
addBlockage(ClassType.BOOLEAN, "OrderedSetMoveTester", "OrderedSetNavigationTester", "SortedSetNaviationTester", "SetTestSuiteBuilder", "OrderedSetTestSuiteBuilder", "SortedSetTestSuiteBuilder", "NavigableSetTestSuiteBuilder", "SortedSetSubsetTestSetGenerator", "OrderedMapNavigationTester", "OrderedMapTestSuiteBuilder", "OrderedSetIterationTester", "SortedSetIterationTester");
|
||||
addBlockage(ClassType.BOOLEAN, "TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "MapTests");
|
||||
addBlockage(ClassType.BOOLEAN, T -> T.endsWith("Tester") && (T.startsWith("Iterable") ||T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
prepPackages();
|
||||
//Init Modules here
|
||||
addModules(createModules());
|
||||
finishPackages();
|
||||
}
|
||||
|
||||
protected void create(ClassType mainType, ClassType subType)
|
||||
public void addModules(List<BaseModule> modules)
|
||||
{
|
||||
GlobalVariables type = new GlobalVariables(mainType, subType);
|
||||
type.createFlags();
|
||||
type.createHelperVariables();
|
||||
type.createVariables();
|
||||
type.createPreFunctions();
|
||||
type.createClassTypes();
|
||||
type.createFunctions();
|
||||
if(mainType == subType) variables.add(type);
|
||||
biVariables.add(type);
|
||||
if(mainType.isObject()) enumVariables.add(type);
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).setManager(manager);
|
||||
}
|
||||
|
||||
protected void addBiClass(String...classNames)
|
||||
{
|
||||
for(String s : classNames)
|
||||
{
|
||||
biRequired.put(s, "2");
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
biPackages.forEach(modules.get(i)::init);
|
||||
}
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
protected void addBlockage(ClassType type, Predicate<String> filter)
|
||||
private void finishPackages()
|
||||
{
|
||||
blockedPredicate.computeIfAbsent(type, T -> new ArrayList<>()).add(filter);
|
||||
biPackages.forEach(ModulePackage::finish);
|
||||
if((flags & SAVE) != 0) manager.save();
|
||||
}
|
||||
|
||||
protected void addBlockage(ClassType type, String...args)
|
||||
private void prepPackages()
|
||||
{
|
||||
for(String s : args)
|
||||
if((flags & LOAD) != 0) manager.load();
|
||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
||||
{
|
||||
EnumSet<ClassType> set = blocked.get(s);
|
||||
if(set == null)
|
||||
{
|
||||
set = EnumSet.noneOf(ClassType.class);
|
||||
blocked.put(s, set);
|
||||
entry.setRequirements(requirements::put);
|
||||
biPackages.add(entry);
|
||||
if(entry.isSame()) simplePackages.add(entry);
|
||||
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||
}
|
||||
set.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public void test() throws InterruptedException, IOException
|
||||
{
|
||||
init();
|
||||
List<String> keys = new ArrayList<>();
|
||||
List<String> values = new ArrayList<>();
|
||||
for(int i = 0,m=variables.size();i<m;i++) {
|
||||
variables.get(i).testComparason(keys, values);
|
||||
}
|
||||
System.out.println("Original: "+keys);
|
||||
System.out.println("Copy: "+values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createProcesses(String name, Consumer<TemplateProcess> acceptor)
|
||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
||||
{
|
||||
String splitter = biRequired.get(name);
|
||||
boolean valueRequired = enumRequired.contains(name);
|
||||
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
||||
for(int i = 0,m=vars.size();i<m;i++)
|
||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||
for(int i = 0,m=packages.size();i<m;i++)
|
||||
{
|
||||
GlobalVariables type = vars.get(i);
|
||||
if(isAllowed(type.getType(), name))
|
||||
{
|
||||
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
||||
}
|
||||
packages.get(i).process(fileName, process);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isAllowed(ClassType type, String fileName)
|
||||
{
|
||||
EnumSet<ClassType> types = blocked.get(fileName);
|
||||
if(types != null && types.contains(type)) return false;
|
||||
List<Predicate<String>> list = blockedPredicate.get(type);
|
||||
if(list != null) {
|
||||
for(int i = 0,m=list.size();i<m;i++) {
|
||||
if(list.get(i).test(fileName)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
||||
if(enumRequired.contains(name)) return enumVariables;
|
||||
if(bi) return biVariables;
|
||||
return variables;
|
||||
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||
if(type == null) return simplePackages;
|
||||
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||
if(type == RequiredType.ENUM) return enumPackages;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private String getModuleInfo(Path basePath) {
|
||||
|
@ -329,11 +253,13 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
boolean force = flags.contains("force");
|
||||
boolean tests = flags.contains("tests");
|
||||
boolean forceTests = flags.contains("force-tests");
|
||||
// new PrimitiveCollectionsBuilder(silent).test();
|
||||
new PrimitiveCollectionsBuilder(silent).process(force);
|
||||
boolean load = flags.contains("load");
|
||||
boolean save = flags.contains("save");
|
||||
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||
if(tests) {
|
||||
createTests(silent).process(force || forceTests);
|
||||
createTesters(silent).process(force || forceTests);
|
||||
createTests(silent, flag).process(force || forceTests);
|
||||
createTesters(silent, flag).process(force || forceTests);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException | IOException e)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package speiger.src.builder;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public enum RequiredType
|
||||
{
|
||||
BI_CLASS,
|
||||
ENUM
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package speiger.src.builder;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import speiger.src.builder.modules.BaseModule;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SettingsManager
|
||||
{
|
||||
boolean loaded;
|
||||
JsonObject data = new JsonObject();
|
||||
Set<String> moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType) {
|
||||
if(!loaded) return true;
|
||||
if(!isEnabled(data, base.getModuleName())) return false;
|
||||
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||
if(!isEnabled(result, "Enabled")) return false;
|
||||
if(base.isBiModule()) {
|
||||
result = getObject(result, valueType.getClassPath(), false);
|
||||
if(!isEnabled(result, "Enabled")) return false;
|
||||
}
|
||||
result = getObject(result, base.getModuleName(), false);
|
||||
return (result.size() <= 0 || isEnabled(result, "Enabled")) && base.areDependenciesLoaded();
|
||||
}
|
||||
|
||||
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry)
|
||||
{
|
||||
if(!loaded) return true;
|
||||
if(!isEnabled(data, base.getModuleName())) return false;
|
||||
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||
if(!isEnabled(result, "Enabled")) return false;
|
||||
if(base.isBiModule()) {
|
||||
result = getObject(result, valueType.getClassPath(), false);
|
||||
if(!isEnabled(result, "Enabled")) return false;
|
||||
}
|
||||
result = getObject(result, base.getModuleName(), false);
|
||||
return (result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry))) && base.areDependenciesLoaded();
|
||||
}
|
||||
|
||||
public void addModule(BaseModule module) {
|
||||
if(loaded) return;
|
||||
String moduleName = module.getModuleName();
|
||||
moduleNames.add(moduleName);
|
||||
data.addProperty(moduleName, true);
|
||||
if(module.isBiModule()) {
|
||||
for(ClassType keyType : ModulePackage.TYPE) {
|
||||
for(ClassType valueType : ModulePackage.TYPE) {
|
||||
if(!module.isModuleValid(keyType, valueType)) continue;
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.addProperty("Enabled", true);
|
||||
for(String key : module.getModuleKeys(keyType, valueType)) {
|
||||
obj.addProperty(key, true);
|
||||
}
|
||||
addModule(keyType, valueType, true, moduleName, obj);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for(ClassType keyType : ModulePackage.TYPE) {
|
||||
if(!module.isModuleValid(keyType, keyType)) continue;
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.addProperty("Enabled", true);
|
||||
for(String key : module.getModuleKeys(keyType, keyType)) {
|
||||
obj.addProperty(key, true);
|
||||
}
|
||||
addModule(keyType, keyType, false, moduleName, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try(BufferedReader reader = Files.newBufferedReader(Paths.get("ModulSettings.json"))) {
|
||||
data = JsonParser.parseReader(reader).getAsJsonObject();
|
||||
loaded = true;
|
||||
}
|
||||
catch(Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
public void save() {
|
||||
data.asMap().keySet().removeAll(moduleNames);
|
||||
JsonObject result = new JsonObject();
|
||||
for(String s : moduleNames) {
|
||||
result.addProperty(s, true);
|
||||
}
|
||||
result.asMap().putAll(data.asMap());
|
||||
|
||||
try(JsonWriter writer = new JsonWriter(Files.newBufferedWriter(Paths.get("ModulSettings.json")))) {
|
||||
writer.setIndent("\t");
|
||||
Streams.write(result, writer);
|
||||
}
|
||||
catch(Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
private void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) {
|
||||
JsonObject result = getObject(data, keyType.getClassPath(), true);
|
||||
if(bi) {
|
||||
result = getObject(result, valueType.getClassPath(), true);
|
||||
}
|
||||
result.add(moduleName, obj);
|
||||
}
|
||||
|
||||
private JsonObject getObject(JsonObject data, String name, boolean create) {
|
||||
JsonObject obj = data.getAsJsonObject(name);
|
||||
if(obj == null) {
|
||||
obj = new JsonObject();
|
||||
data.add(name, obj);
|
||||
if(create) obj.addProperty("Enabled", true);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private boolean isEnabled(JsonObject obj, String key) {
|
||||
if(obj.has(key)) return obj.getAsJsonPrimitive(key).getAsBoolean();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class AsyncModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new AsyncModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Async"; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
protected void loadRemappers() {}
|
||||
@Override
|
||||
protected void loadTestClasses() {}
|
||||
@Override
|
||||
protected void loadFunctions() {}
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||
@Override
|
||||
protected void loadBlockades() {
|
||||
if(!isModuleEnabled()) {
|
||||
addBlockedFiles("AsyncBuilder", "Task");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void loadFlags() {
|
||||
if(isModuleEnabled()) {
|
||||
addKeyFlag("ASYNC_MODULE");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addClassMapper("ASYNC_BUILDER", "AsyncBuilder");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("BASE_TASK", "Base%sTask");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("TASK", "Task");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
import speiger.src.builder.ModulePackage;
|
||||
import speiger.src.builder.RequiredType;
|
||||
import speiger.src.builder.SettingsManager;
|
||||
import speiger.src.builder.mappers.ArgumentMapper;
|
||||
import speiger.src.builder.mappers.InjectMapper;
|
||||
import speiger.src.builder.mappers.LineMapper;
|
||||
import speiger.src.builder.mappers.SimpleMapper;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class BaseModule
|
||||
{
|
||||
SettingsManager manager;
|
||||
ModulePackage entry;
|
||||
protected ClassType keyType;
|
||||
protected ClassType valueType;
|
||||
|
||||
public final void setManager(SettingsManager manager) {
|
||||
this.manager = manager;
|
||||
manager.addModule(this);
|
||||
}
|
||||
|
||||
public final void init(ModulePackage entry) {
|
||||
this.entry = entry;
|
||||
keyType = entry.getKeyType();
|
||||
valueType = entry.getValueType();
|
||||
loadVariables();
|
||||
loadClasses();
|
||||
loadTestClasses();
|
||||
loadFunctions();
|
||||
loadRemappers();
|
||||
loadBlockades();
|
||||
loadFlags();
|
||||
}
|
||||
|
||||
public final void cleanup() {
|
||||
entry = null;
|
||||
keyType = null;
|
||||
valueType = null;
|
||||
manager = null;
|
||||
}
|
||||
|
||||
protected abstract void loadVariables();
|
||||
protected abstract void loadClasses();
|
||||
protected abstract void loadTestClasses();
|
||||
protected abstract void loadFunctions();
|
||||
protected abstract void loadRemappers();
|
||||
protected abstract void loadBlockades();
|
||||
protected abstract void loadFlags();
|
||||
|
||||
public abstract String getModuleName();
|
||||
public boolean isBiModule() { return false; }
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||
|
||||
protected boolean isModuleEnabled() {
|
||||
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
||||
}
|
||||
|
||||
protected boolean isModuleEnabled(String name) {
|
||||
return manager == null || manager.isModuleEnabled(this, keyType, valueType, name);
|
||||
}
|
||||
|
||||
protected boolean isDependencyLoaded(BaseModule module) {
|
||||
return isDependencyLoaded(module, true);
|
||||
}
|
||||
|
||||
protected boolean isDependencyLoaded(BaseModule module, boolean key) {
|
||||
return manager == null || (module.isBiModule() ? manager.isModuleEnabled(module, keyType, valueType) : (key ? manager.isModuleEnabled(module, keyType, keyType) : manager.isModuleEnabled(module, valueType, valueType)));
|
||||
}
|
||||
|
||||
public boolean areDependenciesLoaded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void addFlag(String name) {
|
||||
entry.addFlag(name);
|
||||
}
|
||||
|
||||
protected void addKeyFlag(String name) {
|
||||
entry.addFlag(name);
|
||||
entry.addGlobalFlag(keyType.getCapType()+"_"+name);
|
||||
}
|
||||
|
||||
protected void addBiRequirement(String fileName) {
|
||||
entry.addRequirement(fileName, RequiredType.BI_CLASS);
|
||||
entry.addSplitter(fileName, "%1$s2%2$s");
|
||||
}
|
||||
|
||||
protected void addEnumRequirement(String fileName) {
|
||||
entry.addRequirement(fileName, RequiredType.ENUM);
|
||||
entry.addSplitter(fileName, "%2$s");
|
||||
|
||||
}
|
||||
|
||||
protected void addBiRequirement(String fileName, String splitter) {
|
||||
entry.addRequirement(fileName, RequiredType.BI_CLASS);
|
||||
entry.addSplitter(fileName, "%1$s"+splitter+"%2$s");
|
||||
}
|
||||
|
||||
protected void addRequirement(String fileName, String splitter, RequiredType type) {
|
||||
entry.addRequirement(fileName, type);
|
||||
entry.addSplitter(fileName, splitter);
|
||||
}
|
||||
|
||||
protected void addRemapper(String fileName, String actualName) {
|
||||
entry.addRemapper(fileName, actualName);
|
||||
}
|
||||
|
||||
protected void addBlockedFiles(String... name) {
|
||||
entry.addBlockedFiles(name);
|
||||
}
|
||||
|
||||
protected void addBlockedFilter(Predicate<String> filter) {
|
||||
entry.addBlockedFilter(filter);
|
||||
}
|
||||
|
||||
protected void addClassMapper(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+replacement));
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+replacement));
|
||||
}
|
||||
|
||||
protected void addBiClassMapper(String pattern, String replacement, String splitter) {
|
||||
entry.addMapper(new SimpleMapper("KEY_"+pattern, "KEY_"+pattern, keyType.getFileType()+splitter+keyType.getFileType()+replacement));
|
||||
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement));
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+splitter+valueType.getFileType()+replacement));
|
||||
}
|
||||
|
||||
protected void addAbstractMapper(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getFileType())));
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType())));
|
||||
}
|
||||
|
||||
protected void addAbstractBiMapper(String pattern, String replacement, String splitter) {
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType()+splitter+valueType.getFileType())));
|
||||
}
|
||||
|
||||
protected void addFunctionMapper(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, replacement+valueType.getNonFileType()));
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+keyType.getNonFileType()));
|
||||
}
|
||||
|
||||
protected void addFunctionValueMapper(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+valueType.getNonFileType()));
|
||||
}
|
||||
|
||||
protected void addFunctionMappers(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType())));
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getNonFileType())));
|
||||
}
|
||||
|
||||
protected void addFunctionValueMappers(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, valueType.getNonFileType())));
|
||||
}
|
||||
|
||||
protected void addSimpleMapper(String pattern, String replacement) {
|
||||
entry.addMapper(new SimpleMapper(pattern, pattern, replacement));
|
||||
}
|
||||
|
||||
protected void addAnnontion(String pattern, String value) {
|
||||
if(keyType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
|
||||
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
|
||||
}
|
||||
|
||||
protected void addValueAnnontion(String pattern, String value) {
|
||||
if(valueType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
|
||||
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
|
||||
}
|
||||
|
||||
protected void addComment(String pattern, String value) {
|
||||
if(keyType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
|
||||
else entry.addMapper(new LineMapper(pattern, pattern));
|
||||
}
|
||||
|
||||
protected void addValueComment(String pattern, String value) {
|
||||
if(valueType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
|
||||
else entry.addMapper(new LineMapper(pattern, pattern));
|
||||
}
|
||||
|
||||
protected InjectMapper addInjectMapper(String pattern, String replacement) {
|
||||
InjectMapper mapper = new InjectMapper(pattern, pattern, replacement);
|
||||
entry.addMapper(mapper);
|
||||
return mapper;
|
||||
}
|
||||
|
||||
protected ArgumentMapper addArgumentMapper(String pattern, String replacement) {
|
||||
return addArgumentMapper(pattern, replacement, ", ");
|
||||
}
|
||||
|
||||
protected ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter) {
|
||||
ArgumentMapper mapper = new ArgumentMapper(pattern, pattern, replacement, splitter);
|
||||
entry.addMapper(mapper);
|
||||
return mapper;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class CollectionModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new CollectionModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Collection"; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); }
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType)
|
||||
{
|
||||
return new TreeSet<>(Arrays.asList("Streams", "Splititerators", "IArray", "Strategy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags() {
|
||||
if(isModuleEnabled()) addKeyFlag("COLLECTION_MODULE");
|
||||
if(isModuleEnabled("Streams")) addKeyFlag("STREAM_FEATURE");
|
||||
if(isModuleEnabled("Splititerators")) addKeyFlag("SPLIT_ITERATOR_FEATURE");
|
||||
if(isModuleEnabled("IArray")) addKeyFlag("IARRAY_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades() {
|
||||
if(!isModuleEnabled()) {
|
||||
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
||||
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
|
||||
}
|
||||
if(!isModuleEnabled("Splititerators")) addBlockedFiles("Splititerator", "Splititerators");
|
||||
if(!isModuleEnabled("IArray")) addBlockedFiles("IArray");
|
||||
if(!isModuleEnabled("Strategy")) addBlockedFiles("Strategy");
|
||||
|
||||
if(keyType.isObject()) {
|
||||
addBlockedFiles("Stack");
|
||||
addBlockedFiles("CollectionStreamTester");
|
||||
}
|
||||
if(keyType == ClassType.BOOLEAN) {
|
||||
addBlockedFiles("CollectionRemoveIfTester", "CollectionStreamTester");
|
||||
addBlockedFilter(T -> T.endsWith("Tester") && T.startsWith("Iterable"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addRemapper("IArray", "I%sArray");
|
||||
addRemapper("AbstractCollection", "Abstract%sCollection");
|
||||
|
||||
//Test Classes
|
||||
addRemapper("AbstractIteratorTester", "Abstract%sIteratorTester");
|
||||
addRemapper("MinimalCollection", "Minimal%sCollection");
|
||||
addRemapper("TestCollectionGenerator", "Test%sCollectionGenerator");
|
||||
addRemapper("AbstractContainerTester", "Abstract%sContainerTester");
|
||||
addRemapper("AbstractCollectionTester", "Abstract%sCollectionTester");
|
||||
addRemapper("SimpleTestGenerator", "Simple%sTestGenerator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionMapper("NEXT", "next");
|
||||
addSimpleMapper("NEW_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getKeyType()+"Stream");
|
||||
addFunctionMapper("PREVIOUS", "previous");
|
||||
addFunctionMapper("REMOVE_KEY", "rem");
|
||||
addSimpleMapper("TO_ARRAY", "to"+keyType.getNonFileType()+"Array");
|
||||
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||
|
||||
//Helper Classes
|
||||
addClassMapper("ARRAYS", "Arrays");
|
||||
addClassMapper("COLLECTIONS", "Collections");
|
||||
addClassMapper("ITERABLES", "Iterables");
|
||||
addClassMapper("SPLIT_ITERATORS", "Splititerators");
|
||||
addClassMapper("ITERATORS", "Iterators");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("COLLECTION", "Collection");
|
||||
addClassMapper("ITERABLE", "Iterable");
|
||||
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
||||
addClassMapper("ITERATOR", "Iterator");
|
||||
if(keyType.isObject()) addSimpleMapper("STACK", "Stack");
|
||||
else addClassMapper("STACK", "Stack");
|
||||
addClassMapper("STRATEGY", "Strategy");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection");
|
||||
addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester");
|
||||
addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester");
|
||||
addClassMapper("ITERATOR_TESTER", "IteratorTester");
|
||||
addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder");
|
||||
addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester");
|
||||
addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester");
|
||||
addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester");
|
||||
|
||||
//Helper Classes
|
||||
addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator");
|
||||
addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator");
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FunctionModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new FunctionModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Function"; }
|
||||
@Override
|
||||
public boolean isBiModule() { return true; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
protected void loadFlags() {}
|
||||
@Override
|
||||
protected void loadTestClasses() {}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
addBiRequirement("BiConsumer", "");
|
||||
addBiRequirement("UnaryOperator", "");
|
||||
addBiRequirement("Function");
|
||||
addRemapper("BiConsumer", "%sConsumer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Interfaces
|
||||
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
||||
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
||||
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
||||
addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction");
|
||||
addBiClassMapper("FUNCTION", "Function", "2");
|
||||
addClassMapper("PREDICATE", "2BooleanFunction");
|
||||
addClassMapper("SUPPLIER", "Supplier");
|
||||
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
||||
if(keyType.isObject())
|
||||
{
|
||||
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
||||
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||
addSimpleMapper("CONSUMER", "Consumer");
|
||||
addSimpleMapper("IARRAY", "IObjectArray");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(valueType.isObject())
|
||||
{
|
||||
addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||
addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer");
|
||||
}
|
||||
else addClassMapper("CONSUMER", "Consumer");
|
||||
addFunctionMappers("IARRAY", "I%sArray");
|
||||
}
|
||||
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
|
||||
addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class JavaModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new JavaModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Base"; }
|
||||
@Override
|
||||
protected void loadVariables()
|
||||
{
|
||||
createHelperVars(keyType, false, "KEY");
|
||||
createHelperVars(valueType, true, "VALUE");
|
||||
loadBaseVariables();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags()
|
||||
{
|
||||
addFlag("TYPE_"+keyType.getCapType());
|
||||
addFlag("VALUE_"+valueType.getCapType());
|
||||
if(keyType == valueType) addFlag("SAME_TYPE");
|
||||
if(keyType.hasFunction(valueType)) addFlag("JDK_FUNCTION");
|
||||
if(!keyType.needsCustomJDKType()) addFlag("JDK_TYPE");
|
||||
if(!keyType.isPrimitiveBlocking()) addFlag("PRIMITIVES");
|
||||
if(!valueType.isPrimitiveBlocking()) addFlag("VALUE_PRIMITIVES");
|
||||
if(valueType.needsCustomJDKType()) addFlag("JDK_VALUE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers() {}
|
||||
@Override
|
||||
protected void loadBlockades() {}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
||||
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
||||
|
||||
//Shared by Maps and Pairs so moved to java.
|
||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
||||
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
||||
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
addSimpleMapper("JAVA_PREDICATE", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Predicate");
|
||||
addSimpleMapper("JAVA_CONSUMER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Consumer");
|
||||
addSimpleMapper("JAVA_SUPPLIER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Supplier");
|
||||
addSimpleMapper("JAVA_FUNCTION", keyType.getFunctionClass(valueType));
|
||||
addSimpleMapper("JAVA_BINARY_OPERATOR", keyType == ClassType.BOOLEAN ? "" : (keyType.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"BinaryOperator"));
|
||||
addSimpleMapper("JAVA_UNARY_OPERATOR", keyType.isObject() ? "BinaryOperator" : keyType == ClassType.BOOLEAN ? "" : keyType.getCustomJDKType().getFileType()+"UnaryOperator");
|
||||
addSimpleMapper("JAVA_SPLIT_ITERATOR", keyType.isPrimitiveBlocking() ? "Spliterator" : "Of"+keyType.getCustomJDKType().getFileType());
|
||||
addSimpleMapper("JAVA_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Stream");
|
||||
addSimpleMapper("JAVA_BUFFER", keyType.getFileType()+"Buffer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
addClassMapper("HELPERS", "Helpers");
|
||||
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
||||
}
|
||||
|
||||
private void loadBaseVariables()
|
||||
{
|
||||
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
||||
addSimpleMapper("PACKAGE", keyType.getPathType());
|
||||
addSimpleMapper("CLASS_TYPE", keyType.getClassType());
|
||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
||||
addSimpleMapper("KEY_TYPE", keyType.getKeyType());
|
||||
addSimpleMapper("KEY_OBJECT_TYPE", keyType.isObject() ? "Object" : keyType.getKeyType());
|
||||
addSimpleMapper("KEY_STRING_TYPE", keyType.isObject() ? "String" : keyType.getKeyType());
|
||||
addSimpleMapper("KEY_SPECIAL_TYPE", keyType.isObject() ? "E" : keyType.getKeyType());
|
||||
addSimpleMapper("CLASS_OBJECT_TYPE", keyType.getClassType());
|
||||
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
||||
addSimpleMapper("CLASS_STRING_TYPE", keyType.isObject() ? "String" : keyType.getClassType());
|
||||
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
||||
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
||||
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
||||
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
||||
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
||||
addSimpleMapper("KEY_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||
addSimpleMapper("VALUE_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||
|
||||
addSimpleMapper("EMPTY_KEY_VALUE", keyType.getEmptyValue());
|
||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
||||
|
||||
addSimpleMapper("INVALID_KEY_VALUE", keyType.getInvalidValue());
|
||||
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
||||
|
||||
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", keyType.isObject() ? "<String>" : "");
|
||||
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
||||
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||
|
||||
|
||||
addSimpleMapper(" KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+">" : "");
|
||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", "+keyType.getKeyType()+">" : "");
|
||||
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getClassType()+">" : "");
|
||||
|
||||
|
||||
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" VALUE_CLASS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getClassValueType()+">" : "");
|
||||
|
||||
addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
||||
addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+keyType.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces();
|
||||
|
||||
addSimpleMapper(" NO_GENERIC_TYPE", keyType.isObject() ? "<?>" : "");
|
||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
||||
addSimpleMapper(" KEY_COMPAREABLE_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||
|
||||
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "<? super "+keyType.getKeyType()+">" : "");
|
||||
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? super "+keyType.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
||||
|
||||
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? "<? extends "+keyType.getKeyType()+">" : "");
|
||||
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? extends "+keyType.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
||||
|
||||
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
||||
|
||||
addInjectMapper(" KEY_SPECIAL_GENERIC_TYPE", keyType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" KSK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" KKS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
||||
addArgumentMapper(" KSS_GENERIC_TYPE", keyType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" VSV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" VVS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
||||
addArgumentMapper(" VSS_GENERIC_TYPE", valueType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
||||
|
||||
addSimpleMapper(" GENERIC_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+">" : "");
|
||||
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
||||
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", keyType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
||||
addSimpleMapper(" GENERIC_KEY_ENUM_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||
|
||||
addInjectMapper(" GENERIC_KEY_SPECIAL_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
||||
addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
||||
|
||||
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+", "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" COMPAREABLE_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||
addSimpleMapper("KV_BRACES", keyType.isObject() || valueType.isObject() ? "<>" : "");
|
||||
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
||||
addSimpleMapper("BRACES", keyType.isObject() ? "<>" : "");
|
||||
if(keyType.needsCustomJDKType())
|
||||
{
|
||||
addSimpleMapper("JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||
addSimpleMapper("SANITY_CAST", "castTo"+keyType.getFileType());
|
||||
}
|
||||
addSimpleMapper("JAVA_CLASS", keyType.getCustomJDKType().getClassType());
|
||||
if(valueType.needsCustomJDKType())
|
||||
{
|
||||
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
||||
}
|
||||
addSimpleMapper("[SPACE]", " ");
|
||||
addComment("@ArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
||||
addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection");
|
||||
addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
||||
addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection");
|
||||
addAnnontion("@PrimitiveOverride", "@Override");
|
||||
addSimpleMapper("@PrimitiveDoc", "");
|
||||
addAnnontion("@Primitive", "@Deprecated");
|
||||
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
||||
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
||||
}
|
||||
|
||||
private void createHelperVars(ClassType type, boolean value, String fix)
|
||||
{
|
||||
addArgumentMapper("EQUALS_"+fix+"_TYPE", "Objects.equals(%2$s, "+(type.isObject() ? "%1$s" : fix+"_TO_OBJ(%1$s)")+")").removeBraces();
|
||||
addInjectMapper(fix+"_EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
||||
addInjectMapper(fix+"_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
||||
addArgumentMapper(fix+"_EQUALS_NOT", type.getEquals(true)).removeBraces();
|
||||
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
||||
addSimpleMapper("FILE_"+fix+"_TYPE", type.getFileType());
|
||||
|
||||
addArgumentMapper("COMPAREABLE_TO_"+fix, type.isObject() ? "((Comparable<"+type.getKeyType(value)+">)%1$s).compareTo(("+type.getKeyType(value)+")%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||
addArgumentMapper("COMPARE_TO_"+fix, type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||
|
||||
addInjectMapper(fix+"_TO_OBJ", type.isObject() ? "%s" : type.getClassType(value)+".valueOf(%s)").removeBraces();
|
||||
addInjectMapper("OBJ_TO_"+fix, type.isObject() ? "%s" : "%s."+type.getKeyType(value)+"Value()").removeBraces();
|
||||
addInjectMapper("CLASS_TO_"+fix, type.isObject() ? "("+type.getKeyType(value)+")%s" : "(("+type.getClassType(value)+")%s)."+type.getKeyType(value)+"Value()").removeBraces();
|
||||
|
||||
addInjectMapper(fix+"_TO_HASH", type.isObject() ? "Objects.hashCode(%s)" : type.getClassType(value)+".hashCode(%s)").removeBraces();
|
||||
addInjectMapper(fix+"_TO_STRING", type.isObject() ? "Objects.toString(%s)" : type.getClassType(value)+".toString(%s)").removeBraces();
|
||||
|
||||
addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : "");
|
||||
addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY");
|
||||
addInjectMapper("NEW_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||
addInjectMapper("NEW_SPECIAL_"+fix+"_ARRAY", type.isObject() ? "(E[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||
if(value) addInjectMapper("NEW_CLASS_VALUE_ARRAY", type.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces();
|
||||
else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ListModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new ListModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "List"; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
protected void loadFlags() {
|
||||
if(isModuleEnabled()) addKeyFlag("LIST_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addKeyFlag("LISTS_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
if(implementations && isModuleEnabled("ArrayList")) addKeyFlag("ARRAY_LIST_FEATURE");
|
||||
if(implementations && isModuleEnabled("LinkedList")) addKeyFlag("LINKED_LIST_FEATURE");
|
||||
if(implementations && isModuleEnabled("ImmutableList")) addKeyFlag("IMMUTABLE_LIST_FEATURE");
|
||||
if(implementations && isModuleEnabled("CopyOnWriteList")) addKeyFlag("COPY_ON_WRITE_LIST_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Lists");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
if(implementations || !isModuleEnabled("ArrayList")) addBlockedFiles("ArrayList");
|
||||
if(implementations || !isModuleEnabled("LinkedList")) addBlockedFiles("LinkedList");
|
||||
if(implementations || !isModuleEnabled("ImmutableList")) addBlockedFiles("ImmutableList");
|
||||
if(implementations || !isModuleEnabled("CopyOnWriteList")) addBlockedFiles("CopyOnWriteList");
|
||||
if(!isModuleEnabled()) addBlockedFiles("List", "AbstractList");
|
||||
|
||||
if(keyType.isObject()) addBlockedFiles("ListFillBufferTester");
|
||||
if(keyType == ClassType.BOOLEAN) addBlockedFiles("ListFillBufferTester", "ListReplaceAllTester");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
return new TreeSet<>(Arrays.asList("Implementations", "Wrappers", "ArrayList", "LinkedList", "ImmutableList", "CopyOnWriteList"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() {
|
||||
return isDependencyLoaded(CollectionModule.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addRemapper("AbstractList", "Abstract%sList");
|
||||
addRemapper("ImmutableList", "Immutable%sList");
|
||||
addRemapper("CopyOnWriteList", "CopyOnWrite%sArrayList");
|
||||
|
||||
//Test Classes
|
||||
addRemapper("AbstractListTester", "Abstract%sListTester");
|
||||
addRemapper("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
||||
addRemapper("TestListGenerator", "Test%sListGenerator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionMapper("GET_KEY", "get");
|
||||
addFunctionMapper("REMOVE_LAST", "removeLast");
|
||||
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
||||
addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss");
|
||||
addFunctionMappers("SORT", "sort%ss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addClassMapper("ARRAY_LIST", "ArrayList");
|
||||
addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList");
|
||||
addClassMapper("LINKED_LIST", "LinkedList");
|
||||
addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
||||
|
||||
//SubClasses
|
||||
addClassMapper("SUB_LIST", "SubList");
|
||||
addClassMapper("LIST_ITER", "ListIter");
|
||||
|
||||
//Helper Classes
|
||||
addClassMapper("LISTS", "Lists");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("LIST", "List");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder");
|
||||
addClassMapper("LIST_TESTS", "ListTests");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester");
|
||||
addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester");
|
||||
|
||||
//Helper classes
|
||||
addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class MapModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new MapModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Map"; }
|
||||
@Override
|
||||
public boolean isBiModule() { return true; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
Set<String> sets = new TreeSet<>();
|
||||
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
||||
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
||||
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
||||
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
||||
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
||||
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
||||
return sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags()
|
||||
{
|
||||
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||
|
||||
if(isModuleEnabled("OrderedMap")) {
|
||||
addFlag("ORDERED_MAP_FEATURE");
|
||||
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||
}
|
||||
if(isModuleEnabled("SortedMap")) {
|
||||
addFlag("SORTED_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
||||
}
|
||||
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||
if(hashMap) addFlag("HASH_MAP_FEATURE");
|
||||
if(customHashMap) addFlag("CUSTOM_HASH_MAP_FEATURE");
|
||||
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
|
||||
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||
if(ordered) addBlockedFiles("OrderedMap");
|
||||
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||
|
||||
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
||||
|
||||
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
||||
if(enumMap) addBlockedFiles("EnumMap");
|
||||
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
||||
|
||||
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
||||
|
||||
boolean sorted = !isModuleEnabled("SortedMap");
|
||||
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
||||
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
||||
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
||||
|
||||
if(keyType == ClassType.BOOLEAN)
|
||||
{
|
||||
//Main Classes
|
||||
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
||||
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
||||
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
||||
addBlockedFiles("TestSortedMapGenerator", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||
addBlockedFiles("TestOrderedMapGenerator");
|
||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addBiRequirement("Map");
|
||||
addBiRequirement("SortedMap");
|
||||
addBiRequirement("OrderedMap");
|
||||
addBiRequirement("NavigableMap");
|
||||
addBiRequirement("ConcurrentMap");
|
||||
addBiRequirement("AbstractMap");
|
||||
addEnumRequirement("EnumMap");
|
||||
addEnumRequirement("LinkedEnumMap");
|
||||
addBiRequirement("ConcurrentOpenHashMap");
|
||||
addBiRequirement("ImmutableOpenHashMap");
|
||||
addBiRequirement("OpenHashMap");
|
||||
addBiRequirement("LinkedOpenHashMap");
|
||||
addBiRequirement("OpenCustomHashMap");
|
||||
addBiRequirement("LinkedOpenCustomHashMap");
|
||||
addBiRequirement("ArrayMap");
|
||||
addBiRequirement("RBTreeMap");
|
||||
addBiRequirement("AVLTreeMap");
|
||||
addBiRequirement("Maps");
|
||||
|
||||
addRemapper("AbstractMap", "Abstract%sMap");
|
||||
addRemapper("EnumMap", "Enum2%sMap");
|
||||
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBiRequirement("TestMapGenerator");
|
||||
addBiRequirement("TestSortedMapGenerator");
|
||||
addBiRequirement("TestOrderedMapGenerator");
|
||||
addBiRequirement("SimpleMapTestGenerator");
|
||||
addBiRequirement("DerivedMapGenerators");
|
||||
addBiRequirement("AbstractMapTester");
|
||||
addBiRequirement("MapTestSuiteBuilder");
|
||||
addBiRequirement("SortedMapTestSuiteBuilder");
|
||||
addBiRequirement("NavigableMapTestSuiteBuilder");
|
||||
addBiRequirement("OrderedMapTestSuiteBuilder");
|
||||
addBiRequirement("MapTests");
|
||||
addBiRequirement("MapConstructorTests");
|
||||
addBiRequirement("TestMap");
|
||||
addBiRequirement("MapAddToTester");
|
||||
addBiRequirement("MapSubFromTester");
|
||||
addBiRequirement("MapClearTester");
|
||||
addBiRequirement("MapComputeIfAbsentTester");
|
||||
addBiRequirement("MapComputeIfPresentTester");
|
||||
addBiRequirement("MapComputeTester");
|
||||
addBiRequirement("MapCopyTester");
|
||||
addBiRequirement("MapContainsTester");
|
||||
addBiRequirement("MapContainsKeyTester");
|
||||
addBiRequirement("MapContainsValueTester");
|
||||
addBiRequirement("MapCreatorTester");
|
||||
addBiRequirement("MapEntrySetTester");
|
||||
addBiRequirement("MapEqualsTester");
|
||||
addBiRequirement("MapForEachTester");
|
||||
addBiRequirement("MapGetOrDefaultTester");
|
||||
addBiRequirement("MapGetTester");
|
||||
addBiRequirement("MapHashCodeTester");
|
||||
addBiRequirement("MapIsEmptyTester");
|
||||
addBiRequirement("MapMergeTester");
|
||||
addBiRequirement("MapMergeBulkTester");
|
||||
addBiRequirement("MapPutAllArrayTester");
|
||||
addBiRequirement("MapPutAllTester");
|
||||
addBiRequirement("MapPutIfAbsentTester");
|
||||
addBiRequirement("MapPutTester");
|
||||
addBiRequirement("MapRemoveEntryTester");
|
||||
addBiRequirement("MapRemoveOrDefaultTester");
|
||||
addBiRequirement("MapRemoveTester");
|
||||
addBiRequirement("MapReplaceAllTester");
|
||||
addBiRequirement("MapReplaceEntryTester");
|
||||
addBiRequirement("MapReplaceTester");
|
||||
addBiRequirement("MapSizeTester");
|
||||
addBiRequirement("MapSupplyIfAbsentTester");
|
||||
addBiRequirement("MapToStringTester");
|
||||
addBiRequirement("NavigableMapNavigationTester");
|
||||
addBiRequirement("SortedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapMoveTester");
|
||||
addBiRequirement("MapConstructorTester");
|
||||
|
||||
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
||||
addRemapper("TestMap", "Test%sMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
||||
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
||||
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
||||
addFunctionValueMapper("COMPUTE", "compute");
|
||||
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
||||
addFunctionMapper("DEQUEUE", "dequeue");
|
||||
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
||||
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||
else addSimpleMapper("GET_VALUE", "get");
|
||||
addSimpleMapper("GET_JAVA", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
|
||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
||||
addFunctionValueMapper("MERGE", "merge");
|
||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
||||
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
||||
addFunctionMapper("REMOVE", "remove");
|
||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
||||
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
||||
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
||||
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
||||
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
||||
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||
|
||||
//Helper Classes
|
||||
addBiClassMapper("MAPS", "Maps", "2");
|
||||
|
||||
//Interfaces
|
||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
||||
addBiClassMapper("MAP", "Map", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||
|
||||
//Helper Classes
|
||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
||||
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
||||
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PairModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new PairModule();
|
||||
@Override
|
||||
public String getModuleName() { return "Pair"; }
|
||||
@Override
|
||||
public boolean isBiModule() { return true; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
protected void loadFunctions() {}
|
||||
@Override
|
||||
protected void loadTestClasses() {}
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return new TreeSet<>(Arrays.asList("Mutable", "Immutable")); }
|
||||
|
||||
@Override
|
||||
protected void loadFlags() {
|
||||
if(isModuleEnabled()) addFlag("PAIR_MODULE");
|
||||
if(isModuleEnabled("Mutable")) addFlag("MUTABLE_PAIR");
|
||||
if(isModuleEnabled("Immutable")) addFlag("IMMUTABLE_PAIR");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades() {
|
||||
if(!isModuleEnabled()) addBlockedFiles("Pair");
|
||||
if(!isModuleEnabled("Mutable")) addBlockedFiles("MutablePair");
|
||||
if(!isModuleEnabled("Immutable")) addBlockedFiles("ImmutablePair");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers() {
|
||||
//Main Classes
|
||||
addBiRequirement("Pair", "");
|
||||
addBiRequirement("MutablePair", "");
|
||||
addBiRequirement("ImmutablePair", "");
|
||||
|
||||
//Test Classes
|
||||
addBiRequirement("PairTester", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses() {
|
||||
//Implementations
|
||||
addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", "");
|
||||
addBiClassMapper("MUTABLE_PAIR", "MutablePair", "");
|
||||
|
||||
//Interfaces
|
||||
addBiClassMapper("PAIR", "Pair", "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PrioQueueModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new PrioQueueModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "PriorityQueue"; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
protected void loadFunctions() {}
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
return new TreeSet<>(Arrays.asList("Wrappers", "Implementations", "Dequeue", "FiFoQueue", "HeapQueue", "ArrayPrioQueue"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags() {
|
||||
if(isModuleEnabled()) addFlag("QUEUE_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addKeyFlag("QUEUES_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
if(isModuleEnabled("Dequeue")) {
|
||||
addKeyFlag("DEQUEUE_FEATURE");
|
||||
if(implementations && isModuleEnabled("FiFoQueue")) addKeyFlag("FIFO_QUEUE_FEATURE");
|
||||
}
|
||||
if(implementations && isModuleEnabled("HeapQueue")) addKeyFlag("HEAP_QUEUE_FEATURE");
|
||||
if(implementations && isModuleEnabled("ArrayPrioQueue")) addKeyFlag("ARRAY_QUEUE_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades() {
|
||||
if(!isModuleEnabled()) addBlockedFiles("PriorityQueue", "AbstractPriorityQueue");
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("PriorityQueues");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
boolean dequeue = !isModuleEnabled("Dequeue");
|
||||
if(dequeue) addBlockedFiles("PriorityDequeue");
|
||||
if(dequeue || implementations || !isModuleEnabled("FiFoQueue")) addBlockedFiles("ArrayFIFOQueue");
|
||||
if(implementations || !isModuleEnabled("HeapQueue")) addBlockedFiles("HeapPriorityQueue");
|
||||
if(implementations || !isModuleEnabled("ArrayPrioQueue")) addBlockedFiles("ArrayPriorityQueue");
|
||||
|
||||
if(keyType == ClassType.BOOLEAN) {
|
||||
addBlockedFiles("QueueTests");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers() {
|
||||
//Main Classes
|
||||
addRemapper("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
||||
|
||||
//Test Classes
|
||||
addRemapper("TestQueueGenerator", "Test%sQueueGenerator");
|
||||
addRemapper("AbstractQueueTester", "Abstract%sQueueTester");
|
||||
addRemapper("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses() {
|
||||
//Implementation Classes
|
||||
addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue");
|
||||
addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue");
|
||||
addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
||||
|
||||
//Helper Classes
|
||||
addClassMapper("PRIORITY_QUEUES", "PriorityQueues");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("PRIORITY_QUEUE", "PriorityQueue");
|
||||
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder");
|
||||
addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder");
|
||||
addClassMapper("QUEUE_TESTS", "QueueTests");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester");
|
||||
|
||||
//Helper Classes
|
||||
addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator");
|
||||
addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SetModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new SetModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Set"; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
|
||||
@Override
|
||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
Set<String> sets = new TreeSet<>();
|
||||
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||
sets.addAll(Arrays.asList("OrderedSet", "SortedSet"));
|
||||
sets.addAll(Arrays.asList("ArraySet", "ImmutableSet"));
|
||||
sets.addAll(Arrays.asList("HashSet", "LinkedHashSet"));
|
||||
sets.addAll(Arrays.asList("CustomHashSet", "LinkedCustomHashSet"));
|
||||
sets.addAll(Arrays.asList("AVLTreeSet", "RBTreeSet"));
|
||||
return sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags()
|
||||
{
|
||||
if(isModuleEnabled()) addFlag("SET_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addFlag("SETS_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
boolean hashSet = implementations && isModuleEnabled("HashSet");
|
||||
boolean customHashSet = implementations && isModuleEnabled("CustomHashSet");
|
||||
|
||||
if(isModuleEnabled("OrderedSet")) {
|
||||
addFlag("ORDERED_SET_FEATURE");
|
||||
if(implementations && isModuleEnabled("ArraySet")) addFlag("ARRAY_SET_FEATURE");
|
||||
if(hashSet && isModuleEnabled("LinkedHashSet")) addFlag("LINKED_SET_FEATURE");
|
||||
if(customHashSet && isModuleEnabled("LinkedCustomHashSet")) addFlag("LINKED_CUSTOM_SET_FEATURE");
|
||||
}
|
||||
if(isModuleEnabled("SortedSet")) {
|
||||
addFlag("SORTED_SET_FEATURE");
|
||||
if(implementations && isModuleEnabled("AVLTreeSet")) addFlag("AVL_TREE_SET_FEATURE");
|
||||
if(implementations && isModuleEnabled("RBTreeSet")) addFlag("RB_TREE_SET_FEATURE");
|
||||
}
|
||||
if(implementations && isModuleEnabled("ImmutableSet")) addFlag("IMMUTABLE_SET_FEATURE");
|
||||
if(hashSet) addFlag("HASH_SET_FEATURE");
|
||||
if(customHashSet) addFlag("CUSTOM_HASH_SET_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(!isModuleEnabled()) addBlockedFiles("Set", "AbstractSet");
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Sets");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
if(implementations || !isModuleEnabled("ImmutableSet")) addBlockedFiles("ImmutableOpenHashSet");
|
||||
|
||||
boolean ordered = !isModuleEnabled("OrderedSet");
|
||||
if(ordered) addBlockedFiles("OrderedSet");
|
||||
boolean hashSet = implementations || !isModuleEnabled("HashSet");
|
||||
if(hashSet) addBlockedFiles("OpenHashSet");
|
||||
if(hashSet || ordered || !isModuleEnabled("LinkedHashSet")) addBlockedFiles("LinkedOpenHashSet");
|
||||
|
||||
boolean customHashSet = implementations || !isModuleEnabled("CustomHashSet");
|
||||
if(customHashSet) addBlockedFiles("OpenCustomHashSet");
|
||||
if(customHashSet || ordered || !isModuleEnabled("LinkedCustomHashSet")) addBlockedFiles("LinkedOpenCustomHashSet");
|
||||
|
||||
if(implementations || ordered || !isModuleEnabled("ArraySet")) addBlockedFiles("ArraySet");
|
||||
|
||||
boolean sorted = !isModuleEnabled("SortedSet");
|
||||
if(sorted) addBlockedFiles("SortedSet", "NavigableSet");
|
||||
if(implementations || sorted || !isModuleEnabled("AVLTreeSet")) addBlockedFiles("AVLTreeSet");
|
||||
if(implementations || sorted || !isModuleEnabled("RBTreeSet")) addBlockedFiles("RBTreeSet");
|
||||
|
||||
if(keyType == ClassType.BOOLEAN)
|
||||
{
|
||||
//Main Classes
|
||||
addBlockedFiles("SortedSet", "NavigableSet", "AVLTreeSet", "RBTreeSet");
|
||||
addBlockedFiles("OrderedSet", "ArraySet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||
addBlockedFiles("Set", "Sets", "AbstractSet", "OpenHashSet", "OpenCustomHashSet", "ImmutableOpenHashSet");
|
||||
|
||||
//Test Classes
|
||||
addBlockedFiles("SetTests", "SetTestSuiteBuilder");
|
||||
addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedSetIterationTester");
|
||||
addBlockedFiles("SortedSetTestSuiteBuilder", "TestSortedSetGenerator", "SortedSetNaviationTester", "SortedSetSubsetTestSetGenerator", "SortedSetIterationTester", "SortedSetNaviationTester");
|
||||
addBlockedFiles("NavigableSetTestSuiteBuilder", "TestNavigableSetGenerator", "NavigableSetNavigationTester");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addRemapper("AbstractSet", "Abstract%sSet");
|
||||
addRemapper("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
||||
|
||||
//Test Classes
|
||||
addRemapper("MinimalSet", "Minimal%sSet");
|
||||
addRemapper("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
||||
addRemapper("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
||||
addRemapper("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
||||
addRemapper("TestSetGenerator", "Test%sSetGenerator");
|
||||
addRemapper("AbstractSetTester", "Abstract%sSetTester");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
||||
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
||||
addFunctionMapper("FIRST_KEY", "first");
|
||||
addFunctionMapper("LAST_KEY", "last");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractMapper("MINIMAL_SET", "Minimal%sSet");
|
||||
addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder");
|
||||
addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder");
|
||||
addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder");
|
||||
addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder");
|
||||
addClassMapper("SET_TESTS", "SetTests");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester");
|
||||
|
||||
//Helper Classes
|
||||
addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator");
|
||||
addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator");
|
||||
addAbstractMapper("TEST_NAVIGABLE_SET_GENERATOR", "Test%sNavigableSetGenerator");
|
||||
addAbstractMapper("TEST_SORTED_SET_GENERATOR", "Test%sSortedSetGenerator");
|
||||
addAbstractMapper("TEST_ORDERED_SET_GENERATOR", "Test%sOrderedSetGenerator");
|
||||
addAbstractMapper("TEST_SET_GENERATOR", "Test%sSetGenerator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addClassMapper("LINKED_CUSTOM_HASH_SET", "LinkedOpenCustomHashSet");
|
||||
addClassMapper("LINKED_HASH_SET", "LinkedOpenHashSet");
|
||||
addAbstractMapper("IMMUTABLE_HASH_SET", "Immutable%sOpenHashSet");
|
||||
addClassMapper("CUSTOM_HASH_SET", "OpenCustomHashSet");
|
||||
addClassMapper("HASH_SET", "OpenHashSet");
|
||||
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
||||
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
||||
addClassMapper("ARRAY_SET", "ArraySet");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
||||
|
||||
//Helper Classes
|
||||
addClassMapper("SETS", "Sets");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("NAVIGABLE_SET", "NavigableSet");
|
||||
addClassMapper("SORTED_SET", "SortedSet");
|
||||
addClassMapper("ORDERED_SET", "OrderedSet");
|
||||
addClassMapper("SET", "Set");
|
||||
}
|
||||
}
|
|
@ -5,16 +5,20 @@ import java.util.Collection;
|
|||
import java.util.Objects;
|
||||
import java.util.function.JAVA_PREDICATE;
|
||||
import java.util.function.Predicate;
|
||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
@ -179,7 +183,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
||||
return TO_ARRAY(action.get(size()));
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -291,6 +295,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
|
@ -303,11 +308,15 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
* @return a Stream of the closest java type
|
||||
*/
|
||||
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||
|
||||
#endif
|
||||
#if STREAM_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||
#endif
|
||||
#endif
|
||||
}
|
|
@ -17,16 +17,46 @@ import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
|||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if ARRAY_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
#endif
|
||||
#endif
|
||||
#if SET_MODULE && !TYPE_BOOLEAN
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if LINKED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
#else if SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
#else if ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#if ASYNC_MODULE
|
||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
|
||||
/**
|
||||
|
@ -86,6 +116,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
iterator().forEachRemaining(input, action);
|
||||
}
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
|
@ -93,6 +124,8 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||
|
||||
#endif
|
||||
#if ASYNC_MODULE
|
||||
/**
|
||||
* Creates a Async Builder for moving work of the thread.
|
||||
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
||||
|
@ -103,6 +136,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
return new ASYNC_BUILDERBRACES(this);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the mapping function
|
||||
|
@ -202,25 +236,46 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
return collection;
|
||||
}
|
||||
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||
* @return a new ArrayList of all elements
|
||||
*/
|
||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||
#if ARRAY_LIST_FEATURE
|
||||
return pour(new ARRAY_LISTBRACES());
|
||||
#else
|
||||
return pour(new LINKED_LISTBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && SET_MODULE
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||
* @return a new LinkedHashSet of all elements
|
||||
*/
|
||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||
#if LINKED_SET_FEATURE
|
||||
return pour(new LINKED_HASH_SETBRACES());
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if SET_FEATURE
|
||||
return pour(new HASH_SETBRACES());
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
return pour(new RB_Tree_SETBRACES());
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
return pour(new AVL_Tree_SETBRACES());
|
||||
#else if ARRAY_SET_FEATURE
|
||||
return pour(new ARRAY_SETBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||
|
@ -232,12 +287,12 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
if(prov != null) {
|
||||
int size = prov.size();
|
||||
if(size >= 0) {
|
||||
KEY_TYPE[] array = action.get(size);
|
||||
KEY_TYPE[] array = action.apply(size);
|
||||
ITERATORS.unwrap(array, iterator());
|
||||
return array;
|
||||
}
|
||||
}
|
||||
return ITERATORS.pour(iterator()).TO_ARRAY(action);
|
||||
return ARRAYS.pour(iterator(), action);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
|
@ -254,7 +309,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
return array;
|
||||
}
|
||||
}
|
||||
return ITERATORS.pour(iterator()).TO_ARRAY();
|
||||
return ARRAYS.pour(iterator());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -266,7 +321,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.TEST_VALUE(iter.NEXT())) return true;
|
||||
if(filter.test(iter.NEXT())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -279,7 +334,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.TEST_VALUE(iter.NEXT())) return false;
|
||||
if(filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -292,7 +347,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(!filter.TEST_VALUE(iter.NEXT())) return false;
|
||||
if(!filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -306,7 +361,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE entry = iter.NEXT();
|
||||
if(filter.TEST_VALUE(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -377,7 +432,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.TEST_VALUE(iter.NEXT())) result++;
|
||||
if(filter.test(iter.NEXT())) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,9 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||
* @param k the value that should be processed
|
||||
* @return the result of the function
|
||||
*/
|
||||
public VALUE_TYPE GET_VALUE(KEY_TYPE k);
|
||||
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||
|
||||
#if JDK_FUNCTION
|
||||
#if VALUE_BOOLEAN
|
||||
@Override
|
||||
public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); }
|
||||
#if JDK_FUNCTION && VALUE_BOOLEAN
|
||||
|
||||
/**
|
||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||
|
@ -35,19 +32,19 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.test(T);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||
return T -> !GET_VALUE(T);
|
||||
return T -> !APPLY(T);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,23 +54,14 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.test(T);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
#else if VALUE_OBJECT
|
||||
|
||||
@Override
|
||||
public default VALUE_TYPE apply(KEY_TYPE k) { return GET_VALUE(k); }
|
||||
#else
|
||||
|
||||
@Override
|
||||
public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k) { return GET_VALUE(k); }
|
||||
#endif
|
||||
#endif
|
||||
}
|
|
@ -8,7 +8,10 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
#endif
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.function.Predicate;
|
||||
|
@ -38,33 +41,38 @@ import speiger.src.collections.utils.Stack;
|
|||
#else
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
#if PRIMITIVES
|
||||
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#if IARRAY_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.IARRAY;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
#if !IARRAY_FEATURE
|
||||
import speiger.src.collections.utils.IArray;
|
||||
#endif
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
|
||||
*
|
||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link Stack}
|
||||
#if IARRAY_FEATURE
|
||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
|
||||
#else
|
||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IArray}, {@link STACK}
|
||||
#endif
|
||||
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
|
||||
*
|
||||
* @Type(T)
|
||||
*/
|
||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY<KEY_TYPE>, Stack<KEY_TYPE>
|
||||
#if IARRAY_FEATURE
|
||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
|
||||
#else
|
||||
/**
|
||||
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
|
||||
*
|
||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
|
||||
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
|
||||
*/
|
||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY, STACK
|
||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IArray, STACK KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
static final int DEFAULT_ARRAY_SIZE = 10;
|
||||
|
@ -587,6 +595,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return data[(size() - 1) - index];
|
||||
}
|
||||
|
||||
#if IARRAY_FEATURE
|
||||
/**
|
||||
* Provides the Underlying Array in the Implementation
|
||||
* @return underlying Array
|
||||
|
@ -606,6 +615,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return data.getClass() != Object[].class;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
/**
|
||||
* A Type Specific foreach function that reduces (un)boxing
|
||||
|
@ -639,7 +649,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return true;
|
||||
if(filter.test(data[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -648,7 +658,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return false;
|
||||
if(filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -657,7 +667,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.TEST_VALUE(data[i])) return false;
|
||||
if(!filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -666,7 +676,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
||||
if(filter.test(data[i])) return data[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -715,7 +725,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
if(filter.test(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1159,8 +1169,8 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||
}
|
||||
|
||||
|
||||
#if PRIMITIVES
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES && STREAM_FEATURE
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
|
@ -1177,4 +1187,5 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
*/
|
||||
@Override
|
||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, size, 16464); }
|
||||
#endif
|
||||
}
|
|
@ -41,12 +41,14 @@ import speiger.src.collections.utils.Stack;
|
|||
#else
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
#if PRIMITIVES
|
||||
#if PRIMITIVES && STREAM_FEATURE && SPLIT_ITERATOR_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
|
@ -148,8 +150,8 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
* @Type(T)
|
||||
* @return a typed List
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
public static GENERIC_KEY_BRACES COPY_ON_WRITE_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
||||
COPY_ON_WRITE_LIST KEY_GENERIC_TYPE list = new COPY_ON_WRITE_LISTBRACES();
|
||||
list.data = (KEY_TYPE[])ObjectArrays.newArray(c, 0);
|
||||
return list;
|
||||
}
|
||||
|
@ -773,7 +775,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
Objects.requireNonNull(filter);
|
||||
KEY_TYPE[] data = this.data;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return true;
|
||||
if(filter.test(data[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -783,7 +785,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
Objects.requireNonNull(filter);
|
||||
KEY_TYPE[] data = this.data;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return false;
|
||||
if(filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -793,7 +795,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
Objects.requireNonNull(filter);
|
||||
KEY_TYPE[] data = this.data;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(!filter.TEST_VALUE(data[i])) return false;
|
||||
if(!filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -803,7 +805,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
Objects.requireNonNull(filter);
|
||||
KEY_TYPE[] data = this.data;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
||||
if(filter.test(data[i])) return data[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -856,7 +858,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
KEY_TYPE[] data = this.data;
|
||||
int result = 0;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
if(filter.test(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1409,7 +1411,8 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
||||
}
|
||||
|
||||
#if PRIMITIVES
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES && STREAM_FEATURE
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
|
@ -1427,6 +1430,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
@Override
|
||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
||||
|
||||
#endif
|
||||
static final class COWIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
KEY_TYPE[] data;
|
||||
|
@ -2080,9 +2084,11 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||
}
|
||||
}
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
@Override
|
||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 16464); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
||||
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
||||
|
|
|
@ -29,12 +29,14 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
#if PRIMITIVES
|
||||
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
|
@ -301,7 +303,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return true;
|
||||
if(filter.test(data[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -310,7 +312,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return false;
|
||||
if(filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -319,7 +321,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(!filter.TEST_VALUE(data[i])) return false;
|
||||
if(!filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -328,7 +330,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
||||
if(filter.test(data[i])) return data[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -377,7 +379,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
if(filter.test(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -487,7 +489,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
||||
}
|
||||
|
||||
#if PRIMITIVES
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES && STREAM_FEATURE
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
|
@ -505,6 +508,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
@Override
|
||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
||||
|
||||
#endif
|
||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||
int index;
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package speiger.src.collections.PACKAGE.lists;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#if DEQUEUE_FEATURE
|
||||
import java.util.Comparator;
|
||||
#endif
|
||||
import java.util.function.BiFunction;
|
||||
#else if PRIMITIVES
|
||||
import java.nio.JAVA_BUFFER;
|
||||
|
@ -31,9 +33,13 @@ import speiger.src.collections.PACKAGE.collections.STACK;
|
|||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if DEQUEUE_FEATURE
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
#if DEQUEUE_FEATURE
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
|
@ -62,10 +68,10 @@ import speiger.src.collections.utils.SanityChecks;
|
|||
*
|
||||
* @Type(T)
|
||||
*/
|
||||
#if TYPE_OBJECT
|
||||
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, Stack KEY_GENERIC_TYPE
|
||||
#else
|
||||
#if DEQUEUE_FEATURE
|
||||
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
|
||||
#else
|
||||
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements STACK KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
Entry KEY_GENERIC_TYPE first;
|
||||
|
@ -222,6 +228,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return true;
|
||||
}
|
||||
|
||||
#if DEQUEUE_FEATURE
|
||||
@Override
|
||||
public void enqueue(KEY_TYPE e) {
|
||||
add(e);
|
||||
|
@ -232,6 +239,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
add(0, e);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public void push(KEY_TYPE e) {
|
||||
add(e);
|
||||
|
@ -291,6 +299,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return a;
|
||||
}
|
||||
|
||||
#if DEQUEUE_FEATURE
|
||||
@Override
|
||||
public KEY_TYPE first() {
|
||||
if(first == null) throw new NoSuchElementException();
|
||||
|
@ -303,11 +312,11 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return last.value;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE peek(int index) {
|
||||
return GET_KEY((size() - 1) - index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE GET_KEY(int index) {
|
||||
checkRange(index);
|
||||
|
@ -412,7 +421,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(filter.TEST_VALUE(entry.value)) return true;
|
||||
if(filter.test(entry.value)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -421,7 +430,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(filter.TEST_VALUE(entry.value)) return false;
|
||||
if(filter.test(entry.value)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -430,7 +439,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(!filter.TEST_VALUE(entry.value)) return false;
|
||||
if(!filter.test(entry.value)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -439,7 +448,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(filter.TEST_VALUE(entry.value)) return entry.value;
|
||||
if(filter.test(entry.value)) return entry.value;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -488,7 +497,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(filter.TEST_VALUE(entry.value)) result++;
|
||||
if(filter.test(entry.value)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -525,6 +534,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
}
|
||||
|
||||
#endif
|
||||
#if DEQUEUE_FEATURE
|
||||
@Override
|
||||
public void onChanged() {}
|
||||
@Override
|
||||
|
@ -538,25 +548,24 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
@Override
|
||||
public KEY_TYPE dequeueLast() {
|
||||
return pop();
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE pop() {
|
||||
if(last == null) throw new NoSuchElementException();
|
||||
return unlinkLast(last);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE pop() {
|
||||
return dequeueLast();
|
||||
}
|
||||
|
||||
#if DEQUEUE_FEATURE
|
||||
@Override
|
||||
public boolean removeFirst(KEY_TYPE e) {
|
||||
if(size == 0) return false;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(KEY_EQUALS(entry.value, e)) {
|
||||
unlink(entry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#if TYPE_OBJECT
|
||||
return remove(e);
|
||||
#else
|
||||
return REMOVE_KEY(e);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -571,6 +580,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE swapRemove(int index) {
|
||||
checkRange(index);
|
||||
|
@ -653,7 +663,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#else
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||
return removeFirst(e);
|
||||
if(size == 0) return false;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(KEY_EQUALS(entry.value, e)) {
|
||||
unlink(entry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,9 @@ import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
|||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#if LISTS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
@ -379,6 +381,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
@Override
|
||||
public LIST KEY_GENERIC_TYPE subList(int from, int to);
|
||||
|
||||
#if LISTS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped List that is Synchronized
|
||||
* @return a new List that is synchronized
|
||||
|
@ -401,6 +404,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
*/
|
||||
public default LIST KEY_GENERIC_TYPE unmodifiable() { return LISTS.unmodifiable(this); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A function to ensure the elements are within the requested size.
|
||||
* If smaller then the stored elements they get removed as needed.
|
||||
|
|
|
@ -11,7 +11,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if MAPS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#endif
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
#if !SAME_TYPE
|
||||
|
@ -19,6 +21,7 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
|||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||
#endif
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
#endif
|
||||
|
@ -47,6 +50,22 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
return this;
|
||||
}
|
||||
|
||||
protected ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterable(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
#if MAPS_FEATURE
|
||||
return MAPS.fastIterable(map);
|
||||
#else
|
||||
return map.ENTRY_SET();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterator(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
#if MAPS_FEATURE
|
||||
return MAPS.fastIterator(map);
|
||||
#else
|
||||
return map.ENTRY_SET().iterator();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -63,14 +82,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
#if VALUE_PRIMITIVES
|
||||
@Override
|
||||
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(m);iter.hasNext();) {
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(m);iter.hasNext();) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||
}
|
||||
|
@ -101,7 +120,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
#endif
|
||||
@Override
|
||||
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||
}
|
||||
|
||||
|
@ -161,14 +180,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
|
||||
@Override
|
||||
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
|
||||
}
|
||||
|
@ -195,7 +214,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
|
@ -246,7 +265,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||
|
@ -298,7 +317,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||
}
|
||||
|
@ -332,7 +351,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
|
@ -383,7 +402,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
|
@ -423,7 +442,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);
|
||||
while(iter.hasNext()) hash += iter.next().hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
|
|
@ -698,7 +698,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -836,7 +836,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(seg.keys[index])) return true;
|
||||
if(filter.test(seg.keys[index])) return true;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(seg.keys[index])) return false;
|
||||
if(filter.test(seg.keys[index])) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1045,7 +1045,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(!filter.TEST_VALUE(seg.keys[index])) return false;
|
||||
if(!filter.test(seg.keys[index])) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(seg.keys[index])) return seg.keys[index];
|
||||
if(filter.test(seg.keys[index])) return seg.keys[index];
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1159,7 +1159,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(seg.keys[index])) result++;
|
||||
if(filter.test(seg.keys[index])) result++;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1253,7 +1253,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return true;
|
||||
if(filter.test(seg.values[index])) return true;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return false;
|
||||
if(filter.test(seg.values[index])) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1293,7 +1293,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.VALUE_TEST_VALUE(seg.values[index])) return false;
|
||||
if(!filter.test(seg.values[index])) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1387,7 +1387,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return seg.values[index];
|
||||
if(filter.test(seg.values[index])) return seg.values[index];
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -1408,7 +1408,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) result++;
|
||||
if(filter.test(seg.values[index])) result++;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -2141,14 +2141,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = findIndex(hash, key);
|
||||
if(index < 0) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
insert(-index-1, key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
VALUE_TYPE newValue = values[index];
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
newValue = mappingFunction.GET_VALUE(key);
|
||||
newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
values[index] = newValue;
|
||||
}
|
||||
|
|
|
@ -702,7 +702,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -716,7 +716,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -730,7 +730,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -775,7 +775,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return null;
|
||||
|
@ -790,7 +790,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -961,7 +961,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -973,7 +973,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -985,7 +985,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1043,7 +1043,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
|
@ -1056,7 +1056,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -1124,7 +1124,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
||||
if(filter.test(values[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -1136,7 +1136,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1148,7 +1148,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(!filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1206,7 +1206,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return EMPTY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
||||
if(filter.test(values[index])) return values[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -1219,7 +1219,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
if(filter.test(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -22,11 +22,8 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
|||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
@ -542,14 +539,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
Objects.requireNonNull(mappingFunction);
|
||||
int index = findIndex(key);
|
||||
if(index < 0) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
insert(-index-1, key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
VALUE_TYPE newValue = values[index];
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
newValue = mappingFunction.GET_VALUE(key);
|
||||
newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
values[index] = newValue;
|
||||
}
|
||||
|
@ -609,7 +606,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||
|
@ -886,12 +883,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -904,12 +901,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -922,12 +919,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -973,12 +970,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -992,12 +989,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1120,9 +1117,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1131,9 +1128,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1142,9 +1139,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1201,9 +1198,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
||||
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i];
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
@ -1213,9 +1210,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1276,9 +1273,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true;
|
||||
if(containsNull && filter.test(values[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return true;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1287,9 +1284,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
||||
if(containsNull && filter.test(values[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1298,9 +1295,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(values[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1357,9 +1354,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_VALUE;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex];
|
||||
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return values[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -1369,9 +1366,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
||||
if(containsNull && filter.test(values[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1420,7 +1417,8 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
int lastReturned = -1;
|
||||
int nextIndex = Integer.MIN_VALUE;
|
||||
boolean returnNull = containsNull;
|
||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
||||
KEY_TYPE[] wrapped = null;
|
||||
int wrappedIndex = 0;
|
||||
|
||||
public boolean hasNext() {
|
||||
if(nextIndex == Integer.MIN_VALUE) {
|
||||
|
@ -1432,7 +1430,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
{
|
||||
while(true) {
|
||||
if(--pos < 0) {
|
||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
||||
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||
nextIndex = -pos - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -1451,7 +1449,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
returnedPos = pos;
|
||||
if(nextIndex < 0){
|
||||
lastReturned = Integer.MAX_VALUE;
|
||||
int value = findIndex(wrapped.GET_KEY(nextIndex));
|
||||
int value = findIndex(wrapped[nextIndex]);
|
||||
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
|
@ -1470,7 +1468,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||
else {
|
||||
CUSTOM_HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
||||
CUSTOM_HASH_MAP.this.remove(wrapped[-returnedPos - 1]);
|
||||
lastReturned = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -1493,13 +1491,20 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
if(startPos < last) {
|
||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
||||
wrapped.add(keys[startPos]);
|
||||
}
|
||||
if(startPos < last) addWrapper(keys[startPos]);
|
||||
keys[last] = current;
|
||||
values[last] = values[startPos];
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapper(KEY_TYPE value) {
|
||||
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||
else if(wrappedIndex >= wrapped.length) {
|
||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||
wrapped = newArray;
|
||||
}
|
||||
wrapped[wrappedIndex++] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -706,7 +706,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -720,7 +720,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -734,7 +734,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -779,7 +779,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return null;
|
||||
|
@ -794,7 +794,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -960,7 +960,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -972,7 +972,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -984,7 +984,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1042,7 +1042,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
|
@ -1055,7 +1055,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -1124,7 +1124,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
||||
if(filter.test(values[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -1136,7 +1136,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1148,7 +1148,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(!filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1206,7 +1206,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return EMPTY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
||||
if(filter.test(values[index])) return values[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -1219,7 +1219,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
if(filter.test(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -22,11 +22,8 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
|||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
@ -503,14 +500,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
Objects.requireNonNull(mappingFunction);
|
||||
int index = findIndex(key);
|
||||
if(index < 0) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
insert(-index-1, key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
VALUE_TYPE newValue = values[index];
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
newValue = mappingFunction.GET_VALUE(key);
|
||||
newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
values[index] = newValue;
|
||||
}
|
||||
|
@ -570,7 +567,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||
|
@ -846,12 +843,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -864,12 +861,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -882,12 +879,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -933,12 +930,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -952,12 +949,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1076,9 +1073,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1087,9 +1084,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1098,9 +1095,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1157,9 +1154,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
||||
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i];
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
@ -1169,9 +1166,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1232,9 +1229,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true;
|
||||
if(containsNull && filter.test(values[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return true;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1243,9 +1240,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
||||
if(containsNull && filter.test(values[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1254,9 +1251,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(values[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1313,9 +1310,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_VALUE;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex];
|
||||
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return values[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -1325,9 +1322,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
||||
if(containsNull && filter.test(values[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1376,7 +1373,8 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
int lastReturned = -1;
|
||||
int nextIndex = Integer.MIN_VALUE;
|
||||
boolean returnNull = containsNull;
|
||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
||||
KEY_TYPE[] wrapped = null;
|
||||
int wrappedIndex = 0;
|
||||
|
||||
public boolean hasNext() {
|
||||
if(nextIndex == Integer.MIN_VALUE) {
|
||||
|
@ -1388,7 +1386,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
{
|
||||
while(true) {
|
||||
if(--pos < 0) {
|
||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
||||
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||
nextIndex = -pos - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -1407,7 +1405,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
returnedPos = pos;
|
||||
if(nextIndex < 0){
|
||||
lastReturned = Integer.MAX_VALUE;
|
||||
int value = findIndex(wrapped.GET_KEY(nextIndex));
|
||||
int value = findIndex(wrapped[nextIndex]);
|
||||
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
|
@ -1426,7 +1424,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
}
|
||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||
else {
|
||||
HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
||||
HASH_MAP.this.remove(wrapped[-returnedPos - 1]);
|
||||
lastReturned = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -1449,13 +1447,20 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
if(startPos < last) {
|
||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
||||
wrapped.add(keys[startPos]);
|
||||
}
|
||||
if(startPos < last) addWrapper(keys[startPos]);
|
||||
keys[last] = current;
|
||||
values[last] = values[startPos];
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapper(KEY_TYPE value) {
|
||||
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||
else if(wrappedIndex >= wrapped.length) {
|
||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||
wrapped = newArray;
|
||||
}
|
||||
wrapped[wrappedIndex++] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#endif
|
||||
|
@ -215,7 +214,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
KEY_TYPE[] keys = NEW_KEY_ARRAY(map.size());
|
||||
VALUE_TYPE[] values = NEW_VALUE_ARRAY(keys.length);
|
||||
int index = 0;
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(map)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(map)) {
|
||||
keys[index] = entry.ENTRY_KEY();
|
||||
values[index] = entry.ENTRY_VALUE();
|
||||
index++;
|
||||
|
@ -678,7 +677,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -692,7 +691,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -706,7 +705,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -751,7 +750,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return null;
|
||||
|
@ -766,7 +765,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -904,7 +903,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -916,7 +915,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -928,7 +927,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -986,7 +985,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
|
@ -999,7 +998,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int index = firstIndex;
|
||||
int result = 0;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
@ -1065,7 +1064,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return false;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
||||
if(filter.test(values[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -1077,7 +1076,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1089,7 +1088,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return true;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
||||
if(!filter.test(values[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -1147,7 +1146,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
if(size() <= 0) return EMPTY_VALUE;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
||||
if(filter.test(values[index])) return values[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -1160,7 +1159,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
if(filter.test(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -27,7 +27,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||
|
@ -176,7 +175,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
*/
|
||||
public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
this(map.size());
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(map);iter.hasNext();size++) {
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(map);iter.hasNext();size++) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
keys[size] = entry.ENTRY_KEY();
|
||||
values[size] = entry.ENTRY_VALUE();
|
||||
|
@ -499,14 +498,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(mappingFunction);
|
||||
int index = findIndex(key);
|
||||
if(index == -1) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
insertIndex(size++, key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
VALUE_TYPE newValue = values[index];
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
newValue = mappingFunction.GET_VALUE(key);
|
||||
newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
values[index] = newValue;
|
||||
}
|
||||
|
@ -566,7 +565,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
VALUE_TYPE newValue = index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||
|
@ -803,7 +802,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -815,7 +814,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -827,7 +826,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -865,7 +864,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -878,7 +877,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -998,7 +997,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(keys[i])) return true;
|
||||
if(filter.test(keys[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1007,7 +1006,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(keys[i])) return false;
|
||||
if(filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1016,7 +1015,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.TEST_VALUE(keys[i])) return false;
|
||||
if(!filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1064,7 +1063,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(keys[i])) return keys[i];
|
||||
if(filter.test(keys[i])) return keys[i];
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
@ -1074,7 +1073,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(keys[i])) result++;
|
||||
if(filter.test(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1124,7 +1123,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[i])) return true;
|
||||
if(filter.test(values[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1133,7 +1132,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1142,7 +1141,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.VALUE_TEST_VALUE(values[i])) return false;
|
||||
if(!filter.test(values[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1190,7 +1189,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
||||
if(filter.test(values[i])) return values[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -1200,7 +1199,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
if(filter.test(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
|||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.objects.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||
|
@ -377,7 +376,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
public VALUE_TYPE COMPUTE_IF_ABSENT(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
int index = key.ordinal();
|
||||
if(!isSet(index)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
set(index);
|
||||
values[index] = newValue;
|
||||
|
@ -385,7 +384,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
}
|
||||
VALUE_TYPE newValue = values[index];
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
newValue = mappingFunction.GET_VALUE(key);
|
||||
newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
values[index] = newValue;
|
||||
}
|
||||
|
@ -449,7 +448,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
T key = entry.ENTRY_KEY();
|
||||
int index = key.ordinal();
|
||||
VALUE_TYPE newValue = !isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||
|
|
|
@ -33,7 +33,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
|||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||
|
@ -556,13 +555,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
#endif
|
||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||
if(entry == null) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
entry.value = newValue;
|
||||
}
|
||||
|
@ -627,7 +626,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||
|
@ -1158,7 +1157,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1165,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1173,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1219,7 +1218,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1227,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1849,7 +1848,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
if(filter.test(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1861,7 +1860,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
if(filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1873,7 +1872,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
if(!filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1911,7 +1910,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
if(filter.test(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1924,7 +1923,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
if(filter.test(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1978,7 +1977,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
if(filter.test(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1986,7 +1985,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1994,7 +1993,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(!filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2039,7 +2038,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
if(filter.test(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2047,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
if(filter.test(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2326,7 +2325,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
if(filter.test(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2334,7 +2333,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2342,7 +2341,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(!filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2387,7 +2386,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
if(filter.test(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -2396,7 +2395,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
if(filter.test(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2486,7 +2485,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
if(filter.test(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2498,7 +2497,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
if(filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2510,7 +2509,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
if(!filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2548,7 +2547,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
if(filter.test(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2561,7 +2560,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
if(filter.test(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
|||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||
|
@ -559,13 +558,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
#endif
|
||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||
if(entry == null) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||
entry.value = newValue;
|
||||
}
|
||||
|
@ -630,7 +629,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||
|
@ -1215,7 +1214,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1223,7 +1222,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1230,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1275,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -1285,7 +1284,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1916,7 +1915,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
if(filter.test(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1928,7 +1927,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
if(filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1940,7 +1939,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
if(!filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1978,7 +1977,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
if(filter.test(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1991,7 +1990,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
if(filter.test(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2045,7 +2044,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
if(filter.test(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2053,7 +2052,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2061,7 +2060,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(!filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2106,7 +2105,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
if(filter.test(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -2115,7 +2114,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
if(filter.test(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2393,7 +2392,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
if(filter.test(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2401,7 +2400,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2409,7 +2408,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
if(!filter.test(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2454,7 +2453,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
if(filter.test(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
|
@ -2463,7 +2462,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
if(filter.test(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2553,7 +2552,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
if(filter.test(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2565,7 +2564,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
if(filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2577,7 +2576,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
if(!filter.test(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2615,7 +2614,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
if(filter.test(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2628,7 +2627,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
if(filter.test(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -12,34 +12,65 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Function;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||
import java.util.Comparator;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN && SORTED_MAP_FEATURE
|
||||
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN
|
||||
#if LINKED_CUSTOM_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
||||
#endif
|
||||
#if CUSTOM_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
||||
#endif
|
||||
#if LINKED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
||||
#endif
|
||||
#if MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
||||
#endif
|
||||
#if IMMUTABLE_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
||||
#endif
|
||||
#if AVL_TREE_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||
#endif
|
||||
#if RB_TREE_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||
#endif
|
||||
#if ARRAY_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||
#endif
|
||||
#if CONCURRENT_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
#if ENUM_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||
#endif
|
||||
#if LINKED_ENUM_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#if CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
#if MAPS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if !SAME_TYPE
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||
|
@ -404,13 +435,19 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return VALUE_TO_OBJ(replace(OBJ_TO_KEY(key), OBJ_TO_VALUE(value)));
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public default VALUE_TYPE APPLY(KEY_TYPE key) {
|
||||
return GET_VALUE(key);
|
||||
}
|
||||
/**
|
||||
* A Type Specific get method to reduce boxing/unboxing
|
||||
* @param key the key that is searched for
|
||||
* @return the searched value or default return value
|
||||
*/
|
||||
@Override
|
||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key);
|
||||
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
/**
|
||||
* A Type Specific getOrDefault method to reduce boxing/unboxing
|
||||
* @param key the key that is searched for
|
||||
|
@ -505,7 +542,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
*/
|
||||
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#if MAPS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped Map that is Synchronized
|
||||
* @return a new Map that is synchronized
|
||||
|
@ -658,6 +695,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
}
|
||||
|
||||
#endif
|
||||
#if MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @Type(T)
|
||||
|
@ -731,6 +769,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new HASH_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LINKED_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @Type(T)
|
||||
|
@ -804,6 +844,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if IMMUTABLE_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @param keys the keys that should be inserted
|
||||
|
@ -856,7 +898,9 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
#if ENUM_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @param keyType the EnumClass that should be used
|
||||
|
@ -924,6 +968,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new ENUM_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LINKED_ENUM_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @param keyType the EnumClass that should be used
|
||||
|
@ -990,7 +1036,10 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
return new LINKED_ENUM_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#if CUSTOM_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @param strategy the Hash Controller
|
||||
|
@ -1070,6 +1119,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LINKED_CUSTOM_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @param strategy the Hash Controller
|
||||
|
@ -1149,6 +1200,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ARRAY_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @Type(T)
|
||||
|
@ -1222,7 +1275,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new ARRAY_MAPKV_BRACES(map);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#if RB_TREE_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @Type(T)
|
||||
|
@ -1300,6 +1354,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new RB_TREE_MAPKV_BRACES(map, comp);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if AVL_TREE_MAP_FEATURE
|
||||
/**
|
||||
* Helper function to unify code
|
||||
* @Type(T)
|
||||
|
@ -1376,6 +1432,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
return new AVL_TREE_MAPKV_BRACES(map, comp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1454,7 +1511,11 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
* @return self
|
||||
*/
|
||||
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
#if MAPS_FEATURE
|
||||
return putAll(MAPS.fastIterable(map));
|
||||
#else
|
||||
return putAll(map.ENTRY_SET());
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1483,11 +1544,14 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return this;
|
||||
}
|
||||
|
||||
#if MAP_FEATURE || LINKED_MAP_FEATURE || CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE || AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE || CONCURRENT_MAP_FEATURE
|
||||
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
|
||||
e.putAll(keys, values, 0, size);
|
||||
return e;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Hash Map
|
||||
* @return a HASH_MAP
|
||||
|
@ -1496,6 +1560,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new HASH_MAPKV_BRACES(size));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LINKED_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Linked Hash Map
|
||||
* @return a LINKED_HASH_MAP
|
||||
|
@ -1504,6 +1570,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if IMMUTABLE_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Immutable Hash Map
|
||||
* @return a IMMUTABLE_HASH_MAP
|
||||
|
@ -1512,6 +1580,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if CUSTOM_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Custom Hash Map
|
||||
* @param strategy the that controls the keys and values
|
||||
|
@ -1521,6 +1591,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LINKED_CUSTOM_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Linked Custom Hash Map
|
||||
* @param strategy the that controls the keys and values
|
||||
|
@ -1530,6 +1602,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if CONCURRENT_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Concurrent Hash Map
|
||||
* @return a CONCURRENT_HASH_MAP
|
||||
|
@ -1538,6 +1612,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ARRAY_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a Array Map
|
||||
* @return a ARRAY_MAP
|
||||
|
@ -1546,6 +1622,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return new ARRAY_MAPKV_BRACES(keys, values, size);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if RB_TREE_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a RedBlack TreeMap
|
||||
* @return a RB_TREE_MAP
|
||||
|
@ -1563,6 +1641,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
return putElements(new RB_TREE_MAPKV_BRACES(comp));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if AVL_TREE_MAP_FEATURE
|
||||
/**
|
||||
* Builds the Keys and Values into a AVL TreeMap
|
||||
* @return a AVL_TREE_MAP
|
||||
|
@ -1579,6 +1659,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.maps.interfaces;
|
|||
|
||||
import java.util.NavigableMap;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
#if MAPS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Specific Navigable Map interface with a couple helper methods
|
||||
|
@ -37,6 +39,8 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||
/** @return a Type Specific Navigable Key Set */
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
||||
|
||||
#if MAPS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped NavigableMap that is Synchronized
|
||||
* @return a new NavigableMap that is synchronized
|
||||
|
@ -59,6 +63,7 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||
*/
|
||||
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||
|
||||
#if MAPS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
#endif
|
||||
|
@ -102,6 +104,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||
@Override
|
||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||
|
||||
#if MAPS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped SortedMap that is Synchronized
|
||||
* @return a new SortedMap that is synchronized
|
||||
|
@ -127,6 +130,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||
@Override
|
||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
||||
* @Type(T)
|
||||
|
|
|
@ -10,7 +10,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
|||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
#if MAPS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
||||
#endif
|
||||
|
@ -37,6 +39,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||
@Override
|
||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
||||
|
||||
#if MAPS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped SortedMap that is Synchronized
|
||||
* @return a new SortedMap that is synchronized
|
||||
|
@ -59,6 +62,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||
*/
|
||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package speiger.src.collections.PACKAGE.misc.pairs;
|
||||
|
||||
#if IMMUTABLE_PAIR
|
||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.IMMUTABLE_PAIR;
|
||||
#endif
|
||||
#if MUTABLE_PAIR
|
||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Key Value Pair Interface that allows to reduce boxing/unboxing.
|
||||
* @Type(T)
|
||||
|
@ -9,6 +14,7 @@ import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
|||
*/
|
||||
public interface PAIR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
#if IMMUTABLE_PAIR
|
||||
/**
|
||||
* Empty Reference for Immutable Pairs
|
||||
*/
|
||||
|
@ -68,6 +74,8 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||
return new IMMUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||
}
|
||||
|
||||
#endif
|
||||
#if MUTABLE_PAIR
|
||||
/**
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
|
@ -118,6 +126,7 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||
return new MUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Sets the Key of the Pair.
|
||||
* @param key the key that should be set.
|
||||
|
|
|
@ -270,7 +270,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return true;
|
||||
if(filter.test(array[(first + i) % array.length])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
||||
if(filter.test(array[(first + i) % array.length])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(!filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
||||
if(!filter.test(array[(first + i) % array.length])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||
Objects.requireNonNull(filter);
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
int index = (first + i) % array.length;
|
||||
if(filter.TEST_VALUE(array[index])) {
|
||||
if(filter.test(array[index])) {
|
||||
KEY_TYPE data = array[index];
|
||||
removeIndex(index);
|
||||
return data;
|
||||
|
@ -351,7 +351,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) result++;
|
||||
if(filter.test(array[(first + i) % array.length])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) return true;
|
||||
if(filter.test(array[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) return false;
|
||||
if(filter.test(array[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.TEST_VALUE(array[i])) return false;
|
||||
if(!filter.test(array[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) {
|
||||
if(filter.test(array[i])) {
|
||||
KEY_TYPE data = array[i];
|
||||
removeIndex(i);
|
||||
return data;
|
||||
|
@ -353,7 +353,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) result++;
|
||||
if(filter.test(array[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) return true;
|
||||
if(filter.test(array[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) return false;
|
||||
if(filter.test(array[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.TEST_VALUE(array[i])) return false;
|
||||
if(!filter.test(array[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) {
|
||||
if(filter.test(array[i])) {
|
||||
KEY_TYPE data = array[i];
|
||||
removeIndex(i);
|
||||
return data;
|
||||
|
@ -340,7 +340,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) result++;
|
||||
if(filter.test(array[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import java.util.Iterator;
|
|||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if QUEUES_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
||||
|
@ -81,6 +83,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||
*/
|
||||
public default KEY_TYPE last() { return peek(size()-1); }
|
||||
|
||||
#if QUEUES_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped PriorityDequeue that is Synchronized
|
||||
* @return a new PriorityDequeue that is synchronized
|
||||
|
@ -96,6 +99,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||
*/
|
||||
public default PRIORITY_DEQUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
||||
}
|
|
@ -12,7 +12,9 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if QUEUES_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
@ -147,8 +149,9 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||
* @return draining iterator of the PriorityQueue
|
||||
*/
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if QUEUES_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||
* @return a new PriorityQueue that is synchronized
|
||||
|
@ -164,6 +167,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||
*/
|
||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A method to drop the contents of the Queue without clearing the queue
|
||||
* @Type(E)
|
||||
|
@ -186,7 +190,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
||||
return TO_ARRAY(action.get(size()));
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -364,7 +364,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1269,7 +1269,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -1279,7 +1279,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return true;
|
||||
if(filter.test(data[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return false;
|
||||
if(filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.TEST_VALUE(data[i])) return false;
|
||||
if(!filter.test(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
||||
if(filter.test(data[i])) return data[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
if(filter.test(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -349,7 +349,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -360,7 +360,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -415,7 +415,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -427,7 +427,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -547,7 +547,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -558,7 +558,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -569,7 +569,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -624,7 +624,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -636,7 +636,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -402,7 +402,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
if(filter.test(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
|
@ -413,7 +413,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
if(filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -424,7 +424,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
if(!filter.test(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
|
@ -479,7 +479,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
|
@ -491,7 +491,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
if(filter.test(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -4,7 +4,9 @@ import java.util.NavigableSet;
|
|||
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
#if SETS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
|
||||
/**
|
||||
|
@ -119,7 +121,7 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SETS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped NavigableSet that is Synchronized
|
||||
* @return a new NavigableSet that is synchronized
|
||||
|
|
|
@ -13,8 +13,6 @@ import java.util.function.BiFunction;
|
|||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
|
@ -524,9 +522,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -535,9 +533,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -546,9 +544,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -605,9 +603,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_VALUE;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
||||
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i];
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -617,9 +615,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -630,7 +628,8 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
int lastReturned = -1;
|
||||
int nextIndex = Integer.MIN_VALUE;
|
||||
boolean returnNull = containsNull;
|
||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
||||
KEY_TYPE[] wrapped = null;
|
||||
int wrappedIndex = 0;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
@ -642,7 +641,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
else {
|
||||
while(true) {
|
||||
if(--pos < 0) {
|
||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
||||
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||
nextIndex = -pos - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -662,7 +661,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
returnedPos = pos;
|
||||
if(nextIndex < 0){
|
||||
lastReturned = Integer.MAX_VALUE;
|
||||
KEY_TYPE value = wrapped.GET_KEY(nextIndex);
|
||||
KEY_TYPE value = wrapped[nextIndex];
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
}
|
||||
|
@ -680,7 +679,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
}
|
||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||
else {
|
||||
CUSTOM_HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
||||
CUSTOM_HASH_SET.this.remove(wrapped[-returnedPos - 1]);
|
||||
lastReturned = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -702,12 +701,19 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
if(startPos < last) {
|
||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
||||
wrapped.add(keys[startPos]);
|
||||
}
|
||||
if(startPos < last) addWrapper(keys[startPos]);
|
||||
keys[last] = current;
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapper(KEY_TYPE value) {
|
||||
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||
else if(wrappedIndex >= wrapped.length) {
|
||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||
wrapped = newArray;
|
||||
}
|
||||
wrapped[wrappedIndex++] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,6 @@ import java.util.function.BiFunction;
|
|||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
|
@ -387,9 +385,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -398,9 +396,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -409,9 +407,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
||||
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -468,9 +466,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return EMPTY_VALUE;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
||||
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i];
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -480,9 +478,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -597,7 +595,8 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
int lastReturned = -1;
|
||||
int nextIndex = Integer.MIN_VALUE;
|
||||
boolean returnNull = containsNull;
|
||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
||||
KEY_TYPE[] wrapped = null;
|
||||
int wrappedIndex = 0;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
@ -610,7 +609,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
{
|
||||
while(true) {
|
||||
if(--pos < 0) {
|
||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
||||
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||
nextIndex = -pos - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -630,7 +629,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
returnedPos = pos;
|
||||
if(nextIndex < 0){
|
||||
lastReturned = Integer.MAX_VALUE;
|
||||
KEY_TYPE value = wrapped.GET_KEY(nextIndex);
|
||||
KEY_TYPE value = wrapped[nextIndex];
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
}
|
||||
|
@ -648,7 +647,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
}
|
||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||
else {
|
||||
HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
||||
HASH_SET.this.remove(wrapped[-returnedPos - 1]);
|
||||
lastReturned = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -670,12 +669,19 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
if(startPos < last) {
|
||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
||||
wrapped.add(keys[startPos]);
|
||||
}
|
||||
if(startPos < last) addWrapper(keys[startPos]);
|
||||
keys[last] = current;
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapper(KEY_TYPE value) {
|
||||
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||
else if(wrappedIndex >= wrapped.length) {
|
||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||
wrapped = newArray;
|
||||
}
|
||||
wrapped[wrappedIndex++] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.sets;
|
|||
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
#if SETS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +89,7 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
|||
*/
|
||||
public KEY_TYPE POLL_LAST_KEY();
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SETS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped OrderedSet that is Synchronized
|
||||
* @return a new OrderedSet that is synchronized
|
||||
|
|
|
@ -364,7 +364,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1264,7 +1264,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
if(filter.test(entry.key)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
if(filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1282,7 +1282,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
if(!filter.test(entry.key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1330,7 +1330,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
if(filter.test(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
@ -1340,7 +1340,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
if(filter.test(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Set;
|
|||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SETS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
|
@ -64,7 +64,7 @@ public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GE
|
|||
public KEY_TYPE addOrGet(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SETS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped Set that is Synchronized
|
||||
* @return a new Set that is synchronized
|
||||
|
|
|
@ -9,7 +9,9 @@ import java.util.Comparator;
|
|||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
#if SETS_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +43,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
|||
*/
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SETS_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped SortedSet that is Synchronized
|
||||
* @return a new SortedSet that is synchronized
|
||||
|
|
|
@ -9,10 +9,11 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||
#else
|
||||
import java.util.Comparator;
|
||||
|
||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
/**
|
||||
|
@ -132,10 +133,39 @@ public class ARRAYS
|
|||
* @return array with all requested elements of the iterator
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
|
||||
ITERATORS.pour(iter, list, max);
|
||||
return list.TO_ARRAY(NEW_KEY_ARRAY(list.size()));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that pours all elements of a iterator into a Array
|
||||
* @param iter the elements that should be gathered.
|
||||
* @ArrayType(T)
|
||||
* @param action that is creating the Array to be poured into
|
||||
* @return array with all elements of the iterator
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, Int2ObjectFunction<KEY_TYPE[]> action) {
|
||||
return pour(iter, Integer.MAX_VALUE, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function that pours all elements of a iterator into a Array
|
||||
* @param iter the elements that should be gathered.
|
||||
* @param max how many elements should be added
|
||||
* @param action that is creating the Array to be poured into
|
||||
* @ArrayType(T)
|
||||
* @return array with all requested elements of the iterator
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, Int2ObjectFunction<KEY_TYPE[]> action) {
|
||||
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
|
||||
ITERATORS.pour(iter, list, max);
|
||||
return list.TO_ARRAY(action.apply(list.size()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Method to validate if the current value is the lowest value in the heap
|
||||
* @param data the current heap.
|
||||
|
|
|
@ -17,27 +17,55 @@ import java.util.Comparator;
|
|||
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.functions.TASK;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if ARRAY_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#else if LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
#endif
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE
|
||||
#if SET_MODULE
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if LINKED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
#else if SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
#else if ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
||||
#endif
|
||||
#if !TYPE_INT
|
||||
#if !TYPE_INT && INT_ASYNC_MODULE
|
||||
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
||||
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
||||
#endif
|
||||
|
@ -113,6 +141,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
||||
}
|
||||
|
||||
#if ARRAY_LIST_FEATURE
|
||||
/**
|
||||
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
||||
* @param values that should be wrapped
|
||||
|
@ -123,6 +152,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
/**
|
||||
* Maps the elements to something else
|
||||
* @param mapper the mapping function
|
||||
|
@ -154,6 +185,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Filters out the unwanted elements out of the Iterable
|
||||
* @param filter the elements that should be kept
|
||||
|
@ -214,6 +246,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return this;
|
||||
}
|
||||
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
/**
|
||||
* Iterates over the Iterable with a desired action
|
||||
* @param action that should be applied
|
||||
|
@ -223,6 +256,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Reduces the elements inside of the Iterable down to one element
|
||||
* @param operator that reduces the elements.
|
||||
|
@ -257,23 +291,46 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
|
||||
#endif
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
/**
|
||||
* Pours all elements into a List that can be later
|
||||
* @return a new Builder with the pour function applied
|
||||
*/
|
||||
public ObjectAsyncBuilder<LIST KEY_GENERIC_TYPE> pourAsList() {
|
||||
#if ARRAY_LIST_FEATURE
|
||||
return pour(new ARRAY_LISTBRACES());
|
||||
#else
|
||||
return pour(new LINKED_LISTBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && SET_MODULE
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
/**
|
||||
* Pours all elements into a Set that can be later
|
||||
* @return a new Builder with the pour function applied
|
||||
*/
|
||||
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
|
||||
#if LINKED_SET_FEATURE
|
||||
return pour(new LINKED_HASH_SETBRACES());
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if SET_FEATURE
|
||||
return pour(new HASH_SETBRACES());
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
return pour(new RB_Tree_SETBRACES());
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
return pour(new AVL_Tree_SETBRACES());
|
||||
#else if ARRAY_SET_FEATURE
|
||||
return pour(new ARRAY_SETBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
/**
|
||||
* Pours all elements into a collection that can be later
|
||||
|
@ -285,6 +342,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if BOOLEAN_ASYNC_MODULE
|
||||
/**
|
||||
* Searches through the elements of the Iterable to find if the desired element is present.
|
||||
* @param filter that decides the desired elements
|
||||
|
@ -312,6 +371,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Searches through the elements of the Iterable to find if the desired element.
|
||||
* If not present it will return the default value of the type
|
||||
|
@ -323,6 +383,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return this;
|
||||
}
|
||||
|
||||
#if INT_ASYNC_MODULE
|
||||
/**
|
||||
* Counts all desired elements inside the Iterable
|
||||
* @param filter that decides the desired elements
|
||||
|
@ -332,6 +393,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Optional way to add a custom executor that runs this offthread task.
|
||||
* Can only be set after the action was decided on.
|
||||
|
@ -512,6 +574,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
}
|
||||
|
||||
#if BOOLEAN_ASYNC_MODULE
|
||||
private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask
|
||||
{
|
||||
ITERATOR KEY_GENERIC_TYPE iter;
|
||||
|
@ -530,11 +593,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
switch(type) {
|
||||
case 0:
|
||||
while(shouldRun() && iter.hasNext()) {
|
||||
#if TYPE_OBJECT
|
||||
if(filter.getBoolean(iter.NEXT())) {
|
||||
#else
|
||||
if(filter.GET_VALUE(iter.NEXT())) {
|
||||
#endif
|
||||
if(filter.test(iter.NEXT())) {
|
||||
setResult(true);
|
||||
return true;
|
||||
}
|
||||
|
@ -542,11 +601,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
break;
|
||||
case 1:
|
||||
while(shouldRun() && iter.hasNext()) {
|
||||
#if TYPE_OBJECT
|
||||
if(filter.getBoolean(iter.NEXT())) {
|
||||
#else
|
||||
if(filter.GET_VALUE(iter.NEXT())) {
|
||||
#endif
|
||||
if(filter.test(iter.NEXT())) {
|
||||
setResult(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -554,11 +609,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
break;
|
||||
case 2:
|
||||
while(shouldRun() && iter.hasNext()) {
|
||||
#if TYPE_OBJECT
|
||||
if(!filter.getBoolean(iter.NEXT())) {
|
||||
#else
|
||||
if(!filter.GET_VALUE(iter.NEXT())) {
|
||||
#endif
|
||||
if(!filter.test(iter.NEXT())) {
|
||||
setResult(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -580,6 +631,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
||||
{
|
||||
ITERATOR KEY_GENERIC_TYPE iter;
|
||||
|
@ -594,11 +646,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
protected boolean execute() throws Exception {
|
||||
while(shouldRun() && iter.hasNext()) {
|
||||
KEY_TYPE entry = iter.NEXT();
|
||||
#if TYPE_OBJECT
|
||||
if(filter.getBoolean(iter.NEXT())) {
|
||||
#else
|
||||
if(filter.GET_VALUE(iter.NEXT())) {
|
||||
#endif
|
||||
if(filter.test(iter.NEXT())) {
|
||||
setResult(entry);
|
||||
return true;
|
||||
}
|
||||
|
@ -614,6 +662,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
}
|
||||
|
||||
#if INT_ASYNC_MODULE
|
||||
private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask
|
||||
{
|
||||
ITERATOR KEY_GENERIC_TYPE iter;
|
||||
|
@ -628,7 +677,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
@Override
|
||||
protected boolean execute() throws Exception {
|
||||
while(shouldRun() && iter.hasNext()) {
|
||||
if(filter.TEST_VALUE(iter.NEXT())) {
|
||||
if(filter.test(iter.NEXT())) {
|
||||
counted++;
|
||||
}
|
||||
}
|
||||
|
@ -648,6 +697,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#if OBJECT_ASYNC_MODULE
|
||||
private static class CollectTask KSS_GENERIC_TYPE<V, T extends COLLECTION KEY_SPECIAL_GENERIC_TYPE<V>> extends BaseObjectTask<T>
|
||||
{
|
||||
ITERATOR KEY_SPECIAL_GENERIC_TYPE<V> iter;
|
||||
|
@ -704,6 +755,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Base Task of the Actions that can be performed.
|
||||
* Allows to simplify the actions that get executed.
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
#if !TYPE_BOOLEAN
|
||||
import java.util.ConcurrentModificationException;
|
||||
#endif
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.function.Predicate;
|
||||
|
@ -13,6 +20,9 @@ import java.util.function.Consumer;
|
|||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
|
@ -21,6 +31,12 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
|||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.utils.HashUtil;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
/**
|
||||
* A Helper class for Collections
|
||||
*/
|
||||
|
@ -75,6 +91,557 @@ public class COLLECTIONS
|
|||
return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Singleton Collection of a given element
|
||||
* @param element the element that should be converted into a singleton collection
|
||||
* @Type(T)
|
||||
* @return a singletoncollection of the given element
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE singleton(KEY_TYPE element) {
|
||||
return new SingletonCollectionBRACES(element);
|
||||
}
|
||||
|
||||
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
||||
return new CollectionWrapperBRACES();
|
||||
}
|
||||
|
||||
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper(int size) {
|
||||
return new CollectionWrapperBRACES(size);
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper() {
|
||||
return new DistinctCollectionWrapperBRACES();
|
||||
}
|
||||
|
||||
protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper(int size) {
|
||||
return new DistinctCollectionWrapperBRACES(size);
|
||||
}
|
||||
|
||||
#endif
|
||||
protected static class CollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements ITrimmable {
|
||||
KEY_TYPE[] elements;
|
||||
int size = 0;
|
||||
|
||||
public CollectionWrapper() {
|
||||
this(10);
|
||||
}
|
||||
|
||||
public CollectionWrapper(int size) {
|
||||
if(size < 0) throw new IllegalStateException("Size has to be 0 or greater");
|
||||
elements = NEW_KEY_ARRAY(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(KEY_TYPE o) {
|
||||
if(size >= elements.length) elements = Arrays.copyOf(elements, (int)Math.min((long)elements.length + (elements.length >> 1), SanityChecks.MAX_ARRAY_SIZE));
|
||||
elements[size++] = o;
|
||||
return true;
|
||||
}
|
||||
|
||||
public KEY_TYPE GET_KEY(int index) {
|
||||
if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||
return elements[index];
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
public boolean remove(Object e) {
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(KEY_EQUALS(elements[i], e)) {
|
||||
removeIndex(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(KEY_EQUALS(elements[i], e)) {
|
||||
removeIndex(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
private void removeIndex(int index) {
|
||||
if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||
size--;
|
||||
if(index != size) System.arraycopy(elements, index+1, elements, index, size - index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||
int index = 0;
|
||||
int lastReturned = -1;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return index < size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
int i = index++;
|
||||
return elements[(lastReturned = i)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if(lastReturned == -1) throw new IllegalStateException();
|
||||
removeIndex(lastReturned);
|
||||
index = lastReturned;
|
||||
lastReturned = -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
#if TYPE_OBJECT
|
||||
for(int i = 0;i<size;elements[i] = null,i++);
|
||||
#endif
|
||||
size = 0;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public void sort(Comparator<? super CLASS_TYPE> c) {
|
||||
if(c != null) ARRAYS.stableSort(elements, size, c);
|
||||
else ARRAYS.stableSort(elements, size);
|
||||
}
|
||||
|
||||
public void unstableSort(Comparator<? super CLASS_TYPE> c) {
|
||||
if(c != null) ARRAYS.unstableSort(elements, size, c);
|
||||
else ARRAYS.unstableSort(elements, size);
|
||||
}
|
||||
|
||||
#else
|
||||
public void sort(COMPARATOR c) {
|
||||
if(c != null) ARRAYS.stableSort(elements, size, c);
|
||||
else ARRAYS.stableSort(elements, size);
|
||||
}
|
||||
|
||||
public void unstableSort(COMPARATOR c) {
|
||||
if(c != null) ARRAYS.unstableSort(elements, size, c);
|
||||
else ARRAYS.unstableSort(elements, size);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(int i = 0;i<size;i++)
|
||||
action.accept(elements[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(int i = 0;i<size;i++)
|
||||
action.accept(input, elements[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(int size) {
|
||||
if(size > size() || size() == elements.length) return false;
|
||||
int value = Math.max(size, size());
|
||||
elements = value == 0 ? EMPTY_KEY_ARRAY : Arrays.copyOf(elements, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAndTrim(int size) {
|
||||
if(elements.length <= size) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
elements = size == 0 ? EMPTY_KEY_ARRAY : NEW_KEY_ARRAY(size);
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public Object[] toArray() {
|
||||
Object[] obj = new Object[size];
|
||||
for(int i = 0;i<size;i++)
|
||||
obj[i] = KEY_TO_OBJ(elements[i]);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public <E> E[] toArray(E[] a) {
|
||||
if(a == null) a = (E[])new Object[size];
|
||||
else if(a.length < size) a = (E[])ObjectArrays.newArray(a.getClass().getComponentType(), size);
|
||||
#if TYPE_OBJECT
|
||||
System.arraycopy(elements, 0, a, 0, size);
|
||||
#else
|
||||
for(int i = 0;i<size;i++)
|
||||
a[i] = (E)KEY_TO_OBJ(elements[i]);
|
||||
#endif
|
||||
if (a.length > size) a[size] = null;
|
||||
return a;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||
if(a.length < size) a = new KEY_TYPE[size];
|
||||
System.arraycopy(elements, 0, a, 0, size);
|
||||
if (a.length > size) a[size] = EMPTY_KEY_VALUE;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
protected static class DistinctCollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE {
|
||||
KEY_TYPE[] keys;
|
||||
boolean containsNull;
|
||||
int minCapacity;
|
||||
int nullIndex;
|
||||
int maxFill;
|
||||
int mask;
|
||||
int size;
|
||||
|
||||
public DistinctCollectionWrapper() {
|
||||
this(HashUtil.DEFAULT_MIN_CAPACITY);
|
||||
}
|
||||
|
||||
public DistinctCollectionWrapper(int size) {
|
||||
if(minCapacity < 0) throw new IllegalStateException("Minimum Capacity is negative. This is not allowed");
|
||||
minCapacity = nullIndex = HashUtil.arraySize(minCapacity, HashUtil.DEFAULT_LOAD_FACTOR);
|
||||
mask = nullIndex - 1;
|
||||
maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1);
|
||||
keys = NEW_KEY_ARRAY(nullIndex + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(KEY_TYPE o) {
|
||||
if(KEY_EQUALS_NULL(o)) {
|
||||
if(containsNull) return false;
|
||||
containsNull = true;
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
if(KEY_EQUALS_NOT_NULL(current)) {
|
||||
if(KEY_EQUALS(current, o)) return false;
|
||||
while(KEY_EQUALS_NOT_NULL((current = keys[pos = (++pos & mask)])))
|
||||
if(KEY_EQUALS(current, o)) return false;
|
||||
}
|
||||
keys[pos] = o;
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, HashUtil.DEFAULT_LOAD_FACTOR));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
#if TYPE_OBJECT
|
||||
if(o == null) return containsNull;
|
||||
#else
|
||||
if(o == null) return false;
|
||||
if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return containsNull;
|
||||
#endif
|
||||
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
if(KEY_EQUALS_NULL(current)) return false;
|
||||
if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||
while(true) {
|
||||
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||
else if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
#if TYPE_OBJECT
|
||||
if(o == null) return (containsNull ? removeNullIndex() : false);
|
||||
#else
|
||||
if(o == null) return false;
|
||||
if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return (containsNull ? removeNullIndex() : false);
|
||||
#endif
|
||||
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
if(KEY_EQUALS_NULL(current)) return false;
|
||||
if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||
while(true) {
|
||||
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||
else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||
}
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public boolean contains(KEY_TYPE o) {
|
||||
if(KEY_EQUALS_NULL(o)) return containsNull;
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
if(KEY_EQUALS_NULL(current)) return false;
|
||||
if(KEY_EQUALS(current, o)) return true;
|
||||
while(true) {
|
||||
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||
else if(KEY_EQUALS(current, o)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE o) {
|
||||
if(KEY_EQUALS_NULL(o)) return containsNull ? removeNullIndex() : false;
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
if(KEY_EQUALS_NULL(current)) return false;
|
||||
if(KEY_EQUALS(current, o)) return removeIndex(pos);
|
||||
while(true) {
|
||||
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||
else if(KEY_EQUALS(current, o)) return removeIndex(pos);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
protected boolean removeIndex(int pos) {
|
||||
if(pos == nullIndex) return containsNull ? removeNullIndex() : false;
|
||||
keys[pos] = EMPTY_KEY_VALUE;
|
||||
size--;
|
||||
shiftKeys(pos);
|
||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean removeNullIndex() {
|
||||
containsNull = false;
|
||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
||||
size--;
|
||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new SetIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
if(size() <= 0) return;
|
||||
if(containsNull) action.accept(keys[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistinctCollectionWrapper KEY_GENERIC_TYPE copy() {
|
||||
DistinctCollectionWrapper KEY_GENERIC_TYPE set = new DistinctCollectionWrapperBRACES(0);
|
||||
set.minCapacity = minCapacity;
|
||||
set.mask = mask;
|
||||
set.maxFill = maxFill;
|
||||
set.nullIndex = nullIndex;
|
||||
set.containsNull = containsNull;
|
||||
set.size = size;
|
||||
set.keys = Arrays.copyOf(keys, keys.length);
|
||||
return set;
|
||||
}
|
||||
|
||||
protected void shiftKeys(int startPos) {
|
||||
int slot, last;
|
||||
KEY_TYPE current;
|
||||
while(true) {
|
||||
startPos = ((last = startPos) + 1) & mask;
|
||||
while(true){
|
||||
if(KEY_EQUALS_NULL((current = keys[startPos]))) {
|
||||
keys[last] = EMPTY_KEY_VALUE;
|
||||
return;
|
||||
}
|
||||
slot = HashUtil.mix(KEY_TO_HASH(current)) & mask;
|
||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
keys[last] = current;
|
||||
}
|
||||
}
|
||||
|
||||
protected void rehash(int newSize) {
|
||||
int newMask = newSize - 1;
|
||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||
while(true) {
|
||||
if(--i < 0) throw new ConcurrentModificationException("Set was modified during rehash");
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) break;
|
||||
}
|
||||
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
||||
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
||||
newKeys[pos] = keys[i];
|
||||
}
|
||||
nullIndex = newSize;
|
||||
mask = newMask;
|
||||
maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1);
|
||||
keys = newKeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if(size == 0) return;
|
||||
size = 0;
|
||||
containsNull = false;
|
||||
Arrays.fill(keys, EMPTY_KEY_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
private class SetIterator implements ITERATOR KEY_GENERIC_TYPE {
|
||||
int pos = nullIndex;
|
||||
int returnedPos = -1;
|
||||
int lastReturned = -1;
|
||||
int nextIndex = Integer.MIN_VALUE;
|
||||
boolean returnNull = containsNull;
|
||||
KEY_TYPE[] wrapped = null;
|
||||
int wrappedIndex = 0;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if(nextIndex == Integer.MIN_VALUE) {
|
||||
if(returnNull) {
|
||||
returnNull = false;
|
||||
nextIndex = nullIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(true) {
|
||||
if(--pos < 0) {
|
||||
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||
nextIndex = -pos - 1;
|
||||
break;
|
||||
}
|
||||
if(KEY_EQUALS_NOT_NULL(keys[pos])){
|
||||
nextIndex = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nextIndex != Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
returnedPos = pos;
|
||||
if(nextIndex < 0){
|
||||
lastReturned = Integer.MAX_VALUE;
|
||||
KEY_TYPE value = wrapped[nextIndex];
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
}
|
||||
KEY_TYPE value = keys[(lastReturned = nextIndex)];
|
||||
nextIndex = Integer.MIN_VALUE;
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if(lastReturned == -1) throw new IllegalStateException();
|
||||
if(lastReturned == nullIndex) {
|
||||
containsNull = false;
|
||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
||||
}
|
||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||
else {
|
||||
#if TYPE_OBJECT
|
||||
DistinctCollectionWrapper.this.remove(wrapped[-returnedPos - 1]);
|
||||
#else
|
||||
DistinctCollectionWrapper.this.REMOVE_KEY(wrapped[-returnedPos - 1]);
|
||||
#endif
|
||||
lastReturned = -1;
|
||||
return;
|
||||
}
|
||||
size--;
|
||||
lastReturned = -1;
|
||||
}
|
||||
|
||||
private void shiftKeys(int startPos) {
|
||||
int slot, last;
|
||||
KEY_TYPE current;
|
||||
while(true) {
|
||||
startPos = ((last = startPos) + 1) & mask;
|
||||
while(true){
|
||||
if(KEY_EQUALS_NULL((current = keys[startPos]))) {
|
||||
keys[last] = EMPTY_KEY_VALUE;
|
||||
return;
|
||||
}
|
||||
slot = HashUtil.mix(KEY_TO_HASH(current)) & mask;
|
||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||
startPos = ++startPos & mask;
|
||||
}
|
||||
if(startPos < last) addWrapper(keys[startPos]);
|
||||
keys[last] = current;
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapper(KEY_TYPE value) {
|
||||
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||
else if(wrappedIndex >= wrapped.length) {
|
||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||
wrapped = newArray;
|
||||
}
|
||||
wrapped[wrappedIndex++] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
private static class SingletonCollection KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE
|
||||
{
|
||||
KEY_TYPE element;
|
||||
|
||||
SingletonCollection(KEY_TYPE element) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
#endif
|
||||
@Override
|
||||
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator()
|
||||
{
|
||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||
boolean next = true;
|
||||
@Override
|
||||
public boolean hasNext() { return next; }
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
next = false;
|
||||
return element;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public int size() { return 1; }
|
||||
|
||||
@Override
|
||||
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronized Collection Wrapper for the synchronizedCollection function
|
||||
* @Type(T)
|
||||
|
|
|
@ -7,7 +7,9 @@ import speiger.src.collections.utils.IArray;
|
|||
|
||||
/**
|
||||
* Type-Specific Helper class to get the underlying array of array implementations.
|
||||
#if ARRAY_LIST_FEATURE
|
||||
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
||||
#endif
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
|
@ -17,14 +18,8 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
|
||||
/**
|
||||
|
@ -303,7 +298,7 @@ public class ITERABLES
|
|||
@Override
|
||||
public void forEach(Consumer<? super T> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterable.forEach(E -> action.accept(mapper.GET_VALUE(E)));
|
||||
iterable.forEach(E -> action.accept(mapper.apply(E)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,7 +320,7 @@ public class ITERABLES
|
|||
@Override
|
||||
public void forEach(Consumer<? super T> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterable.forEach(E -> mapper.GET_VALUE(E).forEach(action));
|
||||
iterable.forEach(E -> mapper.apply(E).forEach(action));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -349,7 +344,7 @@ public class ITERABLES
|
|||
public void forEach(Consumer<? super T> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterable.forEach(E -> {
|
||||
T[] array = mapper.GET_VALUE(E);
|
||||
T[] array = mapper.apply(E);
|
||||
for(int i = 0,m=array.length;i<m;action.accept(array[i++]));
|
||||
});
|
||||
}
|
||||
|
@ -380,19 +375,19 @@ public class ITERABLES
|
|||
@Override
|
||||
public void forEach(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
iterable.forEach(action.andThen(list::add));
|
||||
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||
iterable.forEach(action.andThen(repeater::add));
|
||||
for(int i = 0;i<repeats;i++)
|
||||
list.forEach(action);
|
||||
repeater.forEach(action);
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
iterable.forEach(T -> {action.accept(T); list.add(T);});
|
||||
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||
iterable.forEach(T -> {action.accept(T); repeater.add(T);});
|
||||
for(int i = 0;i<repeats;i++)
|
||||
list.forEach(action);
|
||||
repeater.forEach(action);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -416,12 +411,12 @@ public class ITERABLES
|
|||
@Override
|
||||
public void forEach(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterable.forEach(T -> { if(!filter.TEST_VALUE(T)) action.accept(T); } );
|
||||
iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } );
|
||||
}
|
||||
#else
|
||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterable.forEach(T -> { if(!filter.TEST_VALUE(T)) action.accept(T); } );
|
||||
iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -496,19 +491,19 @@ public class ITERABLES
|
|||
@Override
|
||||
public void forEach(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
iterable.forEach(list::add);
|
||||
list.unstableSort(sorter);
|
||||
list.forEach(action);
|
||||
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper();
|
||||
iterable.forEach(wrapper::add);
|
||||
wrapper.unstableSort(sorter);
|
||||
wrapper.forEach(action);
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
iterable.forEach(list::add);
|
||||
list.unstableSort(sorter);
|
||||
list.forEach(action);
|
||||
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper();
|
||||
iterable.forEach(wrapper::add);
|
||||
wrapper.unstableSort(sorter);
|
||||
wrapper.forEach(action);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -538,14 +533,14 @@ public class ITERABLES
|
|||
action.accept(T);
|
||||
});
|
||||
#else
|
||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
||||
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
||||
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -16,15 +16,18 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if ARRAY_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#else if LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Helper class for Iterators
|
||||
|
@ -468,6 +471,8 @@ public class ITERATORS
|
|||
}
|
||||
|
||||
#endif
|
||||
#if LIST_MODULE
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
/**
|
||||
* A Helper function to pours all elements of a Iterator into a List
|
||||
* @param iter the elements that should be poured into list.
|
||||
|
@ -486,12 +491,20 @@ public class ITERATORS
|
|||
* @return A list of all requested elements of the Iterator
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
||||
#if ARRAY_LIST_FEATURE
|
||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
#else
|
||||
LINKED_LIST KEY_GENERIC_TYPE list = new LINKED_LISTBRACES();
|
||||
#endif
|
||||
pour(iter, list, max);
|
||||
#if ARRAY_LIST_FEATURE
|
||||
list.trim();
|
||||
#endif
|
||||
return list;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
/**
|
||||
* A Helper function to pours all elements of a Iterator into a Collection
|
||||
* @param iter the elements that should be poured into list.
|
||||
|
@ -751,41 +764,21 @@ public class ITERATORS
|
|||
private static class EmptyIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasNext() { return false; }
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
public KEY_TYPE NEXT() { throw new NoSuchElementException(); }
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPrevious() { return false; }
|
||||
@Override
|
||||
public KEY_TYPE PREVIOUS() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
public KEY_TYPE PREVIOUS() { throw new NoSuchElementException(); }
|
||||
@Override
|
||||
public int nextIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int nextIndex() { return 0; }
|
||||
@Override
|
||||
public int previousIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int previousIndex() { return -1; }
|
||||
@Override
|
||||
public void remove() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public void set(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
@ -839,7 +832,7 @@ public class ITERATORS
|
|||
|
||||
@Override
|
||||
public T next() {
|
||||
return mapper.GET_VALUE(iterator.NEXT());
|
||||
return mapper.apply(iterator.NEXT());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -865,7 +858,7 @@ public class ITERATORS
|
|||
foundNext = true;
|
||||
while(iterator.hasNext()) {
|
||||
if(last != null && last.hasNext()) return;
|
||||
last = mapper.GET_VALUE(iterator.NEXT()).iterator();
|
||||
last = mapper.apply(iterator.NEXT()).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -901,7 +894,7 @@ public class ITERATORS
|
|||
foundNext = true;
|
||||
while(iterator.hasNext()) {
|
||||
if(last != null && last.hasNext()) return;
|
||||
last = ObjectIterators.wrap(mapper.GET_VALUE(iterator.NEXT()));
|
||||
last = ObjectIterators.wrap(mapper.apply(iterator.NEXT()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -925,7 +918,7 @@ public class ITERATORS
|
|||
final int repeats;
|
||||
int index = 0;
|
||||
ITERATOR KEY_GENERIC_TYPE iter;
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||
|
||||
public RepeatingIterator(ITERATOR KEY_GENERIC_TYPE iter, int repeat) {
|
||||
this.iter = iter;
|
||||
|
@ -937,7 +930,7 @@ public class ITERATORS
|
|||
if(iter.hasNext()) return true;
|
||||
if(index < repeats) {
|
||||
index++;
|
||||
iter = list.iterator();
|
||||
iter = repeater.iterator();
|
||||
return iter.hasNext();
|
||||
}
|
||||
return false;
|
||||
|
@ -947,7 +940,7 @@ public class ITERATORS
|
|||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
KEY_TYPE value = iter.NEXT();
|
||||
if(index == 0) list.add(value);
|
||||
if(index == 0) repeater.add(value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -956,7 +949,7 @@ public class ITERATORS
|
|||
{
|
||||
ITERATOR KEY_GENERIC_TYPE iterator;
|
||||
COMPARATOR KEY_GENERIC_TYPE sorter;
|
||||
LIST KEY_GENERIC_TYPE sortedElements = null;
|
||||
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE sortedElements = null;
|
||||
int index = 0;
|
||||
|
||||
public SortedIterator(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||
|
@ -968,7 +961,11 @@ public class ITERATORS
|
|||
public boolean hasNext() {
|
||||
if(sortedElements == null) {
|
||||
boolean hasNext = iterator.hasNext();
|
||||
sortedElements = hasNext ? pour(iterator) : LISTS.empty();
|
||||
if(hasNext) {
|
||||
sortedElements = COLLECTIONS.wrapper();
|
||||
pour(iterator, sortedElements);
|
||||
}
|
||||
else sortedElements = COLLECTIONS.wrapper();
|
||||
if(hasNext) sortedElements.unstableSort(sorter);
|
||||
}
|
||||
return index < sortedElements.size();
|
||||
|
@ -987,7 +984,7 @@ public class ITERATORS
|
|||
#if TYPE_BOOLEAN
|
||||
int filtered;
|
||||
#else
|
||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
||||
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||
#endif
|
||||
KEY_TYPE lastFound;
|
||||
boolean foundNext = false;
|
||||
|
@ -1048,7 +1045,7 @@ public class ITERATORS
|
|||
if(foundNext) return;
|
||||
while(iterator.hasNext()) {
|
||||
lastFound = iterator.NEXT();
|
||||
if(filter.TEST_VALUE(lastFound)) {
|
||||
if(filter.test(lastFound)) {
|
||||
foundNext = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,14 @@ package speiger.src.collections.PACKAGE.utils;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
#if IARRAY_FEATURE
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.Random;
|
||||
import java.util.RandomAccess;
|
||||
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
#endif
|
||||
#if PRIMITIVES
|
||||
import java.nio.JAVA_BUFFER;
|
||||
#endif
|
||||
|
@ -17,7 +21,9 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||
import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
#if IARRAY_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#endif
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +66,11 @@ public class LISTS
|
|||
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l) {
|
||||
#if IARRAY_FEATURE
|
||||
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l)));
|
||||
#else
|
||||
return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +81,11 @@ public class LISTS
|
|||
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l, Object mutex) {
|
||||
#if IARRAY_FEATURE
|
||||
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex)));
|
||||
#else
|
||||
return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,6 +106,7 @@ public class LISTS
|
|||
*/
|
||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE reverse(LIST KEY_GENERIC_TYPE list) {
|
||||
int size = list.size();
|
||||
#if IARRAY_FEATURE
|
||||
if(list instanceof IARRAY) {
|
||||
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
||||
#if TYPE_OBJECT
|
||||
|
@ -106,6 +121,7 @@ public class LISTS
|
|||
return list;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
if(list instanceof RandomAccess) {
|
||||
for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--) {
|
||||
KEY_TYPE t = list.GET_KEY(i);
|
||||
|
@ -143,6 +159,7 @@ public class LISTS
|
|||
*/
|
||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE shuffle(LIST KEY_GENERIC_TYPE list, Random random) {
|
||||
int size = list.size();
|
||||
#if IARRAY_FEATURE
|
||||
if(list instanceof IARRAY) {
|
||||
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
||||
#if TYPE_OBJECT
|
||||
|
@ -164,7 +181,8 @@ public class LISTS
|
|||
#endif
|
||||
return list;
|
||||
}
|
||||
for(int i = list.size(); i-- != 0;) {
|
||||
#endif
|
||||
for(int i = size; i-- != 0;) {
|
||||
int p = random.nextInt(i + 1);
|
||||
KEY_TYPE t = list.GET_KEY(i);
|
||||
list.set(i, list.GET_KEY(p));
|
||||
|
@ -231,6 +249,7 @@ public class LISTS
|
|||
public SingletonList KEY_GENERIC_TYPE copy() { return new SingletonListBRACES(element); }
|
||||
}
|
||||
|
||||
#if IARRAY_FEATURE
|
||||
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
|
||||
{
|
||||
IARRAY KEY_GENERIC_TYPE l;
|
||||
|
@ -271,6 +290,7 @@ public class LISTS
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
private static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess
|
||||
{
|
||||
SynchronizedRandomAccessList(LIST KEY_GENERIC_TYPE l) {
|
||||
|
|
|
@ -11,7 +11,9 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
#if DEQUEUE_FEATURE
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
|
@ -46,6 +48,7 @@ public class PRIORITY_QUEUES
|
|||
return queue instanceof SynchronizedPriorityQueue ? (SynchronizedPriorityQueue KEY_GENERIC_TYPE)queue : new SynchronizedPriorityQueueBRACES(queue, mutex);
|
||||
}
|
||||
|
||||
#if DEQUEUE_FEATURE
|
||||
/**
|
||||
* Returns a synchronized PriorityDequeue instance based on the instance given.
|
||||
* @param dequeue that should be synchronized
|
||||
|
@ -67,6 +70,7 @@ public class PRIORITY_QUEUES
|
|||
return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Wrapper class for synchronization
|
||||
* @Type(T)
|
||||
|
@ -134,6 +138,7 @@ public class PRIORITY_QUEUES
|
|||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
||||
}
|
||||
|
||||
#if DEQUEUE_FEATURE
|
||||
/**
|
||||
* Wrapper class for synchronization
|
||||
* @Type(T)
|
||||
|
@ -166,4 +171,5 @@ public class PRIORITY_QUEUES
|
|||
@Override
|
||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2,31 +2,30 @@ package speiger.src.collections.PACKAGE.utils;
|
|||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
#if TYPE_BOOLEAN
|
||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
||||
import speiger.src.collections.booleans.sets.BooleanSet;
|
||||
import speiger.src.collections.booleans.utils.BooleanCollections.EmptyCollection;
|
||||
#else
|
||||
#if TYPE_OBJECT
|
||||
#if TYPE_OBJECT && SORTED_SET_FEATURE
|
||||
import java.util.Comparator;
|
||||
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
#if !TYPE_OBJECT && SORTED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if SORTED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if ORDERED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
#endif
|
||||
#if SORTED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Helper class for sets
|
||||
|
@ -51,7 +50,6 @@ public class SETS
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
/**
|
||||
* Creates a Synchronized set while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
|
@ -75,6 +73,7 @@ public class SETS
|
|||
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
#if SORTED_SET_FEATURE
|
||||
/**
|
||||
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
|
@ -98,6 +97,8 @@ public class SETS
|
|||
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_SET_FEATURE
|
||||
/**
|
||||
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
|
@ -121,6 +122,8 @@ public class SETS
|
|||
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if SORTED_SET_FEATURE
|
||||
/**
|
||||
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
|
@ -144,6 +147,7 @@ public class SETS
|
|||
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Creates Unmodifyable Set wrapper
|
||||
* @param s set that should be made unmodifiable
|
||||
|
@ -154,6 +158,7 @@ public class SETS
|
|||
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
|
||||
}
|
||||
|
||||
#if SORTED_SET_FEATURE
|
||||
/**
|
||||
* Creates Unmodifyable SortedSet wrapper
|
||||
* @param s sortedSet that should be made unmodifiable
|
||||
|
@ -164,6 +169,8 @@ public class SETS
|
|||
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_SET_FEATURE
|
||||
/**
|
||||
* Creates Unmodifyable OrderedSet wrapper
|
||||
* @param s OrderedSet that should be made unmodifiable
|
||||
|
@ -174,6 +181,8 @@ public class SETS
|
|||
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if SORTED_SET_FEATURE
|
||||
/**
|
||||
* Creates Unmodifyable NavigableSet wrapper
|
||||
* @param s navigableSet that should be made unmodifiable
|
||||
|
@ -254,7 +263,7 @@ public class SETS
|
|||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SORTED_SET_FEATURE
|
||||
private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE n;
|
||||
|
@ -340,6 +349,8 @@ public class SETS
|
|||
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); }
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_SET_FEATURE
|
||||
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
ORDERED_SET KEY_GENERIC_TYPE s;
|
||||
|
@ -373,6 +384,8 @@ public class SETS
|
|||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
#if SORTED_SET_FEATURE
|
||||
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
SORTED_SET KEY_GENERIC_TYPE s;
|
||||
|
@ -406,6 +419,7 @@ public class SETS
|
|||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
|
||||
* @Type(T)
|
||||
|
@ -434,6 +448,7 @@ public class SETS
|
|||
#endif
|
||||
}
|
||||
|
||||
#if SORTED_SET_FEATURE
|
||||
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
|
||||
{
|
||||
ITrimmable trim;
|
||||
|
@ -597,6 +612,8 @@ public class SETS
|
|||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_SET_FEATURE
|
||||
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||
{
|
||||
ITrimmable trim;
|
||||
|
@ -656,6 +673,7 @@ public class SETS
|
|||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||
}
|
||||
|
||||
#endif
|
||||
private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||
{
|
||||
ITrimmable trim;
|
||||
|
@ -704,5 +722,4 @@ public class SETS
|
|||
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
|
||||
* @Type(T)
|
||||
|
@ -19,6 +21,17 @@ public interface STRATEGY KEY_GENERIC_TYPE
|
|||
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Normal Strategy
|
||||
*/
|
||||
public static final STRATEGY NO_GENERIC_TYPE NORMAL = new NormalStrategyBRACES();
|
||||
|
||||
/**
|
||||
* @Type(T)
|
||||
* @return a Normal Strategy that is behaving exactly like the normal Hash Strategy in the Hash Collections
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE normalStrategy() { return (STRATEGY KEY_GENERIC_TYPE)NORMAL; }
|
||||
|
||||
/**
|
||||
* Type Specific HashCode function
|
||||
* @param o the element that the hashcode is requested for (if object may be null)
|
||||
|
@ -47,5 +60,18 @@ public interface STRATEGY KEY_GENERIC_TYPE
|
|||
@Override
|
||||
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Strategy that simulates the normal Hash Collection Behavior if you want to use Hash Control Collections to replace normal ones.
|
||||
* Only real reason to do that is you have to use this and want to get rid of implementations.
|
||||
* @Type(T)
|
||||
*/
|
||||
public static class NormalStrategy KEY_GENERIC_TYPE implements STRATEGY KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public int hashCode(KEY_TYPE o) { return KEY_TO_HASH(o); }
|
||||
@Override
|
||||
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return EQUALS_KEY_TYPE(key, value); }
|
||||
}
|
||||
}
|
|
@ -3,9 +3,9 @@ package speiger.src.collections.PACKAGE.utils.maps;
|
|||
#if !TYPE_BOOLEAN
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
#if TYPE_OBJECT && SORTED_MAP_FEATURE
|
||||
import java.util.Comparator;
|
||||
#else
|
||||
#else if !TYPE_OBJECT
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
|
@ -18,27 +18,34 @@ import java.util.function.Function;
|
|||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||
import speiger.src.collections.objects.utils.ObjectSets;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
||||
#if SORTED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
#if !TYPE_BOOLEAN
|
||||
#if SORTED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
#endif
|
||||
#if ORDERED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
#endif
|
||||
#if SORTED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
#endif
|
||||
#if ORDERED_MAP_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
|
@ -49,10 +56,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
|
|||
#endif
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS;
|
||||
#if !SAME_TYPE && !VALUE_OBJECT
|
||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Helper class that provides you with Singleton/Empty/Synchronized/Unmodifyable Maps
|
||||
|
@ -123,8 +126,6 @@ public class MAPS
|
|||
else entries.forEach(action);
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the map.
|
||||
* @param map the map that should be synchronized
|
||||
|
@ -147,6 +148,7 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE synchronize(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedMap ? map : new SynchronizedMapKV_BRACES(map, mutex); }
|
||||
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the SortedMap.
|
||||
* @param map the SortedMap that should be synchronized
|
||||
|
@ -169,6 +171,8 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); }
|
||||
|
||||
#endif
|
||||
#if ORDERED_MAP_FEATURE
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the OrderedMap.
|
||||
* @param map the OrderedMap that should be synchronized
|
||||
|
@ -191,6 +195,8 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); }
|
||||
|
||||
#endif
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
|
||||
* @param map the NavigableMap that should be synchronized
|
||||
|
@ -213,6 +219,7 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE synchronize(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedNavigableMap ? map : new SynchronizedNavigableMapKV_BRACES(map, mutex); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the Map
|
||||
* @param map the map that should be made Unmodifiable
|
||||
|
@ -223,6 +230,7 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); }
|
||||
|
||||
#if ORDERED_MAP_FEATURE
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap
|
||||
* @param map the OrderedMap that should be made Unmodifiable
|
||||
|
@ -233,6 +241,8 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); }
|
||||
|
||||
#endif
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap
|
||||
* @param map the SortedMap that should be made Unmodifiable
|
||||
|
@ -253,6 +263,7 @@ public class MAPS
|
|||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Helper function that creates a Unmodifyable Entry
|
||||
* @param entry the Entry that should be made unmodifiable
|
||||
|
@ -344,7 +355,7 @@ public class MAPS
|
|||
|
||||
@Override
|
||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||
if(values == null) values = VALUE_SETS.singleton(value);
|
||||
if(values == null) values = VALUE_COLLECTIONS.singleton(value);
|
||||
return values;
|
||||
}
|
||||
@Override
|
||||
|
@ -425,6 +436,7 @@ public class MAPS
|
|||
public void set(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* The Unmodifyable Navigable Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
|
@ -496,6 +508,8 @@ public class MAPS
|
|||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_MAP_FEATURE
|
||||
/**
|
||||
* The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
|
@ -548,6 +562,8 @@ public class MAPS
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
|
@ -587,6 +603,7 @@ public class MAPS
|
|||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* The Unmodifyable Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
|
@ -669,7 +686,7 @@ public class MAPS
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if ORDERED_MAP_FEATURE
|
||||
/**
|
||||
* The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation
|
||||
* @Type(T)
|
||||
|
@ -708,6 +725,7 @@ public class MAPS
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
|
||||
* @Type(T)
|
||||
|
@ -741,6 +759,7 @@ public class MAPS
|
|||
|
||||
}
|
||||
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* The Synchronized Navigable Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
|
@ -859,6 +878,8 @@ public class MAPS
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#if ORDERED_MAP_FEATURE
|
||||
/**
|
||||
* The Synchronized Ordered Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
|
@ -916,6 +937,8 @@ public class MAPS
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#if SORTED_MAP_FEATURE
|
||||
/**
|
||||
* The Synchronized Sorted Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
|
@ -977,6 +1000,7 @@ public class MAPS
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* The Synchronized Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
|
@ -1148,5 +1172,4 @@ public class MAPS
|
|||
public void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) { synchronized(mutex) { map.forEach(action); } }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue