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

10
LINES

< > BotCompany Repo | #1020676 // combinedCollection - contains()-only combined collection

JavaX fragment (include)

1  
static <A> Collection<A> combinedCollection(final Collection<A> a, final Collection<A> b) {
2  
  if (empty(a)) ret b;
3  
  if (empty(b)) ret a;
4  
  
5  
  ret new AbstractCollection<A> {
6  
    public int size() { ret a.size() + b.size(); } // >= real value
7  
    public bool contains(O o) { ret a.contains(o) || b.contains(o); }
8  
    public Iterator<A> iterator() { fail("not implemented"); }
9  
  };
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020676
Snippet name: combinedCollection - contains()-only combined collection
Eternal ID of this version: #1020676/2
Text MD5: d9b057181196bd7522dd295185956cb9
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-30 18:34:45
Source code size: 391 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 184 / 216
Version history: 1 change(s)
Referenced in: [show references]