Originally posted by steve souza:
You would have to answer bills questions to get a definitive answer, but if you only care about about the index number when you do a 'get' you may be able to do a binary search and count the steps that it takes to get to your destination. That assumes an ordered collection.
say your collection has 1,000,000 entries. You start by looking at element 500,000. If that is less than your value you would take element 750,000 (if less then you would take element 250,000), and keep halving the interval until you reach your destination. The number you land at is the correct number. If you delete or add any elements the number will adjust itself.
Originally posted by Ilja Preuss:
Collections.binarySearch will do exactly that.
Originally posted by Nicholas Jordan:
On an un-sorted Set or List?
That assumes an ordered collection.
Originally posted by William Brogden:
I keep hoping the original poster will come back and explain more about the problem
Possible approaches keep occuring to me but they all depend on the answers to the questions I originally posted.