»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 10-01-2003, 06:25 PM   #1 (permalink)
Registered User
 
Join Date: Oct 2001
Posts: 691
zskillz is on a distinguished road
Send a message via AIM to zskillz
how is the "find" algorithm in text editors constructed?

I'm going to have to write a program that parses through a very large text file looking for an instance of a specific word....

in the past, I've just read it line by line, and searched each token for a match to what I want... however, this seems like it'd be really really slow. So I'm curious how programs like wordpad/notepad, etc. do it. I feel like I could really cut down on a lot of wasted time if I could mimic that implementation...

so I'm looking for suggestions or any sort of help that you have to offer!

thanks in advance,
-Z

zskillz is offline   Reply With Quote
Old 10-02-2003, 06:56 AM   #2 (permalink)
Registered User
 
SpookyEddy's Avatar
 
Join Date: Oct 2001
Location: UK
Posts: 3,125
SpookyEddy is on a distinguished road
I would select your open source text editor of choice, grab its source code and have a quick look how they implement search functions. I had a quick check and vim, emacs and nano all have a search.c that should give you some ideas, link lists seem to be mentioned.

Regards

ed
SpookyEddy is offline   Reply With Quote
Old 10-02-2003, 10:30 PM   #3 (permalink)
Banned
 
Join Date: Sep 2003
Posts: 35
pedantic is on a distinguished road
Quote:
however, this seems like it'd be really really slow.
was it really slow in the past? like, when you did it?

text editors simply search the string/stream/char_array that is in memory. no reason for file/io, just memory search.
pedantic is offline   Reply With Quote
Old 10-02-2003, 10:59 PM   #4 (permalink)
Registered User
 
Nighthawk's Avatar
 
Join Date: Oct 2001
Location: Univ. of Wash. Seattle, WA
Posts: 1,915
Nighthawk is on a distinguished road
It depends on the language you're using. I think the way I'd do it is to write it in Perl using a regular expression and make it into a module.. I'm not sure whether other languages have regexp or not.
Nighthawk is offline   Reply With Quote
Old 10-03-2003, 03:56 PM   #5 (permalink)
Registered User
 
Join Date: Oct 2001
Posts: 691
zskillz is on a distinguished road
Send a message via AIM to zskillz
So I'm doing this in java right now, but I'll probably convert it to C or C++ (more likely) in the future.

The files that I'm going to be searching through are going to be multiple thousands of lines of code... possibly up to 100k+ lines. (these are the output files of electronic structure calculations on various molecules). The output is so long because this technique is a self-consistant field (SCF) calculation, so it takes the results from the current run - prints them - then reinserts them into the new run. These repeats until the convergence tolerence is reached....

anyway... it's sort of beside the point. I'm looking for a way to rip a chunk of the output from the code (the final output actual) and then I'll be doing calculations based on the output that I take....

I was just hoping to find a faster/more efficient way to get to the information that I want then going line by line through these gigantic files.

any other ideas are invited and appreciated.

thanks
-Z
zskillz is offline   Reply With Quote
Old 10-03-2003, 09:48 PM   #6 (permalink)
Banned
 
Join Date: Sep 2003
Posts: 35
pedantic is on a distinguished road
Quote:
any other ideas are invited and appreciated.
except mine...

Quote:
I was just hoping to find a faster/more efficient way to get to the information that I want then going line by line through these gigantic files.
stop searching, line by line, read the gigantic file at once, then search for token!

how slow was it in the past?
pedantic is offline   Reply With Quote
Old 10-03-2003, 10:03 PM   #7 (permalink)
Registered User
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: New York
Posts: 1,588
VHockey86 is on a distinguished road
Try searching the web for source code on "find" functions
VHockey86 is offline   Reply With Quote
Reply




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
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 10:16 PM.