Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1029115 // lcStream_itemCounts

JavaX fragment (include) [tags: use-pretranspiled]

Uses 11335K of libraries. Click here for Pure Java version (4622L/29K).

scope lcStream_itemCounts.

// counts how often an item actually appears in the text
static MultiSet<Int> lcStream_itemCounts(LCStreamingCompressor comp) {
  new MultiSet<Int> ms;
  for (int idx : comp.chain.toList())
    recurse(comp, ms, idx);
  ret ms;
}

svoid #recurse(LCStreamingCompressor comp, MultiSet<Int> ms, int idx) {
  ms.add(idx);
  IntPair p = comp.getPair(idx);
  if (p != null) {
    recurse(comp, ms, p.a);
    recurse(comp, ms, p.b);
  }
}

end scope

Author comment

Began life as a copy of #1029110

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029115
Snippet name: lcStream_itemCounts
Eternal ID of this version: #1029115/6
Text MD5: 807613c1fdf6db799914ac97ab17ebdd
Transpilation MD5: 51531a14a1b66dcc805055cba72093c0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-20 01:35:58
Source code size: 489 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 208 / 298
Version history: 5 change(s)
Referenced in: [show references]