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

11
LINES

< > BotCompany Repo | #1013100 // LatestList - fixed-size list (up to) of last added elements

JavaX fragment (include)

1  
sclass LatestList<A> extends LinkedList<A> {
2  
  int limit;
3  
4  
  *(int *limit) {}
5  
6  
  public bool add(A o) {
7  
    if (limit == 0) true;
8  
    while (size() >= limit) super.remove();
9  
    ret super.add(o);
10  
  }
11  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1013100
Snippet name: LatestList - fixed-size list (up to) of last added elements
Eternal ID of this version: #1013100/3
Text MD5: f884cfbc89180cf8b7bd66a6abcdd1e4
Author: stefan
Category: javax / chat
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-25 20:57:06
Source code size: 211 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 451 / 1005
Version history: 2 change(s)
Referenced in: [show references]