随笔分类 -  c++学习基础代码

摘要:1. transform() 算法有两种形式: transform( b1, e1, b2, op ) transform( b1, e1, b2, b3, op ) 注意: 如果目标与源相同,transform() 就和for_each() 一样 如果想以某值替换符合规则的元素,应使用replac 阅读全文
posted @ 2015-03-06 18:20 SandKing 阅读(16) 评论(0) 推荐(0)
摘要:1.copy() 2.copy_backward() 3.注意: (1) 没有copy_if()算法,可以使用remove_copy_if() 算法 (2) 复制过程中要逆转元素次序,使用 reverse_copy() 算法 (3) 把容器内所有元素赋值给另一个容器,要用赋值操作符或容器的assig 阅读全文
posted @ 2015-03-05 18:14 SandKing 阅读(12) 评论(0) 推荐(0)
摘要:1. equal(b, e, b2) 比较第一个容器和第二个容器内容是否相等 2. equal( b, e, b2, p ) 3. mismatch( b, e, b2 ) 查找两个容器中第一个不相等的数据 4. mismatch(b, ,e, b2, p ) 5. lexicographical_ 阅读全文
posted @ 2015-03-05 15:36 SandKing 阅读(10) 评论(0) 推荐(0)
摘要:1. for_each( b, e, p ) 2 使用for_each() 算法遍历数据 3. 使用for_each() 和函数对象修改数据 4. 使用for_each() 的返回值 #include <iostream> #include <algorithm> #include <vector> 阅读全文
posted @ 2015-03-04 17:50 SandKing 阅读(7) 评论(0) 推荐(0)
摘要:已序容器查找算法 1.lower_bound() 第一个可能的位置 2.upper_bound() 最后一个可能的位置 3.equal_range() 查找第一个和最后一个可能的位置 ***注意:关联式容器有等效的成员函数,性能更佳 #include <iostream> #include <alg 阅读全文
posted @ 2015-03-04 16:19 SandKing 阅读(6) 评论(0) 推荐(0)
摘要:已序查找算法之 1. binary_search(b, e, v ) --只能找一个; 找到或没找到,不能返回位置 2. binary_search(b, e, v, p ) 3. include(b, e, sb, se ) 4. include(b, e, sb, se, p ) #includ 阅读全文
posted @ 2015-03-04 15:38 SandKing 阅读(6) 评论(0) 推荐(0)
摘要:1. adjacent_find(b, e) //找两个连续相等的 2. adjacent_find(b, e, p ) #include <iostream> #include <algorithm> #include <vector> using namespace std; bool doub 阅读全文
posted @ 2015-03-04 15:02 SandKing 阅读(5) 评论(0) 推荐(0)
摘要:find_first_of(b, e, sb, se ) 找sb,se中间的任意一个 find_first_on(b , e, sb, se, bp ) 使用逆向迭代器 没有find_last_of算法 string和stl查找的区别 string函数 stl算法 find() find() rfi 阅读全文
posted @ 2015-03-04 14:27 SandKing 阅读(7) 评论(0) 推荐(0)
摘要:1.search() 2.find_end() 注意: 这两个算法是一对 第二个算法应该叫search_end(),但被命名为find_end() #include <iostream> #include <algorithm> #include <vector> #include <list> u 阅读全文
posted @ 2015-03-04 12:34 SandKing 阅读(6) 评论(0) 推荐(0)
摘要:search_n 查找连续匹配的 search 1. search_n(b,e, c, v) 2. search_n(b, e, c, v, p ) --p谓词 3.注意 该算法的第二种形式应该是 search_n_if(b,e,c,p) #include <iostream> #include < 阅读全文
posted @ 2015-03-04 12:03 SandKing 阅读(9) 评论(0) 推荐(0)
摘要:1.find() 2.find_if() 3.search_n() 4.search() 5.find_end() 6.find_first_of() 7.adjacent_find() 已序区间查找算法: binary_search() includes() lower_bound() upper 阅读全文
posted @ 2015-03-03 18:57 SandKing 阅读(1) 评论(0) 推荐(0)
摘要:1.min_element(b, e) 2.min_element(b, e, op) 3.max_element(b, e) 4.max_element(b, e, op) #include <iostream> #include <algorithm> #include <deque> usin 阅读全文
posted @ 2015-03-03 16:06 SandKing 阅读(13) 评论(0) 推荐(0)
摘要:1.count 2.count_if 3.关联容器的等效成员函数 (1) set.count (2) multiset.count (3) map.count (4) multimap.count #include <iostream> #include <algorithm> #include < 阅读全文
posted @ 2015-03-03 15:46 SandKing 阅读(8) 评论(0) 推荐(0)
摘要:1.预定义的函数对象 2.自定义的函数对象 3.容器和函数对象 4.算法和函数对象 #include <iostream> #include <set> #include <algorithm> #include <vector> using namespace std; void Print( i 阅读全文
posted @ 2015-03-03 15:12 SandKing 阅读(5) 评论(0) 推荐(0)
摘要:1. 100多种算法 2.函数对象(function objects ) 3.函数适配器(function adapters ) 4.三个头文件 #include <algorithm> #include <numeric> #include <functional> 预定义函数对象 negate< 阅读全文
posted @ 2015-03-03 14:18 SandKing 阅读(5) 评论(0) 推荐(0)
摘要:1.set(集)、multiset(多集) 2.红黑树 3.基本操作 insert count和find erase 注意:不能通过find进行修改 #include <iostream> #include <set> using namespace std; template <typename 阅读全文
posted @ 2015-03-03 12:41 SandKing 阅读(7) 评论(0) 推荐(0)
摘要:map(映射) \ multimap(多映射) 红黑树(数据结构 ) 基本操作 insert: 4种方法 count和find erase:3重方法 ***注意:不能通过find进行修改! #include <iostream> #include <map> #include <string> us 阅读全文
posted @ 2015-03-02 18:49 SandKing 阅读(5) 评论(0) 推荐(0)
摘要:s.compare(s2) s.compare(pos1,n1,s2) s.compare(pos1,n1,s2,pos2,n2) s.compare(pos1,n1,cp) s.compare(pos1,n1,cp,n2) #include <iostream> #include <string> 阅读全文
posted @ 2015-03-02 17:11 SandKing 阅读(1) 评论(0) 推荐(0)
摘要:s.find(args) 严格匹配查找 s.rfind(args) 严格匹配查找 s.find_first_of(args, pos) 查找任意匹配字符,从pos开始找, s.find_last_of(args, pos) s.find_first_not_of(args) 查找任意不匹配字符 s. 阅读全文
posted @ 2015-03-02 16:48 SandKing 阅读(6) 评论(0) 推荐(0)
摘要:1.三个substr重载函数 2.六个append重载函数 3.十个replace重载函数 #include <iostream> #include <string> using namespace std; int main( int argc, char **argv ) { string s( 阅读全文
posted @ 2015-03-02 15:59 SandKing 阅读(8) 评论(0) 推荐(0)