// use "*" as wildcard // may return null, and returned list is "volatile" (only valid as long as the index is not changed) static LLS positionalTokenIndex_filter(PositionalTokenIndex idx, LS tok) { int cutOff = 1; // if we find a list shorter than this, we just return it. must be at least 1 LLS shortestList = null; for (int i = 1; i < l(tok); i += 2) { S t = tok.get(i); if (!eq(t, "*")) { LLS list = idx.byToken(i/2, t); if (l(list) < cutOff) ret list; if (shortestList == null || l(list) < l(shortestList)) shortestList = list; } } if (shortestList == null) // pattern must be all wildcards - return full list ret idx.fullList(); ret shortestList; }