This is some of my personal opinions after I read "STL source analysis", because it is necessary to digest a thing, the best way is to write down their own opinions and understand. After the accumulation of time, it will slowly accumulate you to the true sense. This is my first to formally study notes. I used to have some, but it is more zero, which is more fascinated by STL. I hope to get the master's pointing, because I am still not very understanding for allocator and adapter, I also wrote some imitation of Allocator and Adapter, but it is not very clear, sometimes it is written, and it is not necessarily possible. Especially Adapter, I don't understand the meaning and use of the source. I hope everyone will give me a point. All STL masters and newcomers are welcome to point me. Life-long learning! ! !
Note 1: Some of the algorithms, imitation functions, and interfaces:
First, algorithm:
It is a set of template functions. Operate OK based on the purpose we have to operate. In fact, when we look at STL, you often see the template
Template
T2 SUM_AMONG (T1 First, T1 Last, T2 Init)
{
For (; first! = Last; first )
INIT = * first;
Return init;
}
My algorithm can also be placed in the STL standard library as a number of elements between the two iterators, similar to Accumulate
Template
T Accumulate (InputITerator First, TIIT)
{
For (; first! = Last; first )
INIT = * first;
Return init;
}
The same features like these two functions are the second writing that people can understand clearly. It is important to use this function that you should remember:
1. Your InputItemrator Class Ierator should have! =, , * These three pointer behavior. Otherwise, you use a lot of mistakes.
2. As a variable (or object), it should have a behavior ability such as =. For example, we use
Vector
Int S;
S = Accumulate (v.being (), v.end (), s); / / The result should be 9