Leo's Blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            13 隨筆 :: 3 文章 :: 18 評論 :: 0 Trackbacks
          < 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 >
          posted on 2006-04-29 20:59 Leo 閱讀(480) 評論(2)  編輯  收藏 所屬分類: 技術隨文

          評論

          # re: js寫的Hashtable類 2006-06-21 11:38 google
          不錯,leo終于有新作了  回復  更多評論
            

          # re: js寫的Hashtable類 2006-06-21 13:31 anyang
          蹭分,走人!  回復  更多評論
            

          主站蜘蛛池模板: 海晏县| 安丘市| 萍乡市| 永城市| 石林| 甘洛县| 甘南县| 千阳县| 宜兰县| 舒城县| 寿宁县| 潜山县| 蒙城县| 肇东市| 鱼台县| 沙坪坝区| 丹巴县| 双柏县| 岳西县| 玛纳斯县| 隆化县| 昌都县| 横峰县| 尚义县| 桓台县| 黄陵县| 通榆县| 望谟县| 高淳县| 汤阴县| 皋兰县| 时尚| 兴城市| 松阳县| 长泰县| 洪江市| 梧州市| 灵宝市| 泰宁县| 庄河市| 康平县|