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

13
LINES

< > BotCompany Repo | #1020960 // findBeginningOfBracketPart

JavaX fragment (include)

// i must point at the (possibly imaginary) closing bracket (any of the 2 types, not type parameters)
// index returned is index of opening bracket
static int findBeginningOfBracketPart(LS cnc, int i) {
  int j = i-2, level = 1;
  while (j > 0) {
    if (eqOneOf(cnc.get(j), "}", ")")) ++level;
    else if (eqOneOf(cnc.get(j), "{", "(")) --level;
    if (level == 0)
      ret j;
    j -= 2;
  }
  return -1;
}

Author comment

Began life as a copy of #1001165

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020960
Snippet name: findBeginningOfBracketPart
Eternal ID of this version: #1020960/1
Text MD5: 7dfc1a8d28674aa55e563239cd1a7b08
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-12 21:36:58
Source code size: 423 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 351 / 367
Referenced in: [show references]