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]

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

1  
static <A> L<A> wrapAsReversedList(A[] array) {
2  
  int n = l(array);
3  
  ret new RandomAccessAbstractList<A> {
4  
    public int size() { ret n; }
5  
    public A get(int i) { ret array[n-1-i]; }
6  
    public A set(int i, A a) {
7  
      A old = array[n-1-i];
8  
      array[n-1-i] = a;
9  
      ret old;
10  
    }
11  
  };
12  
}

Author comment

Began life as a copy of #1029070

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt, wnsclhtenguj

No comments. add comment

Snippet ID: #1030633
Snippet name: wrapAsReversedList
Eternal ID of this version: #1030633/5
Text MD5: 96c74c5481b250cafb9c5f03c282ceab
Transpilation MD5: 86190fc2cb79a5166e6a8313e15f5adc
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: 113 / 204
Version history: 4 change(s)
Referenced in: [show references]