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

32
LINES

< > BotCompany Repo | #1024411 // LogNArray [dev.]

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

Transpiled version (12768L) is out of date.

1  
sclass LogNArray<A> extends RandomAccessAbstractList<A> {
2  
  class Node {
3  
    O a, b; // Node or A
4  
    int size;
5  
    
6  
    int get(int i) {
7  
      if (i >= a)
8  
    }
9  
  }
10  
  
11  
  bool empty;
12  
  O root;
13  
  
14  
  int nodeSize(O o) {
15  
    if (o cast Node) ret o.size;
16  
    ret 1;
17  
  }
18  
  
19  
  public int size() {
20  
    if (empty) ret 0;
21  
    if (root cast Node) ret root.size;
22  
    ret 1;
23  
  }
24  
  
25  
  public A get(int i) {
26  
    if (i < 0 || empty || i >= size()) throw new IndexOutOfBoundsException();
27  
    if (root cast Node) {
28  
      ret node.get(i);
29  
    }
30  
    ret (A) root;
31  
  }
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024411
Snippet name: LogNArray [dev.]
Eternal ID of this version: #1024411/2
Text MD5: c3975f30c57b9c5b4e20533c9b6d6997
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-11 01:41:22
Source code size: 581 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 220 / 286
Version history: 1 change(s)
Referenced in: [show references]