Team LiB
Previous Section Next Section

Defined Terms

术语

adaptor(适配器)

A library type, function, or iterator that given a type, function, or iterator, makes it act like another. There are three sequential container adaptors: stack, queue, and priority_queue. Each of these adaptors defines a new interface on top of an underlying sequential container.

一种标准库类型、函数或迭代器,使某种标准库类型、函数或迭代器的行为类似于另外一种标准库类型、函数或迭代器。系统提供了三种顺序容器适配器:stack(栈)、queue(队列)以及 priority_queue(优先级队列)。所有的适配器都会在其基础顺序容器上定义一个新接口。

begin(begin 操作)

Container operation that returns an iterator referring to the first element in the container, if there is one, or the off-the-end iterator ff the container is empty.

一种容器操作。如果容器中有元素,该操作返回指向容器中第一个元素的迭代器;如果容器为空,则返回超出末端迭代器。

container(容器)

A type that holds a collection of objects of a given type. Each library container type is a template type. To define a container, we must specify the type of the elements stored in the container. The library containers are variable-sized.

一种存储给定类型对象集合的类型。所有标准库容器类型都是模板类型。定义容器时,必须指定在该容器中存储的元素是什么类型。标准库容器具有可变的长度。

deque(双端队列)

Sequential container. Elements in a deque are accessed by their positional index. Like a vector in all respects except that it supports fast insertion at the front of the container as well as at the end and does not relocate elements as a result of insertions or deletions at either end.

一种顺序容器。deque 中存储的元素通过其下标位置访问。该容器类型在很多方面与 vector 一样,唯一的不同是 deque 类型支持在容器首部快速地插入新元素,就像在尾部插入一样,而且无论在容器的哪一端插入或删除都不会引起元素的重新定位。

end(end 操作)

Container operation that returns an iterator referring to the element one past the end of the container.

一种容器操作,返回指向容器的超出末端的下一位置的迭代器。

invalidated iterator(无效迭代器)

An iterator that refers to an element that no longer exists. Using an invalidated iterator is undefined and can cause serious run-time problems.

指向不再存在的元素的迭代器。无效迭代器的使用未定义,可能会导致严重的运行时错误。

iterator(迭代器)

A type whose operations support navigating among the elements of a container and examining values in the container. Each of the library containers has four companion iterator types listed in Table 9.5 (p. 316). The library iterators all support the dereference (*) and arrow (->) operators to examine the value to which the iterator refers. They also support prefix and postfix increment (++) and decrement (--) and the equality (==) and inequality (!=) operators.

一种类型,其操作支持遍历和检查容器元素的操作。所有标准库容器都定义了表 9.5 列出的 4 种迭代器,与之共同工作。标准库迭代器都支持解引用(*)操作符和箭头(->)操作符,用于检查迭代器指向的元素值。它们还支持前置和后置的自增(++)、自减操作符(--),以及相等(==)和不等(!=)操作符。

iterator range(迭代器范围)

A range of elements denoted by a pair of iterators. The first iterator refers to the first element in the sequence, and the second iterator refers one past the last element. If the range is empty, then the iterators are equal (and vice versaif the iterators are equal, they denote an empty range). If the range is non-empty, then it must be possible to reach the second iterator by repeatedly incrementing the first iterator. By incrementing the iterator, each element in the sequence can be processed.

由一对迭代器标记的一段元素范围。第一个迭代器指向序列中的第一个元素,而第二个迭代器则指向该范围中的最后一个元素的下一位置。如果这段范围为空,则这两个迭代器相等(反之亦然——如果这两个迭代器相等,则它们标记一个空范围)。如果这段范围非空,则对第一个空范围)。如果这段范围非空,则对第一个迭代器重复做自增运算,必然能达第二个迭代器。通过这个对迭代器进行自增的过程,即可处理该序列中所有的元素。

left-inclusive interval(左闭合区间)

A range of values that includes its first element but not its last. Typically denoted as [i, j) meaning the sequence starting at and including i up to but excluding j.

一段包含第一个元素但不包含最后一个元素的范围。一般表示为 [i, j),意味着该序列从 i 开始(包括 i)一直到 j,但不包含 j

list(列表)

Sequential container. Elements in a list may be accessed only sequentiallystarting from a given element, we can get to another element by incrementing or decrementing across each element between them. Supports fast insertion (or deletion) anywhere in the list. Adding elements does not affect other elements in the list; iterators remain valid when new elements are added. When an element is removed, only the iterators to that element are invalidated.

一种顺序容器。list 中的元素只能顺序访问——从给定元素开始,要获取另一个元素,则必须通过自增或自减迭代器的操作遍历这两个元素之间的所有元素。list 容器支持在容器的任何位置实现快速插入(或删除)运算。新元素的插入不会影响 list 中的其他元素。插入元素时,迭代器保持有效;删除元素时,只有指向该元素的迭代器失效。

priority_queue(优先级队列)

Adaptor for the sequential containers that yields a queue in which elements are inserted, not at the end but according to a specified priority level. By default, priority is determined by using the less-than operator for the element type.

一种顺序容器适配器。在这种队列中,新元素不是在队列尾部插入,而是根据指定的优先级级别插入。默认情况下,元素的优先级由元素类型的小于操作符决定。

queue(队列)

Adaptor for the sequential containers that yields a type that lets us add elements to the back and remove elements from the front.

一种顺序容器适配器。在这种队列中,保证只在队尾插入新元素,而且只在队首删除元素。

sequential container(顺序容器)

A type that holds an ordered collection of objects of a single type. Elements in a sequential container are accessed by position.

以有序集合的方式存储单一类型对象的类型。顺序容器中的元素可通过下标访问。

stack(栈)

Adaptor for the sequential containers that yields a type that lets us add and remove elements from one end only.

一种顺序容器适配器,这种类型只能在一端插入和删除元素。

vector(向量)

Sequential container. Elements in a vector are accessed by their positional index. We add elements to a vector by calling push_back or insert. Adding elements to a vector might cause it be reallocated, invalidating all iterators into the vector. Adding (or removing) an element in the middle of a vector invalidates all iterators to elements after the insertion (or deletion) point.

一种顺序容器。vector 中的元素通过其位置下标访问。可通过调用 push_backinsert 函数在 vector 中添加元素。在 vector 中添加元素可能会导致重新为容器分配内存空间,也可能会使所有的迭代器失效。在 vector 容器中间添加(或删除)元素将使所有指向插入(或删除)点后面的元素的迭代器失效。

Team LiB
Previous Section Next Section