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

16
LINES

< > BotCompany Repo | #1014003 // setBit

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

Transpiled version (41L) is out of date.

1  
svoid setBit(BitSet b, int bit) {
2  
  b?.set(bit);
3  
}
4  
5  
svoid setBit(BitSet b, int bit, bool value) {
6  
  b?.set(bit, value);
7  
}
8  
9  
svoid setBit(byte[] b, int bit, bool value default true) {
10  
  int idx = bit >> 3;
11  
  byte mask = cast 1 << (bit & 7);
12  
  if (value)
13  
    b[idx] |= mask;
14  
  else
15  
    b[idx] &= ~mask;
16  
}

Author comment

Began life as a copy of #1005056

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: #1014003
Snippet name: setBit
Eternal ID of this version: #1014003/6
Text MD5: 8a2d9b95edf842d5272c9e44ade297e9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-05 18:40:40
Source code size: 316 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 451 / 565
Version history: 5 change(s)
Referenced in: [show references]