Which is the best way to determine whether a Hashtable contains all keys/values of another Hashtable ?
This can also be interpreted as: how to determine whether a Hashtable is a subset of another Hashtable.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Iterate over all the key/value pairs in the “smaller” hashtable and check whether they exist (with the right values) in the “bigger” hashtable, basically. You could do a
Countcheck to start with to check that the “smaller” table really is smaller (or the same size) to start with, of course.This will be O(n) where n is the size of the smaller hashtable, assuming reasonable hashes in the larger one and constant time equality checking. You can’t do better than that.