RT

解决方案 »

  1.   

    hash_set<YourType, YourHashFcn> YourHashSetObject;
      

  2.   

    YourType, YourHashFcn分别是什么类型
      

  3.   

    YourType是你希望你的hash_set容器里面存放的数据类型啊。比如hash_set<int>。
    YourHashFcn就是你想要设置的哈希函数函数指针或函数对象。
      

  4.   

    Java的HashSet<E>使用的hash值是由你放入的那个元素的hashCode()来实现的比如说
    HashSet<String> hashset=new HashSet<String>();
    String str="fox_for_cloud";
    hashset.add(str);这时,HashSet用来放置str实例的hash值由str.hashCode()给出的
    hashCode()是在Object类里面定义的 如果你放入HashCode的实例的类没有重写过hashCode()的话 就会使用Object类里面定义的哪个 这时hash值就是这个实例的内存地址 这是java中唯一出现过内存地址的地方