Libraryless. Click here for Pure Java version (34L/1K).
1 | static int[] bitSetToIntArray(BitSet bs) { |
2 | if (bs == null) null; |
3 | int n = bs.cardinality(); |
4 | int[] result = new[n]; |
5 | int j = 0; |
6 | for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) |
7 | result[j++] = i; |
8 | ret result; |
9 | } |
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: | 245 / 335 |
Version history: | 2 change(s) |
Referenced in: | [show references] |