Loading [MathJax]/jax/input/MathML/config.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Engineering LibreTexts

Search

  • Filter Results
  • Location
  • Classification
    • Article type
    • Author
    • Set as Cover Page of Book
    • License
    • Show TOC
    • Transcluded
    • OER program or Publisher
    • Autonumber Section Headings
    • License Version
    • Print CSS
  • Include attachments
Searching in
About 1 results
  • https://eng.libretexts.org/Bookshelves/Computer_Science/Databases_and_Data_Structures/Open_Data_Structures_-_An_Introduction_(Morin)/02%3A_Array-Based_Lists/2.02%3A_FastArrayStack_-_An_Optimized_ArrayStack
    void resize() { T[] b = newArray(Math.max(2*n,1)); System.arraycopy(a, 0, b, 0, n); a = b; } void add(int i, T x) { if (i < 0 || i > n) throw new IndexOutOfBoundsException(); if (n + 1 > a.length) res...void resize() { T[] b = newArray(Math.max(2*n,1)); System.arraycopy(a, 0, b, 0, n); a = b; } void add(int i, T x) { if (i < 0 || i > n) throw new IndexOutOfBoundsException(); if (n + 1 > a.length) resize(); System.arraycopy(a, i, a, i+1, n-i); a[i] = x; n++; } T remove(int i) { if (i < 0 || i > n - 1) throw new IndexOutOfBoundsException(); T x = a[i]; System.arraycopy(a, i+1, a, i, n-i-1); n--; if (a.length >= 3*n) resize(); return x; }

Support Center

How can we help?