Fast Array Stack - WilfullMurder/DataStructures-Java GitHub Wiki

Fast Array Stack

Subclass of ArrayStack that overrides some functions for speed. Most of the work done by an ArrayStack involves the shifting and copying of data (by add(i,x), remove(i) and resize()). In the super implementation, this was done using for loops. Turns out that many programming environments have specific functions that are very efficient at copying and moving blocks of data. In Java there is the System.arraycopy(s,i,d,j,n) method. Although using this functions does not asymptotically decrease the running times, it can still be a worthwhile optimization. The use of the native System.arraycopy(s,i,d,j,n) resulted in speedups of a factor between 2 and 3, depending on the types of operations performed. **Mileage may vary**.

⚠️ **GitHub.com Fallback** ⚠️