forked from Speiger/Primitive-Collections
New Features
-Added: Count method for Iterable -Fixed: A couple of bugs with the new stream removers not working well in LinkedCollections
This commit is contained in:
parent
3f872463b6
commit
07abba6312
|
@ -6,6 +6,7 @@
|
|||
- Added: Java Iterator/Iterable support for Stream replacing methods
|
||||
- Added: Suppliers.
|
||||
- Added: SupplyIfAbsent but value generator is a supplier
|
||||
- Added: Count feature into Iterable
|
||||
|
||||
### Version 0.4.0
|
||||
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
||||
|
|
|
@ -27,6 +27,7 @@ To highlight things that may be wanted.
|
|||
- findFirst: Allows to find the first element of a Predicated Iterable.
|
||||
- filter: Allows to filter unwanted elements for wrapped Iterable
|
||||
- matchAny/matchNone/matchAll: Allows to find elements in a collection.
|
||||
- count: counts all valid elements in a collection
|
||||
- forEach: Allows to input a second element into a forEach move allowing for more flexibility for Method References
|
||||
- Collection:
|
||||
- containsAny: Allows to test if another collection contains an of the elements of the tested collection.
|
||||
|
@ -46,7 +47,7 @@ To highlight things that may be wanted.
|
|||
- addToAll: Same as addTo but bulkVersion.
|
||||
- removeOrDefault: removes a Element and if not present returns the default value instead of the present value.
|
||||
- mergeAll: BulkVersion of Merge function.
|
||||
- computeIfAbsent: A Supplier based generator that covers a lot more reference method cases
|
||||
- supplyIfAbsent: A Supplier based computeIfAbsent
|
||||
- Sorted Map:
|
||||
- addAndMoveToFirst/Last (From FastUtil but moved to Interface): Allows to add a element to the first/last position of a sorted Map.
|
||||
- moveToFirst/Last: Moves the desired element at the first/last position of the Map.
|
||||
|
|
|
@ -170,4 +170,18 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
||||
* @param filter that should be applied
|
||||
* @return the amount of Valid Elements
|
||||
*/
|
||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.TEST_VALUE(iter.NEXT())) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -643,6 +643,16 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific set function to reduce (un)boxing
|
||||
* @param index the index of the element to set
|
||||
|
|
|
@ -325,6 +325,16 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0,m=data.length;i<m;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE set(int index, KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
|
|
|
@ -452,6 +452,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||
if(filter.TEST_VALUE(entry.value)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE set(int index, KEY_TYPE e) {
|
||||
checkRange(index);
|
||||
|
|
|
@ -740,6 +740,21 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object o) {
|
||||
|
@ -944,6 +959,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||
|
||||
|
@ -1059,6 +1087,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -874,6 +874,25 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return CUSTOM_HASH_MAP.this.size();
|
||||
|
@ -1015,6 +1034,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1111,6 +1142,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -717,6 +717,21 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object o) {
|
||||
|
@ -921,6 +936,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) return result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||
|
||||
|
@ -1037,6 +1065,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -834,6 +834,25 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
int result = 0;
|
||||
if(containsNull) {
|
||||
entry.set(keys[nullIndex], values[nullIndex]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return HASH_MAP.this.size();
|
||||
|
@ -975,6 +994,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1071,6 +1102,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -629,6 +629,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -642,6 +643,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -655,6 +657,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(!filter.getBoolean(entry)) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -668,10 +671,26 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) return entry;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
entry.set(keys[index], values[index]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object o) {
|
||||
|
@ -846,6 +865,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int index = firstIndex;
|
||||
int result = 0;
|
||||
while(index != -1){
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||
|
||||
|
@ -959,6 +991,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1){
|
||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -1206,6 +1206,19 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<length;i++) {
|
||||
entry.set(keys[offset+i], values[offset+i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object o) {
|
||||
|
@ -1357,6 +1370,17 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
for(int i = 0;i<length;i++) {
|
||||
if(filter.TEST_VALUE(keys[i+offset])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||
@Override
|
||||
|
@ -1449,6 +1473,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<length;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[offset+i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class SubFastEntryIterator extends SubMapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
@ -1738,6 +1772,19 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||
for(int i = 0;i<size;i++) {
|
||||
entry.set(keys[i], values[i]);
|
||||
if(filter.getBoolean(entry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object o) {
|
||||
|
@ -1885,6 +1932,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||
@Override
|
||||
|
@ -1970,6 +2027,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.VALUE_TEST_VALUE(values[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -1554,6 +1554,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1631,6 +1644,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
@ -2043,6 +2065,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -2121,6 +2152,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -1607,6 +1607,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1684,6 +1697,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
@ -1919,6 +1941,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static final class KeySet KEY_VALUE_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE {
|
||||
|
@ -2096,6 +2131,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -2174,6 +2218,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -284,6 +284,16 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_G
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(int size) {
|
||||
int newSize = Math.max(size, size());
|
||||
|
|
|
@ -307,6 +307,16 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new Iter();
|
||||
|
|
|
@ -294,6 +294,16 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(array[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean removeIndex(int index) {
|
||||
array[index] = array[--size];
|
||||
#if TYPE_OBJECT
|
||||
|
|
|
@ -346,6 +346,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
||||
Entry KEY_GENERIC_TYPE node = tree;
|
||||
int compare;
|
||||
|
@ -1050,6 +1060,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
Entry KEY_GENERIC_TYPE previous;
|
||||
|
|
|
@ -392,6 +392,16 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(filter.TEST_VALUE(data[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
protected int findIndex(KEY_TYPE o) {
|
||||
for(int i = size-1;i>=0;i--)
|
||||
|
|
|
@ -312,6 +312,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -322,6 +323,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -332,6 +334,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -342,10 +345,23 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new SetIterator();
|
||||
|
|
|
@ -549,6 +549,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -559,6 +560,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -569,6 +571,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -579,10 +582,23 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||
return new SetIterator();
|
||||
|
|
|
@ -404,6 +404,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return true;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -414,6 +415,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -424,6 +426,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -434,10 +437,23 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.TEST_VALUE(keys[index])) result++;
|
||||
index = (int)links[index];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNodeAdded(int pos) {
|
||||
if(size == 0) {
|
||||
|
|
|
@ -521,6 +521,18 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private class SetIterator implements ITERATOR KEY_GENERIC_TYPE {
|
||||
int pos = nullIndex;
|
||||
int lastReturned = -1;
|
||||
|
|
|
@ -390,6 +390,18 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return 0;
|
||||
int result = 0;
|
||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ensureCapacity(int newCapacity) {
|
||||
int size = HashUtil.arraySize(newCapacity, loadFactor);
|
||||
if(size > nullIndex) rehash(size);
|
||||
|
|
|
@ -346,6 +346,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
||||
Entry KEY_GENERIC_TYPE node = tree;
|
||||
int compare;
|
||||
|
@ -1111,6 +1121,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(filter.TEST_VALUE(entry.key)) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
Entry KEY_GENERIC_TYPE previous;
|
||||
|
|
Loading…
Reference in New Issue