MCPcopy Create free account
hub / github.com/BaseXdb/basex / initLen

Method initLen

basex-core/src/main/java/org/basex/gui/view/map/MapView.java:564–593  ·  view source on GitHub ↗

Initializes the text lengths and stores them into an array.

()

Source from the content-addressed store, hash-verified

562 * Initializes the text lengths and stores them into an array.
563 */
564 private void initLen() {
565 final Data data = gui.context.data();
566 if(textLen != null || gui.gopts.get(GUIOptions.MAPWEIGHT) == 0) return;
567
568 final int size = data.meta.size;
569 textLen = new int[size];
570
571 final IntList pars = new IntList();
572 int l = 0;
573
574 for(int pre = 0; pre < size; ++pre) {
575 final int kind = data.kind(pre);
576 final int par = data.parent(pre, kind);
577
578 final int ll = l;
579 while(l > 0 && pars.get(l - 1) > par) {
580 textLen[pars.get(l - 1)] += textLen[pars.get(l)];
581 --l;
582 }
583 if(l > 0 && ll != l) textLen[pars.get(l - 1)] += textLen[pars.get(l)];
584 pars.set(l, pre);
585
586 if(kind == Data.DOC || kind == Data.ELEM) {
587 pars.set(++l, 0);
588 } else {
589 textLen[pre] = data.textLen(pre, kind != Data.ATTR);
590 }
591 }
592 while(--l >= 0) textLen[pars.get(l)] += textLen[pars.get(l + 1)];
593 }
594}

Callers 1

calcMethod · 0.95

Calls 7

kindMethod · 0.95
parentMethod · 0.95
getMethod · 0.95
setMethod · 0.95
textLenMethod · 0.95
getMethod · 0.65
dataMethod · 0.45

Tested by

no test coverage detected