﻿// JScript 文件

function ArrayList()
 {
      this.map = new Array();
    //list对象的item
      this.Item=function(key, value)
      {
        this.key = key;
        this.value = value;
      };
      this.setAt=function(key, value)
      {
          for (var i = 0; i < this.map.length; i++)
          {
            if ( this.map[i].key == key )
            {
              this.map[i].value = value;
              return;
            }
          }
          this.map[this.map.length] = new this.Item(key, value);
      };
     this.indexUp=function(index)
     {
         return this.map[index].value;
     };
     this.lookUp=function(key)
     {
          for (var i = 0; i < this.map.length; i++)
          {
            if ( this.map[i].key == key )
            {
              return this.map[i].value;
            }
          } 
          return null;
      };
     this.removeKey=function(key)
     {
          var v;
          for (var i = 0; i < this.map.length; i++)
          {
            v = this.map.pop();
            if ( v.key == key )
              continue;
              
            this.map.unshift(v);
          }
      };

    this.getCount=function()
    {
      return this.map.length;
    };

    this.isEmpty=function()
    {
      return this.map.length <= 0;
    };
}