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

9
LINES

< > BotCompany Repo | #1029072 // bitSetToIntArray - int array receives the indices of set bits

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

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

static int[] bitSetToIntArray(BitSet bs) {
  if (bs == null) null;
  int n = bs.cardinality();
  int[] result = new[n];
  int j = 0;
  for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1))
    result[j++] = i;
  ret result;
}

Author comment

Began life as a copy of #1020586

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: #1029072
Snippet name: bitSetToIntArray - int array receives the indices of set bits
Eternal ID of this version: #1029072/3
Text MD5: edff847e4d018add4fa751c273faf4d2
Transpilation MD5: 7d5a59a2b8173e72bbbf6aea0412e465
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-26 16:07:24
Source code size: 242 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 246 / 336
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)