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:
2021-09-28 13:20:05 +02:00
parent 3f872463b6
commit 07abba6312
25 changed files with 572 additions and 1 deletions
@@ -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();