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

21
LINES

< > BotCompany Repo | #1008631 // class IntRange - range of ints (start/end)

JavaX fragment (include)

// it's unclear whether the end is inclusive or exclusive
// (usually exclusive I guess)
sclass IntRange {
  int start, end;
  
  *() {}
  *(int *start, int *end) {}
  *(IntRange r) { start = r.start; end = r.end; }
  
  [stdEq]
  
  final int length() { ret end-start; }
  final bool empty() { ret start >= end; }
  final bool isEmpty() { ret start >= end; }
  
  sS _fieldOrder = "start end";
  
  toString { ret "[" + start + ";" + end + "]"; }
  
  bool contains(int i) { ret i >= start && i <= end; }
}

Author comment

Began life as a copy of #1005873

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008631
Snippet name: class IntRange - range of ints (start/end)
Eternal ID of this version: #1008631/17
Text MD5: 7a96be33c5f41deea4ee53c63217489b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-03-14 21:33:18
Source code size: 527 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 664 / 2208
Version history: 16 change(s)
Referenced in: [show references]