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

19
LINES

< > BotCompany Repo | #1028864 // CountingVarMaker

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2563L/16K).

1  
sclass CountingVarMaker implements VarMaker {
2  
  S prefix = "";
3  
  Set<S> taken = ciSet();
4  
  int i;
5  
  
6  
  *() {}
7  
  *(S *prefix) {}
8  
  *(S *prefix, Cl<S> taken) { addAll(this.taken, taken); }
9  
  
10  
  public void addTaken(S s) { taken.add(s); }
11  
  
12  
  public S get() {
13  
    S s;
14  
    do ping {
15  
      s = prefix + ++i;
16  
    } while (taken.contains(s));
17  
    ret s;
18  
  }
19  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028864
Snippet name: CountingVarMaker
Eternal ID of this version: #1028864/5
Text MD5: c8b50cefc5bd2f03a4984feff4810fb0
Transpilation MD5: 02de23f9f6a0dc05f6ea5e69409e898c
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-10 19:36:26
Source code size: 372 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 429
Version history: 4 change(s)
Referenced in: [show references]