1. Trang chủ
  2. » Công Nghệ Thông Tin

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

102 899 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 102
Dung lượng 364,96 KB

Nội dung

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