Click here to Skip to main content
16,011,502 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Fastest Search Technique Pin
Jason Henderson5-Jun-02 9:31
Jason Henderson5-Jun-02 9:31 
GeneralRe: Fastest Search Technique Pin
Joel Holdsworth5-Jun-02 10:02
Joel Holdsworth5-Jun-02 10:02 
GeneralRe: Fastest Search Technique Pin
Sidney5-Jun-02 10:10
Sidney5-Jun-02 10:10 
GeneralRe: Fastest Search Technique Pin
Christopher Lord5-Jun-02 10:29
Christopher Lord5-Jun-02 10:29 
GeneralRe: Fastest Search Technique Pin
Paul M Watt5-Jun-02 10:40
mentorPaul M Watt5-Jun-02 10:40 
GeneralRe: Fastest Search Technique Pin
Sidney5-Jun-02 11:09
Sidney5-Jun-02 11:09 
GeneralRe: Fastest Search Technique Pin
Paul M Watt5-Jun-02 12:20
mentorPaul M Watt5-Jun-02 12:20 
GeneralRe: Fastest Search Technique Pin
jan larsen6-Jun-02 0:05
jan larsen6-Jun-02 0:05 
If you only want to search the file and your strings are as you say fixed, then this is also a possibility:

Map your file using CreateFileMapping() and MapViewOfFile() from the Win32 API.
The filemapping lets you access your file as if it was a chunk of memory, and the OS takes care of all the IO stuff in the background.

MapViewOfFile() returns a pointer that you can pass as the basepointer to bsearch() from the C-runtime (stdlib.h).
This function does a binary search using a base pointer to an array of items, the size of each item (that's why the strings have to be fixed) and a function pointer to a function that can compare two strings (you could easily wrap strcmp() or lstrcmp() for this purpose).

This technique should be the fastest way of searching, but if insertion is an issue, then of course you should use trees.


"It could have been worse, it could have been ME!"
GeneralRe: Fastest Search Technique Pin
Ed Gadziemski5-Jun-02 12:32
professionalEd Gadziemski5-Jun-02 12:32 
GeneralRe: Fastest Search Technique Pin
Paul M Watt5-Jun-02 12:43
mentorPaul M Watt5-Jun-02 12:43 
GeneralIcons in Dialogs Pin
Dov Sherman5-Jun-02 8:35
Dov Sherman5-Jun-02 8:35 
GeneralRe: Icons in Dialogs Pin
Mike Nordell5-Jun-02 9:36
Mike Nordell5-Jun-02 9:36 
GeneralRe: Icons in Dialogs Pin
Ed Gadziemski5-Jun-02 12:33
professionalEd Gadziemski5-Jun-02 12:33 
GeneralMutex problem Pin
Hans Ruck5-Jun-02 8:14
Hans Ruck5-Jun-02 8:14 
GeneralRe: Mutex problem Pin
Mike Nordell5-Jun-02 9:40
Mike Nordell5-Jun-02 9:40 
GeneralRe: Mutex problem Pin
Hans Ruck5-Jun-02 21:07
Hans Ruck5-Jun-02 21:07 
GeneralRe: Mutex problem Pin
Mike Nordell6-Jun-02 9:57
Mike Nordell6-Jun-02 9:57 
GeneralRe: Mutex problem Pin
John M. Drescher6-Jun-02 10:06
John M. Drescher6-Jun-02 10:06 
GeneralRe: Mutex problem Pin
John M. Drescher6-Jun-02 10:11
John M. Drescher6-Jun-02 10:11 
Generalstring to wstring conversion Pin
5-Jun-02 7:41
suss5-Jun-02 7:41 
GeneralRe: string to wstring conversion Pin
Mike Nordell5-Jun-02 7:57
Mike Nordell5-Jun-02 7:57 
GeneralVC++ XML integration Pin
5-Jun-02 7:31
suss5-Jun-02 7:31 
GeneralRe: VC++ XML integration Pin
Nemanja Trifunovic5-Jun-02 7:48
Nemanja Trifunovic5-Jun-02 7:48 
GeneralError when using EnumObjects function. Pin
redeemer5-Jun-02 7:16
redeemer5-Jun-02 7:16 
GeneralRe: Error when using EnumObjects function. Pin
Cathy6-Jun-02 9:43
Cathy6-Jun-02 9:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.