Click here to Skip to main content
15,849,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am having some 10000's messages in a file (consider emails in a pst file)

I need to create an index file to search the whole messages quickly. There would be some custom tags support for search too.(like "In subject Only", "In To field" etc)

Kindly let me know if anyone has a good approach for creating index file and corresponding search.

Google Desktop, Windows 7 instant file search, Outlook email search do pretty well
(with respect to my current program)

I have goggled this extensively about didn't get a right direction to proceed.
All what I have currently is an approach where I create tags and their file-pointer,and in table way and then do a fseek to it.
But I am not sure those would work effectively at the end of day.

All ideas welcome.
Thanks for any help in advance!
Updated 30-Jun-11 18:59pm

1 solution

I'd create a map for each index. That way the effort to look up a particular entry is constant, it just takes some time to create the map, but that is already solved perfectly within map.
Share this answer
harish85 1-Jul-11 11:42am    
Thanks you Stefan, But what do we have in the map? "tags and file_pointer"?
map will require its implementation in C,but I am exploring that option!
Stefan_Lang 4-Jul-11 4:29am    
No need to implement your own, use the STL class map. See for reference.

Nate that you can create elements for the map using the STL function make_pair<keytype,valuetype>(KeyType key, ValueType val). For example here's a map that stores strings by some integer id:

#include <string>
#include <pair>
#include <map>
#include <io>
using std;

typedef pair<int,string> StrID;
typedef map<int,string> StrLookup;

void test() {
StrLookup myStringIndex;
myStringIndex.insert(make_pair(2, string(", ")));
myStringIndex.insert(make_pair(3, string("world")));
myStringIndex.insert(make_pair(1, string("hello")));

cout << myStringIndex[1].second // "hello"
<< myStringIndex[2].second // ", "
<< myStringIndex[3].second // "world"
<< endl;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900