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

13
LINES

< > BotCompany Repo | #1024612 // removeNonStreaksFromBitSetShorterThan

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

Libraryless. Click here for Pure Java version (38L/1K).

svoid removeNonStreaksFromBitSetShorterThan(BitSet bs, int min) {
  if (bs == null) ret;
  int n = bs.length();
  int i = -1;
  while true {
    i = bs.nextClearBit(i+1);
    if (i >= n) break;
    int j = bs.nextSetBit(i+1);
    if (j-i < min)
      bs.set(i, j, true);
    i = j;
  }
}

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: #1024612
Snippet name: removeNonStreaksFromBitSetShorterThan
Eternal ID of this version: #1024612/5
Text MD5: 6b612794ed74b95156019302c668309d
Transpilation MD5: 8c59e81e2406b0f9330f1e0f809f7083
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-20 00:22:14
Source code size: 299 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 198 / 296
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024613 - bitSetStreaks