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

21
LINES

< > BotCompany Repo | #1002041 // cmp function (standard compare)

JavaX fragment (include)

1  
static int cmp(Number a, Number b) {
2  
  ret a == null ? b == null ? 0 : -1 : cmp(a.doubleValue(), b.doubleValue());
3  
}
4  
5  
static int cmp(double a, double b) {
6  
  ret a < b ? -1 : a == b ? 0 : 1;
7  
}
8  
9  
static int cmp(int a, int b) {
10  
  ret a < b ? -1 : a == b ? 0 : 1;
11  
}
12  
13  
static int cmp(long a, long b) {
14  
  ret a < b ? -1 : a == b ? 0 : 1;
15  
}
16  
17  
static int cmp(O a, O b) {
18  
  if (a == null) ret b == null ? 0 : -1;
19  
  if (b == null) ret 1;
20  
  ret ((Comparable) a).compareTo(b);
21  
}

Author comment

Began life as a copy of #1001540

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002041
Snippet name: cmp function (standard compare)
Eternal ID of this version: #1002041/4
Text MD5: 9fc9492b222d98c9638e682d61d38675
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-05 17:42:49
Source code size: 483 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 850 / 2389
Version history: 3 change(s)
Referenced in: [show references]