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

4
LINES

< > BotCompany Repo | #1002098 // resizeCollection

JavaX fragment (include)

1  
static <A> void resizeCollection(List<A> l, A value, int size) {
2  
  while (l(l) > size) l.remove(l(l)-1);
3  
  while (l(l) < size) l.add(value);
4  
}

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: #1002098
Snippet name: resizeCollection
Eternal ID of this version: #1002098/1
Text MD5: a19908602c0926006bdf3e28c93e4ebb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-18 17:08:55
Source code size: 145 bytes / 4 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 615 / 864
Referenced in: [show references]