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:
+67
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user