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

13
LINES

< > BotCompany Repo | #1017794 // findEndOfBracketPart2 - with square brackets

JavaX fragment (include)

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

Author comment

Began life as a copy of #1001165

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017794
Snippet name: findEndOfBracketPart2 - with square brackets
Eternal ID of this version: #1017794/3
Text MD5: ea2280bedc69c69da9191aa301166461
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-10 14:49:03
Source code size: 461 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 321 / 400
Version history: 2 change(s)
Referenced in: [show references]