BrianMc1958
asked on
Can a HashSet be ordered on a non-key field?
Dear Experts,
I have a HashSet containing "Customer" beans. Each bean contains a CustName and a CustScore. I override "equals" and "hash" using CustName only. CustScore is just an ordinary field in the bean.
However, I now need to determine which customers were in the top 10% of CustScores. I know I can do this by iterating the set, and then building and sorting internal arrays. But I'm wondering if there is some way to directly tell the HashSet, "Give me all the customer beans in CustScore order"?
Thanks,
BrianMc1958
I have a HashSet containing "Customer" beans. Each bean contains a CustName and a CustScore. I override "equals" and "hash" using CustName only. CustScore is just an ordinary field in the bean.
However, I now need to determine which customers were in the top 10% of CustScores. I know I can do this by iterating the set, and then building and sorting internal arrays. But I'm wondering if there is some way to directly tell the HashSet, "Give me all the customer beans in CustScore order"?
Thanks,
BrianMc1958
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
:)
Regards,
Muruga
--------------------------
Tryout personalized emailing services at http://www.mailaide.com