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

16
LINES

< > BotCompany Repo | #1029548 // ciCharComparator (same ordering as String.CASE_INSENSITIVE_ORDER)

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

Libraryless. Click here for Pure Java version (48L/1K).

static simplyCached CharComparator ciCharComparator() {
  ret new ciCharComparator_C;
}

final sclass ciCharComparator_C implements CharComparator {
  public int compare(char c1, char c2) {
    if (c1 == c2) ret 0;
    c1 = Character.toUpperCase(c1);
    c2 = Character.toUpperCase(c2);
    if (c1 == c2) ret 0;
    c1 = Character.toLowerCase(c1);
    c2 = Character.toLowerCase(c2);
    // No overflow because of numeric promotion
    ret c1 - c2;
  }
}

Author comment

Began life as a copy of #1014136

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029548
Snippet name: ciCharComparator (same ordering as String.CASE_INSENSITIVE_ORDER)
Eternal ID of this version: #1029548/4
Text MD5: 500c2d437bb8693fc47d806bbeb6b9dd
Transpilation MD5: e8e71fa64dcab19a01dd25da33606c9d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-23 09:34:49
Source code size: 469 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 286
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)