Skip to content

Instantly share code, notes, and snippets.

@koduki
Created February 24, 2009 16:16
Show Gist options
  • Save koduki/69646 to your computer and use it in GitHub Desktop.
Save koduki/69646 to your computer and use it in GitHub Desktop.
class ArrayList implments List{
private Object[] buff = null;
private int last = 0;
public ArrayList(){ this(128); }
public ArrayList(int n){
buff = new Object[n];
}
public add(Object o ){
if (last == buff.length) {
Object[] xs = new Object[buff.length * 2];
for(int i=0;i<buff.length;i++) xs[i] = buff[i];
buff = xs;
}
buff[last] = o; last++;
}
public get(int n){return buff[n]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment