Skip to content

Instantly share code, notes, and snippets.

@koduki
Created February 24, 2009 16:43
Show Gist options
  • Save koduki/69653 to your computer and use it in GitHub Desktop.
Save koduki/69653 to your computer and use it in GitHub Desktop.
class ArrayMap{
class Entry{
Object key;
Object value;
Entry(object k, object v){
this.key = k;
this.value = v;
}
}
private List<Entry> xs;
public ArrayMap(){
xs = new ArrayList<Entry>();
}
public void put(Object key, Object value){
for(int i=0;i<xs.length;i++){
if (xs.get(i).key.equals(key)){
xs.get(i).value = value;
return;
}
}
if(!isContain) xs.add(new Entry(key, value));
}
public Object get(Object key){
for(Object x : xs){
if x.key.equals(key) returnx.value;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment