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

13
LINES

< > BotCompany Repo | #1003919 // getBracketMap2

JavaX fragment (include)

static L<int> getBracketMap2(L<S> tok, Map<Integer, Integer> map, S openingBrackets, S closingBrackets) {
  map.clear();
  new L<int> stack;
  for (int i = 1; i < l(tok); i+= 2) {
    S t = tok.get(i);
    if (l(t) == 1)
      if (openingBrackets.contains(t))
        stack.add(i);
      else if (closingBrackets.contains(tok.get(i)))
        map.put(empty(stack) ? 0 : liftLast(stack), i);
  }
  ret stack;
}

Author comment

Began life as a copy of #1002118

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003919
Snippet name: getBracketMap2
Eternal ID of this version: #1003919/1
Text MD5: c9c5413831750a0080247df785431f08
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-30 18:27:25
Source code size: 421 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 510 / 621
Referenced in: [show references]