### Question:
WindowOperator implements Operator { @VisibleForTesting static int findEndPosition(int startPosition, int endPosition, BiPredicate<Integer, Integer> comparator) { checkArgument(startPosition >= 0, "startPosition must be greater or equal than zero: %s", startPosition); checkArgument(startPosition < endPosition, "startPosition (%s) must be less than endPosition (%s)", startPosition, endPosition); int left = startPosition; int right = endPosition; while (left + 1 < right) { int middle = (left + right) >>> 1; if (comparator.test(startPosition, middle)) { left = middle; } else { right = middle; } } return right; } WindowOperator(
            OperatorContext operatorContext,
            List<Type> sourceTypes,
            List<Integer> outputChannels,
            List<WindowFunctionDefinition> windowFunctionDefinitions,
            List<Integer> partitionChannels,
            List<Integer> preGroupedChannels,
            List<Integer> sortChannels,
            List<SortOrder> sortOrder,
            int preSortedChannelPrefix,
            int expectedPositions,
            PagesIndex.Factory pagesIndexFactory,
            boolean spillEnabled,
            SpillerFactory spillerFactory,
            OrderingCompiler orderingCompiler); @Override OperatorContext getOperatorContext(); @Override void finish(); @Override boolean isFinished(); @Override ListenableFuture<?> isBlocked(); @Override boolean needsInput(); @Override void addInput(Page page); @Override Page getOutput(); @Override ListenableFuture<?> startMemoryRevoke(); @Override void finishMemoryRevoke(); @Override void close();  }### Answer:
@Test public void testFindEndPosition() { assertFindEndPosition("0", 1); assertFindEndPosition("11", 2); assertFindEndPosition("1111111111", 10); assertFindEndPosition("01", 1); assertFindEndPosition("011", 1); assertFindEndPosition("0111", 1); assertFindEndPosition("0111111111", 1); assertFindEndPosition("012", 1); assertFindEndPosition("01234", 1); assertFindEndPosition("0123456789", 1); assertFindEndPosition("001", 2); assertFindEndPosition("0001", 3); assertFindEndPosition("0000000001", 9); assertFindEndPosition("000111", 3); assertFindEndPosition("0001111", 3); assertFindEndPosition("0000111", 4); assertFindEndPosition("000000000000001111111111", 14); }