首先看下在整个container上面的复制. c1=c2 可以等同于 c1.erase(c1.begin(),c1.end()) //delete all elems in c1 c1.insert(c1.begin(),c2.begin(),c2.end); 在赋值后,c1和c2完全相等,即使他们曾经的size不相等,赋值后也相等了. =和assign操作会是左边的容器的迭代器失效.然而,swap不会使迭代器失效.after swap,iteratros continue to refer t
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 How To Add Swap on Ubuntu 14.04 PostedApril 28, 2014 597.9kviews GETTING STARTED LINUX BASICS SERVER OPTIMIZATION UBUNTU Introduction One of the easiest way of increas
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each
Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, onl
swap(a, b): a ^= b b ^= a a ^= b 先明确一下,a ^ a = 0,同时对于一切数x ^ 0 = x 可以这样理解,第三行: b ^= a b ^= a ^ b b = b ^ a ^ b b = 0 ^ a b = a 第四行: a ^= b a = a ^ b a = (原来的a ^ b) ^ 原来的a a = b