-
October 13th, 2010, 11:49 AM
#16
Re: Obtain a pointer to data inside a trend items array
i just gave that to shiw the looping logic i am going through:
pos = m_TrendItems[pen].GetTrendPoints().GetTailPosition();
if(pos)
trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos);
while(pos && trendpoint.m_time < m_selection.time)
{
trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos );
}
.GetTrendPoints() returns m_TrendPoints which is of type
typedef CList<CCsTrendPoint, CCsTrendPoint> CCsTrendPoints;
so technically i am working on CList m_TrendPoints;
m_TrendPoints.GetPrev(pos );
Gets the list element identified by pos, then sets pos to the POSITION value of the previous entry in the list.
now instead of getting the point, i want to get a pointer to the point something like:
trendpoint* = &m_TrendPoints.GetPrev(pos );
now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional, so that first dimension is pen and second dimension is index and value at it is the pointer
something like trendpoint[pen][i]*, how to do this?
-
October 13th, 2010, 11:54 AM
#17
Re: Obtain a pointer to data inside a trend items array
continued.........
trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of 1st hour)
trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of second hour)
trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of third hour) etc
like so for each pen.
-
October 13th, 2010, 12:07 PM
#18
Re: Obtain a pointer to data inside a trend items array
Originally Posted by amara.fortheworld@gmail.com
i just gave that to shiw the looping logic i am going through:
POSITIONS are not pointers -- POSITIONS are POSITIONS. It acts like a pointer, but it isn't one. It is similar to an STL "iterator". There is no interface to turn a POSITION into a pointer because the POSITION is your "pointer".
So if you have a POSITION of something in the CList, then you have a "pointer" to what you want (even though technically, POSITIONS are not pointers).
Regards,
Paul McKenzie
-
October 13th, 2010, 12:11 PM
#19
Re: Obtain a pointer to data inside a trend items array
Originally Posted by Paul McKenzie
POSITIONS are not pointers -- POSITIONS are POSITIONS. It acts like a pointer, but it isn't one. It is similar to an STL "iterator". There is no interface to turn a POSITION into a pointer because the POSITION is your "pointer".
So if you have a POSITION of something in the CList, then you have a "pointer" to what you want (even though technically, POSITIONS are not pointers).
Regards,
Paul McKenzie
Right. As I said earlier, you can use the POSITION to hop directly to any point in the list. Then GetNext or GetPrev to move backwards or forwards.
-
October 13th, 2010, 12:12 PM
#20
Re: Obtain a pointer to data inside a trend items array
Originally Posted by amara.fortheworld@gmail.com
trendpoint* = &m_TrendPoints.GetPrev(pos );
now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional, so that first dimension is pen and second dimension is index and value at it is the pointer
something like trendpoint[pen][i]*, how to do this?
That makes no sense at all to me.
-
October 13th, 2010, 12:16 PM
#21
Re: Obtain a pointer to data inside a trend items array
Originally Posted by amara.fortheworld@gmail.com
now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional,
Your terminology is very confusing.
1) A pointer is not an array. You cannot turn a pointer into an array.
2) You now want to turn this "array" into a two-dimensional array. You can't turn a one-dimensional array into 2-dimensions without defining what you mean by turning a 1-d array into a 2-d array.
Regards,
Paul McKenzie
-
October 13th, 2010, 12:20 PM
#22
Re: Obtain a pointer to data inside a trend items array
Originally Posted by amara.fortheworld@gmail.com
continued.........
You know what might be more beneficial -- you tell us what your high-level problem is that you're trying to solve, instead of telling us how you are "solving" it and having us try to make your solution work.
That way, others can give you much better advice than trying to take what you think is a solution, and trying to make something work out of something that is unworkable.
Regards,
Paul McKenzie
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|