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

18
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; }
  
  sS _fieldOrder = "start end";
  
  toString { ret "[" + start + ";" + end + "]"; }
}

Author comment

Began life as a copy of #1005873

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1008631
Snippet name: class IntRange - range of ints (start/end)
Eternal ID of this version: #1008631/15
Text MD5: 56622251e60daac4ca02d2900c0e7e76
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-26 14:15:45
Source code size: 421 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 1551
Version history: 14 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1008631 & http://1008631.tinybrain.de