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

13
LINES

< > BotCompany Repo | #1030043 // listToMapOfListsWithKeyDetector

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

Libraryless. Click here for Pure Java version (2530L/16K).

static <A> Map<A, L<A>> listToMapOfListsWithKeyDetector(IPred<A> keyDetector, L<A> l, A preludeKey) {
  new LinkedHashMap<A, L<A>> map;
  L<A> currentList = null;
  fOr (A a : l)
    if (keyDetector.get(a))
      map.put(a, currentList = new L);
    else {
      if (currentList == null)
        map.put(preludeKey, currentList = new L);
      currentList.add(a);
    }
  ret map;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030043
Snippet name: listToMapOfListsWithKeyDetector
Eternal ID of this version: #1030043/4
Text MD5: 0f9170f3f21a07c6d6317d8df4387ad6
Transpilation MD5: 13dcee456a1b45269bca1802b5dcf34e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-02 13:21:36
Source code size: 394 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 105 / 148
Version history: 3 change(s)
Referenced in: [show references]