代码改变世界

随笔分类 -  STL

二叉树的基本遍历操作

2011-08-25 19:22 by Daniel Zheng, 399 阅读, 收藏, 编辑
摘要: 1 #include <queue> 2 #include <iostream> 3 using namespace std; 4 5 #define QSIZE 100 6 struct BTree 7 8 { 9 int value; 10 struct BTree* lChild; 11 struct BTree* rChild; 12 }; 13 14 void VisitNode(BTree * T) 15 { 16 cout<<T->value<<" "; 17 } 18 BTree * Insert(BTr 阅读全文

Working with Bit Flags Using STL

2011-08-15 12:39 by Daniel Zheng, 278 阅读, 收藏, 编辑
摘要: Bits can be very efficient way of storing settings and flags. STL supplies classes that help organize and manipulate bitwise information.The bitset Classstd::bitset is an STL class designed for handling information in bits and bit flags. The std::bitset is not classified as an STL container because 阅读全文

Adaptive Container: stack and queue

2011-08-14 22:53 by Daniel Zheng, 312 阅读, 收藏, 编辑
摘要: The standard template library (STL) features containers that adapt othersto simulate stack and queue behavior. Such containers that internally useanother and present a distinct behavior are called adaptive containers.Using the STL stack ClassThe STL stack is a generic class that allows insertions an 阅读全文

STL Algorithms

2011-08-14 20:25 by Daniel Zheng, 345 阅读, 收藏, 编辑
摘要: One important part of the standard template library is a set of generic functions, supplied by the header <algorithm>. that help manipulate or work with the contents of a container.What Are STL Algorithms?Finding, searching, removing, and counting are some generic algorithmic activities that f 阅读全文

Understanding Function Objects

2011-08-13 00:24 by Daniel Zheng, 301 阅读, 收藏, 编辑
摘要: Function objects or functors might sould exotic or intimidating, but they are entities of C++ that you have probably seen if not also used, without having realized it.The Concept of Function Objects and PredicateOn a conceptual level, function objects are objects that work as function. On an impleme 阅读全文

STL map and multimap

2011-08-12 10:02 by Daniel Zheng, 392 阅读, 收藏, 编辑
摘要: A Brief IntroductionThe map and multimap are key-value pair containers that allow for a lookup on the basis of a key. The difference between the map and multimap is that only the latter allows for duplicates, whereas the former can store only unique keys.Th facilitate quick searching, STL implementa 阅读全文

STL set and multiset

2011-08-11 23:48 by Daniel Zheng, 378 阅读, 收藏, 编辑
摘要: The set and multiset are containers that facilitate a quick lookup of keys in a container that stores them; that is, the keys are the values stored in the one-dimensional container.The difference between the set and the multiset is that latter allows for duplicates whereas the former can store only 阅读全文

STL list

2011-08-11 17:03 by Daniel Zheng, 371 阅读, 收藏, 编辑
摘要: The standard template library supplies the programmer with a doubly linked list in the form of template class std::list.STL's list class allows for constant time insertions at the front, back, or middle of the sequence.Basic list OperationsBefore use it, you need to include the header file <l 阅读全文

STL Dynamic Array Classes

2011-08-11 01:26 by Daniel Zheng, 365 阅读, 收藏, 编辑
摘要: Dynamic arrays supply the programmer with the flexibility of storing data without needing to know the exact volume thereof at the time of programming the application, the way static arrays do. Naturally, this is a frequently needed requirement and the STL supplies a ready-to-use solution in the form 阅读全文

The STL string Class

2011-08-11 00:49 by Daniel Zheng, 358 阅读, 收藏, 编辑
摘要: The STL string class std::string helps you in the following ways:Reduces the effort of creation and manipulating stringsIncreases the stability of the application being programmed by internally managing memory allocation detailsSupplies copy constructor and assignment operators that automatically en 阅读全文

An Introduction to the Standard Template Library

2011-08-10 15:23 by Daniel Zheng, 235 阅读, 收藏, 编辑
摘要: STL consist of three components:Container for storing informationIterators for accessing the information storedAlgorithms for manipulating the content of the containersSTL ContainersContainers are STL classes that are used to store data. There are two types of container classes:Sequential containers 阅读全文