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

18
LINES

< > BotCompany Repo | #1005183 // limitedListCollector

JavaX fragment (include)

// collects into l
static <A> Collector<A> limitedListCollector(final Collection<A> l, final int max) {
  ret new Collector<A>() {
    bool full() {
      ret l(l) >= max;
    }
    
    bool add(A a) {
      if (full()) false;
      l.add(a);
      ret full();
    }
    
    bool contains(A a) {
      ret l.contains(a);
    }
  };
}

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: 508 / 523
Referenced in: [show references]