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

13
LINES

< > BotCompany Repo | #1020960 // findBeginningOfBracketPart

JavaX fragment (include)

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

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: 239 / 279
Referenced in: [show references]