☆藍色夢想☆

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

          js寫的Hashtable類

          Posted on 2006-08-16 23:22 ☆藍色夢想☆ 閱讀(275) 評論(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 >
          主站蜘蛛池模板: 晋江市| 建瓯市| 安塞县| 西畴县| 丰顺县| 乐亭县| 邵武市| 古田县| 丹寨县| 新营市| 乌兰县| 庆城县| 韶关市| 浦县| 开封县| 桦甸市| 酉阳| 兴宁市| 全椒县| 景东| 鹤峰县| 昔阳县| 十堰市| 琼中| 莲花县| 蒙自县| 北辰区| 嘉鱼县| 夹江县| 卓尼县| 英德市| 沂水县| 永善县| 北川| 朝阳区| 时尚| 临潭县| 定兴县| 达日县| 固始县| 瑞安市|