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

31
LINES

< > BotCompany Repo | #1006543 - mapToObjectArray - interleave keys and values; also toObjectArray(map(...))

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2523L/16K).

static O[] mapToObjectArray(Map map) {
  new L l;
  for (O o : keys(map)) {
    l.add(o);
    l.add(map.get(o));
  }
  ret toObjectArray(l);
}

static O[] mapLike mapToObjectArray(O f, Cl l) {
  int n = l(l);
  O[] array = new[n];
  if (n != 0) {
    Iterator it = iterator(l);
    for i to n:
      array[i] = callF(f, it.next());
  }
  ret array;
}

static O[] mapToObjectArray(O f, O[] l) {
  int n = l(l);
  O[] array = new[n];
  for i to n:
    array[i] = callF(f, l[i]);
  ret array;
}

static <A> O[] mapToObjectArray(Cl<A> l, IF1<A, O> f) {
  ret mapToObjectArray(f, l);
}

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1006543
Snippet name: mapToObjectArray - interleave keys and values; also toObjectArray(map(...))
Eternal ID of this version: #1006543/9
Text MD5: c0274a9b74fe1a54adca1cf9866b2b55
Transpilation MD5: f8d6eb1387cdb1ea67f70f7500f93af6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-16 17:24:53
Source code size: 610 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 326 / 401
Version history: 8 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1006543 & http://1006543.tinybrain.de