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)

1  
sclass WeakIdentityHashSet<A> extends AbstractSet<A> {
2  
  Map<A, Bool> map = newWeakIdentityHashMap();
3  
  
4  
  public int size() { ret map.size(); }
5  
  public Iterator<A> iterator() { ret keys(map).iterator(); }
6  
  public bool contains(O o) { ret map.containsKey(o); }
7  
  
8  
  public bool add(A a) {
9  
    ret map.put(a, Bool.TRUE) != null;
10  
  }
11  
  public bool remove(O o) { ret map.remove(o) != null; }
12  
  
13  
  O mutex() { ret collectionMutex(map); }
14  
}

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