六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 5|回复: 0

散列过滤

[复制链接]

升级  93.33%

52

主题

52

主题

52

主题

秀才

Rank: 2

积分
190
 楼主| 发表于 2013-2-4 19:49:58 | 显示全部楼层 |阅读模式
1.在一些字符串数组中,常会有重复的记录,比如手机号码,我们可以通过Hashtable来对其进行过滤
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6 0% 50%; padding-bottom: 4px; width: 95%; padding-top: 4px;">public String[] checkArray(String[] str)...{
        Hashtable
<String, String> hash=new Hashtable<String, String>();

        
for(int i=0;i<str.length;i++)...{
            
if(!hash.containsKey(str))
                hash.put(str, str);
        }


        Enumeration enumeration
=hash.keys();
        String[] str_new
=new String[hash.size()];
        
int i=0;

        
while(enumeration.hasMoreElements())...{
            str_new
=enumeration.nextElement().toString();
            i
++;
        }

        
return str_new;
    }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表