Merge branch 'master' into debug
This commit is contained in:
commit
49ce7fbfbe
@ -6,8 +6,14 @@
|
|||||||
- Added: ToArray/pushTop functions to Stack.class.
|
- Added: ToArray/pushTop functions to Stack.class.
|
||||||
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
||||||
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
||||||
|
- Added: Iterators.infinite as an option that will create a Infinite Iterator based on the inputed one.
|
||||||
|
- Added: List.indexedIterator which allows you to create a iterator with a customized iteration indecies. Useful if you want to transform lists output.
|
||||||
|
- Added: PriorityQueue.contains is now a function
|
||||||
|
- Added: Iterators/Async Builders now support MapToPrimitiveType function on the object variant. So more processing can be done. (Will be expanded upon later versions)
|
||||||
- Fixed: SetValue wasn't working on forEach implementations.
|
- Fixed: SetValue wasn't working on forEach implementations.
|
||||||
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
||||||
|
- Fixed: Supplier was using the wrong dataType in their function name.
|
||||||
|
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
||||||
|
|
||||||
### Version 0.8.0
|
### Version 0.8.0
|
||||||
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
||||||
|
|||||||
@ -50,7 +50,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.Speiger:Primitive-Collections:0.7.0'
|
implementation 'com.github.Speiger:Primitive-Collections:0.9.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.8.0';
|
version = '0.9.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'com.google.code.gson:gson:2.10'
|
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.2.2'
|
builderImplementation 'de.speiger:Simple-Code-Generator:1.3.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
||||||
|
|
||||||
|
|||||||
@ -45,23 +45,19 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
SettingsManager manager = new SettingsManager();
|
SettingsManager manager = new SettingsManager();
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder()
|
public PrimitiveCollectionsBuilder() {
|
||||||
{
|
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess)
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess) {
|
||||||
{
|
|
||||||
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
{
|
|
||||||
this(false, sourceFolder, outputFolder, dataFolder);
|
this(false, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
{
|
|
||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,42 +84,24 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFileValid(Path fileName)
|
protected boolean isFileValid(Path fileName) { return true; }
|
||||||
{
|
@Override
|
||||||
return true;
|
protected boolean relativePackages() { return true; }
|
||||||
}
|
@Override
|
||||||
|
protected boolean debugUnusedMappers() { return false; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean relativePackages()
|
protected void afterFinish() {
|
||||||
{
|
if((flags & SPECIAL) == 0 && getVersion() > 8) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean debugUnusedMappers()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void afterFinish()
|
|
||||||
{
|
|
||||||
if((flags & SPECIAL) == 0 && getVersion() > 8)
|
|
||||||
{
|
|
||||||
Path basePath = Paths.get("src/main/java");
|
Path basePath = Paths.get("src/main/java");
|
||||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java"))) {
|
||||||
{
|
|
||||||
writer.write(getModuleInfo(basePath));
|
writer.write(getModuleInfo(basePath));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseModule> createModules()
|
public List<BaseModule> createModules() {
|
||||||
{
|
|
||||||
List<BaseModule> modules = new ArrayList<>();
|
List<BaseModule> modules = new ArrayList<>();
|
||||||
modules.add(JavaModule.INSTANCE);
|
modules.add(JavaModule.INSTANCE);
|
||||||
modules.add(FunctionModule.INSTANCE);
|
modules.add(FunctionModule.INSTANCE);
|
||||||
@ -139,38 +117,31 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init()
|
protected void init() {
|
||||||
{
|
|
||||||
prepPackages();
|
prepPackages();
|
||||||
//Init Modules here
|
//Init Modules here
|
||||||
addModules(createModules());
|
addModules(createModules());
|
||||||
finishPackages();
|
finishPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addModules(List<BaseModule> modules)
|
public void addModules(List<BaseModule> modules) {
|
||||||
{
|
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
modules.get(i).setManager(manager);
|
modules.get(i).setManager(manager);
|
||||||
}
|
}
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
biPackages.forEach(modules.get(i)::init);
|
biPackages.forEach(modules.get(i)::init);
|
||||||
}
|
}
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
modules.forEach(BaseModule::cleanup);
|
||||||
modules.get(i).cleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishPackages()
|
private void finishPackages() {
|
||||||
{
|
|
||||||
biPackages.forEach(ModulePackage::finish);
|
biPackages.forEach(ModulePackage::finish);
|
||||||
if((flags & SAVE) != 0) manager.save();
|
if((flags & SAVE) != 0) manager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepPackages()
|
private void prepPackages() {
|
||||||
{
|
|
||||||
if((flags & LOAD) != 0) manager.load();
|
if((flags & LOAD) != 0) manager.load();
|
||||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
for(ModulePackage entry : ModulePackage.createPackages(globalFlags)) {
|
||||||
{
|
|
||||||
entry.setRequirements(requirements::put);
|
entry.setRequirements(requirements::put);
|
||||||
biPackages.add(entry);
|
biPackages.add(entry);
|
||||||
if(entry.isSame()) simplePackages.add(entry);
|
if(entry.isSame()) simplePackages.add(entry);
|
||||||
@ -179,11 +150,9 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
public void createProcesses(String fileName, Consumer<TemplateProcess> process) {
|
||||||
{
|
|
||||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||||
for(int i = 0,m=packages.size();i<m;i++)
|
for(int i = 0,m=packages.size();i<m;i++) {
|
||||||
{
|
|
||||||
packages.get(i).process(fileName, process);
|
packages.get(i).process(fileName, process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,8 +166,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
|
|
||||||
private String getModuleInfo(Path basePath) {
|
private String getModuleInfo(Path basePath) {
|
||||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||||
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
try(Stream<Path> stream = Files.walk(getOutputFolder())) {
|
||||||
{
|
|
||||||
stream.filter(Files::isDirectory)
|
stream.filter(Files::isDirectory)
|
||||||
.filter(this::containsFiles)
|
.filter(this::containsFiles)
|
||||||
.map(basePath::relativize)
|
.map(basePath::relativize)
|
||||||
@ -206,8 +174,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
.map(this::sanitize)
|
.map(this::sanitize)
|
||||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -218,34 +185,26 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sanitize(String input)
|
private String sanitize(String input) {
|
||||||
{
|
|
||||||
return input.replace("\\", ".").replace("/", ".");
|
return input.replace("\\", ".").replace("/", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsFiles(Path path)
|
private boolean containsFiles(Path path) {
|
||||||
{
|
try(Stream<Path> stream = Files.walk(path, 1)) {
|
||||||
try(Stream<Path> stream = Files.walk(path, 1))
|
|
||||||
{
|
|
||||||
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVersion()
|
private int getVersion() {
|
||||||
{
|
|
||||||
String version = System.getProperty("java.version");
|
String version = System.getProperty("java.version");
|
||||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
int dot = version.indexOf(".");
|
int dot = version.indexOf(".");
|
||||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String...args)
|
public static void main(String...args) {
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||||
|
|||||||
@ -59,6 +59,9 @@ public abstract class BaseModule
|
|||||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||||
|
|
||||||
|
public ClassType keyType() { return keyType; }
|
||||||
|
public ClassType valueType() { return valueType; }
|
||||||
|
|
||||||
protected boolean isModuleEnabled() {
|
protected boolean isModuleEnabled() {
|
||||||
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,8 +54,8 @@ public class FunctionModule extends BaseModule
|
|||||||
protected void loadFunctions()
|
protected void loadFunctions()
|
||||||
{
|
{
|
||||||
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||||
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
|
||||||
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -108,6 +108,9 @@ public class MapModule extends BaseModule
|
|||||||
addBlockedFiles("TestOrderedMapGenerator");
|
addBlockedFiles("TestOrderedMapGenerator");
|
||||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||||
}
|
}
|
||||||
|
if(valueType == ClassType.OBJECT) {
|
||||||
|
addBlockedFiles("MapComputeIfAbsentNonDefaultTester", "MapComputeIfPresentNonDefaultTester", "MapComputeNonDefaultTester", "MapSupplyIfAbsentNonDefaultTester");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -158,6 +161,9 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("MapComputeIfAbsentTester");
|
addBiRequirement("MapComputeIfAbsentTester");
|
||||||
addBiRequirement("MapComputeIfPresentTester");
|
addBiRequirement("MapComputeIfPresentTester");
|
||||||
addBiRequirement("MapComputeTester");
|
addBiRequirement("MapComputeTester");
|
||||||
|
addBiRequirement("MapComputeIfAbsentNonDefaultTester");
|
||||||
|
addBiRequirement("MapComputeIfPresentNonDefaultTester");
|
||||||
|
addBiRequirement("MapComputeNonDefaultTester");
|
||||||
addBiRequirement("MapCopyTester");
|
addBiRequirement("MapCopyTester");
|
||||||
addBiRequirement("MapContainsTester");
|
addBiRequirement("MapContainsTester");
|
||||||
addBiRequirement("MapContainsKeyTester");
|
addBiRequirement("MapContainsKeyTester");
|
||||||
@ -184,6 +190,7 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("MapReplaceTester");
|
addBiRequirement("MapReplaceTester");
|
||||||
addBiRequirement("MapSizeTester");
|
addBiRequirement("MapSizeTester");
|
||||||
addBiRequirement("MapSupplyIfAbsentTester");
|
addBiRequirement("MapSupplyIfAbsentTester");
|
||||||
|
addBiRequirement("MapSupplyIfAbsentNonDefaultTester");
|
||||||
addBiRequirement("MapToStringTester");
|
addBiRequirement("MapToStringTester");
|
||||||
addBiRequirement("NavigableMapNavigationTester");
|
addBiRequirement("NavigableMapNavigationTester");
|
||||||
addBiRequirement("SortedMapNavigationTester");
|
addBiRequirement("SortedMapNavigationTester");
|
||||||
|
|||||||
@ -16,6 +16,19 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
|
import speiger.src.collections.booleans.collections.BooleanIterable;
|
||||||
|
#endif
|
||||||
|
#iterate
|
||||||
|
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument PACKAGE bytes shorts ints longs floats doubles
|
||||||
|
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#if FILTER_TYPE
|
||||||
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
@ -165,6 +178,25 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
return ITERABLES.map(this, mapper);
|
return ITERABLES.map(this, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#if FILTER_TYPE
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
|
* @param mapper the mapping function
|
||||||
|
* @return a new Iterable that returns the desired result
|
||||||
|
*/
|
||||||
|
default OUTPUT_ITERABLE mapToDATA_TYPE(MAPPER<T> mapper) {
|
||||||
|
return ITERABLES.mapToDATA_TYPE(this, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
* @param mapper the flatMapping function
|
* @param mapper the flatMapping function
|
||||||
|
|||||||
@ -12,6 +12,9 @@ import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if INT_LIST_MODULE && !TYPE_INT
|
||||||
|
import speiger.src.collections.ints.lists.IntList;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@ -243,6 +246,18 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
return new LIST_ITER(index);
|
return new LIST_ITER(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
||||||
|
return new IndexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
||||||
|
return new ListIndexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) {
|
public void size(int size) {
|
||||||
while(size > size()) add(EMPTY_KEY_VALUE);
|
while(size > size()) add(EMPTY_KEY_VALUE);
|
||||||
@ -629,6 +644,154 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
private class ListIndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
IntList indecies;
|
||||||
|
int index;
|
||||||
|
int lastReturned = -1;
|
||||||
|
|
||||||
|
ListIndexedIterator(IntList indecies) {
|
||||||
|
this.indecies = indecies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return index < indecies.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
int i = index++;
|
||||||
|
return GET_KEY((lastReturned = indecies.getInt(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return index > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE PREVIOUS() {
|
||||||
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
|
index--;
|
||||||
|
return GET_KEY((lastReturned = indecies.getInt(index)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int nextIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int previousIndex() {
|
||||||
|
return index-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(KEY_TYPE e) {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
ABSTRACT_LIST.this.set(lastReturned, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, indecies.size() - index);
|
||||||
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, index);
|
||||||
|
index -= steps;
|
||||||
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private class IndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
int[] indecies;
|
||||||
|
int index;
|
||||||
|
int lastReturned = -1;
|
||||||
|
|
||||||
|
IndexedIterator(int[] indecies) {
|
||||||
|
this.indecies = indecies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return index < indecies.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
int i = index++;
|
||||||
|
return GET_KEY((lastReturned = indecies[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return index > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE PREVIOUS() {
|
||||||
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
|
index--;
|
||||||
|
return GET_KEY((lastReturned = indecies[index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int nextIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int previousIndex() {
|
||||||
|
return index-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(KEY_TYPE e) {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
ABSTRACT_LIST.this.set(lastReturned, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, indecies.length - index);
|
||||||
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, index);
|
||||||
|
index -= steps;
|
||||||
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
@ -706,7 +869,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
int steps = Math.min(amount, index);
|
int steps = Math.min(amount, index);
|
||||||
index -= steps;
|
index -= steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
|||||||
#if LISTS_FEATURE
|
#if LISTS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
#endif
|
#endif
|
||||||
|
#if INT_LIST_MODULE && !TYPE_INT
|
||||||
|
import speiger.src.collections.ints.lists.IntList;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
@ -425,6 +428,26 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index);
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Iterator that follows the indecies provided.<br>
|
||||||
|
* For example if the Lists Contents is:<br> -1, 0 1 <br>and the indecies are: <br>0, 1, 2, 2, 1, 0<br>
|
||||||
|
* then the iterator will return the following values: <br>-1, 0, 1, 1, 0, -1
|
||||||
|
* @param indecies that should be used for the iteration.
|
||||||
|
* @return a custom indexed iterator
|
||||||
|
*/
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies);
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
/**
|
||||||
|
* Creates a Iterator that follows the indecies provided.<br>
|
||||||
|
* For example if the Lists Contents is:<br> -1, 0 1 <br>and the indecies are: <br>0, 1, 2, 2, 1, 0<br>
|
||||||
|
* then the iterator will return the following values: <br>-1, 0, 1, 1, 0, -1
|
||||||
|
* @param indecies that should be used for the iteration.
|
||||||
|
* @return a custom indexed iterator
|
||||||
|
*/
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies);
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type-Specific List of subList
|
* A Type-Specific List of subList
|
||||||
* @see java.util.List#subList(int, int)
|
* @see java.util.List#subList(int, int)
|
||||||
|
|||||||
@ -218,22 +218,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
VALUE_TYPE value = GET_VALUE(key);
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
|
||||||
remove(key);
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -257,20 +241,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
VALUE_TYPE value;
|
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -294,20 +264,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
VALUE_TYPE value;
|
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -331,6 +287,51 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
VALUE_TYPE value = GET_VALUE(key);
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||||
|
remove(key);
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -346,6 +347,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
@ -518,13 +518,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).compute(hash, key, mappingFunction);
|
return getSegment(hash).compute(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -532,13 +525,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
|
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -546,13 +532,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
|
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -560,6 +539,28 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
|
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -567,6 +568,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
|
return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -2269,29 +2271,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfAbsent(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE computeIfAbsent(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@ -2319,29 +2298,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfAbsentNonDefault(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
if(index < 0) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VALUE_TYPE supplyIfAbsent(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
protected VALUE_TYPE supplyIfAbsent(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@ -2369,29 +2325,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE supplyIfAbsentNonDefault(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
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 = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfPresent(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE computeIfPresent(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@ -2415,6 +2348,76 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE computeNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
protected VALUE_TYPE computeIfAbsentNonDefault(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
if(index < 0) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE supplyIfAbsentNonDefault(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
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 = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfPresentNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE computeIfPresentNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@ -2433,6 +2436,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
protected VALUE_TYPE merge(int hash, KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE merge(int hash, KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -554,25 +554,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -596,25 +577,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -638,6 +600,64 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index < 0) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -657,25 +677,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index < 0) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -690,6 +691,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
@ -514,25 +514,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -556,25 +537,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -598,6 +560,64 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index < 0) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -617,25 +637,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index < 0) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -650,6 +651,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
@ -494,20 +494,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
|||||||
@ -512,25 +512,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index == -1) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insertIndex(size++, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -554,25 +535,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index == -1) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -596,6 +558,64 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index == -1) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index == -1) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insertIndex(size++, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index == -1) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -615,25 +635,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index == -1) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -648,6 +649,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
@ -382,26 +382,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(!isSet(index)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
set(index);
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
clear(index);
|
|
||||||
values[index] = EMPTY_VALUE;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@ -425,25 +405,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(!isSet(index)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
set(index);
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@ -467,6 +428,65 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(!isSet(index)) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(!isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
clear(index);
|
||||||
|
values[index] = EMPTY_VALUE;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
if(!isSet(index)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
set(index);
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
clear(index);
|
||||||
|
values[index] = EMPTY_VALUE;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
if(!isSet(index)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
set(index);
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@ -486,25 +506,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(!isSet(index)) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(!isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
clear(index);
|
|
||||||
values[index] = EMPTY_VALUE;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@ -519,6 +520,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(T key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(T key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
|
|||||||
@ -567,28 +567,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -614,27 +592,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -660,27 +617,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -703,6 +639,71 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -720,6 +721,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -1769,6 +1771,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
#endif
|
#endif
|
||||||
if(!inRange(key)) return getDefaultReturnValue();
|
if(!inRange(key)) return getDefaultReturnValue();
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
||||||
|
#if VALUE_OBJECT
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
@ -1777,6 +1780,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
return newValue;
|
return newValue;
|
||||||
|
#else
|
||||||
|
if(entry == null) return getDefaultReturnValue();
|
||||||
|
entry.value = mappingFunction.apply(key, entry.value);
|
||||||
|
return entry.value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -569,28 +569,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -616,27 +594,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
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.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@ -662,27 +619,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -705,6 +641,71 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
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.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -722,6 +723,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@ -1835,6 +1837,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
#endif
|
#endif
|
||||||
if(!inRange(key)) return getDefaultReturnValue();
|
if(!inRange(key)) return getDefaultReturnValue();
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
||||||
|
#if VALUE_OBJECT
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
@ -1843,6 +1846,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
return newValue;
|
return newValue;
|
||||||
|
#else
|
||||||
|
if(entry == null) return getDefaultReturnValue();
|
||||||
|
entry.value = mappingFunction.apply(key, entry.value);
|
||||||
|
return entry.value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -389,6 +389,35 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computation
|
* @return the result of the computation
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param valueProvider the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
|
/**
|
||||||
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if present
|
||||||
|
* @return the result of the default return value or present value
|
||||||
|
* @note if not present then compute is not executed
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@ -398,15 +427,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computation
|
* @return the result of the computation
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
|
||||||
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param mappingFunction the operator that should generate the value if not present
|
|
||||||
* @return the result of the computed value or present value
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@ -416,15 +436,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param valueProvider the value if not present
|
|
||||||
* @return the result of the computed value or present value
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
|
||||||
/**
|
/**
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@ -434,16 +445,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
/**
|
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param mappingFunction the operator that should generate the value if present
|
|
||||||
* @return the result of the default return value or present value
|
|
||||||
* @note if not present then compute is not executed
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@ -454,6 +455,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @note if not present then compute is not executed
|
* @note if not present then compute is not executed
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type Specific merge method to reduce boxing/unboxing
|
* A Type Specific merge method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
|||||||
@ -168,6 +168,15 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
return index >= array.length ? array[index-array.length] : array[index];
|
return index >= array.length ? array[index-array.length] : array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) {
|
||||||
|
if(first == last) return false;
|
||||||
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
|
if(e == array[(first + i) % array.length]) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
if(first == last) return false;
|
if(first == last) return false;
|
||||||
|
|||||||
@ -228,6 +228,13 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) {
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
|
|||||||
@ -236,6 +236,13 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) {
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
|
|||||||
@ -111,6 +111,13 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
*/
|
*/
|
||||||
public default KEY_TYPE first() { return peek(0); }
|
public default KEY_TYPE first() { return peek(0); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to find out if a element is part of the queue
|
||||||
|
* @param e the element that is searched for
|
||||||
|
* @return true if the element is in the queue
|
||||||
|
*/
|
||||||
|
public boolean contains(KEY_TYPE e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the first found element in the queue
|
* Removes the first found element in the queue
|
||||||
* @param e the element that should be removed
|
* @param e the element that should be removed
|
||||||
|
|||||||
@ -16,6 +16,16 @@ import java.util.function.IntFunction;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
#iterate
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
||||||
|
#argument PACKAGE booleans bytes shorts ints longs floats doubles
|
||||||
|
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
||||||
|
#if CHECK
|
||||||
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.BUILDER;
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
#if OBJECT_ASYNC_MODULE
|
#if OBJECT_ASYNC_MODULE
|
||||||
@ -23,7 +33,9 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.TASK;
|
import speiger.src.collections.PACKAGE.functions.TASK;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
#if OBJECT_ASYNC_MODULE
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
@ -59,7 +71,9 @@ import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||||
@ -67,7 +81,9 @@ import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
|||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT && INT_ASYNC_MODULE
|
#if !TYPE_INT && INT_ASYNC_MODULE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
@ -187,6 +203,25 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
||||||
|
#if CHECK
|
||||||
|
/**
|
||||||
|
* Maps the elements to something else
|
||||||
|
* @param mapper the mapping function
|
||||||
|
* @return a new Builder Object with the mapped Iterable
|
||||||
|
*/
|
||||||
|
public BUILDER mapToTYPE(MAPPER<T> mapper) {
|
||||||
|
return new BUILDER(ITERABLES.mapToTYPE(iterable, mapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Filters out the unwanted elements out of the Iterable
|
* Filters out the unwanted elements out of the Iterable
|
||||||
|
|||||||
@ -19,6 +19,26 @@ import speiger.src.collections.objects.collections.ObjectIterable;
|
|||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
#else
|
||||||
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
import speiger.src.collections.booleans.collections.BooleanIterable;
|
||||||
|
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||||
|
#endif
|
||||||
|
#iterate
|
||||||
|
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#argument CONSUMER ByteConsumer ShortConsumer IntConsumer LongConsumer FloatConsumer DoubleConsumer
|
||||||
|
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument OUTPUT_ITERATOR ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
||||||
|
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument PACKAGE bytes shorts ints longs floats doubles
|
||||||
|
#if FILTER_TYPE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERATOR;
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
@ -56,6 +76,39 @@ public class ITERABLES
|
|||||||
return new MappedIterable<>(iterable, mapper);
|
return new MappedIterable<>(iterable, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
||||||
|
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#if FILTER_TYPE
|
||||||
|
/**
|
||||||
|
* A Helper function that maps a Java-Iterable into a new Type.
|
||||||
|
* @param iterable the iterable that should be mapped
|
||||||
|
* @param mapper the function that decides what the result turns into.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a iterable that is mapped to a new result
|
||||||
|
*/
|
||||||
|
public static <T> OUTPUT_ITERABLE mapToDATA_TYPE(Iterable<? extends CLASS_TYPE> iterable, MAPPER<T> mapper) {
|
||||||
|
return new MAPPED_TYPEIterable<>(wrap(iterable), mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that maps a Iterable into a new Type.
|
||||||
|
* @param iterable the iterable that should be mapped
|
||||||
|
* @param mapper the function that decides what the result turns into.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a iterable that is mapped to a new result
|
||||||
|
*/
|
||||||
|
public static <T> OUTPUT_ITERABLE mapToDATA_TYPE(ITERABLE KEY_GENERIC_TYPE iterable, MAPPER<T> mapper) {
|
||||||
|
return new MAPPED_TYPEIterable<>(iterable, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
||||||
* @param iterable the iterable that should be flatMapped
|
* @param iterable the iterable that should be flatMapped
|
||||||
@ -280,6 +333,44 @@ public class ITERABLES
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument CONSUMER BooleanConsumer ByteConsumer ShortConsumer IntConsumer LongConsumer FloatConsumer DoubleConsumer
|
||||||
|
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
||||||
|
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument APPLY test applyAsByte applyAsShort applyAsInt applyAsLong applyAsFloat applyAsDouble
|
||||||
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
private static class MAPPED_TYPEIterable<E> implements OUTPUT_ITERABLE, ISizeProvider
|
||||||
|
{
|
||||||
|
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
||||||
|
MAPPER<E> mapper;
|
||||||
|
|
||||||
|
MAPPED_TYPEIterable(ITERABLE<E> iterable, MAPPER<E> mapper) {
|
||||||
|
this.iterable = iterable;
|
||||||
|
this.mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OUTPUT_ITERATOR iterator() {
|
||||||
|
return ITERATORS.mapToDATA_TYPE(iterable.iterator(), mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
|
return prov == null ? -1 : prov.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEach(CONSUMER action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
iterable.forEach(E -> action.accept(mapper.APPLY(E)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>, ISizeProvider
|
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>, ISizeProvider
|
||||||
{
|
{
|
||||||
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.CONSUMER;
|
|
||||||
#endif
|
#endif
|
||||||
|
import java.util.function.Consumer;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@ -16,8 +16,23 @@ import speiger.src.collections.objects.collections.ObjectIterator;
|
|||||||
import speiger.src.collections.objects.utils.ObjectIterators;
|
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
#else
|
||||||
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
|
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||||
|
#endif
|
||||||
|
#iterate
|
||||||
|
#argument ITERATOR ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
||||||
|
#argument PACKAGE bytes shorts ints longs floats doubles
|
||||||
|
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@ -33,6 +48,7 @@ import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
|||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.CollectionWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Iterators
|
* A Helper class for Iterators
|
||||||
@ -107,6 +123,7 @@ public class ITERATORS
|
|||||||
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OBJECT_COLLECTION_MODULE
|
||||||
/**
|
/**
|
||||||
* A Helper function that maps a Java-Iterator into a new Type.
|
* A Helper function that maps a Java-Iterator into a new Type.
|
||||||
* @param iterator that should be mapped
|
* @param iterator that should be mapped
|
||||||
@ -131,6 +148,40 @@ public class ITERATORS
|
|||||||
return new MappedIterator<>(iterator, mapper);
|
return new MappedIterator<>(iterator, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
||||||
|
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
|
#if FILTER_TYPE
|
||||||
|
/**
|
||||||
|
* A Helper function that maps a Java-Iterator into a new Type.
|
||||||
|
* @param iterator that should be mapped
|
||||||
|
* @param mapper the function that decides what the result turns into.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a iterator that is mapped to a new result
|
||||||
|
*/
|
||||||
|
public static <T> OUTPUT_ITERATOR mapToDATA_TYPE(Iterator<? extends CLASS_TYPE> iterator, MAPPER<T> mapper) {
|
||||||
|
return new MAPPED_TYPEIterator<>(wrap(iterator), mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that maps a Iterator into a new Type.
|
||||||
|
* @param iterator that should be mapped
|
||||||
|
* @param mapper the function that decides what the result turns into.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a iterator that is mapped to a new result
|
||||||
|
*/
|
||||||
|
public static <T> OUTPUT_ITERATOR mapToDATA_TYPE(ITERATOR KEY_GENERIC_TYPE iterator, MAPPER<T> mapper) {
|
||||||
|
return new MAPPED_TYPEIterator<>(iterator, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
||||||
* @param iterator that should be flatMapped
|
* @param iterator that should be flatMapped
|
||||||
@ -245,6 +296,26 @@ public class ITERATORS
|
|||||||
return new RepeatingIteratorBRACES(wrap(iterator), repeats);
|
return new RepeatingIteratorBRACES(wrap(iterator), repeats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that creates a infinitely looping iterator
|
||||||
|
* @param iterator that should be looping infinitely
|
||||||
|
* @Type(T)
|
||||||
|
* @return a infinitely looping iterator
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE infinite(ITERATOR KEY_GENERIC_TYPE iterator) {
|
||||||
|
return new InfiniteIteratorBRACES(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that creates a infinitely looping iterator from a Java Iterator
|
||||||
|
* @param iterator that should be looping infinitely
|
||||||
|
* @Type(T)
|
||||||
|
* @return a infinitely looping iterator
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE infinite(Iterator<? extends CLASS_TYPE> iterator) {
|
||||||
|
return new InfiniteIteratorBRACES(wrap(iterator));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that hard limits the Iterator to a specific size
|
* A Helper function that hard limits the Iterator to a specific size
|
||||||
* @param iterator that should be limited
|
* @param iterator that should be limited
|
||||||
@ -846,6 +917,42 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
||||||
|
#argument NEXT_TYPE nextBoolean nextByte nextShort nextInt nextLong nextFloat nextDouble
|
||||||
|
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument APPLY test applyAsByte applyAsShort applyAsInt applyAsLong applyAsFloat applyAsDouble
|
||||||
|
#argument DATA_TYPE boolean byte short int long float double
|
||||||
|
private static class MAPPED_TYPEIterator<E> implements OUTPUT_ITERATOR
|
||||||
|
{
|
||||||
|
ITERATOR<E> iterator;
|
||||||
|
MAPPER<E> mapper;
|
||||||
|
|
||||||
|
MAPPED_TYPEIterator(ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator, MAPPER<E> mapper) {
|
||||||
|
this.iterator = iterator;
|
||||||
|
this.mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return iterator.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DATA_TYPE NEXT_TYPE() {
|
||||||
|
return mapper.APPLY(iterator.NEXT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
return iterator.skip(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
private static class FlatMappedIterator KSS_GENERIC_TYPE<E, T,[SPACE]V extends Iterable<T>> implements ObjectIterator<T>
|
private static class FlatMappedIterator KSS_GENERIC_TYPE<E, T,[SPACE]V extends Iterable<T>> implements ObjectIterator<T>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator;
|
ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator;
|
||||||
@ -918,6 +1025,42 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class InfiniteIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
|
CollectionWrapper KEY_GENERIC_TYPE looper = COLLECTIONS.wrapper();
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
public InfiniteIterator(ITERATOR KEY_GENERIC_TYPE iter) {
|
||||||
|
this.iter = iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(iter != null) {
|
||||||
|
if(iter.hasNext()) {
|
||||||
|
KEY_TYPE value = iter.NEXT();
|
||||||
|
looper.add(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else iter = null;
|
||||||
|
}
|
||||||
|
return looper.GET_KEY((index++) % looper.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public void forEachRemaining(CONSUMER action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
||||||
|
#endif
|
||||||
|
public void forEachRemaining(Consumer<? super CLASS_TYPE> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
||||||
|
public <E> void forEachRemaining(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
||||||
|
}
|
||||||
|
|
||||||
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
final int repeats;
|
final int repeats;
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST;
|
import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#if INT_LIST_MODULE && !TYPE_INT
|
||||||
|
import speiger.src.collections.ints.lists.IntList;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@ -408,6 +411,18 @@ public class LISTS
|
|||||||
return l.listIterator(index);
|
return l.listIterator(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
||||||
|
return l.indexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
||||||
|
return l.indexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
||||||
return LISTS.synchronize(l.subList(from, to));
|
return LISTS.synchronize(l.subList(from, to));
|
||||||
@ -535,6 +550,18 @@ public class LISTS
|
|||||||
return ITERATORS.unmodifiable(l.listIterator(index));
|
return ITERATORS.unmodifiable(l.listIterator(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
||||||
|
return ITERATORS.unmodifiable(l.indexedIterator(indecies));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
||||||
|
return ITERATORS.unmodifiable(l.indexedIterator(indecies));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
||||||
return LISTS.unmodifiable(l.subList(from, to));
|
return LISTS.unmodifiable(l.subList(from, to));
|
||||||
@ -633,6 +660,18 @@ public class LISTS
|
|||||||
return ITERATORS.empty();
|
return ITERATORS.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
||||||
|
return ITERATORS.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
||||||
|
return ITERATORS.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return 1; }
|
public int hashCode() { return 1; }
|
||||||
|
|
||||||
|
|||||||
@ -116,6 +116,8 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
||||||
@Override
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) { synchronized(mutex) { return queue.contains(e); } }
|
||||||
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
||||||
|
|||||||
@ -341,19 +341,21 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@ -411,19 +413,21 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@ -670,19 +674,21 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@ -1110,19 +1116,21 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTENonDefault(key, mappingFunction); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENT(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENT(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENTNonDefault(key, mappingFunction); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENT(key, valueProvider); } }
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTENonDefault(key, mappingFunction); } }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENTNonDefault(key, mappingFunction); } }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENTNonDefault(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENTNonDefault(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENT(key, valueProvider); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENTNonDefault(key, valueProvider); } }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENTNonDefault(key, valueProvider); } }
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -53,6 +53,11 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCl
|
|||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester;
|
||||||
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||||
@ -78,6 +83,9 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRe
|
|||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester;
|
||||||
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
@ -105,6 +113,12 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester.class);
|
||||||
|
#endif
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||||
|
|||||||
@ -0,0 +1,153 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.maps;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
||||||
|
#endignore
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||||
|
#endignore
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_supportedAbsent() {
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
getMap().setDefaultReturnValue(true);
|
||||||
|
#endif
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectAdded(e3());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_supportedAbsentFirst() {
|
||||||
|
getMap().setDefaultReturnValue(v0());
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectContents(entry(k0(), v3()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
||||||
|
getMap().setDefaultReturnValue(v0());
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
return v0();
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_supportedPresent() {
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
|
throw new AssertionFailedError();
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ExpectedException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_functionThrows() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
throw new ExpectedException();
|
||||||
|
});
|
||||||
|
fail("Expected ExpectedException");
|
||||||
|
} catch (ExpectedException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_unsupportedAbsent() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
|
// allowed to be called
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
return v3();
|
||||||
|
});
|
||||||
|
fail("COMPUTE_IF_ABSENT(notPresent, function) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
||||||
|
try {
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
return v0();
|
||||||
|
}));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
|
try {
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsent() {
|
public void testComputeIfAbsent_supportedAbsent() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
@ -40,11 +40,19 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsentFirst() {
|
public void testComputeIfAbsent_supportedAbsentFirst() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
#if VALUE_OBJECT
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
expectContents(entry(k0(), v3()));
|
expectContents(entry(k0(), v3()));
|
||||||
|
#else
|
||||||
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@ -53,7 +61,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v0();
|
return v0();
|
||||||
}));
|
}));
|
||||||
@ -66,7 +74,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedPresent() {
|
public void testComputeIfAbsent_supportedPresent() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@ -76,11 +84,15 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
|
#if VALUE_OBJECT
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
|
#else
|
||||||
|
expectAdded(entry(k3(), INVALID_VALUE));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@ -92,7 +104,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_functionThrows() {
|
public void testComputeIfAbsent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
});
|
});
|
||||||
@ -107,7 +119,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedAbsent() {
|
public void testComputeIfAbsent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
||||||
// allowed to be called
|
// allowed to be called
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return v3();
|
return v3();
|
||||||
@ -124,7 +136,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v0();
|
return v0();
|
||||||
}));
|
}));
|
||||||
@ -139,7 +151,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -0,0 +1,104 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.maps;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_supportedAbsent() {
|
||||||
|
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||||
|
throw new AssertionFailedError();
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_supportedPresent() {
|
||||||
|
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectReplacement(entry(k0(), v3()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_functionReturnsNull() {
|
||||||
|
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
}));
|
||||||
|
expectMissing(e0());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ExpectedException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_functionThrows() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
throw new ExpectedException();
|
||||||
|
});
|
||||||
|
fail("Expected ExpectedException");
|
||||||
|
} catch (ExpectedException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_unsupportedAbsent() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||||
|
throw new AssertionFailedError();
|
||||||
|
});
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testComputeIfPresent_unsupportedPresent() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
||||||
|
fail("Expected UnsupportedOperationException");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_supportedAbsent() {
|
public void testComputeIfPresent_supportedAbsent() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@ -32,7 +32,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_supportedPresent() {
|
public void testComputeIfPresent_supportedPresent() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return v3();
|
return v3();
|
||||||
@ -45,7 +45,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_functionReturnsNull() {
|
public void testComputeIfPresent_functionReturnsNull() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
@ -63,7 +63,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_functionThrows() {
|
public void testComputeIfPresent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@ -79,7 +79,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_unsupportedAbsent() {
|
public void testComputeIfPresent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
});
|
});
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
@ -93,7 +93,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_unsupportedPresent() {
|
public void testComputeIfPresent_unsupportedPresent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> v3());
|
||||||
fail("Expected UnsupportedOperationException");
|
fail("Expected UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException expected) {
|
} catch (UnsupportedOperationException expected) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,148 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.maps;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
||||||
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
|
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
#endignore
|
||||||
|
public void testCompute_absentToPresent() {
|
||||||
|
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
assertEquals(INVALID_VALUE, v);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectAdded(e3());
|
||||||
|
assertEquals(getNumElements() + 1, getMap().size());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
#endignore
|
||||||
|
public void testCompute_absentToAbsent() {
|
||||||
|
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
assertEquals(INVALID_VALUE, v);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
assertEquals(getNumElements(), getMap().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testCompute_presentToPresent() {
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
getMap().setDefaultReturnValue(true);
|
||||||
|
#endif
|
||||||
|
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
return v3();
|
||||||
|
}));
|
||||||
|
expectReplacement(entry(k0(), v3()));
|
||||||
|
assertEquals(getNumElements(), getMap().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testCompute_presentToAbsent() {
|
||||||
|
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
}));
|
||||||
|
expectMissing(e0());
|
||||||
|
expectMissingKeys(k0());
|
||||||
|
assertEquals(getNumElements() - 1, getMap().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ExpectedException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testCompute_presentFunctionThrows() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
|
assertEquals(k0(), k);
|
||||||
|
assertEquals(v0(), v);
|
||||||
|
throw new ExpectedException();
|
||||||
|
});
|
||||||
|
fail("Expected ExpectedException");
|
||||||
|
} catch (ExpectedException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
|
#endignore
|
||||||
|
public void testCompute_absentFunctionThrows() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
assertEquals(INVALID_VALUE, v);
|
||||||
|
throw new ExpectedException();
|
||||||
|
});
|
||||||
|
fail("Expected ExpectedException");
|
||||||
|
} catch (ExpectedException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_REMOVE)
|
||||||
|
#endignore
|
||||||
|
public void testCompute_removeAbsent() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
assertEquals(INVALID_VALUE, v);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
});
|
||||||
|
fail("Expected UnsupportedOperationException");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testCompute_putAbsent() {
|
||||||
|
try {
|
||||||
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
|
assertEquals(k3(), k);
|
||||||
|
assertEquals(INVALID_VALUE, v);
|
||||||
|
return INVALID_VALUE;
|
||||||
|
});
|
||||||
|
fail("Expected UnsupportedOperationException");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentToPresent() {
|
public void testCompute_absentToPresent() {
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTE(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return v3();
|
return v3();
|
||||||
@ -34,13 +34,18 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentToAbsent() {
|
public void testCompute_absentToAbsent() {
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
|
#if VALUE_OBJECT
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
assertEquals(getNumElements(), getMap().size());
|
assertEquals(getNumElements(), getMap().size());
|
||||||
|
#else
|
||||||
|
expectAdded(entry(k3(), INVALID_VALUE));
|
||||||
|
assertEquals(getNumElements()+1, getMap().size());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@ -48,7 +53,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentToPresent() {
|
public void testCompute_presentToPresent() {
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTE(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return v3();
|
return v3();
|
||||||
@ -62,14 +67,19 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentToAbsent() {
|
public void testCompute_presentToAbsent() {
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
|
#if VALUE_OBJECT
|
||||||
expectMissing(e0());
|
expectMissing(e0());
|
||||||
expectMissingKeys(k0());
|
expectMissingKeys(k0());
|
||||||
assertEquals(getNumElements() - 1, getMap().size());
|
assertEquals(getNumElements() - 1, getMap().size());
|
||||||
|
#else
|
||||||
|
expectReplacement(entry(k0(), INVALID_VALUE));
|
||||||
|
assertEquals(getNumElements(), getMap().size());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@ -82,7 +92,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentFunctionThrows() {
|
public void testCompute_presentFunctionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
getMap().COMPUTE(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@ -98,7 +108,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentFunctionThrows() {
|
public void testCompute_absentFunctionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
getMap().COMPUTE(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@ -114,7 +124,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_removeAbsent() {
|
public void testCompute_removeAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
getMap().COMPUTE(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
@ -130,7 +140,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_putAbsent() {
|
public void testCompute_putAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
getMap().COMPUTE(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
|
|||||||
@ -0,0 +1,130 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.maps;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
||||||
|
#endignore
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||||
|
#endignore
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_supportedAbsent() {
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
getMap().setDefaultReturnValue(true);
|
||||||
|
#endif
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
||||||
|
expectAdded(e3());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
||||||
|
getMap().setDefaultReturnValue(v0());
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||||
|
expectContents(entry(k0(), v3()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
||||||
|
getMap().setDefaultReturnValue(v0());
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_supportedPresent() {
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
||||||
|
throw new AssertionFailedError();
|
||||||
|
}));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ExpectedException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_functionThrows() {
|
||||||
|
try {
|
||||||
|
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
||||||
|
throw new ExpectedException();
|
||||||
|
});
|
||||||
|
fail("Expected ExpectedException");
|
||||||
|
} catch (ExpectedException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_unsupportedAbsent() {
|
||||||
|
try {
|
||||||
|
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
||||||
|
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
||||||
|
try {
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@MapFeature.Require(absent = SUPPORTS_PUT)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
#endignore
|
||||||
|
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
|
try {
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsent() {
|
public void testSupplyIfAbsent_supportedAbsent() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k3(), this::v3));
|
||||||
expectAdded(e3());
|
expectAdded(e3());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +37,13 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
#if VALUE_OBJECT
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||||
expectContents(entry(k0(), v3()));
|
expectContents(entry(k0(), v3()));
|
||||||
|
#else
|
||||||
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||||
|
expectUnchanged();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@ -47,7 +52,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedPresent() {
|
public void testSupplyIfAbsent_supportedPresent() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), () -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@ -67,8 +72,12 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENT(k3(), () -> INVALID_VALUE));
|
||||||
|
#if VALUE_OBJECT
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
|
#else
|
||||||
|
expectAdded(entry(k3(), INVALID_VALUE));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@ -80,7 +89,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_functionThrows() {
|
public void testSupplyIfAbsent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
getMap().SUPPLY_IF_ABSENT(k3(), () -> {
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
});
|
});
|
||||||
fail("Expected ExpectedException");
|
fail("Expected ExpectedException");
|
||||||
@ -94,7 +103,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedAbsent() {
|
public void testSupplyIfAbsent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
getMap().SUPPLY_IF_ABSENT(k3(), this::v3);
|
||||||
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
||||||
} catch (UnsupportedOperationException expected) {
|
} catch (UnsupportedOperationException expected) {
|
||||||
}
|
}
|
||||||
@ -107,7 +116,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@ -119,7 +128,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
|
|||||||
@ -59,6 +59,18 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContains() {
|
||||||
|
if(getValidPriorityQueueTests().contains(PriorityQueueTest.CONTAINS)) {
|
||||||
|
IntPriorityQueue queue = create(EMPTY_ARRAY);
|
||||||
|
for(int i = 0;i<100;i++) {
|
||||||
|
queue.enqueue(i);
|
||||||
|
}
|
||||||
|
Assert.assertEquals(true, queue.contains(40));
|
||||||
|
Assert.assertEquals(false, queue.contains(140));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() {
|
public void testRemove() {
|
||||||
if(getValidPriorityQueueTests().contains(PriorityQueueTest.REMOVE)) {
|
if(getValidPriorityQueueTests().contains(PriorityQueueTest.REMOVE)) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ public enum PriorityQueueTest
|
|||||||
{
|
{
|
||||||
IN_OUT,
|
IN_OUT,
|
||||||
PEEK,
|
PEEK,
|
||||||
|
CONTAINS,
|
||||||
REMOVE,
|
REMOVE,
|
||||||
TO_ARRAY,
|
TO_ARRAY,
|
||||||
COPY;
|
COPY;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user