Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Llame a este método para cambiar elementos de la lista.
void SwapElements(
POSITION pos1,
POSITION pos2
) throw( );
Parámetros
pos1
el primer valor de la POSICIÓN.pos2
el segundo valor de la POSICIÓN.
Comentarios
Cambie los elementos de las dos posiciones especificadas.En las compilaciones de depuración, un error de aserción aparecerá si cualquier valor de posición es igual a NULL.
Ejemplo
// Define the integer list
CAtlList<int> myList;
// Populate the list
for (int i = 0; i < 100; i++)
{
myList.AddHead(i);
}
// Order is: 99, 98, 97, 96...
ATLASSERT(myList.GetHead() == 99);
ATLASSERT(myList.GetTail() == 0);
// Perform a crude bubble sort
for (int j = 0; j < 100; j++)
{
for(int i = 0; i < 99; i++)
{
if (myList.GetAt(myList.FindIndex(i)) >
myList.GetAt(myList.FindIndex(i+1)))
{
myList.SwapElements(myList.FindIndex(i), myList.FindIndex(i+1));
}
}
}
// Order is: 0, 1, 2, 3...
ATLASSERT(myList.GetHead() == 0);
ATLASSERT(myList.GetTail() == 99);
Requisitos
encabezado: atlcoll.h