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

11
LINES

< > BotCompany Repo | #1006222 // makeReversedComparator - convert two-argument func to reversed Comparator

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

Libraryless. Click here for Pure Java version (9154L/51K).

1  
static Comparator makeReversedComparator(O f) {
2  
  ret new Comparator {
3  
    public int compare(O a, O b) {
4  
      ret (int) callF(f, b, a);
5  
    }
6  
  };
7  
}
8  
9  
static <A> Comparator<A> makeReversedComparator(Comparator<A> c) {
10  
  ret (a, b) -> c.compare(b, a);
11  
}

Author comment

Began life as a copy of #1006220

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006222
Snippet name: makeReversedComparator - convert two-argument func to reversed Comparator
Eternal ID of this version: #1006222/5
Text MD5: ac6cb840b61333dabde88492d8cee21a
Transpilation MD5: 0d03a84cd5ce9b13b8303d6453596158
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-25 16:07:06
Source code size: 263 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 559 / 641
Version history: 4 change(s)
Referenced in: [show references]