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

12
LINES

< > BotCompany Repo | #1030633 - wrapAsReversedList

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

Transpiled version (2709L) is out of date.

static <A> L<A> wrapAsReversedList(A[] array) {
  int n = l(array);
  ret new RandomAccessAbstractList<A> {
    public int size() { ret n; }
    public A get(int i) { ret array[n-1-i]; }
    public A set(int i, A a) {
      A old = array[n-1-i];
      array[n-1-i] = a;
      ret old;
    }
  };
}

Author comment

Began life as a copy of #1029070

download  show line numbers  debug dex   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1030633
Snippet name: wrapAsReversedList
Eternal ID of this version: #1030633/5
Text MD5: 96c74c5481b250cafb9c5f03c282ceab
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-02-09 10:28:30
Source code size: 308 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 14 / 33
Version history: 4 change(s)
Referenced in: [show references]

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