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

10
LINES

< > BotCompany Repo | #1036154 // addToArrayWithDoublingStrategy

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

Transpiled version (9263L) is out of date.

1  
meta-for double also as float, long {
2  
  static double[] addToArrayWithDoublingStrategy(double[] array, int currentSize, double element) {
3  
    if (currentSize >= l(array)) {
4  
      array = resizeArray(array, max(1, limitToSafeArraySize(l(array)*2L)));
5  
      if (currentSize >= l(array)) fail("Can't handle more than 2 billion elements at once");
6  
    }
7  
    array[currentSize++] = element;
8  
    ret array;
9  
  }
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036154
Snippet name: addToArrayWithDoublingStrategy
Eternal ID of this version: #1036154/5
Text MD5: 2c06f6e181b5595943af2dc030cb22ff
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-03 19:27:28
Source code size: 415 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 134 / 189
Version history: 4 change(s)
Referenced in: [show references]