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

14
LINES

< > BotCompany Repo | #1015374 // WeakIdentityHashSet (hopefully complete, synchronized)

JavaX fragment (include)

sclass WeakIdentityHashSet<A> extends AbstractSet<A> {
  Map<A, Bool> map = newWeakIdentityHashMap();
  
  public int size() { ret map.size(); }
  public Iterator<A> iterator() { ret keys(map).iterator(); }
  public bool contains(O o) { ret map.containsKey(o); }
  
  public bool add(A a) {
    ret map.put(a, Bool.TRUE) != null;
  }
  public bool remove(O o) { ret map.remove(o) != null; }
  
  O mutex() { ret collectionMutex(map); }
}

Author comment

Began life as a copy of #1011596

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: #1015374
Snippet name: WeakIdentityHashSet (hopefully complete, synchronized)
Eternal ID of this version: #1015374/1
Text MD5: c5e5be837e1bfd21317d51b1c475a147
Author: stefan
Category: javax / collections
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-13 14:15:47
Source code size: 450 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 318 / 979
Referenced in: [show references]