Created
February 24, 2009 16:43
-
-
Save koduki/69653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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