Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CAtlArray and CAtlList - sorting?

400 views
Skip to first unread message

Tom Alter

unread,
Apr 21, 2005, 9:27:49 PM4/21/05
to
Anyone knows how to sort the arrays, or how to insert an element in the array in Ordered?
Because, if you override the Traits, and provide your comparison functions, then it is possible to keep array in Ordered.
CElementTraits::CompareElementsOrdered, but it seems in atlcoll.h header file, where ATL's collection classes are implemented,
I don't see any code where you can add elements in to the array in ordered. But MSDN documentation says that CAtlArray and
CAtlList can be ordered.

Any comments please:


Jason Cone

unread,
Apr 22, 2005, 6:51:42 AM4/22/05
to
Tom,

When MSDN describes CAtlList and/or CAtlArray as being ordered, it's
speaking to the order of the elements with respect to the order in which
they were inserted. It is not, however, speaking to the order of the
elements with respect to the elements' respective values. In other words,
if you insert elements "1", "4", "2", and "3" into a list in that order,
MSDN's use of the word "ordered" means that the order will be "1", "4", "2",
and "3" - not "1", "2", "3", and "4".

Indeed, there is no inherent sorting functionality in the ATL collection
classes - you'll have to roll your own. For a simple and straightforward
(albeit inefficient) example of such an implementation, see the
documentation for the CAtlList::SwapElements() method.

Regards,

Jason Cone


"Tom Alter" <Lord...@MSN.com> wrote in message
news:upZtAqtR...@TK2MSFTNGP14.phx.gbl...

0 new messages