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

16
LINES

< > BotCompany Repo | #1004134 // putKeysFirst - convert Map to litorderedmap with specified keys in front

JavaX fragment (include)

1  
static Map putKeysFirst(Map map, O... keys) {
2  
  Map m2 = litorderedmap();
3  
  Map remaining = cloneMap(map);
4  
  for (O key : keys) {
5  
    if (remaining.containsKey(key)) {
6  
      m2.put(key, remaining.get(key));
7  
      remaining.remove(key);
8  
    }
9  
  }
10  
  m2.putAll(remaining);
11  
  ret m2;
12  
}
13  
14  
static Map putKeysFirst(L keys, Map map) {
15  
  ret putKeysFirst(map, toObjectArray(keys));
16  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004134
Snippet name: putKeysFirst - convert Map to litorderedmap with specified keys in front
Eternal ID of this version: #1004134/3
Text MD5: 1e4a5c3f28bd9227c7c32abc53631c35
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-07 14:30:16
Source code size: 388 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 555 / 548
Version history: 2 change(s)
Referenced in: [show references]