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)

1  
static <A extends Concept> A latest(Class<A> c) {
2  
  long maxID = 0;
3  
  A max = null;
4  
  
5  
  for (A a : list(c))
6  
    if (a.id > maxID) {
7  
      maxID = a.id;
8  
      max = a;
9  
    }
10  
  ret max;
11  
12  
  // This doesn't work:
13  
  //ret last(list(c)); // todo: optimize?
14  
}

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: 549 / 558
Version history: 2 change(s)
Referenced in: [show references]