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

17
LINES

< > BotCompany Repo | #1014327 - toArray - synonym of toObjectArray; also allows a type

JavaX fragment (include)

static O[] toArray(Collection c) {
  ret toObjectArray(c);
}

static <A> A[] toArray(Collection c, Class<A> type) {
  A[] a = arrayOfType(l(c), type);
  if (a.length == 0) ret a;
  asList(c).toArray(a);
  ret a;
}

// array must have correct length and will be filled
static <A> A[] toArray(A[] array, Collection c) {
  if (array == null || c == null) null;
  asList(c).toArray(array);
  ret array;
}

Author comment

Began life as a copy of #1002013

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1014327
Snippet name: toArray - synonym of toObjectArray; also allows a type
Eternal ID of this version: #1014327/6
Text MD5: 100c99ac5e146017e3ea6094ca373daf
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-09 23:43:26
Source code size: 416 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 159
Version history: 5 change(s)
Referenced in: [show references]