简体   繁体   English

对哈希表执行包含操作

[英]perform contains operation for hashtable

I have a hashtable "listUserEvents' which is of the form string,vector. I am trying to see if the hashtable has some data for the given string or not. 我有一个哈希表“ listUserEvents”,其形式为字符串,向量。我试图查看哈希表是否具有给定字符串的某些数据。

listUserEvents = getUserInfo();
for (int i = 0; i < compareEventData.size(); i++) {
          EventData eventForExistingDate = (EventData) compareEventData.elementAt(i);
//here i want to check if listUserEvents  the hashtable has eventForExistingDate.getSummary() for string "hello"
}

how to perform this? 如何执行呢?

If I understand the question correctly, you just want: 如果我正确理解了这个问题,您只需要:

if (listUserEvents.containsKey("hello"))
{
    ...
}

Your description isn't very clear though, as now we're not using eventForExistingDate ... 不过您的描述不是很清楚,因为现在我们不使用eventForExistingDate ...

Note that if you use generic collections, you're unlikely to need the cast in the previous line. 请注意,如果您使用通用集合,则不太可能需要在前一行进行强制转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM