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

4
LINES

< > BotCompany Repo | #1002098 // resizeCollection

JavaX fragment (include)

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

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: 616 / 865
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)