Team LiB
Previous Section Next Section

Defined Terms

术语

abstract data type(抽象数据类型)

A type whose representation is hidden. To use an abstract type, we need know only what operations the type supports.

隐藏其实现的数据类型。使用抽象数据类型时,只需要了解该类型所支持的操作。

bitset

Standard library class that holds a collection of bits and provides operations to test and set the bits in the collection.

一种标准库类型,用于保存位置,并提供地各个位的测试和置位操作。

cctype header(cctype 头文件)

Header inherited from C that contains routines to test character values. See page 88 for a listing of the most common routines.

从 C 标准库继承而来的头文件,包含一组测试字符值的例程。第 8.3.4 节的表 3.3 列出了常用的例程。

class template(类模板)

A blueprint from which many potential class types can be created. To use a class template, we must specify what actual type(s) or value(s) to use. For example, a vector is a template that holds objects of a given type. When we create a vector, we must say what type this vector will hold. vector<int> holds ints, vector<string> holds strings, and so on.

一个可创建许多潜在类类型的蓝图。使用类模板时,必须给出实际的类型和值。例如,vector 类型是保存给定类型对象的模板。创建一个 vector 对象是,必须指出这个 vector 对象所保存的元素的类型。vector<int> 保存 int 的对象,而 vector<string> 则保存 string 对象,以此类推。

container(容器)

A type whose objects hold a collection of objects of a given type.

一种类型,其对象保存一组给定类型的对象的集合。

difference_type

A signed integral type defined by vector that is capable of holding the distance between any two iterators.

一种由 vector 类型定义的 signed 整型,用于存储任意两个迭代器间的距离。

empty

Function defined by the string and vector types. empty returns a bool indicating whether the string has any characters or whether the vector has any elements. Returns TRue if size is zero; false otherwise.

由string类型和vector类型定义的成员函数。empty返回布尔值,用于检测string是否有字符或vector是否有元素。如果string或vector的size为0,则返回true,否则返回false。

getline

Function defined in the string header that takes an istream and a string. The function reads the stream up to the next newline, storing what it read into the string, and returns the istream. The newline is read and discarded.

string头文件中定义的函数,该函数接受一个istream对象和一个string对象,读取输入流直到下一个换行符,存储读入的输入流到string对象中,并返回istream对象。换行符被读入并丢弃。

high-order(高阶)

Bits in a bitset with the largest indices.

bitset对象中索引值最大的位。

index(索引)

Value used in the subscript operator to denote the element to retrieve from a string or vector.

下标操作符所使用的值,用于表示从string对象或vector对象中获取的元素。也称“下标”。

iterator(迭代器)

A type that can be used to examine the elements of a container and to navigate between them.

用于对容器类型的元素进行检查和遍历的数据类型。

iterator arithmetic(迭代器的算术操作)

The arithmetic operations that can be applied to some, but not all, iterator types. An integral type can be added to or subtracted from an iterator, resulting in an iterator positioned that many elements ahead of or behind the original iterator. Two iterators can be subtracted, yielding the distance between the iterators. Iterator arithmetic is valid only on iterators that refer to elements in the same container or the off-the-end iterator of the container.

应用于一些(并非全部)迭代器类型的算术操作。迭代器对象可以加上或减去一个整型数值,结果迭代器指向处于原迭代器之前或之后若干个元素的位置。两个迭代器对象可以相减,得到的结果是它们之间的距离。迭代器算术操作只适用于指向同一容器中的元素或指向容器末端的下一元素迭代器。

low-order(低阶)

Bits in a bitset with the lowest indices.

bitset对象中索引值最小的位。

off-the-end iterator(超出末端的迭代器)

The iterator returned by end. It is an iterator that refers to a nonexistent element one past the end of a container.

由end操作返回的迭代器,是一种指向容器末端之后的不存在元素的迭代器。

push_back

Function defined by vector that appends elements to the back of a vector.

由vector类型定义的成员函数,用于把元素追加到vector对象的尾部。

sentinel(哨兵)

Programming technique that uses a value as a guard to control processing. In this chapter, we showed the use of the iterator returned by end as a guard to stop processing elements in a vector once we had processed every element in the vector.

一种程序设计技术,使用一个值来控制处理过程。在本章中使用由end操作返回的迭代器作为保护符,当处理完vector对象中的所有元素后,用它来停止处理vector中的元素。

size

Function defined by the library types string, vector, and bitset that returns the number of characters, elements, or bits respectively. The string and vector functions return a value of the size_type for the type. For example, size of a string returns a string::size_type. The bitset operation returns a value of type size_t.

