Check out example codes for "what is time complexity of swap function". It will help you in understanding the concepts better.

Code Example 1

The Behaviour is Equivalent to: 

template <class T> void swap ( T& a, T& b )
{
  T c(a); a=b; b=c;
}

Syntax : Swap(a,b) // a = Number 1 , b = Number 2

Time Complexity: It makes one constructions and one assignments
				 So, Linear O(n) time.

Learn ReactJs, React Native from akashmittal.com