home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

how is the "find" algorithm in text editors constructed?

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2089
Discussions: 200,959, Posts: 2,379,528, Members: 246,329
Old October 1st, 2003, 09:25 PM   Digg it!   #1 (permalink)
Senior Member
 
Join Date: Oct 2001
Posts: 881
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 October 2nd, 2003, 09:56 AM     #2 (permalink)
may contain mild peril
 
SpookyEddy's Avatar
 
Join Date: Oct 2001
Location: UK
Posts: 3,329
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
__________________
I dreamt that a large eagle circled the room three times and then got into bed with me and took all the blankets.
SpookyEddy is offline   Reply With Quote
Old October 3rd, 2003, 01:30 AM     #3 (permalink)
Banned
 
Join Date: Sep 2003
Posts: 35
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 October 3rd, 2003, 01:59 AM     #4 (permalink)
Ultimate Member
 
Nighthawk's Avatar
 
Join Date: Oct 2001
Location: Montreal, QC
Posts: 1,950
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 October 3rd, 2003, 06:56 PM     #5 (permalink)
Senior Member
 
Join Date: Oct 2001
Posts: 881
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 October 4th, 2003, 12:48 AM     #6 (permalink)
Banned
 
Join Date: Sep 2003
Posts: 35
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 October 4th, 2003, 01:03 AM     #7 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,334
Try searching the web for source code on "find" functions
VHockey86 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2969)
The disrespect of Obama by Russian .. (42)
Making Health Care Worse (178)
Wireless Televisions. (12)
CPU fan stops spinning randomly (9)
Regular Build (11)
windows 7 problem (7)
Laptop with wireless problem. (5)
windows vista security holes (13)
Is the PSU I received dead? (12)
Print spooler problem (15)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
Recent Discussions
Nvidia GTX 260 problem (0)
windows vista security holes (13)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
Open With ..... Win7 (1)
webcam (0)
upgrade for hp a6101 (0)
Laptop with wireless problem. (5)
Modern Warfare 2: Who Bought It? (64)
tv not turn on-makes clicking sound (2)
CPU fan stops spinning randomly (9)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Point and Shoot Camera Suggestions. (4)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)
How to convert MP3's (4)
Wireless Televisions. (12)


All times are GMT -4. The time now is 09:47 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28