ok, ppl......
i've got a new problem......
im workin on a package at my coll here and im doin spreadsheet....
i have to implement it using linked list and am having trouble in deciding what sort of a linked list i use.... Wat i tht of was, i can first with an empty list and as the cells are filled, only those which have content in them have to be in the list.... If a cell that had content is made empty, then this has to be removed from the list..... i've been thinkin over this for sometime..... this implementation in a spreadsheet involves no complex manipulation.... i need to retrieve it to display on the screen in cells..... Can any of u guys help me out in deciding the type of list......

11 Years
Discussion Span
Last Post by Lord Soth

OK.... lemme see if i can be more coherent......
Im trying to do a spreadsheet in c language similar to lotus 123 but ofcourse with not as many features..... it involves only basic functions that a spreadsheet can do...... For this i have to have a data structure to store the various cells in the spreadsheet..... The problem i have is that this has to be done using linked lists.... so, surely i cannot be using a singly linked list, probably not even a doubly linked list..... So, i need some help in deciding the type of list i need to select to implement in my program..... well, the thing to be remembered is - that the linked list must be easy to retrieve coz spreadsheets involve only retrieval, insertions and less frequent deletions.... Can any1 help??



It is a good question indeed, I think you should use a dynamically allocated 2D array of pointers to a Cell struct. (or class if you use c++ and need OO) Let's say initially you allocate space for 100x100 pointers = 40KB. To check if a cell is empty, check if the pointer for that coordinate is null, if you want to use that cell, dynamically allocate space for cell struct (or instantiate a cell object if you use c++) and let the pointer point this. The question is what to do when you need to access beyond 100x100 then just allocate a new 2d array of pointers of adequate size (say 200x100 100x200 or even 1000x1000 < 4MB) and carefully memcpy each row to new array (you may use reallocate too, it would be easier) and release old array. If you don't want to store formatting data (font, color, bgcolor,etc..) on each cell, then create a struct/class style and let the cell type include a pointer to style type which has a single instance for each different style but linked to every cell using it. Nice huh ?

Lore Soth

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.