473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CObList SetAt method problem....

I'm writing this sorting just to understand how exactly works methods
in CObList. Iteration works fine, but it won't change pointers.

CObList myList;
CPerson* first, second;
POSITION next, position;
int size = myList.GetCount();

for (int i = 0; i < size; i++) {
for (position = myList.GetHeadPosition(); next != NULL;)
{

first = (CPerson*)myList.GetNext(position);
next = position;
second = (CPerson*)myList.GetNext(next);

if (first->get_Number() second->get_Number())
{
temp = first;
myList.SetAt(position, second);
myList.SetAt(next, temp);
}
}
}

Thanks!

Jan 25 '07 #1
2 2088
de**********@gmail.com wrote:
I'm writing this sorting just to understand how exactly works methods
in CObList. Iteration works fine, but it won't change pointers.
What's a CObList? Looks like you want a platform specific group.

--
Ian Collins.
Jan 25 '07 #2
de**********@gmail.com wrote:
I'm writing this sorting just to understand how exactly works methods
in CObList. Iteration works fine, but it won't change pointers.

CObList myList;
CPerson* first, second;
second isn't a pointer, you meant

CPerson *first, *second;
POSITION next, position;
int size = myList.GetCount();

for (int i = 0; i < size; i++) {
for (position = myList.GetHeadPosition(); next != NULL;)
{

first = (CPerson*)myList.GetNext(position);
next = position;
second = (CPerson*)myList.GetNext(next);

if (first->get_Number() second->get_Number())
{
temp = first;
myList.SetAt(position, second);
myList.SetAt(next, temp);
Don't see why you need temp

myList.SetAt(position, second);
myList.SetAt(next, first);
}
}
}

Thanks!
John
>
Jan 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
9
by: Daniel Kay | last post by:
Hello! I have written two template classes which implement the observerpattern in C++. I hope I manage to desribe the problem I have. template<class T> class Observer { /* ... */ }; ...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
by: Frank Natoli | last post by:
Are CObList and CPtrList protected against concurrent access by multiple threads? I presume the answer is "no". If one thread is in the process of changing the list, e.g., Add Head, RemoveTail,...
10
by: Markus Svilans | last post by:
Hi, I have a weird problem in a virtual method. The original method code raises an access violation when it is run. The solution to the problem is to declare a dummy integer inside the virtual...
2
by: =?Utf-8?B?VG9tYXM=?= | last post by:
Hello all. Is there something similar to this in NET? CString s( "abcdef"); s.SetAt(1, 'a'); I am looking for a method in the String class but I do not see anything. Thanks in...
1
bajajv
by: bajajv | last post by:
Hi, What is the difference between CObList and CList? If we use a CList as - CList<CObject*, CObject*>, isnt it similar to CObList?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.