Ignore:
Timestamp:
Feb 18, 2013, 9:31:05 PM (7 years ago)
Author:
sam
Message:

base: add Array::Swap() method and the corresponding unit test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/base/array.h

    r2402 r2435  
    169169    }
    170170
     171    void Swap(int pos1, int pos2)
     172    {
     173        ASSERT(pos1 >= 0);
     174        ASSERT(pos2 >= 0);
     175        ASSERT(pos1 < m_count);
     176        ASSERT(pos2 < m_count);
     177
     178        if (pos1 != pos2)
     179        {
     180            Element tmp = (*this)[pos1];
     181            (*this)[pos1] = (*this)[pos2];
     182            (*this)[pos2] = tmp;
     183        }
     184    }
     185
    171186    void Remove(int pos, int todelete = 1)
    172187    {
Note: See TracChangeset for help on using the changeset viewer.