nikil shar wrote:thanks for the reply everyone. each of my service has a unique service_number which can be used to link packets to its service. i select all the services and packets from the database by doing a join and store them in a vector. Then i iterate over each element using the service_number to match the packets. Hopefully this makes it clearer as to what i am trying to achieve.
It still doesn't sound like you have anything to search on, and if that's the case you will not be able to speed up your search. And when you say a 'vector', do you mean a java.util.Vector? Because, if so, there are probably faster alternatives.
From the sound of it, I think your problem may lie in having all your data lumped together in a single set. If I were doing something like this, I'd probably split it in two:
Services and Packets
and then sort the Packets by service number. Or, if you absolutely have to have it all jammed together, sort the whole thing on [service number + packet sequence].
Also, do you actually have a Service class and a Packet class, and is your 'vector' made up of these objects? Or is it just a bunch of rows from a database SELECT statement?
Java works much better with objects than it does with raw data.
Winston