disk based dictionary - IO efficiency

Discussion in 'C Programming' started by qouify, May 29, 2007.

  1. qouify

    qouify Guest

    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
     
    qouify, May 29, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jas Shultz
    Replies:
    0
    Views:
    991
    Jas Shultz
    Dec 3, 2003
  2. Alex Hunsley

    local disk based JDBC implementation

    Alex Hunsley, Nov 3, 2004, in forum: Java
    Replies:
    11
    Views:
    739
    bilbo
    Nov 4, 2004
  3. Shivram U

    disk based dictionaries

    Shivram U, Dec 2, 2004, in forum: Python
    Replies:
    2
    Views:
    290
    Chris Cioffi
    Dec 3, 2004
  4. Ilias Lazaridis
    Replies:
    6
    Views:
    480
    Ilias Lazaridis
    Feb 21, 2006
  5. Replies:
    12
    Views:
    536
    santosh
    Nov 15, 2006
Loading...

Share This Page