Download as pdf
Download as pdf
You are on page 1of 3
ess2015 ieee unordered set> Input Ovo “torward_ast> reer rere tere re: rere ra rere: tere ra: eee rere ra rare ra: rere re: (oer tere ra rca re rare ra: frprered_ apr unoreree_nap member functions: ie tet et replace cole ceey as reoon imate cunt mls Jaser pert) non-member overload: pert (oe re) Umordered_map - C++ Reference css temphte «a:tunordered_map eerered ney iano or TTT Sieh 1) worderet hap naa ype SE loa toner, 1 ere nha lses Aloe = ailecatore potrcconst Key, T> > 17 nordere Unordered Map, - Unerdered maps ae asocative containers that store elements formed bythe combinten of 2 key value anda mapped value, and which allows for fst retrieval of navdval elements based onthe Keys. {nan arerdered_nap, the key values generally used to uniquely dertify the element, while the mapped valves 2n ‘object wth the Content essocated to this key. Types of key ane mapped valve may der Interaly, the elements in the unorderea_nap are not sort in any particu order with respact to ether thelr key of ‘mapped vlues, but organized ito buckets depenang on their hash values to alow for fast acess to val elements Cdrecty by tit key values (th 2 constant average tme compexty on avers). unordered_nap containers are faster than nap contalners to access individual elements by tel Key, although they are ‘general las eflcent for range teration through 9 subsoto thai elements, Unordered maps implement the dct access operator (operat) which allows for rec acess ofthe mapped value Using its Rey value as argument IReratrs in the container area leas forward teratos Container properti Associative Elements in associative containers are referenced by thet key nd not by their abselute postion in the container Unordered ‘Unotdeted contamers organize thelr elements using nash tables that allow for fast access to elements by thelr key. Each element associates a hay to 2 mapped valu: Keys are meant to dentty the elements whose main content s the mapped vale Unique keys ‘No wo elements in the container can have equivalent keys. Alocator-aware "Te contamer uses an allcstor object to dynamically hance ts storage needs ‘Template parameters ey ‘Type of the Key valves. Fach element in on unonered.nap is uniquely Henke by Rs Key vale. Alased as member type unonderednap!40y pe ‘Type of the mapped value. Each element in an snondered_ nap is used to store some data as its mopped valve. [lased as mariber type snandered. nop: napged ype. Node Mat ths & nat te same as “ordered nap value_type (580 Ba). ‘unary function object type tat takes an object of type Key type as argument and returns a unique vale of type ‘S2e_t based on. This can ether be a dass implementing a function cll aporatar ora poitar toa function (see Constructor fran example. This dteuts to nesnecy>, which returns a Mash vale with proba of ealsion approaching 3 6/ata:sranerse-ainstscsize t3:-nax() ‘Tre unorderee nap object uses the hash values returved by ths function to organize ts elements internal Speeding up th process of fcating individual elements ‘Alased as member type unordered nap! :hasher binary predicate tnt takes two arguments ofthe key type and returns a bool. The expression prea), where reds an object ofthis type and a and’ are key values, Sal return true fa tobe costed equivalent 9. {his can ether be a dass implementing a function el operator o” a poner fo 2 function (eee constructor Fran xample)Tis acts to caus) tockoy>,wnlenretura the same ae eppiying the aque operator (a5) ‘Tre unorderoe_nap object uses this expresean to determine whether two element keys are equvslens Noto clement in at unordered pop container can have keys el Yield true using this predate ‘Alased as member type sfordered_ pap key_eauel ‘Type of the alloctor abject used t define the storage location model Sy deft, the albcater class template sea, which cerns tne simplest memory aloaton model ands vaue-ndependent Biased as member type snordered ap allocator “ype Inthe reference fer the unorceres forthe template parameters. ep member functions, these same names (Key, T, Mesh, Pred and Aloe) ave assumed Inipikwwnw cplusplus. com/eferencelnordered mapiuncrdered_ map! 48 ess2015 Umordered_map - C++ Reference Meratrs to sements of unordered.nap containers acess to both the Key andthe mapped value, For this, the ass fetines what called ite velue tyre, which 2 a cass wns first vale corresponding tothe conct versa ofthe key type (omphite poramater Key) and te second value corresponding to the mopped value (emplate paremeter 7) lterators ofa unordered_map container point to elements ofthis value type. Thus, foran trator called 1 that pots to fan element af nap, fs Koy and mapped value en be dcnssad respectively with 2 (iperises 77 the kay value (oF type Key) 3 (ste) secon Uf the Mapped value (oF ype 1) ae Uf the "element value” (oF Lyoe patreconst Kays T>) Naturally any othe drct access operate, such as -> oF [] can be used, for example: Dsestiests | sane a6 (019), Firat (Bho key value) 2 AC seconds U1 Save as (elshssecond (the espped value) Member types The following aliases are member types of nordere_pap. They ae widely used as parameter and return types by member functions ‘cvsan [eraa] Trembar We. ‘afinition ro fete [ve Fst Pomplate parameter (ex) apes BE [ve second template parareter (7 hasher je tird template parameter (Hash) _[Gefauls to: hashekey_ type fey count lve foureterpiatesarareter (Pred) "aus to: eoual_ Lockey UBD falecater_tyse [Pre th ternpiate parameter (ioc) Befauls tor allocator

You might also like