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

32
LINES

< > BotCompany Repo | #1005718 - class Pt - persistable/portable version of Point

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

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

sclass Pt implements Comparable<Pt> {
  int x, y;
  
  *() {}
  *(Point p) {
    x = p.x;
    y = p.y;
  }
  *(int *x, int *y) {}
  
  Point getPoint() {
    ret new Point(x, y);
  }
  
  public bool equals(O o) {
    ret o instanceof Pt && x == o/Pt.x && y == o/Pt.y;
  }
  
  public int hashCode() {
    ret boostHashCombine(x, y);
  }
  
  // compare in scan order
  public int compareTo(Pt p) {
    if (y != p.y) ret cmp(y, p.y);
    ret cmp(x, p.x);
  }
  
  public S toString() {
    ret x + ", " + y;
  }
}

Author comment

Began life as a copy of #1005390

download  show line numbers  debug dex  old transpilations   

Travelled to 24 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, lulzaavyztxj, mowyntqkapby, mqqgnosmbjvj, odhhsrjjbcgr, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, snaazhdonpnp, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005718
Snippet name: class Pt - persistable/portable version of Point
Eternal ID of this version: #1005718/3
Text MD5: 7e001a21bdc95e5bd3240c962367551f
Transpilation MD5: 042aa435d50044ec8415b3784db41b87
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-03 22:15:37
Source code size: 544 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 491 / 7858
Version history: 2 change(s)
Referenced in: [show references]