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

19
LINES

< > BotCompany Repo | #1006145 // joinBits

JavaX fragment (include)

static Bits joinBits(Collection<Bits> l) {
  if (empty(l)) ret new Bits;
  new Bits bits;
  for (Bits b : l)
    appendBits(bits, b);
  ret bits;
}

static Bits joinBits(Bits a, Bits b) {
  if (a == null) ret b;
  if (b == null) ret a;
  int n = a.n;
  BitSet bs = b.bs;
  Bits c = new Bits(cloneBitSet(a.bs), n+b.n);
  BitSet bs2 = c.bs;
  for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1))
    bs2.set(n+i);
  ret c;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006145
Snippet name: joinBits
Eternal ID of this version: #1006145/1
Text MD5: 0b7921c63bd594a32d4f3eafa960a709
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-21 16:52:01
Source code size: 450 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 521 / 549
Referenced in: [show references]