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

20
LINES

< > BotCompany Repo | #1015623 // TArray (ArrayList with reified element type)

JavaX fragment (include)

1  
static final class TArray<A> extends ArrayList<A> {
2  
  Class<A> type;
3  
4  
  *() {}
5  
  *(Class<A> *type) {}
6  
  
7  
  <B> TArray<B> cast() { ret (TArray) this; }
8  
9  
  public bool add(A a) {
10  
    assertIsInstance(type, a);
11  
    ret super.add(a);
12  
  }
13  
  
14  
  public A set(int i, A a) {
15  
    assertIsInstance(type, a);
16  
    ret super.set(i, a);
17  
  }
18  
19  
  // overwrite more methods?
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015623
Snippet name: TArray (ArrayList with reified element type)
Eternal ID of this version: #1015623/19
Text MD5: d7070cc065330ae7bcd62c618493c1e7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-06 04:44:22
Source code size: 376 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 438 / 985
Version history: 18 change(s)
Referenced in: [show references]