李敏  
日历
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
统计
  • 随笔 - 1
  • 文章 - 40
  • 评论 - 4
  • 引用 - 0

导航

常用链接

留言簿(1)

文章分类

文章档案

相册

收藏夹

它山之石

聚贤庄

搜索

  •  

最新评论

 
 String tests[] = {
      
"aaaa""bbbb""aaaa"
    }
;

    Analysis 
< String > an = new Analysis < String > (tests);

    
//an.add("aaaa");
    
//an.add("bbbb");
    
//an.add(111);

    System.out.println(an.isOnlyOne());

/**
 *处理重复数 
 
*/

class Analysis < T > {
  
private Set < T > temp = new HashSet < T > ();

  
private int count = 0;

  
public Analysis(){

  }


  
public Analysis(T t){
    temp 
= new HashSet < T > (Arrays.asList(t));

    count 
= t.length;
  }


  
/**
   *添加数据 
   
*/

  
public void add(T t){
    temp.add(t);

    count
++;
  }


  
/**
   *检查是否有重复值 
   
*/

  
public boolean isOnlyOne(){
    
//容器的实际大小 
    int containerSize = temp.size();

    
return count == containerSize;

  }

}
posted on 2010-08-11 16:07 李敏 阅读(148) 评论(0)  编辑  收藏 所属分类: 算法

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © 李敏 Powered by: 博客园 模板提供:沪江博客