FileDocCategorySizeDatePackage
AssocArray.javaAPI DocExample3778Mon Apr 06 18:10:24 BST 1998None

AssocArray

public class AssocArray extends Dictionary

Fields Summary
private Vector
keys
private Vector
values
Constructors Summary
Methods Summary
public java.util.Enumerationelements()

    return values.elements();
  
public java.lang.Objectget(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 booleanisEmpty()

    return keys.isEmpty();
  
public java.util.Enumerationkeys()

    return keys.elements();
  
public static voidmain(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.Objectput(java.lang.Object key, java.lang.Object value)

    keys.addElement(key);
    values.addElement(value);
    return key;
  
public java.lang.Objectremove(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 intsize()

      return keys.size();