m_TrendItems is the global array which has almost 10,000 points for each pen. My question is instead of getting the trendpoint, i want to get the pointer for the (position or point).
I want to store this pointer in a separate array and use it in the future so that i don't have to go from the head position always.
How can i do this?
Do i have to go through all the time i have to find a point can't i store a pointer?
here i am wasting time by iterating through all the data points that were present. Instead of this what if i can break my 10 hours of data into 10 parts (each of one hour) and store the pointers for the beginning of each hour.
That way if i have to display points between 8 and 9 hours on the trend i will go to the pointer which has position of datapoint starting at 8th hour and then iterate from there. So instead of
position = m_TrendItems[pen].GetTrendPoints().GetHeadPosition();
i will have position = &pointer for 8th hour. How can i do this!!
Re: Obtain a pointer to data inside a trend items array
It definitely seems like you want a std::map or std::multimap. In particular, check out the lower_bound and upper_bound member functions. http://www.cplusplus.com/reference/stl/map/
Now, *if* the linked list is in sorted order and *if* it conforms to the STL container interface (it doesn't look to right now), then you could use std::lower_bound() directly on it without needing to use a map as the underlying container....but it would still be more efficient if you had random access iterators rather than merely bidirectional iterators, eg, you had a vector or deque rather than a list.
Last edited by Lindley; October 13th, 2010 at 10:10 AM.
Re: Obtain a pointer to data inside a trend items array
Ah---you're using MFC containers rather than STL containers. Well, I don't know those very well, but it's possible MFC has a binary tree container equivalent to std::map.....
Re: Obtain a pointer to data inside a trend items array
Originally Posted by amara.fortheworld@gmail.com
do you have any suggestions GCDEF?
No. I'm still confused about what data types you're working with and I'm tired of trying to figure it out.
GetHeadPosition and GetPrev are members of MFC's CList class. They return a POSITION. You can store that and use it to position yourself anywhere in the list you want. If you need a position in an array, just store the index.
Last edited by GCDEF; October 13th, 2010 at 11:02 AM.
Bookmarks