public BooleanHashSet select(BooleanPredicate predicate) {
   BooleanHashSet set = new BooleanHashSet();
   switch (this.state) {
     case 0:
       return set;
     case 1:
       if (predicate.accept(false)) {
         set.add(false);
       }
       return set;
     case 2:
       if (predicate.accept(true)) {
         set.add(true);
       }
       return set;
     case 3:
       if (predicate.accept(false)) {
         set.add(false);
       }
       if (predicate.accept(true)) {
         set.add(true);
       }
       return set;
     default:
       throw new AssertionError("Invalid state");
   }
 }
Пример #2
0
 public boolean noneSatisfy(BooleanPredicate predicate) {
   for (int i = 0; i < this.size; i++) {
     if (predicate.accept(this.items.get(i))) {
       return false;
     }
   }
   return true;
 }
Пример #3
0
 public boolean noneSatisfy(BooleanPredicate predicate) {
   BooleanIterator iterator = this.booleanIterator();
   while (iterator.hasNext()) {
     if (predicate.accept(iterator.next())) {
       return false;
     }
   }
   return true;
 }
Пример #4
0
 public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone) {
   for (int i = 0; i < this.size; i++) {
     boolean item = this.items.get(i);
     if (predicate.accept(item)) {
       return item;
     }
   }
   return ifNone;
 }
Пример #5
0
 public int count(BooleanPredicate predicate) {
   int count = 0;
   for (int i = 0; i < this.size; i++) {
     if (predicate.accept(this.items.get(i))) {
       count++;
     }
   }
   return count;
 }
Пример #6
0
 public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone) {
   BooleanIterator iterator = this.booleanIterator();
   while (iterator.hasNext()) {
     boolean value = iterator.next();
     if (predicate.accept(value)) {
       return value;
     }
   }
   return ifNone;
 }
Пример #7
0
 public int count(BooleanPredicate predicate) {
   int count = 0;
   BooleanIterator iterator = this.booleanIterator();
   while (iterator.hasNext()) {
     if (predicate.accept(iterator.next())) {
       count++;
     }
   }
   return count;
 }
Пример #8
0
 public BooleanArrayList reject(BooleanPredicate predicate) {
   BooleanArrayList result = new BooleanArrayList();
   for (int i = 0; i < this.size; i++) {
     boolean item = this.items.get(i);
     if (!predicate.accept(item)) {
       result.add(item);
     }
   }
   return result;
 }
 public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone) {
   switch (this.state) {
     case 0:
       return ifNone;
     case 1:
       return !predicate.accept(false) && ifNone;
     case 2:
       return predicate.accept(true) || ifNone;
     case 3:
       if (predicate.accept(false)) {
         return false;
       }
       if (predicate.accept(true)) {
         return true;
       }
       return ifNone;
     default:
       throw new AssertionError("Invalid state");
   }
 }
Пример #10
0
 public BooleanIterable reject(BooleanPredicate predicate) {
   BooleanArrayList result = new BooleanArrayList(BooleanArrayList.this.size);
   BooleanIterator iterator = this.booleanIterator();
   while (iterator.hasNext()) {
     boolean value = iterator.next();
     if (!predicate.accept(value)) {
       result.add(value);
     }
   }
   return result;
 }
 public int count(BooleanPredicate predicate) {
   switch (this.state) {
     case 0:
       return 0;
     case 1:
       return predicate.accept(false) ? 1 : 0;
     case 2:
       return predicate.accept(true) ? 1 : 0;
     case 3:
       int count = 0;
       if (predicate.accept(false)) {
         count++;
       }
       if (predicate.accept(true)) {
         count++;
       }
       return count;
     default:
       throw new AssertionError("Invalid state");
   }
 }