由库类型string、vector和bitset定义的函数,分别用于返回此三个类型的字符个数、元素个素、二进制位的个数。string和vector类的size成员函数返回size_type类型的值(例如,string对象的size操作返回string::size_type类型值)。bitset对象的size操作返回size_t类型值。

size_t

Machine-dependent unsigned integral type defined in cstddef header that is large enough to hold the size of the largest possible array.

在cstddef头文件中定义的机器相关的无符号整型,该类型足以保存最大数组的长度。

在cstddef头文件中定义的机器相关的无符号整型,该类型足以保存最大数组的长度。
size_type

Type defined by the string and vector classes that is capable of containing the size of any string or vector, respectively. Library classes that define size_type define it as an unsigned type.

由string类类型和vector类类型定义的类型,用以保存任意string对象或vecotr对象的长度。标准库类型将size_type定义为unsigned类型。

using declarations(using声明)

Make a name from a namespace accessible directly.

使命名空间的名字可以直接引用。比如:

     using namespace::name;

makes name accessible without the namespace:: prefix.

可以直接访问name而无须前缀namespace::。

value initialization(值初始化)

Initialization that happens for container elements when the container size is specified but there is no explicit element initializer. The elements are initialized as a copy of a compiler-generated value. If the container holds built-in types, then the value copied into the elements is zero. For class types, the value is generated by running the class's default constructor. Container elements that are of class type can be value-initialized only if the class has a default constructor.

当给定容器的长度,但没有显式提供元素的初始式时,对容器元素进行的初始化。元素被初始化为一个编译器产生的值的副本。如果容器保存内置类型变量,则元素的初始值将置为0。如果容器用于保存类对象,则元素的初始值由类的默认构造函数产生。只有类提供了默认构造函数时,类类型的容器元素才能进行值初始化。

++ operator(++操作符)

The iterator types define the increment operator to "add one" by moving the iterator to refer to the next element.

迭代器类型定义的自增操作符,通过“加1”移动迭代器指向下一个元素。

:: operator(::操作符)

The scope operator. It finds the name of its right-hand operand in the scope of its left-hand operand. Used to access names in a namespace, such as std::cout, which represents the name cout from the namespace std. Similarly, used to obtain names from a class, such as string::size_type, which is the size_type defined by the string class.

作用域操作符。::操作符在其左操作数的作用域内找到其右操作数的名字。用于访问某个命名空间中的名字,如std::cout,表明名字cout来自命名空间std。同样地,可用来从某个类取名字,如string::size_type,表明size_type是由string类定义的。

[] operator([]操作符)

An overloaded operator defined by the string, vector, and bitset types. It takes two operands: The left-hand operand is the name of the object and the right-hand operand is an index. It fetches the element whose position matches the index. Indices count from zerothe first element is element 0 and the last is element indexed by obj.size() - 1. Subscript returns an lvalue, so we may use a subscript as the left-hand operand of an assignment. Assigning to the result of a subscript assigns a new value to the indexed element.

由string, vector和bitset类型定义的重载操作符。它接受两个操作数:左操作数是对象名字,右操作数是一个索引。该操作符用于取出位置与索引相符的元素,索引计数从0开始,即第一个元素的索引为0,最后一个元素的索引为obj.size() -1。下标操作返回左值,因此可将下标操作作为赋值操作的左操作数。对下标操作的结果赋值是赋一个新值到相应的元素。

* operator(*操作符)

The iterator types define the dereference operator to return the object to which the iterator refers. Dereference returns an lvalue, so we may use a dereference operator as the left-hand operand of an assignment. Assigning to the result of a dereference assigns a new value to the indexed element.

迭代器类型定义了解引用操作符来返回迭代器所指向的对象。解引用返回左值,因此可将解引用操作符用作赋值操作的左操作数。对解引用操作的结果赋值是赋一个新值到相应的元素。

<< operator<< 操作符)

The string and bitset library types define an output operator. The string operator prints the characters in a string. The bitset operator prints the bit pattern in the bitset.

标准库类型string和bitset定义了输出操作符。string类型的输出操作符将输出string对象中的字符。bitset类型的输出操作符则输出bitset对象的位模式。

>> operator(>> 操作符)

The string and bitset library types define an input operator. The string operator reads whitespace delimited chunks of characters, storing what is read into the right-hand (string) operand. The bitset operator reads a bit sequence into its bitset operand.

标准库类型string和bitset定义了输入操作符。string类型的输入操作符读入以空白字符为分隔符的字符串,并把读入的内容存储在右操作数(string对象)中。bitset类型的输入操作符则读入一个位序列到其bitset操作数中。

Team LiB
Previous Section Next Section