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
          蹭分,走人!  回復  更多評論
            

          主站蜘蛛池模板: 绥德县| 安仁县| 千阳县| 松阳县| 霞浦县| 涿鹿县| 甘洛县| 荣成市| 开远市| 梅河口市| 清涧县| 潞西市| 安龙县| 伊宁市| 前郭尔| 景东| 阜康市| 河间市| 玛沁县| 且末县| 子长县| 项城市| 乐平市| 昔阳县| 建水县| 奉贤区| 乌什县| 海丰县| 洞口县| 乐清市| 仙游县| 清河县| 巍山| 同江市| 白银市| 长乐市| 绵竹市| 山西省| 建瓯市| 惠东县| 兴义市|