The C++ Programming Language Third Edition phần 6 pptx

102 899 0
The C++ Programming Language Third Edition phần 6 pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Section 17.6.2.1 Lookup 501 // not found: i f (b si ze if b.s iz e()*m ax _l oa d < v si ze ma x_ lo ad v.s iz e()) { // if ‘‘too full’’ r es iz e(b si ze re si ze b.s iz e()*g ro w); gr ow // grow r et ur n o pe to r[](k ; re tu rn op er at or k) // rehash } v pu sh _b ac k(E nt ry k,d ef au lt _v al ue b[i v.p us h_ ba ck En tr y(k de fa ul t_ va lu e,b i])); b i] = &v ba ck ; b[i v.b ac k() // add Entry // point to new element r et ur n b i]->v al re tu rn b[i va l; } Unlike m ap h as h_ ma p doesn’t rely on an equality test synthesized from a less-than operation ma p, sh _m ap (§17.1.4.1) This is because of the call of e q() in the loop that looks through elements with the eq same hash value This loop is crucial to the performance of the lookup, and for common and obvious key types such as s tr in g and C-style strings, the overhead of an extra comparison could be sigst ri ng nificant I could have used a s et En tr y> to represent the set of values that have the same hash value se t cl as s al lo ca to r cl as s al lo ca to r

Ngày đăng: 12/08/2014, 19:21

Từ khóa liên quan

Mục lục

  • The C++ Programming Language (Special 3rd Edition)

    • Part III: The Standard Library

      • Ch17 Standard Containers

        • 17.7 Advice

        • 17.8 Exercises

        • Ch18 Algorithms and Function Objects

          • 18.1 Introduction

          • 18.2 Overview of Standard Library Algorithms

          • 18.3 Sequences and Containers

          • 18.4 Function Objects

          • 18.5 Nonmodifying Sequence Algorithms

          • 18.6 Modifying Sequence Algorithms

          • 18.7 Sorted Sequences

          • 18.8 Heaps

          • 18.9 Min and Max

          • 18.10 Permutations

          • 18.11 C Style Algorithms

          • 18.12 Advice

          • 18.13 Exercises

          • Ch19 Iterators and Allocators

            • 19.1 Introduction

            • 19.2 Iterators and Sequences

            • 19.3 Checked Iterators

            • 19.4 Allocators

            • 19.5 Advice

Tài liệu cùng người dùng

Tài liệu liên quan