@Override
    protected boolean filter(final Traverser.Admin<S> traverser) {
        if (this.bypass) return true;

        if (this.high.get() != -1 && this.counter.get() >= this.high.get()) {
            throw FastNoSuchElementException.instance();
        }

        long avail = traverser.bulk();
        if (this.counter.get() + avail <= this.low.get()) {
            // Will not surpass the low w/ this traverser. Skip and filter the whole thing.
            this.counter.getAndAdd(avail);
            return false;
        }

        // Skip for the low and trim for the high. Both can happen at once.

        long toSkip = 0;
        if (this.counter.get() < this.low.get()) {
            toSkip = this.low.get() - this.counter.get();
        }

        long toTrim = 0;
        if (this.high.get() != -1 && this.counter.get() + avail >= this.high.get()) {
            toTrim = this.counter.get() + avail - this.high.get();
        }

        long toEmit = avail - toSkip - toTrim;
        this.counter.getAndAdd(toSkip + toEmit);
        traverser.setBulk(toEmit);

        return true;
    }
@author Bob Briody (http://bobbriody.com)
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java