Esempio n. 1
0
  @Override
  public DisposableValueIterator getValueIterator(boolean bottomUp) {
    if (_viterator == null || !_viterator.isReusable()) {
      _viterator =
          new DisposableValueIterator() {

            DisposableValueIterator vit;

            @Override
            public void bottomUpInit() {
              super.bottomUpInit();
              vit = var.getValueIterator(true);
            }

            @Override
            public void topDownInit() {
              super.topDownInit();
              vit = var.getValueIterator(false);
            }

            @Override
            public boolean hasNext() {
              return vit.hasNext();
            }

            @Override
            public boolean hasPrevious() {
              return vit.hasPrevious();
            }

            @Override
            public int next() {
              return vit.next() + cste;
            }

            @Override
            public int previous() {
              return vit.previous() + cste;
            }

            @Override
            public void dispose() {
              super.dispose();
              vit.dispose();
            }
          };
    }
    if (bottomUp) {
      _viterator.bottomUpInit();
    } else {
      _viterator.topDownInit();
    }
    return _viterator;
  }
Esempio n. 2
0
  @Override
  public DisposableValueIterator getValueIterator(boolean bottomUp) {
    if (_viterator == null || !_viterator.isReusable()) {
      _viterator =
          new DisposableValueIterator() {

            int value;

            @Override
            public void bottomUpInit() {
              super.bottomUpInit();
              this.value = LB.get();
            }

            @Override
            public void topDownInit() {
              super.topDownInit();
              this.value = UB.get();
            }

            @Override
            public boolean hasNext() {
              return this.value != -1;
            }

            @Override
            public boolean hasPrevious() {
              return this.value != -1;
            }

            @Override
            public int next() {
              int old = this.value;
              this.value = VALUES.nextSetBit(this.value + 1);
              return old + OFFSET;
            }

            @Override
            public int previous() {
              int old = this.value;
              this.value = VALUES.prevSetBit(this.value - 1);
              return old + OFFSET;
            }
          };
    }
    if (bottomUp) {
      _viterator.bottomUpInit();
    } else {
      _viterator.topDownInit();
    }
    return _viterator;
  }