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