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)

static final class TArray<A> extends ArrayList<A> {
  Class<A> type;

  *() {}
  *(Class<A> *type) {}
  
  <B> TArray<B> cast() { ret (TArray) this; }

  public bool add(A a) {
    assertIsInstance(type, a);
    ret super.add(a);
  }
  
  public A set(int i, A a) {
    assertIsInstance(type, a);
    ret super.set(i, a);
  }

  // overwrite more methods?
}

download  show line numbers  debug dex   

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

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: 140 / 401
Version history: 18 change(s)
Referenced in: [show references]