CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009

    Question Alocating damanice memory link list .....

    hi everyone here is what I am trying to do.
    I am building a link list which the element are [last|element |next];
    which the link list 2 directional [do not worry about it ...]
    any way the issue is that he [ELEMENT ] is a damanic array of ints, because I do not know the size of the array off hand.

    SO: my question: how should I define in my list.h?

    in list.h
    ?????? row; // what should be the type??? int*?
    ListNode * next;
    ListNode * previuse;

    how would I set the element assuming I have

    in main() ; I have :
    int* a = {1,2,3,4 ,5,6,7,8,9,....} //we do not know how long assuming length = n
    int *b;
    List listing;

    listing.setrow(a); //save it

    b = listing.getrow();

    what should my list.h should look like to save and return it ?

    ??????? List::getrow(); // maybe int*? I do not know
    void setrow(?????? a);

    and finally how should they look like in list.cpp???

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Seattle, WA

    Re: Alocating damanice memory link list .....

    You should break this up into two separable problems----how to represent the dynamic array, and how to represent the linked list.

    If you were using STL, for instance, your data structure would be a std::list< std::vector<int> >.

    You *can* simply make the payload type of the list be an int*, but that's not always useful on its own. At the very least you should associate a size with each array, such as
    struct DynamicArray
        int *arr;
        size_t size;
    But that still leaves you with a great deal of manual bookkeeping to do; you can be far more clever if you wish to be in that regard.

  3. #3
    Join Date
    Oct 2009

    Question Re: Alocating damanice memory link list .....

    Thanks a lot
    How about if I just want to solve any size of matrix in C++, is there any code I could just use.
    Since an small part of my program needs to solve lots of equations like :

    b+f+d = 3
    a+b+f+i+h =2
    and so on
    very fast

    and the number of variables could be more than 400 !!! so memory uses and speed is very VERY VERY important !!!! I do not care about the memory, but the SPEED is important [sorry I am keep saying that]

    is there any solution out there I could use any lib or code???

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Seattle, WA

    Re: Alocating damanice memory link list .....

    LAPACK is the prototypical linear algebra library. Optimized versions are available from several processor vendors, tuned to their specific hardware.

    However, it's written in Fortran. You can call it from C, but there are a few gotchas in doing so, mainly the fact that C uses rowmajor matrix ordering while Fortran uses columnmajor.

    There are some C++ implementations on top of it which may be easier to use. Boost.uBLAS and MTL are two of them. I don't think they support full LAPACK functionality, but at least the basic BLAS matrix math should be in there.

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.