Steve Ochani wrote:
On 10 Dec 2007 at 16:02, David kerber wrote:


I'm running this app in a tomcat 5.5.x container,I am trying to
figure out which form of a list is the best for what I need to do here:

I need to have some kind of list or collection that I can search
quickly for a specific entry, and then start stepping through the list item by item from that point. The items in the list are all of the same user-defined class (not primitives or pre-defined java classes). My current implementation just uses an iterator starting at the beginning, and just walking through until I find the item I want, and continuing to walk from there, but I'm running into performance issues with this.

The individual lists aren't particularly big:  single-digits to at
most a couple hundred items, but I do this processing in a big outer loop
which will need to scale up to a few thousand iterations of
different instances of these lists. What these actually are is individual stores' inventory data, with each list being a list of their inventory data for a month or so, and I will eventually need to iterate over a couple
thousand stores for reporting.

Where is this data coming from?
It's being read from a db.

I would personally use a combo of LinkedList
http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html

where each node would have something like an id of the store and use that id to retrieve the data from a database.
Thanks for the suggestion, Steve. That's essentially what I'm doing in the "outer loop" I mentioned in my OP. The searching inside each list is because I need to combine (possibly) multiple shifts worth of data into a single day for reporting each site. The other thing I have thought about but haven't tried yet is to use arrays and do some kind of external indexing to allow me to quickly find the piece of data I need. The main issue, which I didn't mention in my OP, is that each site has 3 different lists (data from 3 different db tables: sales, receipts, and daily closing inventory) to keep coordinated, so that I am grabbing the correct data for each day's report line.

Keeping less data in each node should make searching the list fast.

Another idea would be to use hashtable of linked lists but it all depends on what you're searching.


-Steve O.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to