I have a JTable that has 50,000 rows. Each row contains 3 columns. The middle column contains a double (price), and reads like this.
col1 col2 col3
1.0031
1.0032
1.0033
1.0034
1.0035
I then have a constantly updating array of about 10-20 prices that gets updated every 20ms.
Im currently iterating over that array, and checking it against the 50,000 rows to find the row it should belong to, and inserting it.
Then on the next update, Im clearing those columns, and repeating.
This is extremely costly though, as each update, I have to iterate over 20 prices, that then each iterate 50,000 times to find the value of the row they should belong to.
Theres gotta be a better way to do this... I really want to be able to just insert the price at a certain row, based on the price. (so each p rice is mapped to an index) if price = 1.0035 insert into row X
Instead I have to do something like If price is in one of 50,000 values, find the value index and insert.
Any ideas as the best way to achieve this?? Hashtable?? quadtree for localized search? Anything faster, because the way Im doing it is far to slow, for the application needs.