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

28
LINES

< > BotCompany Repo | #1016609 // LinkedToken + Tokenization

JavaX fragment (include)

sclass LinkedToken {
  S t;
  LinkedToken prev, next;
  LinkedToken prevIdentical, nextIdentical;
  
  *() {}
  *(S *t) {}
}

sclass Tokenization {
  LinkedToken first, last;
  new Map<S, LinkedToken> firstByContent;
  new Map<S, LinkedToken> lastByContent;
  
  bool contains(S t) {
    ret firstByContent.get(t) != null;
  }
  
  int countInstances(S t) {
    int n = 0;
    LinkedToken lt = firstByContent.get(t);
    while (lt != null) {
      ++n;
      lt = lt.nextIdentical;
    }
    ret n;
  }
}

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: #1016609
Snippet name: LinkedToken + Tokenization
Eternal ID of this version: #1016609/1
Text MD5: 63c077da96808860c7c2d69204aa24ba
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:44:56
Source code size: 531 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 242 / 440
Referenced in: [show references]