Results 1 to 2 of 2

Thread: override hash set and equals problem

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default override hash set and equals problem

    Hello,
    got a probem:
    Qt Code:
    1. class Var {
    2. String name, type;
    3. }
    4. class A {
    5. String flag;
    6. public Map<String,Integer> names = new LinkedHashMap<String, Integer>();
    7. public Map<Var, Integer> paramList = new LinkedHashMap<Var, Integer>();
    8. }
    9. //main
    10. Map<A, Set<B>> map = new LinkedHashMap<A, Set<B>>();
    11. //now I must put stuff inside the map
    To copy to clipboard, switch view to plain text mode 

    I need override but a1.equals(a2) if it has equal:
    - flag
    - Var.type (and not the name)

    I overrode by Eclipse just for the flag and added this to the equal:
    Qt Code:
    1. if (paramList == null) {
    2. if (other.paramList != null)
    3. return false;
    4. // } else if (!paramList.equals(other.paramList))
    5. // return false;
    6.  
    7. } else if ( !this.getATypeParameters().equals( other.getATypeParameters()) )
    8. return false;
    To copy to clipboard, switch view to plain text mode 
    getATypeParameters is my function that return a Set of Var.type. Apparently work; does it make sense? Is it fine?
    thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: override hash set and equals problem

    Hello can't anybody advice me?
    thanks
    Regards

Similar Threads

  1. How to get sha1 hash
    By lyuts in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2012, 15:35
  2. Hash a file with QT
    By manekineko in forum Qt Programming
    Replies: 5
    Last Post: 21st April 2010, 06:55
  3. Replies: 6
    Last Post: 22nd March 2010, 08:57
  4. Basic hash problem
    By feraudyh in forum Newbie
    Replies: 6
    Last Post: 4th December 2009, 08:59
  5. Are there functions to make md5 hash
    By learning_qt in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2009, 04:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.