CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    May 2008
    Posts
    6

    Best data structure for notepad application

    Can any one pls tell me which data structure will best suit the application - notepad.......? Justify as to how its best suited.............



    Thanking u in advance....

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Best data structure for notepad application

    Binary, so you can't read it?

    Is this a homework question? Have you tried GOOGLE?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2008
    Posts
    6

    Re: Best data structure for notepad application

    no ths s not a home work question........

    its a question asked in the technical interview for jobs........

    i had thought about the data structure 'trie'.........

    bt i cld nt obtain a reasonable answer..........


    thats why i posted it here...........

  4. #4
    Join Date
    May 2008
    Posts
    6

    Re: Best data structure for notepad application

    I had tried google............bt still was not satisfied............

  5. #5
    Join Date
    Apr 2008
    Posts
    6

    Re: Best data structure for notepad application

    It will be good to use linked list of fixed sized (may be) arrays of chars for notepad like text handling!

  6. #6
    Join Date
    May 2008
    Posts
    6

    Re: Best data structure for notepad application

    Quote Originally Posted by mandeep2
    It will be good to use linked list of fixed sized (may be) arrays of chars for notepad like text handling!

    but you will not be able to move around the text while editing.......... it becomes difficult for you right..........?

    it should also be convenient for you to move around the text.......?

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Best data structure for notepad application

    Xml
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    May 2008
    Posts
    6

    Re: Best data structure for notepad application

    what do you mean by simply mentioning as xml?

  9. #9
    Join Date
    Jan 2006
    Posts
    25

    Re: Best data structure for notepad application

    if you mean a data structure to store the text typed in notepad, than string would no doubt be one of the most (if not the most) suitable data structure for notepad application since notepad basically handles, well.. string.

    in many languages string is treated just as other builtin datatypes, making most people think that string is just a primitive datatype like bool, int, or char. The truth is that string is actually a char container, making it practically a data structure. a string implementation can utilise any kind of data structure available (linked list and array being the most simple). Implementation wise, we can leave the worries to the language and library designer and simply use what the language & std. library provide (e.g. std::string on c++, String on java, etc).

    just my 2cents
    Last edited by INA_ctive; May 16th, 2008 at 04:58 PM.

  10. #10
    Join Date
    May 2008
    Posts
    6

    Re: Best data structure for notepad application

    Yes,

    Ur suggestion was correct.........

    Actually string is also a good one..............

    Thanks a lot yere.............

  11. #11
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Best data structure for notepad application

    For larger text files, string it not a good solution - for both non-terminated C-style strings or strings which store their length. What if you need to insert some text at the beginning of document (say at 50th character, in a 2MB document). You need to run a loop even for one character insert/delete till 2000000+ counts?

    I would recommend using linked list (or std::list), and store each line as list' one element. Each list' element would be 'string' - which you may limit to few KBs. Any replace, insert, delete would be just replacing the string contents for that line. This would, of course, not require whole 'list' object to be traversed.
    Now here comes the hard part: when there is line break, or merging of two lines - the two list' elements needs to be merged. Say 6th and 7th lines are merged, you need to append 7th line content into 6th, and delete the 7the line from list. 8th line would now become 7th and so on.
    Special taken must be taken care of of multiple lines are being deleted, inserted or replaced - this might be complicated, but appropriate solution.
    Similar thing needs to be done where a single line is being breaked into two lines (a simple Enter key would do!).

    But if your text-editor would be limited (or you place this limitation) to few KBs, you can straightly use string as data-structure. Remeber Notepad.EXE used to support only 65K files?
    Last edited by Ajay Vijay; May 17th, 2008 at 12:55 AM.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  12. #12
    Join Date
    Jan 2011
    Posts
    1

    Re: Best data structure for notepad application

    I have a problem of what type of data structure of my mobile dictionary application. I use notepad to save data. From my program I call the data that save on notepad. pls help me of what data structures that if I save data as a textfile.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured