What’s wrong with this?
for (int i=0; i27 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 948 | Lượt tải: 0
Failing how? In general, we cannot know In practice, we can assume that some kinds of errors are more common than others But sometimes a memory bit just decides to change (cosmic ray, silicon fatigue, ) Why? Power surges/failure The connector vibrated out of its socket Falling debris Falling computer X-rays Transient errors are the wor...
36 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1037 | Lượt tải: 0
They are important to low-level tool builders
If you think you need them, you are probably too close to hardware, but there are a few other uses. For example,
void f(const vector
41 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 963 | Lượt tải: 0
Header line Regular expression: ^[\w ]+( [\w ]+)*$ As string literal: "^[\\w ]+( [\\w ]+)*$" Other lines Regular expression: ^([\w ]+)( \d+)( \d+)( \d+)$ As string literal: "^([\\w ]+)( \\d+)( \\d+)( \\d+)$" Aren’t those invisible tab characters annoying? Define a tab character class Aren’t those invisible space characters annoying? Us...
27 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1031 | Lượt tải: 0
“To make life easier for the serious programmer” i.e., primarily me and my friends/colleagues I love writing code I like reading code I hate debugging Elegant and efficient code I really dislike choosing between the two Elegance, efficiency, and correctness are closely related in many application domains Inelegance/verbosity is a major sour...
40 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1007 | Lượt tải: 0
// a very useful algorithm (missing from the standard library):
template
37 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1098 | Lượt tải: 0
Chỉ play dạng chuẩn dành cho audio kĩ thuật số trên nền tảng PC của Intel. File audio phải có kích thước thích hợp với bộ nhớ có sẵn. Không thể được sử dụng một cách đồng thời bởi nhiều tiểu trình trong cùng một tiến trình
7 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1130 | Lượt tải: 0
By default, use a vector You need a reason not to You can “grow” a vector (e.g., using push_back()) You can insert() and erase() in a vector Vector elements are compactly stored and contiguous For small vectors of small elements all operations are fast compared to lists If you don’t want elements to move, use a list You can “grow” a list (e...
43 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1066 | Lượt tải: 0
An introduction to the STL, the containers and algorithms part of the C++ standard library. Here we’ll meet sequences, iterators, and containers (such as vector, list, and map). The algorithms include find(), find_if(), sort(), copy(), copy_if(), and accumulate().
43 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1014 | Lượt tải: 1
We’ll see how we can change vector’s implementation to better allow for changes in the number of elements. Then we’ll modify vector to take elements of an arbitrary type and add range checking. That’ll imply looking at templates and revisiting exceptions.
38 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1015 | Lượt tải: 0