English 中文(简体)
HashMap钥匙hcode可能失败?
原标题:HashMap key hashcode may fail?
  • 时间:2012-04-10 22:32:02
  •  标签:
  • hashmap

Okay guys, 我正在用我的一个班子做“关键”的工作。

我的问题是:当我一次性获得正确项目时,能否在另一时间获得坏物品?

I mean, I implemented a hashcode algorithm that I view here on another question. And sometimes I get the correct item, another times I dont get it.

Any guess ? is it possible to find one time and right the second time cant find it ? I am not deleting it !

预留时间!

最佳回答

当然,你不需要一致性。 如果用同一算法计算,同一项目的散射值必须始终相同。

回答您的问题的一个可能答案是,你正在使用在第一次搜查和第二次搜查之间修改的物体的某些内部价值进行计算。

你们可能会发生碰撞,因为两个价值观被描绘成同样的散射价值,但你可能掌握着第一次奏效的东西,而第二次失败了。

问题回答

暂无回答




相关问题
Something like HashMap but sorted?

I m writing a Java program that parses all the words from a text file and then adds them to a HashMap. I need to count how many distinct words are contained in the file. I also need to figure out the ...

get string value from HashMap depending on key name

I have a HashMap with various keys and values, how can I get one value out? I have a key in the map called my_code, it should contain a string, how can I just get that without having to iterate ...

Is there a Java equivalent of Python s defaultdict?

In Python, the defaultdict class provides a convenient way to create a mapping from key -> [list of values], in the following example, from collections import defaultdict d = defaultdict(list) d[1]....

Internal implementation of java.util.HashMap and HashSet

I have been trying to understand the internal implementation of java.util.HashMap and java.util.HashSet. Following are the doubts popping in my mind for a while: Whats is the importance of the @...

Java HashMap performance optimization / alternative

I want to create a large HashMap but the put() performance is not good enough. Any ideas? Other data structure suggestions are welcome but I need the lookup feature of a Java Map: map.get(key) In ...

Is HashMap in Java collision safe

I am developing a parser that needs to put key value pairs in hashmap. A key can have multiple values which I can do in this way HashMap<String,ArrayList<String>> . What happens if the ...

C++ STL unordered_map problems and doubts

after some years in Java and C# now I m back to C++. Of course my programming style is influenced by those languages and I tend to feel the need of a special component that I used massively: the HASH ...

热门标签