Libraryless. Click here for Pure Java version (2338L/15K).
// 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; }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025694 |
Snippet name: | positionalTokenIndex_filter |
Eternal ID of this version: | #1025694/3 |
Text MD5: | df91f00ebfa3ecd27959c9019b31590a |
Transpilation MD5: | a6963504a6f8519a0af2746cdc087f22 |
Author: | stefan |
Category: | javax / agi.blue |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-13 23:06:37 |
Source code size: | 725 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 225 / 330 |
Version history: | 2 change(s) |
Referenced in: | [show references] |