I’m wondering if there is an IList<T> implementation that’s backed by a hash like HashSet<T> but offers indexed access?
To be clear, I’m not concerned on how to implement one, just wondering if anyone knows if it’s already available.
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.
You could implement
IList<T>yourself and keep two backing collections – aList<T>and aHashSet<T>. Basically get Visual Studio to provide a “throw exception” implementation for everything inIList<T>, then for each method work out whether you want to proxy it to the list or the set.Of course you’d have to be careful for duplicates etc (define the behaviour of
Add(x),Add(x),Remove(x),Contains(x)– you could end up with it in the list but not the set) but it wouldn’t be too hard.