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)

1  
!include once #1016609 // LinkedToken + Tokenization
2  
3  
static Tokenization makeTokenization(L<S> tokens) {
4  
  new Tokenization tok;
5  
  for (S t : tokens) {
6  
    LinkedToken lt = new(t);
7  
    lt.t = t;
8  
    if (tok.first == null)
9  
      tok.first = lt;
10  
    else {
11  
      lt.prev = tok.last;
12  
      tok.last.next = lt;
13  
    }
14  
    tok.last = lt;
15  
    lt.prevIdentical = tok.lastByContent.get(t);
16  
    if (lt.prevIdentical == null)
17  
      tok.firstByContent.put(t, lt);
18  
    else {
19  
      lt.prevIdentical.nextIdentical = lt;
20  
    }
21  
    tok.lastByContent.put(t, lt);
22  
  }
23  
  ret tok;
24  
}

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