Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 29th, 2008, 7:40 PM   #1
TheAberrant
Newbie
 
Join Date: Jan 2008
Posts: 9
Rep Power: 0 TheAberrant is on a distinguished road
Question Question with Arrays - creating and updating 'top 5' list

The Story...
First post, so hoping to be clear and concise, but might end up wordy since it's pretty late at night.

I've got a parser that has time data along with some additional information contained within a number of logs. I'm creating a summary report of each log, based on information I parse out. One thing I do is determine the time difference between one item and the next, and want to print in this summary the highest five time differences (time difference and time data, as well as another field).

What I'm thinking...
Initially I thought I could use a 2-d Array and check the lowest number first (so $array[4]), and if it's less than that, continue on, if not then check the next element in the array until I find the element that it's less than. At that point I have to loop from the beginning again, shifting all elements down, and then copying the data appropriately.

Another idea was to continually add to the list, then sort every once in a while and just remove all but the top elements (this was something that would be easy to implement, but probably excessively CPU/memory intensive, as I go through about 10-12 thousand lines in each log). I had some other thoughts on Hashes and Linked Lists, but really not sure what the best solution would be. Am I heading in the right direction (so just code as I stated), or is there something easier (or possibly even already implemented...)

Thanks in advanced.
TheAberrant is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC