☆藍色夢想☆

          世界總是反反覆覆錯錯落落地飄去 來不及嘆息 生活不是平平淡淡從從容容的東西 不能放棄
          posts - 57, comments - 5, trackbacks - 0, articles - 0

          js寫的Hashtable類

          Posted on 2006-08-16 23:22 ☆藍色夢想☆ 閱讀(281) 評論(0)  編輯  收藏 所屬分類: AJAX
          < script?language = " javascript " ?type = " text/javascript " >

          function ?Hashtable()
          {
          ????
          this ._hash???????? = ? new ?Object();
          ????
          this .add???????? = ? function (key,value){
          ????????????????????????
          if ( typeof (key) != " undefined " ){
          ????????????????????????????
          if ( this .contains(key) == false ){
          ????????????????????????????????
          this ._hash[key] = typeof (value) == " undefined " ? null :value;
          ????????????????????????????????
          return ? true ;
          ????????????????????????????}?
          else ?{
          ????????????????????????????????
          return ? false ;
          ????????????????????????????}
          ????????????????????????}?
          else ?{
          ????????????????????????????
          return ? false ;
          ????????????????????????}
          ????????????????????}
          ????
          this .remove???????? = ? function (key){ delete ? this ._hash[key];}
          ????
          this .count???????? = ? function (){ var ?i = 0 ; for ( var ?k? in ? this ._hash){i ++ ;}? return ?i;}
          ????
          this .items???????? = ? function (key){ return ? this ._hash[key];}
          ????
          this .contains???? = ? function (key){? return ? typeof ( this ._hash[key]) != " undefined " ;}
          ????
          this .clear???????? = ? function (){ for ( var ?k? in ? this ._hash){ delete ? this ._hash[k];}}

          }

          var ?a? = ? new ?Hashtable();

          a.add(
          " aa " );
          a.add(
          " bb " , 2342 );
          a.add(
          " bb " , 2342 );

          a.remove(
          " aa " );

          alert(a.count());

          alert(a.contains(
          " bb " ));

          alert(a.contains(
          " aa " ));

          alert(a.items(
          " bb " ));


          </ script >
          主站蜘蛛池模板: 遂平县| 常熟市| 永兴县| 德庆县| 昂仁县| 上林县| 明光市| 嵊泗县| 山阳县| 克山县| 专栏| 阳信县| 尖扎县| 军事| 政和县| 石嘴山市| 恩施市| 宣汉县| 青海省| 阜南县| 天津市| 内黄县| 河池市| 平凉市| 东乌| 巴彦淖尔市| 都兰县| 昌黎县| 莫力| 吉安市| 新河县| 望城县| 黔东| 息烽县| 婺源县| 乌鲁木齐县| 资兴市| 永州市| 宁南县| 宽甸| 屏边|