home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / MyC / Src / VarList.cs < prev   
Encoding:
Text File  |  2000-06-23  |  801 b   |  48 lines

  1. namespace MyC
  2. {
  3. using System;
  4. using System.Collections;
  5.  
  6. public class VarList
  7.   {
  8.   Hashtable vhash;
  9.   int vindex;
  10.  
  11.   public VarList()
  12.     {
  13.     vhash = new Hashtable(8);    // arbitrary initial size
  14.     vindex = 0;            // init the index count
  15.     }
  16.  
  17.   public void add(Var e)
  18.     {
  19.     int index = vindex++;
  20.     e.setIndex(index);
  21.     vhash.Add(e.getName(), e);
  22.     vhash.Add(index, e);
  23.     }
  24.  
  25.   public Var FindByName(String s)
  26.     {
  27.     Object o = vhash[s];
  28.     if (o == null)
  29.       return null;
  30.     return ((Var)o);
  31.     }
  32.  
  33.   public Var FindByIndex(int i)
  34.     {
  35.     Object x = i;
  36.     Object o = vhash[x];
  37.     if (o == null)
  38.       return null;
  39.     return (Var)o;
  40.     }
  41.  
  42.   public int Length()
  43.     {
  44.     return vindex;        // number of items in hash
  45.     }
  46.   }
  47.   }
  48.