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

11
LINES

< > BotCompany Repo | #1036502 // multiMapSingletonPairs - get key+value pairs where key only has one value

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

Libraryless. Click here for Pure Java version (9947L/55K).

1  
meta-for MultiMap also as MultiSetMap {
2  
  static <A, B> LPair<A, B> multiMapSingletonPairs(MultiMap<A, B> mm) {
3  
    new LPair<A, B> out;
4  
    if (mm != null) for (A key : mm.keySet()) {
5  
      var values = mm.get(key);
6  
      if (l(values) == 1)
7  
        out.add(pair(key, first(values)));
8  
    }
9  
    ret out;
10  
  }
11  
}

Author comment

Began life as a copy of #1004755

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036502
Snippet name: multiMapSingletonPairs - get key+value pairs where key only has one value
Eternal ID of this version: #1036502/5
Text MD5: 9db8b831ec4846921210c57519204ed0
Transpilation MD5: e14a1aa8440336a3d0f839ea9b341f8b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-07 20:47:19
Source code size: 320 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 81 / 127
Version history: 4 change(s)
Referenced in: [show references]