By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,376 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,376 IT Pros & Developers. It's quick & easy.

disk based dictionary - IO efficiency

P: n/a
Hello,
here is my problem. I have a dictionnary of words (e.g., type
char[N]) stored sequentially (but not sorted) in a file F and I want
to insert in it some words stored in memory in a balanced tree T.
some elements of T may already be in F and I do not want to have them
twice in F after insertion.
i want to do something like this:

for each word in F
- if word is in T
-- remove word from T
for each word in T
- append word to F

here is how I implemented it :
1 - open F in "r" mode
2 - read sequentially (with fread) the words in F and delete them from
T
3 - close F
4 - open F in "a" mode
5 - append (with fwrite) to F all the remaining words of T
6 - close F

my questions are:
1 - is this an efficient way to do, and is there a better way?
2 - are there any trick to know to improve efficiency?

Thanks for help

May 29 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
qouify wrote:
>
here is my problem. I have a dictionnary of words (e.g., type
char[N]) stored sequentially (but not sorted) in a file F and I
want to insert in it some words stored in memory in a balanced
tree T. some elements of T may already be in F and I do not want
to have them twice in F after insertion.
i want to do something like this:

for each word in F
- if word is in T
-- remove word from T
for each word in T
- append word to F
Look at id2id-20, written in std C, available under GPL at:

<http://cbfalconer.home.att.net/download/>

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 29 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.