Methods Summary |
---|
public java.util.Enumeration | elements()
return values.elements();
|
public java.lang.Object | get(java.lang.Object key)
int index = keys.indexOf(key);
// indexOf() Returns -1 if key not found:
if(index == -1) return null;
return values.elementAt(index);
|
public boolean | isEmpty()
return keys.isEmpty();
|
public java.util.Enumeration | keys()
return keys.elements();
|
public static void | main(java.lang.String[] args)
AssocArray aa = new AssocArray();
for(char c = 'a"; c <= 'z"; c++)
aa.put(String.valueOf(c),
String.valueOf(c)
.toUpperCase());
char[] ca = { 'a", 'e", 'i", 'o", 'u" };
for(int i = 0; i < ca.length; i++)
System.out.println("Uppercase: " +
aa.get(String.valueOf(ca[i])));
|
public java.lang.Object | put(java.lang.Object key, java.lang.Object value)
keys.addElement(key);
values.addElement(value);
return key;
|
public java.lang.Object | remove(java.lang.Object key)
int index = keys.indexOf(key);
if(index == -1) return null;
keys.removeElementAt(index);
Object returnval = values.elementAt(index);
values.removeElementAt(index);
return returnval;
|
public int | size()
return keys.size();
|