Fixed that setValue wasn't working with ForEach implementations.
This commit is contained in:
parent
bcc2ffdc13
commit
0f9751bf70
|
@ -3,6 +3,7 @@
|
|||
### Version 0.8.0
|
||||
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
||||
- Added: Dedicated implementations for toArray into TreeSets
|
||||
- Fixed: forEach methods in Maps now can use "setValue" functions.
|
||||
|
||||
### Version 0.8.0
|
||||
- Added: ISizeProvider interface (Optimization Helper)
|
||||
|
|
|
@ -1,155 +1,155 @@
|
|||
package speiger.src.builder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import speiger.src.builder.mappers.IMapper;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ModulePackage
|
||||
{
|
||||
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
||||
public static final ClassType[] TYPE = ClassType.values();
|
||||
final ClassType keyType;
|
||||
final ClassType valueType;
|
||||
Set<String> blocked = new HashSet<>();
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
Map<String, String> splitters = new HashMap<>();
|
||||
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||
List<IMapper> mappers = new ArrayList<>();
|
||||
Set<String> flags = new LinkedHashSet<>();
|
||||
Set<String> globalFlags;
|
||||
Map<String, Integer> flaggedValues = new HashMap<>();
|
||||
BiConsumer<String, RequiredType> requirements = VOID;
|
||||
|
||||
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
||||
this.globalFlags = globalFlags;
|
||||
this.keyType = keyType;
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
requirements = VOID;
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
||||
}
|
||||
|
||||
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public boolean isSame() {
|
||||
return keyType == valueType;
|
||||
}
|
||||
|
||||
public boolean isEnumValid() {
|
||||
return keyType == ClassType.OBJECT;
|
||||
}
|
||||
|
||||
public ClassType getKeyType() {
|
||||
return keyType;
|
||||
}
|
||||
|
||||
public ClassType getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void addFlag(String flag) {
|
||||
flags.add(flag);
|
||||
}
|
||||
|
||||
public void addGlobalFlag(String flag) {
|
||||
globalFlags.add(flag);
|
||||
}
|
||||
|
||||
public void addValue(String key, int value) {
|
||||
flaggedValues.put(key, value);
|
||||
}
|
||||
|
||||
public void addRequirement(String fileName, RequiredType type) {
|
||||
requirements.accept(fileName, type);
|
||||
}
|
||||
|
||||
public void addMapper(IMapper mapper) {
|
||||
mappers.add(mapper);
|
||||
}
|
||||
|
||||
public void addBlockedFilter(Predicate<String> filter) {
|
||||
blockedFilters.add(filter);
|
||||
}
|
||||
|
||||
public void addBlockedFiles(String... names) {
|
||||
blocked.addAll(Arrays.asList(names));
|
||||
}
|
||||
|
||||
public void addSplitter(String fileName, String splitter) {
|
||||
splitters.put(fileName, splitter);
|
||||
}
|
||||
|
||||
public void addRemapper(String fileName, String actualName) {
|
||||
nameRemapper.put(fileName, actualName);
|
||||
}
|
||||
|
||||
public void process(String fileName, Consumer<TemplateProcess> result) {
|
||||
if(isBlocked(fileName)) return;
|
||||
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
||||
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
||||
TemplateProcess process = new TemplateProcess(newName+".java");
|
||||
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
||||
process.addFlags(flags);
|
||||
process.addFlags(globalFlags);
|
||||
process.addMappers(mappers);
|
||||
process.addValues(flaggedValues);
|
||||
result.accept(process);
|
||||
}
|
||||
|
||||
private boolean isBlocked(String fileName) {
|
||||
if(blocked.contains(fileName)) return true;
|
||||
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||
if(blockedFilters.get(i).test(fileName)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||
List<ModulePackage> list = new ArrayList<>();
|
||||
for(ClassType key : TYPE) {
|
||||
for(ClassType value : TYPE) {
|
||||
list.add(new ModulePackage(globalFlags, key, value));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private int sort(String key, String value) {
|
||||
if(value.contains(key)) return 1;
|
||||
else if(key.contains(value)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
class PathBuilder implements UnaryOperator<Path> {
|
||||
String before;
|
||||
|
||||
public PathBuilder(String before) {
|
||||
this.before = before;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path apply(Path t) {
|
||||
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.builder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import speiger.src.builder.mappers.IMapper;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ModulePackage
|
||||
{
|
||||
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
||||
public static final ClassType[] TYPE = ClassType.values();
|
||||
final ClassType keyType;
|
||||
final ClassType valueType;
|
||||
Set<String> blocked = new HashSet<>();
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
Map<String, String> splitters = new HashMap<>();
|
||||
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||
List<IMapper> mappers = new ArrayList<>();
|
||||
Set<String> flags = new LinkedHashSet<>();
|
||||
Set<String> globalFlags;
|
||||
Map<String, Integer> flaggedValues = new HashMap<>();
|
||||
BiConsumer<String, RequiredType> requirements = VOID;
|
||||
|
||||
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
||||
this.globalFlags = globalFlags;
|
||||
this.keyType = keyType;
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
requirements = VOID;
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
||||
}
|
||||
|
||||
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public boolean isSame() {
|
||||
return keyType == valueType;
|
||||
}
|
||||
|
||||
public boolean isEnumValid() {
|
||||
return keyType == ClassType.OBJECT;
|
||||
}
|
||||
|
||||
public ClassType getKeyType() {
|
||||
return keyType;
|
||||
}
|
||||
|
||||
public ClassType getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void addFlag(String flag) {
|
||||
flags.add(flag);
|
||||
}
|
||||
|
||||
public void addGlobalFlag(String flag) {
|
||||
globalFlags.add(flag);
|
||||
}
|
||||
|
||||
public void addValue(String key, int value) {
|
||||
flaggedValues.put(key, value);
|
||||
}
|
||||
|
||||
public void addRequirement(String fileName, RequiredType type) {
|
||||
requirements.accept(fileName, type);
|
||||
}
|
||||
|
||||
public void addMapper(IMapper mapper) {
|
||||
mappers.add(mapper);
|
||||
}
|
||||
|
||||
public void addBlockedFilter(Predicate<String> filter) {
|
||||
blockedFilters.add(filter);
|
||||
}
|
||||
|
||||
public void addBlockedFiles(String... names) {
|
||||
blocked.addAll(Arrays.asList(names));
|
||||
}
|
||||
|
||||
public void addSplitter(String fileName, String splitter) {
|
||||
splitters.put(fileName, splitter);
|
||||
}
|
||||
|
||||
public void addRemapper(String fileName, String actualName) {
|
||||
nameRemapper.put(fileName, actualName);
|
||||
}
|
||||
|
||||
public void process(String fileName, Consumer<TemplateProcess> result) {
|
||||
if(isBlocked(fileName)) return;
|
||||
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
||||
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
||||
TemplateProcess process = new TemplateProcess(newName+".java");
|
||||
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
||||
process.addFlags(flags);
|
||||
process.addFlags(globalFlags);
|
||||
process.addMappers(mappers);
|
||||
process.addValues(flaggedValues);
|
||||
result.accept(process);
|
||||
}
|
||||
|
||||
private boolean isBlocked(String fileName) {
|
||||
if(blocked.contains(fileName)) return true;
|
||||
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||
if(blockedFilters.get(i).test(fileName)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||
List<ModulePackage> list = new ArrayList<>();
|
||||
for(ClassType key : TYPE) {
|
||||
for(ClassType value : TYPE) {
|
||||
list.add(new ModulePackage(globalFlags, key, value));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private int sort(String key, String value) {
|
||||
if(value.contains(key)) return 1;
|
||||
else if(key.contains(value)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
class PathBuilder implements UnaryOperator<Path> {
|
||||
String before;
|
||||
|
||||
public PathBuilder(String before) {
|
||||
this.before = before;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path apply(Path t) {
|
||||
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -652,7 +652,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
action.accept(new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||
action.accept(new MapEntry(index, i));
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -664,14 +664,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1){
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
action.accept(entry);
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(count++, new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||
action.accept(count++, new MapEntry(index, i));
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(input, new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||
action.accept(input, new MapEntry(index, i));
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -724,14 +724,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
@Override
|
||||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
@ -746,14 +746,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
@Override
|
||||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
@ -768,14 +768,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
@Override
|
||||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
@ -797,7 +797,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||
state = operator.apply(state, new MapEntry(index, i));
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -821,11 +821,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
while(index != -1) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]);
|
||||
state = new MapEntry(index, i);
|
||||
index = (int)seg.links[index];
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||
state = operator.apply(state, new MapEntry(index, i));
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
}
|
||||
|
@ -839,14 +839,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
int index = seg.firstIndex;
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
@ -862,14 +862,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0,m=segments.length;i<m;i++) {
|
||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||
long stamp = seg.readLock();
|
||||
try {
|
||||
int index = seg.firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(seg.keys[index], seg.values[index]);
|
||||
entry.set(index, i);
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)seg.links[index];
|
||||
}
|
||||
|
|
|
@ -680,17 +680,17 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
action.accept(entry);
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
int count = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(count++, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
if(size() <= 0) return;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(input, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(input, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
@ -723,10 +723,10 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -737,10 +737,10 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -751,10 +751,10 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
E state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
state = operator.apply(state, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
|
@ -782,11 +782,11 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
while(index != -1) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(keys[index], values[index]);
|
||||
state = new MapEntry(index);
|
||||
index = (int)links[index];
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
state = operator.apply(state, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
|
@ -796,10 +796,10 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -810,11 +810,11 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
|
|
@ -797,7 +797,11 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public MapEntry(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
void set(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return keys[index];
|
||||
|
@ -862,21 +866,21 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
|
||||
@Override
|
||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
if(containsNull) action.accept(new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--)
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(new MapEntry(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
action.accept(entry);
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
action.accept(entry);
|
||||
}
|
||||
}
|
||||
|
@ -886,9 +890,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
if(size() <= 0) return;
|
||||
if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(0, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,9 +900,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
if(size() <= 0) return;
|
||||
if(containsNull) action.accept(input, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(input, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,14 +910,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
}
|
||||
|
@ -924,14 +928,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
|
@ -942,14 +946,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
|
@ -960,10 +964,10 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public <E> E reduce(E identity, BiFunction<E, MAP.Entry KEY_VALUE_GENERIC_TYPE, E> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
E state = identity;
|
||||
if(containsNull) state = operator.apply(state, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) state = operator.apply(state, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -974,17 +978,17 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||
boolean empty = true;
|
||||
if(containsNull) {
|
||||
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
||||
state = new MapEntry(nullIndex);
|
||||
empty = false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(keys[i], values[i]);
|
||||
state = new MapEntry(i);
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -993,14 +997,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
}
|
||||
|
@ -1011,15 +1015,15 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -684,17 +684,17 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
action.accept(entry);
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
int count = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(count++, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
if(size() <= 0) return;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
action.accept(input, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(input, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
@ -727,10 +727,10 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -741,10 +741,10 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -755,10 +755,10 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(!filter.test(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
E state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
state = operator.apply(state, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
|
@ -786,11 +786,11 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
while(index != -1) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(keys[index], values[index]);
|
||||
state = new MapEntry(index);
|
||||
index = (int)links[index];
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
state = operator.apply(state, new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
|
@ -800,10 +800,10 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -815,10 +815,10 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
if(filter.test(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
|
|
@ -756,7 +756,11 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public MapEntry(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
void set(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return keys[index];
|
||||
|
@ -821,21 +825,21 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
|
||||
@Override
|
||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
if(containsNull) action.accept(new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--)
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(new MapEntry(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
action.accept(entry);
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
action.accept(entry);
|
||||
}
|
||||
}
|
||||
|
@ -845,9 +849,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
if(size() <= 0) return;
|
||||
if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(0, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -855,9 +859,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
if(size() <= 0) return;
|
||||
if(containsNull) action.accept(input, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) action.accept(input, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -865,14 +869,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
}
|
||||
|
@ -883,14 +887,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
|
@ -901,14 +905,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
}
|
||||
|
@ -919,10 +923,10 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public <E> E reduce(E identity, BiFunction<E, MAP.Entry KEY_VALUE_GENERIC_TYPE, E> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
E state = identity;
|
||||
if(containsNull) state = operator.apply(state, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||
if(containsNull) state = operator.apply(state, new MapEntry(nullIndex));
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -933,17 +937,17 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||
boolean empty = true;
|
||||
if(containsNull) {
|
||||
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
||||
state = new MapEntry(nullIndex);
|
||||
empty = false;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(keys[i], values[i]);
|
||||
state = new MapEntry(i);
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -952,14 +956,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
}
|
||||
|
@ -970,15 +974,15 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
entry.set(nullIndex);
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -788,16 +788,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(int i = 0;i<size;i++)
|
||||
action.accept(new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
action.accept(new MapEntry(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
if(size() <= 0) return;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
action.accept(entry);
|
||||
}
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(int i = 0;i<size;i++) {
|
||||
action.accept(i, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
action.accept(i, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(int i = 0;i<size;i++) {
|
||||
action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
action.accept(input, new MapEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,9 +822,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -834,9 +834,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -846,9 +846,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(!filter.test(entry)) return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -859,7 +859,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(operator);
|
||||
E state = identity;
|
||||
for(int i = 0;i<size;i++) {
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -872,10 +872,10 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
for(int i = 0;i<size;i++) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = new BasicEntryKV_BRACES(keys[i], values[i]);
|
||||
state = new MapEntry(i);
|
||||
continue;
|
||||
}
|
||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||
state = operator.apply(state, new MapEntry(i));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -884,9 +884,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
return null;
|
||||
|
@ -897,9 +897,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
entry.set(i);
|
||||
if(filter.test(entry)) result++;
|
||||
}
|
||||
return result;
|
||||
|
@ -1404,7 +1404,11 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
public MapEntry(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
void set(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return keys[index];
|
||||
|
|
|
@ -684,7 +684,11 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
public MapEntry(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
void set(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return keys[index];
|
||||
|
|
|
@ -480,17 +480,17 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||
action.accept(new MapEntry(index));
|
||||
index = (int)links[index];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastForEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
MapEntry entry = new MapEntry();
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
entry.set(keys[index], values[index]);
|
||||
entry.set(index);
|
||||
action.accept(entry);
|
||||
index = (int)links[index];
|
||||
}
|
||||
|
@ -910,7 +910,11 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||
public MapEntry(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
void set(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return keys[index];
|
||||
|
|
Loading…
Reference in New Issue