验证是否存在唯一字符串的组合 [英] Verify there is a combination of unique string

查看:95
本文介绍了验证是否存在唯一字符串的组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Details{
 String name;
 String age;
 String email;
 String location;
}

1)如果有中的详细信息列表列表<详细信息> 如何验证名称和电子邮件的组合是否唯一。 (即)对于单个电子邮件地址,不能有两个名称输入。

1) If there is List of Details as in List<Details> how to verify for a combination of name and email collectively unique. (i.e) For a single email address there cant be two name entry.

2)如何验证类文件中所有字段的组合是唯一的。

2) How to verify the combination of all fields in the class file is unique.

解决此问题的完美数据结构是什么?

what would be a perfect data structure to address this ?.

推荐答案

您可以通过之类的分隔符来哈希值,然后找到所有uniques或不是。 详细信息的哈希值在第一种情况下为 name +#+email ,且为 name +#+ age +#+ email +#+ location 在第二种情况下。
您可以使用 Hashmap 如果对于详细信息的每个实例都有指定的键(或散列),则查找重复项。

You can hash values by a separator like #, and then find that all uniques or not. Hash value for a Details is name + "#" + "email in the first case, and is name + "#" + age + "#" + email + "#" + location in the second case. You can using Hashmap to find duplicates if there is any with the specified key (or hash) for each instance of Details.

这篇关于验证是否存在唯一字符串的组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