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

Method iter

basex-core/src/main/java/org/basex/query/func/fn/FnRemove.java:19–45  ·  view source on GitHub ↗
(final QueryContext qc)

Source from the content-addressed store, hash-verified

17 */
18public final class FnRemove extends StandardFunc {
19 @Override
20 public Iter iter(final QueryContext qc) throws QueryException {
21 final Iter input = arg(0).iter(qc);
22 final LongList pos = positions(qc);
23
24 // value-based iterator
25 if(input.valueIter() || pos.size() > 1) return value(input.value(qc, null), pos, qc).iter();
26
27 final long size = input.size();
28 return new Iter() {
29 final long p = pos.get(0);
30 long c;
31
32 @Override
33 public Item next() throws QueryException {
34 return c++ != p || input.next() != null ? input.next() : null;
35 }
36 @Override
37 public Item get(final long i) throws QueryException {
38 return input.get(i < p ? i : i + 1);
39 }
40 @Override
41 public long size() {
42 return Math.max(-1, size - 1);
43 }
44 };
45 }
46
47 @Override
48 public Value value(final QueryContext qc) throws QueryException {

Callers

nothing calls this directly

Calls 9

positionsMethod · 0.95
valueIterMethod · 0.95
valueMethod · 0.95
valueMethod · 0.95
sizeMethod · 0.95
getMethod · 0.95
iterMethod · 0.65
sizeMethod · 0.65
argMethod · 0.45

Tested by

no test coverage detected