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

24
LINES

< > BotCompany Repo | #1016610 // makeTokenization - create linked-list representation of token list

JavaX fragment (include)

!include once #1016609 // LinkedToken + Tokenization

static Tokenization makeTokenization(L<S> tokens) {
  new Tokenization tok;
  for (S t : tokens) {
    LinkedToken lt = new(t);
    lt.t = t;
    if (tok.first == null)
      tok.first = lt;
    else {
      lt.prev = tok.last;
      tok.last.next = lt;
    }
    tok.last = lt;
    lt.prevIdentical = tok.lastByContent.get(t);
    if (lt.prevIdentical == null)
      tok.firstByContent.put(t, lt);
    else {
      lt.prevIdentical.nextIdentical = lt;
    }
    tok.lastByContent.put(t, lt);
  }
  ret tok;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016610
Snippet name: makeTokenization - create linked-list representation of token list
Eternal ID of this version: #1016610/1
Text MD5: 3188a57302c728bdd4bc6c3af56ab8ce
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-25 14:45:37
Source code size: 588 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 269 / 325
Referenced in: [show references]