1. Open file
2. Read line
3. Save values (Name ;Magnitude)
4. Save Name to save variable (saveName)
5. Create Array
6. Store values in array
7. Begin loop
8. Read file
7. If end of file clean up and close
9. If Name == saveName Store values in array
10. else Name <> saveName
-- create new array and store values in new array
-- Save Name to saveName variable
11. return to step # 7
I suspect you would want to do a collection to store the values (as opposed to an array. The reason for this is an array is a fixed size when defined, so there would be no way to re-diminsion the array if you have an inknown number of Names.
jerbo
Junior Poster in Training
84 posts since Sep 2004
Reputation Points: 11
Solved Threads: 1
Better way:
Use a Map with a String representation of the name.
As the values store Lists of magnitudes.
Then you can just do ((List)map.get(name)).add(magnitude) for each record.
You can't increase the size of arrays so using other data structures is a requirement.
As Map and List have what you want why not use them :)
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
1. Open file
2. Read line
3. Save values (Name ;Magnitude)
4. Save Name to save variable (saveName)
5. Create Array
6. Store values in array
7. Begin loop
8. Read file
7. If end of file clean up and close
9. If Name == saveName Store values in array
10. else Name <> saveName
-- create new array and store values in new array
-- Save Name to saveName variable
11. return to step # 7
I suspect you would want to do a collection to store the values (as opposed to an array. The reason for this is an array is a fixed size when defined, so there would be no way to re-diminsion the array if you have an inknown number of Names.
Opps, step 11 sould return to step # 8
jerbo
Junior Poster in Training
84 posts since Sep 2004
Reputation Points: 11
Solved Threads: 1