网站制作

本类阅读TOP10

·IIS 安装配置全攻略
·用VS.NET打开网上下载的.NET web项目出错的解决办法
·HTML 4.0 语言快速参考
·限制TextArea区的文字输入数量
·如何在网页上实现进度条
·Apache的配置步骤及测试
·谈谈Jesse James Garrett提到的Ajax
·html基础学习笔记(2)
·页面垂直居中的两种方法
·用asp遍历目录下文件的例子

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
javascript函数库:HashSet.js

作者:未知 来源:月光软件站 加入时间:2005-6-5 月光软件站

/**
* use as java.util.HashSet
*/

function testHashSet(){
 alert("HashSet test begin:");
 try{
 }
 catch(e){
  alert(e);
 }
 alert("HashSet test end");
}

function HashSet(){ 

    private:
 this.map=new HashMap();
 this.ZERO=new Integer(0);


 
 function HashIterator(it){
        this.it=it;
  
  this.hasNext=hasNext;
  function hasNext() {
   return this.it.hasNext();
        }

        this.next=next;
  function next() {
   return this.it.next().getKey();
        }
    }
 
 public:
 this.size=size;
 function size(){
  return this.map.size();
    }

    this.isEmpty=isEmpty;
 function isEmpty() {
  return this.map.isEmpty();
    }

 this.contains=contains;
 function contains(o) {
  return this.map.containsKey(o);
    }
 
 this.add=add;
 function add(o) {
  return this.map.put(o,this.ZERO)==null;
    }

 this.addAll=addAll;
 function addAll(set){
  var mod=false;
  for(var it=set.iterator();it.hasNext();){
   if(this.add(it.next())) mod=true;
  }
  return mod;
 }

 
 this.remove=remove;
    function remove(o) {
  return this.map.remove(o).equals(this.ZERO);
    }
 
 
    this.clear=clear;
 function clear() {
  this.map.clear();
    }
 
 
 this.iterator=iterator;
 function iterator(){
  return new HashIterator(this.map.iterator());
 }

 
 this.equals=equals;
 function equals(o) {
  if (o.size() != this.size())
   return false;
        for(var it=this.iterator();it.hasNext();){
   if(!o.contains(it.next())) return false;
  }
  return true;
 }
 
 this.hashCode=hashCode;
 function hashCode() {
  var h=0;
  for(var it=this.iterator();it.hasNext();){
   h+=it.next().hashCode();
  }
  return h;
 }
 
 this.toArray=toArray;
 function toArray(){
  var arr=new Array();
  var i=0;
  for(var it=this.iterator();it.hasNext();){
   arr[i++]=it.next();
  }
  return arr;
 }
 
 
}




相关文章

相关软件