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

13
LINES

< > BotCompany Repo | #1003482 - StrictTreeMap - non-overwrite TreeMap (doesn't allow modification, only adding)

JavaX fragment (include)

sclass StrictTreeMap<A, B> extends TreeMap<A, B> {
  bool detailedExceptions;
  
  public B put(A key, B value) {
    B v = get(key);
    if (v != null && neq(v, value))
      if (detailedExceptions)
        fail("Strict map conflict: " + structure(key) + ", " + structure(get(key)) + ", " + structure(value));
      else
        fail("Trying to change strict map.");
    ret super.put(key, value);
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003482
Snippet name: StrictTreeMap - non-overwrite TreeMap (doesn't allow modification, only adding)
Eternal ID of this version: #1003482/1
Text MD5: df422913676a4a8e663b417a510aac93
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-18 19:33:29
Source code size: 416 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 1431
Referenced in: [show references]