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

19
LINES

< > BotCompany Repo | #1028372 // ObjectIndexByClass

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

Libraryless. Click here for Pure Java version (2767L/17K).

sclass ObjectIndexByClass {
  // preserving addition order is nice
  MultiSetMap<Class, O> index = multiSetMap_innerLinkedHashSet();
  
  void add(O o) {
    if (o != null)
      index.put(o.getClass(), o);
  }
  
  void remove(O o) {
    if (o != null)
      index.remove(o.getClass(), o);
  }
  
  // never returns null
  <A> Set<A> get(Class<A> c) {
    ret (Set) index.get(c);
  }
}

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: #1028372
Snippet name: ObjectIndexByClass
Eternal ID of this version: #1028372/4
Text MD5: 746488b3a3797a9dd1202a2c74c59eb8
Transpilation MD5: 7b274b753a29ea290506a8e659621cf6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-14 16:57:32
Source code size: 404 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 146 / 433
Version history: 3 change(s)
Referenced in: [show references]