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

14
LINES

< > BotCompany Repo | #1005752 // latest - get latest concept of type

JavaX fragment (include)

static <A extends Concept> A latest(Class<A> c) {
  long maxID = 0;
  A max = null;
  
  for (A a : list(c))
    if (a.id > maxID) {
      maxID = a.id;
      max = a;
    }
  ret max;

  // This doesn't work:
  //ret last(list(c)); // todo: optimize?
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005752
Snippet name: latest - get latest concept of type
Eternal ID of this version: #1005752/3
Text MD5: 6371d253ed2d6361d6588e63c6f44523
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-03-25 16:13:49
Source code size: 266 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 622 / 631
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)