Standard Template Library Programmer's Guide
Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Standard Template Library Programmer's Guide
- Автор:
- Жанр:
- Год:неизвестен
- ISBN:нет данных
- Рейтинг книги:4 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 80
- 1
- 2
- 3
- 4
- 5
Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
[1] Hash_multimap::iterator is not a mutable iterator, because hash_multimap::value_type is not Assignable. That is, if i is of type hash_multimap::iterator and p is of type hash_multimap::value_type , then *i = p is not a valid expression. However, hash_multimap::iterator isn't a constant iterator either, because it can be used to modify the object that it points to. Using the same notation as above, (*i).second = p is a valid expression.
[2] This member function relies on member template functions, which at present (early 1998) are not supported by all compilers. If your compiler supports member templates, you can call this function with any type of input iterator. If your compiler does not yet support member templates, though, then the arguments must either be of type const value_type* or of type hash_multimap::const_iterator .
Associative Container, Hashed Associative Container, Pair Associative Container, Multiple Hashed Associative Container, set , map , multiset , multimap , hash_set , hash_map , hash_multiset
hash
Categories: containers, functors
Component type: type
The function object hash is a Hash Function; it is used as the default hash function by all of the Hashed Associative Containers that are included in the STL.
The hash template is only defined for template arguments of type char* , const char* , crope , wrope , and the built-in integral types. [1] If you need a Hash Function with a different argument type, you must either provide your own template specialization or else use a different Hash Function.
int main() {
hash H;
cout << "foo –> " << H("foo") << endl;
cout << "bar –> " << H("bar") << endl;
}
Defined in the headers hash_map and hash_set, and in the backward-compatibility headers hash_map.h and hash_set.h. This class is an SGI extension; it is not part of the C++ standard.
Parameter | Description |
---|---|
T |
The argument type. That is, the type of object that is being hashed. |
Hash Function
T must be a type for which a specialization of hash has been defined. The STL defines the following specializations:
• char*
• const char*
• crope
• wrope
• char
• signed char
• unsigned char
• short
• unsigned short
• int
• unsigned int
• long
• unsigned long
None.
Member | Where defined | Description |
---|---|---|
size_t operator()(const T& x) |
Hash Function | Returns x 's hash value. |
All of hash 's members are defined in the Hash Function requirements. Hash does not introduce any new members.
[1] Technically, what this means is that the actual template hash is an empty class; the member function operator() is defined only in the various specializations.
Hashed Associative Container, Hash Function
String package
Character Traits
Category: utilities
Component type: concept
Several library components, including strings, need to perform operations on characters. A Character Traits class is similar to a function object: it encapsulates some information about a particular character type, and some operations on that type.
Note that every member of a Character Traits class is static. There is never any need to create a Character Traits object, and, in fact, there is no guarantee that creating such objects is possible.
Character Traits is not a refinement of any other concept.
Value type | X::char_type |
The character type described by this Character Traits type. |
Int type | X::int_type |
A type that is capable of representing every valid value of type char_type , and, additionally an end-of-file value. For char , for example, the int type may be int , and for wchar_t it may be wint_t . |
Position type | X::pos_type |
A type that can represent the position of a character of type char_type within a file. This type is usually streampos . |
Offset type | X::off_type |
An integer type that can represent the difference between two pos_type values. This type is usually streamoff . |
State type | X::state_type |
A type that can represent a state in a multibyte encoding scheme. This type, if used at all, is usually mbstate_t . |
X
A type that is a model of Character Traits.
c, c1, c2
A value of X 's value type, X::char_type .
e, e1, e2
A value of X 's int type, X::int_type .
n
A value of type size_t .
p, p1, p2
A non-null pointer of type const X::char_type* .
s
A non-null pointer of type X::char_type* .
Name | Expression | Type requirements | Return type |
---|---|---|---|
Character assignment | X::assign(c1, c2) |
c1 is a modifiable lvalue. | void |
Character equality | X::eq(c1, c2) |
bool |
|
Character comparison | X::lt(c1, c2) |
bool |
|
Range comparison | X::compare(p1, p2, n) |
int |
|
Length | X::length(p) |
size_t |
|
Find | X::find(p, n, c) |
const X::char_type* |
|
Move | X::move(s, p, n) |
X::char_type* |
|
Copy | X::copy(s, p, n) |
X::char_type* |
|
Range assignment | X::assign(s, n, c) |
X::char_type* |
|
EOF value | X::eof() |
X::int_type |
|
Not EOF | X::not_eof(e) |
X::int_type |
|
Convert to value type | X::to_char_type(e) |
X::char_type |
|
Convert to int type | X::to_int_type(c) |
X::int_type |
|
Equal int type values | X::eq_int_type(e1, e2) |
bool |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Character assignment | X::assign(c1, c2) |
Performs the assignment c1 = c2 | X::eq(c1, c2) is true . | |
Character equality | X::eq(c1, c2) |
Returns true if and only if c1 and c2 are equal. | ||
Character comparison | X::lt(c1, c2) |
Returns true if and only if c1 is less than c2 . Note that for any two value values c1 and c2 , exactly one of X::lt(c1, c2) , X::lt(c2, c1) , and X::eq(c1, c2) should be true . | ||
Range comparison | X::compare(p1, p2, n) |
[p1, p1+n) and [p2, p2+n) are valid ranges. | Generalization of strncmp . Returns 0 if every element in [p1, p1+n) is equal to the corresponding element in [p2, p2+n) , a negative value if there exists an element in [p1, p1+n) less than the corresponding element in [p2, p2+n) and all previous elements are equal, and a positive value if there exists an element in [p1, p1+n) greater than the corresponding element in [p2, p2+n) and all previous elements are equal. | |
Length | X::length(p) |
Generalization of strlen . Returns the smallest non-negative number n such that X::eq(p+n, X::char_type()) is true. Behavior is undefined if no such n exists. | ||
Find | X::find(p, n, c) |
[p, p+n) is a valid range. | Generalization of strchr . Returns the first pointer q in [p, p+n) such that X::eq(*q, c) is true. Returns a null pointer if no such pointer exists. (Note that this method for indicating a failed search differs from that is find .) | |
Move | X::move(s, p, n) |
[p, p+n) and [s, s+n) are valid ranges (possibly overlapping). | Generalization of memmove . Copies values from the range [p, p+n) to the range [s, s+n) , and returns s . | |
Copy | X::copy(s, p, n) |
[p, p+n) and [s, s+n) are valid ranges which do not overlap. | Generalization of memcpy . Copies values from the range [p, p+n) to the range [s, s+n) , and returns s . | |
Range assignment | X::assign(s, n, c) |
[s, s+n) is a valid range. | Generalization of memset . Assigns the value c to each pointer in the range [s, s+n) , and returns s . | |
EOF value | X::eof() |
Returns a value that can represent EOF. | X::eof() is distinct from every valid value of type X::char_type . That is, there exists no value c such that X::eq_int_type(X::to_int_type(c), X::eof()) is true . | |
Not EOF | X::not_eof(e) |
Returns e if e represents a valid char_type value, and some non-EOF value if e is X::eof() . | ||
Convert to value type | X::to_char_type(e) |
Converts e to X 's int type. If e is a representation of some char_type value then it returns that value; if e is X::eof() then the return value is unspecified. | ||
Convert to int type | X::to_int_type(c) |
Converts c to X 's int type. | X::to_char_type(X::to_int_type(c)) is a null operation. | |
Equal int type values | X::eq_int_type(e1, e2) |
Compares two int type values. If there exist values of type X::char_type such that e1 is X::to_int_type(c1)) and e2 is X::to_int_type(c2)) , then X::eq_int_type(e1, e2) is the same as X::eq(c1, c2) . Otherwise, eq_int_type returns true if e1 and e2 are both EOF and false if one of e1 and e2 is EOF and the other is not. |
length , find , move , copy , and the range version of assign are linear in n .
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.