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

18
LINES

< > BotCompany Repo | #1005183 // limitedListCollector

JavaX fragment (include)

1  
// collects into l
2  
static <A> Collector<A> limitedListCollector(final Collection<A> l, final int max) {
3  
  ret new Collector<A>() {
4  
    bool full() {
5  
      ret l(l) >= max;
6  
    }
7  
    
8  
    bool add(A a) {
9  
      if (full()) false;
10  
      l.add(a);
11  
      ret full();
12  
    }
13  
    
14  
    bool contains(A a) {
15  
      ret l.contains(a);
16  
    }
17  
  };
18  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005183
Snippet name: limitedListCollector
Eternal ID of this version: #1005183/1
Text MD5: da2dc896697a71e341c3f0febe3b7fd0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-20 19:13:53
Source code size: 352 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 577 / 596
Referenced in: [show references]