usr/bin/c++000075500002745140147207350340006445 0ustar00ELF>HD@ @8 @! @@@@@00pp@p@@@Ԕ Ԕ  k kh!0a  kk@@DD k kPtd@ @J@J!!QtdRtd k k/lib64/ld-linux-x86-64.so.2GNU GNU iNJb3 X(ĉݣk|fUaĹ@9JNt /$Cm+H^9!f2^X@.&J-6uuE}-K|Af% 52: (< "!$R_{cWSj]B$Z(4oDC|"ufdkQ!kR!k=$@kPkkQ(@libm.so.6__gmon_start__libc.so.6fflushstrcpyvasprintfreaddirexecv_IO_putcsetlocalefopenstrsignalstrncmpstrrchrpipe__strdupngettextfileno_unlockeddl_iterate_phdrclosedirftellstrncpymbstowcs__stack_chk_failunlinkputcharpthread_mutex_lockreallocabortstdin_exitgetpidkillsbrkstrtolisattymmapfgetcfgetscallocstrlenungetcfread_unlockedmemsetstrstrstrcspn__errno_locationfseekmemcmpgetpagesizedgettextasctimedup2pthread_mutex_unlockputenvwcswidthstdoutfputcfputsstrnlenmemcpyfclosestrtoulmallocstrcatstrcasecmprealpathremove__uflownl_langinfoopendir__ctype_b_locgetenvsscanfstderrmunmapwait4_obstack_newchunksetrlimitexecvpfreopenstrncasecmp__fxstat_obstack_memory_usedfwritefreadiconv_closegettimeofdaywaitpidstrverscmplocaltimestrchrobstack_freevforkiconvmkstempsfdopenqsorticonv_opensleep__ctype_tolower_locbsearchfcntl__fsetlocking__xstatgetrlimitmemmove_obstack_beginbindtextdomainaccessfwrite_unlockedstrcmpstrerror__libc_start_mainferrorstpcpyvfprintfsnprintf__overflowfputs_unlocked__environ__cxa_atexitld-linux-x86-64.so.2__tls_get_addr__pthread_key_createpthread_onceGLIBC_2.3GLIBC_2.14GLIBC_2.4GLIBC_2.11GLIBC_2.2.5g ii ii ii ui ЯkدkMkkkkkk k(k0k8k@kHkPkXk `k hk pk xk kkkkkkkkkȰkаkذkkkkkkkk k! k"(k#0k$8k%@k&Hk'Pk(Xk)`k*hk+pk,xk-k.k/k0k1k2k3k4k5k6ȱk7бk8رk9k:k;k<k=k>k?k@kA kB(kC0kD8kE@kFHkGPkXkH`kIhkJpkKxkLkMkNkOkPkQkRkSkTkUȲkVвkWزkXkYkZk[k\k]k^k_k` ka(kb0kc8kd@keHkfPkgXkh`kihkjpkkxklkmknkokpkqkrksktkuȳkvгkwسkxkykzk{k|k}k~kk k(k0k8k@kHH+HtH5‹+%ċ+@%‹+h%+h%+h%+h%+h%+h%+h%+hp%+h`%z+h P%r+h @%j+h 0%b+h %Z+h %R+h%J+h%B+h%:+h%2+h%*+h%"+h%+h%+h% +hp%+h`%+hP%+h@%+h0%+h %ڊ+h%Ҋ+h%ʊ+h%Š+h %+h!%+h"%+h#%+h$%+h%%+h&%+h'p%+h(`%z+h)P%r+h*@%j+h+0%b+h, %Z+h-%R+h.%J+h/%B+h0%:+h1%2+h2%*+h3%"+h4%+h5%+h6% +h7p%+h8`%+h9P%+h:@%+h;0%+h< %ډ+h=%҉+h>%ʉ+h?%‰+h@%+hA%+hB%+hC%+hD%+hE%+hF%+hGp%+hH`%z+hIP%r+hJ@%j+hK0%b+hL %Z+hM%R+hN%J+hO%B+hP%:+hQ%2+hR%*+hS%"+hT%+hU%+hV% +hWp%+hX`%+hYP%+hZ@%+h[0%+h\ %ڈ+h]%҈+h^%ʈ+h_%ˆ+h`%+ha%+hb%+hc%+hd%+he%+hf%+hgp%+hh`%z+hiP%r+hj@%j+hk0%b+hl %Z+hm%R+hn%J+ho%B+hp%:+hq%2+hr%*+hs%"+ht%+hu%+hv% +hwp%+hx`%+hyP%+hz@%+h{0%+h| %ڇ+h}%҇+h~%ʇ+h%‡+h%+h%+h%+h%+h%+hUSH~PHcmHcHHHZ[]ÃuSH>H?/uH?/uuH1[1AWIAVLcAUATAU1SQD-c+Hl+D9} D9cuH3LLt H1Z[]A\A]A^A_AWIAVACbJAUIATUS1H~ HD9HcMdH A<$-u:A|$lu2A|$IT$u D9}~IT E1CbJ:FH1?1LL:>FHIt Hu1E1CbJL ;FH1H9tHHD$0HD$HFHH[]A\A]A^A_USQu GF1ft GF1f=+H1HHHHHY~HcH|2(;Ft HF1SfH+Hu9HcH{ %LH I-auxbase@ LHHuLD 1Z[]UHSHP+HcHHC+HHh+Z[]USQt XHF1eH>HHH1HE1HуHcHމDx IB|/uLcʾ.J| HtHu1H1*HHZ[H]ATUSuH1/F G;F_HΏ+L$H!uvAHAE rA<>tKA=>tA><uKEAA FAEA:AAHAE 'AEAAAE! hIF1aEt L\$KD1 H,$I/H[]A\A]A^A_ÃATUHSH>jHHuHuIF1%aH1HHH}HHHHH|QIHǀ;tH\HDCDGHu[]LA\1SHHHHdH%(H$1x4D$%=u$H;y=+tH޿;F13dH$dH3%(tHĠ[SH+HtH;dH[[UHAWAVAUATSHH8H=+dH%(HE1H/I3Gz1Dž\IMF=HLH;FIDžHAlxDE5Huc\tLc,1JpÅytH 1Axt`DDPI?H;8LuH8{H`1҉I\t'`u܃tfH=Dž+IF1>Ul`u@ąu9Lc,H=+JFNpLULNJDŽp\HP\BLLpMuMtLvLIM9uEED(DL$DALHAHHLFDLL0IL0IL9uyH@HD(I9t<`AAEDD(DLH@HHLtL)cAjHEdH3%(tHe[A\A]A^A_]S1;H&<މ[UHIHCbJ1SAxJFHHH|$(HD$8;FHD$0+skL +1MQL+DE; HFH5+HH95+skH=ԇ+LGLɇ+L +L+M9u +Lc+H+H +L ~+HDMH)HL!HH)H9HOHi+HZ+HH9skBH=C+qYH~AFX=FHE11StF'!G;FMHkH^>HHD[PH1;FiVStF!G;F,MHH6k>HuHH11?G1[HdH%(HD$1HhkH$HD$dH3%(tLHHdH%(HD$1NH`kH$WHD$dH3%(tHHdH%(HD$1 HXkH$HD$dH3%(tHAUATAUSHAPH+HtnP9tgH5+HߋNDiDnH\K>FuD-+D tD;-uH߾=L@HIEYH߉D[]A\A]1ҾkX[]A\A]AUI>FATUSR1HHÿ>F1rGHIHHuH޿MF1~PHLtH޿NF1`PHUuH޿@NF1EP11L1==+HX[]A\A]@ƉVt OF1 P=z+yjU?Fto11CbJ&rH_~+Ht%Ptʿe?FHt11H{+ H {+H5sz+1ҿ(PFY1d1ZATUSH0dH%(HD$(1t PFmOu?FHn11CbJqH}+Ht3Pt,ʾPJL$LPF?Fn=y+R?F1wn11CbJ)qH b}+Htqu`F!G;FI11H|H1HIĿ?F1kHŋy+HcL$k11?FH$FAy:H|$1HD$ALiD$HILH$HcH3$ HDH$Ht?Fk1t=-y+t*HE1FAAuth$ v=Geodn$mEq$Xp$o$`t%$H)F@@EAA$ $P)F4$ptAAd$EAALACentE+At:A HFA)FIBEAA$(D$.FA)FEIDAEAAAGenuDŽ$DŽ$AADŽ$ADŽ$DŽ$E!ADŽ$DŽ$DŽ$DŽ$" E1ADDAAA  D$Er$tH$$H$$$$$DIAA wuF@F)F)FA ~)FAq)FAd)FAW)FAJABCFA5:FA()FE1ACentA>F)FAAAB$F$t EIPFl7w9$hFFSFIF?F5F+E$F$F $t$FFHD$Ht$FAXFID$CEF$fF$P$pFy$yFAFID]$^F;$FFHD gF$(t E mF$t E pF$t Et }{GwFFFFFFEo$H! $t$FAFIDX$P $ $ $PFHEKFXFEA>F$AFAFAFFFFA!FFM5F+FMẼ$hIL$ALFABFAqFFIE$MH$`FAFHE$YFH$HLE݃$jFL$MLE҃${FL$ IMEă$0AFL$(AFHE$xFHH$HFFLE݃$8FIL$PAFFLE҃$FHL$8AFFMẼ$AFL$MIE$XAFH$HSFLE$FL$XIwFIE˃$A FH$` FMEʃ$A*FL$hMA@FAFIE$ALFH$7FLE$dFL$AFIEAFH$p$]FHDŽ$LEჼ$0FL$xAFID$AFHD$hH$xIE$AFH$0FHD$`HDփ$nFHT$pH$pHD$@FH$H$0ID$AFH$Ht$xMDÃ$AFL$LDɃ$ FL$MDԃ$AFL$LD݃$FL$ID탼$DAFH$LDEA$FMD$:FA3FL$L$LD1L$HT$XL$L$hH$HH$(H$L$`L$XH$L$L$8L$PLD$HLL$@HL$H4$L$ L$H$H$H$H|$PLT$8>FL\$0Hl$(Ld$ Ll$Lt$qIA>F)FM A>F;EFIH$H$PJmFL1H'1H$(dH34%($ DŽ$A>FDŽ$DŽ$AA$ tH$D$D$$DD$D$IVAu`tuH L$L$ډ% ACAS AAAH$ EAAA$$$D$`DՉ$H$$`$`D$D$H$D$$$$D;ED$pfHH;$uaA;(A!wrA w=A ADDEDDDȃt$pDAIuYA A@ADDEDDDA,owA$@ADаADDA9]A:@ADаADDdABw:A=cIA>AA ADаADDADeKAEiAH@A Dа ADDA|AhwXA`Sw AN@ADаADDAf>Ag@ADDEDDDpAy@w Ax@ADаADDDAz(A{@ADаADDAKw\Aw A}@ADаADDAA ADаADDAA A@ADаADDlA AAUA@AA>A@AA '@@@@    E۸@DаDfDkA@AATA@AA=A@AA &@@@@@   @r$`D$D$D$$$$z$$$$RADE$ )H$L$aFnXFdPFZXFP^FFFFH8[]A\A]A^A_USH~PHcdHcHHHH[+Z[]À=e+tP G{F-HcHH=d+wHcHH=d+GAWA1HAVIAUEoATIUSAPHэiDGE1)މD9DF1D9vOAG EtC9tD9s:A Nt+AA-u#A<< ttA4JEMALQG1AMA8 u)t 1MVX[]A\A]A^A_AWIAVAUATUSH dH%(H$1t$T$ DD$(=DpvGg@G,AAu>`GHt1 H~AAu ALJPT$51A>F1D!T$Ht$D!tMwt[t/u[t t.u>h0)G\`)GP)GD)G{8)Go,H9\$v%|$t 8*GU x*GIL$=IHHGHur|$ uNAt *GVAt *GAA@t +G,D@+G1q/Dt$ t +G )GHL1hGEADD$D|$E1IAMLa+IxM(Ht?u Eu-(GSLIL1LLHHQL$I IuH5Y+ RoI@u5IG@I8u5IG8 DL$A11E1AAADL$$DT$,D;5}EIkXEH`Gt D]@Au6IH1HH򮾀HHH< H)觿HAuyUDLHD$0Hk0HIHHIL$(Ht$0H|$0uoGHD$0H\$@1HHT$0HHHH< H)%H]1HHAyGHH| H8LDP%t }Gr GfHH;HHߋL$T$L}HumDIo8}tE@AvuZEAtE1A+GH1%LEs"J,=I+G۽H1HHII u@uH,G豽H1׽H5V+ 1Խ;NM_8A<+Hk0HHILHIHWAHƿG1E1oIuDHH4HttH1HAHLALD$v6GtD;t$w?J1&5G1HT$HT$AMM?J1I4Dt$Ax>F]I8/ H$dH3%(tVH[]A\A]A^A_USHH(A.uy\uXA\OA8tCA\t<9t8Hc׾,GDH)G1LD$HL$DL$v,LD$HL$DL$i\A(;uyXuTAXKHDL$HL$HL$DL$u Hھ,G ~Hھ,GH(D1[],AXH([]AWAAVAUATUHSHQH޿Gu HE1$H޿Gƹ!HAH޿G袹uHE1A'H޿G}HAE1H޿GVuH#H޿G:HAuEt ElEpEtEt!E`EdEhEtIcԉDlEtBD`<,uHtHھ -GD1*Mt9Mp| uh9udZ[]A\A]A^D`-G1A_*H޿G苸AHAAAH޿GKuHH޿G'uH1Hھ-GD)X[]A\A]A^A_HcƺH|9~HHπ.u1u%ttu 1ut9tuZÅtA Hctu$uHkXH= i1H`G1HHkXH`G!t tu&9t H=hPG腸ZH1AUATIUSHHH/dH%(HD$1Hu&HHHHHH$HNJtH,uLoHHHL,$L@3HO@\u{,u H@,H@7HH$8t HHHD$dH3%(I,$tnH[]A\A]Ð1tnATUSHH?Ht +O9vR謓H;uHt:)H,HH4tDgE11H(D`[]A\AWE1AVAAAUIATIUHSAPDHIH3HtHuEu C t1SAUAZ[]A\A]A^A_HkXH`GHtP4G2GGDLk0IHIXE1DHHLMt9PuI@ tBu8t48E1EIIMMtA9Su(uAC tH1LAL1AHHFH~H~HF@H~ HF(HF0HF8FHFLAHcSHHkXfGf1HH GzDJB$3GLkXH EGAAAMIIL[jHDHSCHCHIH1>FHHE1HH;HHK$HkXH DGMk0MHILC1[AWAVAUATUHkXSH8DGH$fAADthHAAAEtH߉LL$(LL$(EtFLHH=5+ J[1,ATI JUSHHx3:HHz3[HLH]A\ J1USHR8tC{9H"JH- R+t"J耜H;HH1eH;tH;;H@1X[]AVEAUAATIUHSHiLcDk(C,Ds8C<CH+[]A\A]A^USHH(H?dH%(HD$1HD$1tt$ Ht$ @1KH=?R+HL$谎HT$H'H;HHcJH5Q+Hk(H.{nHl$M}(DEL]tFM}3 J }3HD$ s(H|$ H0DC,HT$ L$(EDDD$,{8 ~%J!JHu'HI+Ht$ML4$MH!J1LA|$nt$Ht$Lt$IL|$L,$'!J1 Ht$Lt$ML<$IFtIATA@kUHSHI<$Ht AD$H9uHH賈t I׸>FID$[]A\@>FK&JHDÃVtKttH&J*\&JR&JiHt%W&JHLjtytY1ZAUIATIUHcHSHHHHKH9K sH߉T$ cT$ H{LHHkM$AH[]A\A]Éw SHHwC0C[SHHHt ŃHC[AUAATIUSRHI$HUtlu |t}uEt H޿\蹆}H譆HX[]LA\A]SH@HHHH[SHHC0C[H1HG+UHSRHHHSHH9S s HڈHKHqHs H}E1LJX[]ATIUHSHHuw} ~L9t ; uHLHHH)[]A\ATUHSDg1D9} H[]A\USHHHT$`HL$hLD$pLL$xt@)$)$)$)$)$)$)$)$HT$PHdH%(HD$H1H$ HT$D$D$ 0HD$Ht$HHl$ HD$8Ht$(Ht$ L$0H2HD$HdH3%(tH[]ATUSDgHo GG H72Dck []A\USHHHT$`HL$hLD$pLL$xt@)$)$)$)$)$)$)$)$dH%(HD$H1HT$PH$ HHT$D$D$ 0HD$蘀Ht$HHl$ HD$8Ht$(Ht$ L$0HD$HdH3%(tH[]SHt zC[U1HHAUI1ATSHdH%(HE1HPILH HH)H\$HH輀LH血HMdH3 %(Ht[He[A\A]]SyHxHޢHHٰ HH[ATE1UHSHdH%(HD$1%9tH=7+lH=7+Il1Hv>H=v7+HH=e7+HsH$H5K7+H_wLew1t 'J覀HEHT$dH3%(HtZH[]A\SH=6+qtH=6+1[1Ys[ATUSH`dH%(HD$X1HHH=6+t HT$HHl$@'JH=+1LdHl$HH\$H\$8HHT$ (Ht$ Ht HD$(H=+HH'JH1H +7 (JÄHT$ H'~HH kH=k+1X(J见HT$ H'~HH kH=/+1(JkH$ H'~HYH kH=+1(J0HT$ H'~H+H kH=+1(JHT$0 H'~HHMH=|+1)J踀HT$@ H'~HH kH=@+1H)J|HT$H H'~HH kH=+1x)J@I'IyLkH H=+1)JHT$P H'~HKH kH=+1)JH'H#H kHH=V+1*JH'~pHHkH H=!+8*J1]H5+ \~HD$XdH3%(|L Hڹ tH HMGHMuHMHMH kHM,HMZLMHHMHMHHMHH`[]A\U1ɾC1SHdRC%HCX9k`vH{XHHsh袎X[]HX鳈1@SHHpt@oHt H׃fHH@ItfI@tLǪC8C<1ɺCCd肍HCX[UHSRG XHk(H{x.HSH=0+1+Jl}HcSt Hk(H]1X[]HO+w!Ht1HdH%(HD$1H$%9t HHGh01vH0H$+JBHL$dH3 %(tKzHHdH%(HD$1H$%9t HHGh01vHv0H$HBHL$dH3 %(tyHHGHÉ%9t HHGhHt9G81AW%AV9AAUAATIUSQt HHGhDDA9t HIT$h*9ف9t HIL$h1 E1MtE1A9t$8s11LAYlÉ9tHI|$hD E1Mt AE1E9D$8s11LlA9u[EtVEtQDLl.DLH^.IHt{uMtAuL9u#L9uHuvDD):)410ED9sDk LD.HEw LD-IZ[]A\A]A^A_ATI%U9HSt HHGh0HUL+2HJ-HtxtH]L[ -HE[]A\ATIUHSH dH%(HD$1H$HD$%9t HHGhH1-HH$tRxuLHL$Hjv HT$zt(H $Htyuv+Ht$~u MtI $HL$dH3 %(t*wHHHL$H,jH []A\AVAUIATAUSH@dH%(HD$81HHD=+HD$+JHD$+JHD$ +JHD$(+JHD$0 ,JHu Hk(HHk(H^CA J<wLLErfGu {+JHEH4$D1Hپh+JHxEuSDsE1E9u v DLk(MeKHS1,JHwxMtIL$+JD%,JH1TxHSK=,JH1H9xHD$8dH3%(tuH@H []A\A]A^wATIUHSH@dH%(HD$81%9t HHGhHL$0LzhLT$0MtRAJA+2AIRAAAAEBA!1Az@9u3Iczt7Lk(M$t-IKE1,A>FDEEHAT,JE1X,JD$ 4$H\$Dd$+JLT$1wHD$8dH3%(ttH@[]A\AWE1AVAUATUSD_ Dw DWH_DHk(DMk(Lk(HHL$1Ho$uVLNHDD-++Lk(D++DLT$L~AHH~Ln(L~0LVL^ Lv8LN@HNP[]A\A]A^A_DEMk(IL9wPHt$D,1DMMD9sL@DJHqG E9 HD΃MHt$H(EAVHAUATUHSHHHD +A֋V 1_,JAHuU$x,JH1uU0,JH1uU81,JHuEtEHٺ,JE1MxD9e v1DHHAE9uH޿ RtEtPHٺ,JE1xD9e$vDHHAE9uH޿ []A\A]A^s[]A\A]A^AWMxAVAUIATIUHSI\H(L9MAJtM/<$t II9u퀽7tA7@f?Jt"IL9wE$M1M)EEDD$"@$u7uIMHD;XtH9T$wdLHT$LLD\$L $LLT$bsL $HL$D\$HT$u,J1H/H([]A\A]A^A_1G Gt!9‰sHkHHOy&uP|oATUSFH?uBFutNuJ-J1.7AH -J11.EAH (.J11.[ATHLjIUHSH&HhL@0HX(H@ HhfK[]A\Hx0HP(uHHtHJHt @q@1@AWAVIAUATIU1SQDIHxuL&HË(H0uHXH;XLK+LHVuHPH;Pu |tmHruH+Hp%Hx(HHtLGA(ILG+HpCt`HL*.A~LLHX@QHf@Hx(t%+LfA~IA~t {M{5qL{EWA?A\C RAGLHfu 3AA~'AG@I1LJxQt fDxAAHLAHtHHLgdE1LJxQI@LH@QLxf@1L(xHLLftdA~IL~H@QLxf@2IL`E_HIOIWDXfAGHKHS fCMtbu+A,$AAuIHt0LG(uMMu#ADEVE^0A$tEAEA$ EE $EHZ[]A\A]A^A_SHHHiGGDtHuKK[1HxuAUATIUSHQBtH /J1*HW8NHHBH+BH4H9sHw8iFI|$8DMLGEQfDUKfKDmAE9$s I$D E$I$D]M$1HSAITfD[Z[]A\A]DLOE1HIAt^DfCJ t#EuHHtfJ uAA #<"t<'uEt A8EDAHAAHIDH)ATHUSHHHH)H9s:HH)HIH,vHHHHLHH[]A\AVAUIATIUSFt="IH1LLHHH]HcLHHHD( HFHXHPHLL[]A\A]A^AVAUATIUHSHH+f~u-HszcI$HH HE]MHO8AՋVLs HAH+AILH9v Hw8$DIT$8}HHrMHHuH_fDoI$DuM$EM$Duu ML$8Mq[]A\A]A^1QFtLHF@t(H1HH9q(uHw HIHuHtH5J1p'1ZUHSQHHƊFHÈCfJuHHHqHHH)0HZ[]AWAVAAUATUHSHQHHG(L'HzDxDt$AD9EEDT$_Mw\}al,ItLH\H{(LD$1LLwDD$D$;|$D\$EAE|$AM\t"t 'MFMMANv|$kA}*`T$TLLHLI{1|$t |$#LHLV@xILMO?@A{ƃ@LXACEcH4$AHtHLL$L$;LL$L$IcHLL$XHLD$ALK(L+L@H$Ll$(D$$AqH|$@LT$8AD$0ILI:AADDA|$|$0L\$(D$$LH+MkAu9t$$T$$Hl$8D$H||$L$0-A#HT$(LLD$$HrL)ЀNHJDiD9l$$wD\$$H|$8J߃|$$u!f~uLd$@KT"I9AEDT$$L$$HT$(HLL$0LD$LD$LL$0LD$@LLMOL|$(MofA}uLHE1VD$0IEL\$81ɋ0xHftM$M+dHV HHMJL!HqHI}HPILT$8E11ɋ7L_1HH9tE EAA"D EDHDwHfEO|1MILOH{(L 1ҋo AAhGJtr1Ht@h@{AH=`>Jt H=>J„҈StC@tC1HO@tKHHHDcH)C[]A\AUIATIUHSHQHtK{tHsHLHHu1LHHLHHQIHCH}RHZ[H]A\A]ATUHSHHt7{tH{HHHCLepH8V{HELH]A\H6JHH1fUHSHHdH%(HD$1=HHtE@?<u;H4$HHt*ZHHtH HH{uc1HWpHD$dH3%(tSH[]UHAWAVAUATISH(dH%(HE18Hu:M$A@7J1L1AQ]L1ڐL2HHX1QL| HHHH)Ll$I;LHDLL9s'8\uDpA"tA\uHDHHDC1L]L KtHH1A t HAH@t HAfHDHAItfIAtLϪIE1LDLHHsLHHCPM$HLL+'@?Iu KHLLHHEDIIMwIxsHCBD8 HBD0MELD[ApAsMMHuEQAAE D[MmAAUA D[I$HEdH3%(t]QHe[A\A]A^A_]SHG(Hx0u2t$t A9r@t,5=JH1' @t5=J1H1 Hx@p@=uBHpA=HH$HD$MtLd$H*@t$HH&=JHH1 =HFEʼnLH x:JH1T HD$dH3%(tKH []A\A]A^UHSHAQuY[]:J1 1DHt@hHXX[]S1H8G1bH1ɺN=J1@H@B@EH1ɺY=J1@H@@(H1ɺc=J;F@H@v@H1ɺj=J;F@H@@H1ɺi\uEVA"tA\uIA>IIA}AE H8LLH}LELMjLHL)LH.LMZHMtMcPMbPLk(CHCƃQEuJtlH+b{ u\LIt H(@Hxu'u.HHHHH*xuɀ#CLCCLCOAA2*iLHIAOL=HALM sLUHƹLfAJ C|=PtqE9u#CvALALcAIkLnII럿hLpHLIMtH1HAAALHICP譓HDHEHU1L}DHHHLLHEdH3%(tlFHe[A\A]A^A_]SH HƃQtpHPH:JH1a1[UHAWAVAUATSHHLdH%(HE1Hu:LA(;J1H߾1AT$H1YH 2HHp1QL\HHHH)Ll$I>LMLtM9s&A>\uAN"t\uIAIIAW1HA܂E1H1 MM|$LLhGMI<$u HI>LH~HI@LMtHAEMA?Au.LMt s0LHAҀ;t 1LHlAE?tLHAD$M|$=JL FLcLHDY9Mt$` f`ILDL)LHHHItHAGjLHruKBHM]AL$At$ED$AKIUF BA ؈BI}DWAE DWI|$AI|$ALA MM$$IHEdH3%(tfCHe[A\A]A^A_]úMUIHHHHdH%(HE1IIIRMBHLH)HT$HHBD LLHEdH3%(tBAWAVAUATUHSHHL|$PHuAA?JLAADD$ CL|$PDD$ HIHH[]DDDA\A]A^A_AWMAVAAUAATUSHHDttDg09Ho(DeH[SHLL$Xt:)D$`)L$p)$)$)$)$)$)$LL$H\$0dH%(HD$(1H$L $MAȉ1H\$ D$(D$0HD$uH\$(dH3%(t8>H[SHLL$Xt:)D$`)L$p)$)$)$)$)$)$LL$H\$0dH%(HD$(1H$L $MAȉщ1H\$ D$(D$0HD$H\$(dH3%(t~=H[SHLL$Xt:)D$`)L$p)$)$)$)$)$)$LL$H\$0dH%(HD$(1H$L $MAȉщH\$ D$(D$0HD$H\$(dH3%(ttJ?tK@tALEÃ=Ht>It?Jt@KtLAEÃD8tE9tF:t;GEÃ8Dt9Et:FtG;EÃDËWHG19щs@<H@"t@'u9AuLF tDREF8 tDHATUHSHHH)HHHL LaIHHL[]A\HHxtlUSQHhuSH}8uLfuBu9H>HuH~[HCHHsHH}HNHKHu3GfiH6HH1HHHQ LiHH)Ld$IL.L!O,HLHLEfA.oA@HEdH3%(t He[A\A]]AVAUIATUSHA}LE<:t tHIM)I|$IBLHLE1B Iƀ}:S0AI;S4u,tH{ s4HGs4H{(HC HGHC(DC0LS EAO4L[(O$DC0Z[]A\A]A^AWHAVAUATIUSHHHdH%(HD$1#Hun1IE19kv^HCALJHIJvLIDcJAuA cJLX@xH9 r"H\$I9sIA{IAyH) 1LH\$dH3%(t7H[ATULSHdH%(HD$1I8$vjIHHHHuRIH<$HHHHIɃ@<0D$L@tDT$FTD\$DH1HmH\$dH3%(tH[]A\USHAQH:vzHHHMLMӃIBtFL<ABADD(Av"wLHuHEH+TZ[]AWIAVIAUILATIUSLH(LH HT$LD$dH%(HD$1LD$H $I.vT$H4$H|$vI}TI4$w3H;v3E1MAABT%L$A@t=IH+oH;wI}I4$Z MAAAEEMBLBt=BT-IBT-IH+Ht$dH34%(tH([]A\A]A^A_ATIUHSLLI1HA4TH@@AD$A(=wIIvm@TMLHAT1GLAA$w: A$LHΉuw I$Hm I$Hm[]A\AUE1I1ATI1UHSH1HHdH%(HD$81VHHSHKL,$Ld$ HHH)HL$0HD$LD$0HL$HT$ HHH|$ LD$0HL$11HHtLCL+D$0LC_8H{HD$0HH;Hs:HHCLD$0H+D$0HL$11HHD$Hu@8u6HsH;HD$0HHs9HHCH+D$0HD$1H|$8dH3<%(tQHH[]A\A]AUIATIUSLHHH$IPdH%(HD$81HL$ IHHIH)HL$0HD$I_ALD$0HL$HT$ HLu AՉH|$ tt$HsH+t$0HsH|$8dH3<%(tKt (1H{HD$0HH;Hs8HHCH+D$0HD$\HH[]A\A]IHHHAIHHHAIHHH_AIHHHAAVAUATUSHH HHHLPDHvuJEtJHDHGuJv&uJEuJHDHɺGuJHHEHMGuJLDpLHHLxLGuJDHHH=LHHLxEuJL׺&uJHDD HHGuJH(HHEAtJH׺uJIDHHǃ8GuJL@HHLLXLHHǃP GuJLLHHDhH []A\A]A^SHAHu HHAu H|H(Au H0cH@Au HHJHXAu H`[0[USHH8dH%(HD$(1~vPpJ1@t$ HD$.0H$HHHD$HHt$ H=$Eu ЄupJHD10H|$t麸pJH1`1H<$ HT$(dH3%(t H8[]AWIAVIAUATMUHSH L.L$MEu#<upJ11LD$LD$30t*|$u#AM0qJH1LD$dLD$AUut/Ut*hqJH1LD$LD$1Au JtJItM9rׅA|$AEt 1E/EM.t L麈qJL)Bw u$t AAA@uxD(Aw$L麸qJL)H1$uTE7tW9t!}uƅ9OJH1vA$AD$$FE45A1AA9t"BALcB cJ9rLcލpF4cJA>t&<t A t AF u=G @ u- @ u = @> u-F @iw-@PXw"-@=+w61AA@#HٺqJ1LD$LD$@@u `@uG.A u?AtA|$AOT$AT$!AA|$AEMT$ET$A$E|$A<tAAEAAu!|$uLrJL)H1!۸t LHrJL)H1H[]A\A]A^A_UHAWIAVAUIATIS1H8dH%(HE1HBHH)Lt$ILuL9ALLM\tIQHUA 1A|uLL)HLD1HuL9sEuH˃$u5IAHEA$YEDCJtEJHADHUHut!EMrJLH2HUILL)HudH34%(tfHe[A\A]A^A_]øGuJUHSHHdH%(HE1聲x%tHHax7tHHAx=u PvL@JA</u rA<0/tHEHt;HJHHH)IpLL$ILLHߋ@AHEdH3%(tcH]Hc։Hk @`xJH`xJ@<D@D DHD'DPD8DXD=P%H!@p@&D@D(DHD)@ EAV=*AUAATIUHSu]޾*}'J?J*#*]۽*|۽*[ӽ*^*}ͽ*\ӽ*{*~+(,(LpPH1A8AMt LA7IAt LAfIDLAHtfHAtHתDHLƃ/ƃ#ƃ$ǃƃBƃ.ƃ2ƃ+ƃ1ƃ7ƃ9ƃ4ƃ5ƃAǃ`ƃFƃƃGHǃp@HǃxHǃ Hǃ ƃƃƃHǃPHH#LHXLc(Hǃ>FƃQHǃƃCfǃHHLLHCxHCPHCXH1$1HHC8HHC@HǃHǃ HA$@0HD11HHH*H[]A\A]A^Hw(AUATUSHRHH;t HPHHHtHǃǃHHtH1L'HLHH H{8#H{@H{HH}LmDL9tH7MtLH{PHt L/LHt-E1D9H~LIHH<HuXH[]A\A]HHEH}HHHu¸wJP 9uHHH=wJr1USHQ+ Dut =t kuJH t& wvuJHduJHU uuJHAuuJH-uuJH<t uJH(t# uuJHj vJH]tvJHL /vJH="tZH߾AvJ[]$X[]ATUHS tƇ0?tuEƅD.u%.Dtƅ!ƅ%ƅ.E1tE1䀽BAĀCt A EtOAwJSH3HHfH`ʃ?fD  fH@sHwJ<6@xr[]A\ATUHShHt%Hu HHHHE1E11HH$HH1H1H?HtyH$x%Hu;HCIH诼CA|$7ufuH߃TGu#H胼HK(A Hk(H1HF H[]A\UHSHQ;t 1Ҿe@H;t H"Lht1Ht,HHH^mtHH&*t ZH[].X[]UIISHHXdH%(HD$H1Ht$LɾHHL$EHt HHHH\$HdH3%(txHX[]SHHH$dH%(HD$1Z~1-<$HKHSH{LC HHC(ЃHL$dH3 %(tH[SH@H|$H=p4$HHT$HL$dH%(HD$81LD$ D$(H\$8dH3%(D$(tH@[ÃuHvHO@HVHHw@ GHLL@l$hDL$_Ih(DT$pEhDL$x$$L$L$L$uHkHEH} HH IIeH@EDLMMu sAEaIMEl$(A9rH5F 1HAE11ATIL$ IT$L$ t$XAIIL$MLO,+*tIM IUH$@t$XIMH,$LHLLiHHID$ 1L$@M] E1HLD$pL$ L\$hE1IM9t!IkEdAA@IDMIkHLL$L$H|$xHLHIL$L$1E1M9tnAp@uXA8H;|$hr*1HH5E AHT$xILLL=AH|$pIkLH9I@HAIpHqIIH LLH$ HHELeLmLL'H$MN0A~uLLMtLH(0MMeLMeuMtMLImuٽ1H$HLLE1H$HLLL$L$@1I3HtMIStL9}IHH9HLIM9uHtMu4|$XHLE1-Lt$`L=KM>AH$`t$XL)IMLH<$LE1ME|$XHLH$L$`E1HALQE1J<(t MM)N)O*IIxu1|$_LD$`H$(L$H$H$L$0L$@LD$HHT$(t$0LL$H $L$L$H$H$H$H|$H\$@LL|$8Ld$ Ll$,;H$AHILLAAUH$HLLEtH$HLLE1ztH$ HLL`EtH$@HLLEEtH$`HLL*|$XE1t HLH$8dH3<%(Dt`/E11E1=E1A*AAE11AAD$XA#HH[]A\A]A^A_UHSHHHdH%(HD$81Hts?tnH}tgHHRHL$HsxNHT$ LCHKLL$0HT$Hs H4$HUH;t|$ tHC(HKH|$0H91Ht$8dH34%(tHH[]AWIAVIAUATULIH1SHHLd$ Ll$LL$0dH%(HD$x1Ld$L,$\Ht$@H=H\$@L|$HLt$PHl$XLl$`Ld$hvD$H5|HHDփ{uH{(tt HS(HK(1H|$tHH{H{tHH{tH{Ht LL9u LL$0LMH|$xdH3<%(tHĈ[]A\A]A^A_AWAAVIAUMATUSHHLL$Hl$P1LcLII\IM1EAԺLM)L!HHuH5= H|$A1IHEH]LeH[]A\A]A^A_UHHSHWHvHx>yuIHY[]H5d? AX[]HH9w H9FÃHH9r4w5SH^H9_r)w$HOHV1Hz(H9y(@MÃ[HH9w H9FÃHH9rw1H9CÃHH9w H9FÃH1H9CATIIUHSH0HdH%(HD$(1HFHwH9sLHH\L9t81HL$LH GHHu1H5.> HAHL$(dH3 %(HtH0[]A\ATIUSHt$(LI@Ld$ HHt9LkH3NLMQM9t MZM9uIAH9D$0uL9ոv>Ii8IؾHt$HLd$ Hl$(Ht$ HC1[]A\UH= HSHHLOD+OLHdH%(H$1h1H{0HS(H$dH3%(tH[]SHGHH9v8uH5= rC81HwH)HG[AVE1AUATIU1S1۾LMl$tT?EmwLكHH EuH5= LAExA@t?w HHH H1[]A\A]A^AVAUE1ATIU1S1۾LMt$tt0u4[~H_>1҅t! H5l: 1[SH_1҅t[AWAAVAUMATAUHSHH\$XLt$PIA1MIAt HAIAt LAfIDLAHtfHAtHתA}AwQAyw*AbAHAX]tA wA xAHHCAwWA$wAAA-HHCAbw6AAA xHOHCmA 6A!)A5HAHHCH}H{HuOHplHLee1KA4$AHL9rH57 H1ILkjHHCNADHkHC%HLmE1tEELCHHsHYŸHkHHCHDD$ t$t$ADD$ [ HHHH[]A\A]A^A_HCCHHC*HHCH556 H51H[]A\A]A^A_AWAVAUMATIUSHHdH%(H$1HFH9w LFH)L9r1H56 LA1HO HHH;I)L|$@U`H54 LD$XHL$HLd$hHt$@Ll$pH|$PLT$`D$xHuH5H6 Lg1H{HLLHHLL$0E1L|$Ld$ E1ILL$MHL9}HEL\$J4ML$PDC KS|0L\$MT$XHt$(Ht$L$SLD$(LEAGt4wtent tV|$0uOLt$8H|$0uAHD$8IAxt1 t,T$0tuHL$ HT$8MHL3HLEI&L1H$dH34%(t2HĘ[]A\A]A^A_HH9r'wHVH9WrwHNHH1H?GÃAUIIATILUHSHPHF Hv(H/HS0Hs8HAY[]LMHA\A] AVIAUIATIU1SHHHsH9v-HMLHLHHHVHvHMLLHHCH[]A\A]A^AWAVAUATUSHHHH|$Hl$PHu1IH6MH|$LI͹MAHtLH|$IMILL)HIHL9r$I[MH,$MLHS Hs`uBMI)I9{wJ;| sILMLI$Ht$AՅuHSsI$uH[]A\A]A^A_AVIAUIATIUDSH\$8HCHtHkHHt L9.u L9fuD9Ft2HL$0ILʾHtM.L`hL(HC 1[]A\A]A^AUIATL$1UI,0SARH\$8HCHt4HkHLD IpI9t LVM9uM9huH9v8Ih2HL$0ILʾHtL HhLhHC1Z[]A\A]AWAVAUIATIHRHUSHH$0HL$0H$L$ L$(H|$LD$ HD$XLL$8dH%(H$1H$HL$(H\$ H{tH|$ Hu H$LLH0HHp.ttt D$h1~H|$LL(HHIA(t 1HA'IAtL1AfID1LAItfIAt1LתD$hE1L|$xL$D$tHD$PMD$pD$HMD$lHD$`HD$@Ll$@L9mLl$@LUL\$(MOPED$ AL$N,AT$C|*L\$IwXH4$Ht$ }u"LMC<)u$u L$LD$0|$hLmAMGw0rw/z1YwUXtn $L$MuLLCiLT$8IUI;R0rH|$ H5!/ L\$8Is8NLLK-$H$CEmAA $tL$HL$xLH$LiHu5$H;$H$H$uwH$D$lHD$``$uL$D$HCu?L$D$pD$H%$tuH$D$tH|$PHD$@X|$hLML$L|$xt4H;t|$t|$HH|$ML(H1} u?H\$XLL$8LLD$ HL$0LH|$Lt$H\$L<$ H|$(1Hl$(LL$8LLD$ LHL$0H|$Hl$Lt$L<$t{H$4Ht$(H|$LLstSH$H$H HH$HkHS MEHL;D$Pw-1H5, LA1H$dH3%(OIE@HL$PH5* A}`L\$0Hl$HH$LH$I)HH$L$$L$L$DŽ$L\$@$fu H|$(u H|$(IHL DU At0AuXE1IA9At#AutH$x L$K4*H$XIH$P0HpHZuHDL$PHDŽ$ML$XM9veA?t_LLL)M|AC|yIMAC|yIMAC|/yIMH$H$H$0H$(H|$ H4HH$L$@E1IH$P;N$xH$XHHpL.L;/tHuHL$XLQ8MuGH$J(HxH;$sH$LTH$H5$ U?1LLT$pLHHLHHT$`LZH$(H|$ L\$@IH$0IKt LL$HHLD$pLT$@HHT$`L$LLHH\$HD/HHHK+LIL$x|H$H HT$`tL$M)Ll$`LD$`LeL$AH$Hl$HLd$pE1E1L\$xLt$@MDH$yHL$rE1҅tED$AD9rKD)1D$$ANj$A1D$ADA1ADAMAHHH$L$A6@t%w@q@t(@\Ll$XHAu .IL$H$LBHpHlHHIH A<$/Eu LD$XMH8?ANH;$sH$L #H$H5U" Lt$@Hl$HoI1LL$LLHLHH$NH$(H|$ L$IH$0IKt3HL$L$HH$LBD/ILLLIH$HH:AA PH ! AH! Hc4HINj$D$1II1ILIAHH@HL`L;$rH5 HLt$@Hl$HL$Md1D$D)$1ANj$AA1ADAMA^HBDME1GH:L$E4E"HApLd$`E1E1L%Lt$@Hl$HLl$(L|$0H$H\$ H$H$HDŽ$LLHH$LLHE1HE1HD$@E1$8Lt$@Hl$HvH$gLd$(Ll$0H$L|$ ILLLH1HH@L@LHLH$H$H |E1HHL$ H}hH$MnyHD$@LDMMuH$1HILM H MUD]`Ht$0H$H$@HL$(H$@L$HMEHD$HL$XD$`H$hL$PH$pDŽ$xH|$XH$XhMoMMHL$(HT$0H$H|$ M?H LLHL$(HT$0H$H|$ AH|$ uLT$PLd$@MzhMb`MjpIZX1Ht$PLL$@E1LLN`LL~hLLnpLH^XHu^Et8LT$hLL$(HLD$0HL$8H$H|$ L$EHu!E111H$H|$(L|$8AInL$L}HLHU`>HHMFIx@IX0Hty;/ttMx8MtkI1HLHT$0LHLHH|$ IHL$(IMl$It-HeHLLBD /IHLHHIVHZ@M^E11H$H|$(Lt$8IS@A+IPpHu$HHPE1H$H|$(L|$8AIphLL-HH$tMvIHMNhMnp6HMHUE1H|$(Lt$8AMI)I9zw!J;|8 sILL)HHHL9rMbHUL$]LD$(L$@HL$8L$H$@It$IT$ $u'M$$H$@H$H|$(HD$8H$dH3 %(t{LL$0HT$(1LD$XH|$ HL|$L $LL$HHT$LrM-HL$(HT$0LH|$ HItID$jE1E1vHĘ[]A\A]A^A_AWIAVIAUMATIUHSH(dH%(HD$1uKH_ HL$HH $HL$MMLLHHLuu|$HL$t1eHHW LT$HHHuHt5L$MMLLHHLT$u!|$uHLT$E111LLAHL$dH3 %(tDH([]A\A]A^A_AWIAVAUATUSHHHH$H$L$Ht$XH$HH$L$L$L$H$L$0H$H$H$D$dH%(H$81L$H$L  H$LLH$H$8H$@H$H$HL$XH$pHDŽ$(L$0H$D$PH$`DŽ$hL|$ MLt$HH\$0IHt$(HT$`H$H $h L$@H|$HL\$@AD$8uH|$HD$8IĻH|$0Ht$HHH|$HLL$Z H|$0DDt$lAAv!H|$0H5E LML|$ ' t$8H|$0H;$HDŽ$HDŽ$rL1MH5  L|$ HAL$H$H- D$L$HH$L$E1M H)L$H$D$L$DŽ$H|$(Ht$`Hl$(H]Ht?$(2HI?HfH/HHt"봃$(MH|$ L$ILLLbHIH$L1LLt$`1ۃ$4LHHFLL$LHD$PLd$pE1ɅLD$ptEH|$(LAE1T$pH|$(BHtH|$(I0MuL!LE1iH|$ J4LL{HItxLl$xE1ILL$LHHL$tCCDILLl$xIL$D$pH I+l$PAC McMSAkLML|$ H$HLLIH$H$H H|$0L$[E1tE$H$H$EDL$pH$H+T$@H$H|$0H$H$HLLZHHHDŽ$HDŽ$E1D$xHDŽ$E1D$PDŽ$11HD$@1H9^HFHT$(L$$H$L$|DD$pHT$L$lT$8Ht$0L$QH$$L^EAt7wAA AAUtuA%$H$HL$@$uH$AH$DŽ$AD$AtAuuL$D$PcD$AtAuPH$D$xH$6$u,H$H$$uL$L$HU$Etu |$P5|$x*H|$ LLxHILL$L$H$L$DL$lT$8t$pH$LLXL$HH8L@DHPp HX0H@@H$H$L$IFXIF`IF(1|$PI~HLMVPIFhIFpL;$rL1MH5 L|$ HAH$H$H- D$L$H$L$ L)H$LH$H$H$D$DŽ$($(Av H|$(Av H|$(IIM EF At0AuRE1IA3At#Au6E1IAE1IA E1I9AEt HD$@dLd$8~L$@~D$8HD$8flD$8L$Ht$`HILf)$LHt$XH|$ K$(LML|$ IvHHLLILxLLLd$@L$Ht$(HLML$I胼$IEL$H$LHt$XH|$ e`L$H|$ LLL~1L4$hLML|$ u YLML|$ H$HLL13L$H;$(HkHLLHIt4HHH$HLL/~L$L$(H |LLQLH龈LHH8Ll$XH$HrhL`HA LpL$LhHh H$L$L$L$H$H$$HB(1@LB0LJ8LR@LZHHJPHzXZ`t HAH@t HAfHDHAItfIAtLHt`AM u MMMtMI'LHUtLLmLLmuMtLH$L L 1H$8dH3%(tHH[]A\A]A^A_IHH9HAASIHЃ Mt@A<:A41@A9wpMtAHHMMtA HHMAtDA  Dۃ A1뒸 [ATUSHHHdH%(HD$1HyH<$< w$< <Ht5<<txw < H<DaHKNDED΃@uAAAE Et}pADYHH $DxbHHH $LHiLAH,$DaQL$AAEu2H<$AyHHH,$ QDt H $H 1H\$dH3%(tвH[]A\UHSHHdH%(HD$1H<$H$H9s>8u#HPH$pHHcLD8L$HHH^u1HL$dH3 %(tIH[]AUATIUHSHHdH%(HD$1HHH$H4$H9sSHNHH $DV~H4$AAxH<$McJt/>uSHu1ML$L$A8u/MHI@L $EXEPH$AEIcA<0tL$H<$OWHLcJ4/tL,$0HI4$HHH eH\$dH3%(tH[]A\A]UIAHAWAVAUATSH(Lg HH@Ht$dH%(HE1IHLWAMt LfAIAt LAfIDLAHtfHAtHߪEk8E1ɹAAEk8L9t D2Au3Ek8EEAAAA DʳE LEk8LLBAMB$}JAK81DzM1C<zLz1D4McMAuM1EDAIcAsADAHZ1LcMD,A AHDrHZE1BHcLtAALcF,ErB:I1`kuAHH=uF1Ҁ`ktAHHu%Et$ 1AHH=uAC@uEt$ M1AC81PDzDBAEMcEND*kE0At AXA@AxEHMD9EyDL9ED%E1APE0MhDLcMM9s\D9uKkF*9< 1HH}HHH)HD$HHHHtuMDAL4AK8IEMDzDjLBDzMAMLBfLB]AA1A E Ek8HudH34%(tAHe[A\A]A^A_]AWAVF4AUAATIUSDHHE9M|$ Ht$$It$(DD$4AHt$ DIyD DD)D9NI|$t,~(I $DA tA uA|$8x Mu&MMcMD$(M)Dt$0LT$8MMAD$8uLL\$(SL\$(uj|$(ug!D$L$AHt$LDLDD$DD$4L$Vt;\$0|AD$8u~wE1D9LD$8} +D9| AE)ALD$HcALH|$ t1E9~10H|$ H7A<uADC<u HAE9D)DD9}EuD)HA HD$Hc8H|$ t Ht$ A<#;\$0|$(AD$8 t HH[]A\A]A^A_AWHIHAVAUATUSHLq(H$H$dH<%(H$1H$`Ht$8f謭HH$Ag8=b*H$IGIG0IWuF`k1@H1H(DutƆ`kHHu$c*;b*IuII?Ht ҭI II?uH$譧 *IG L$I/D$hDŽ$ D$lHD$PMMA MAL$MML$LAAHL$AHL$AHL$HL$HH$IH$M%H$MH$H$MӁH$MA@H$ ML$(ALMAHA AHA Hȃ@HHMLL$XLT$pL$HL$ML$PH$0H$8H$@H|$xHl$`HD$HHD$0H$L$`L;L$88(IIMH$`AtA.w?(cw $%*h+%\w?[%{m|N^h%IMIHl$PH;$H$IAE1H9$s E1Ay\AEIA(uH$tA|$H$EAE$IMҾHIIBIv`HIH9tIHt$PHL$HH)H|$0HHD$`HHLHDHLDHHHDHT$PLD$HHD$0IMVII)IM9v<`H9L$8uH$0H$"MQML$`AtA*u$+L$`@A ?A L;L$8uDH|$Xt*\u/L9T$8YMYML$`AYtA?t+tL$`H|$HE7M.MFHL)HL9vvIMLIIBIveHII9tH|$PL)LT$HHHD$`L HLDLMIDLL$PHD$HtMH$`txAO.A4? p.9u\AtVH;D$8sOMtDEO C A D9u,H$8u!L\$HE AI)AD]AD]Dl$HEA)ADmADmE1HE1HI.MFHH)HL9vwIMHIIBIv(HIoH9tH)Hl$PHt$HHHD$`HLHHDHHHDHL$PHD$HsLD$HAHkE)AEAL9t HˊSHD$HHD$0DPAEDDPLl$PIIINHH)HH9v`HHɾHHHBIvDHIH9tH)HD$`MLHMMELMLELd$HLeLl$PH;l$Ht H@}@}EEEHD$0LH=HHH=HBIv觤HIH9t7H)HL$0HD$`HTIMDHHEMMEHHHDHD$0IIFMI)II9uHl$PLLl$HEMHTH9L$8T Ld$0Ll$PIIFHH)H"H9v^H=4HHH=HBIvգHIH9tH)HD$`I|HMLELMLELd$0Ll$PHl$HM&MFIM)IM9IMLIIBIvMHII9tL\$PHt$HL)LD$0HHD$`IMH IDHHDLMIDHT$PHL$HHD$0\L$`LUL$A;^ƒUH$`}^u HH$`H$`H$M.INHL)HH9HHɾLHHBIv_HII9tLL$PH\$HL)LT$0H$HD$`M$ML,MDHLDLMIDLd$PLl$HHD$0OHGHA  HHD$@I1@tAIAt LAfIDLAItfIAtLϪL$AzuH$tAJL]DŽ$1ML$L$L$`L;t$8{M~ML$`AtAH$tX\uSL9|$8 M~ML$`EvtG44EH|$@DAAD$7q]uL;$I-tA~]tH$薚 InH9$wA~[t`MnL9$wA~[uA~^tDA~]t=LL$@L$H$`HT$8$L]ubDŽ$Av@-u^A~]tWHl$8L9@LL$@L$H$`ILHL$`tH$趙H$[@:gHT$8L9IL9L$`Hl$8E1L$`I9MuML$`AEtA<:uA}]t%L9t AtAALj4pƄ$pA<:Ƅ pA}]H$pHJ&H$pNJH$pTJD$$H$pZJD$(H$pyJD$,МH$p`J輜H$pfJD$覜H$plJAlj$\臜H$prJD$qH$pWGD$[H$p=GD$EH$pxJD$$X%|$$D$ tc$XtX$\tMtItEtA|$t:|$t3|$t,|$t%|$,t|$(tH$qHD$8L9MmL9L$`yDt$E1E D$XE1u%H0B6uE|$$uHfB1u,|$(uLC0u|$,u0LC1t!EHt$@DAEB<u謞HfB 2uG|$u蓞LfC<0x0Et~LfC1u|$u3eLfC2@t!ELL$@DAAA<1|$u+HB0uK|$uLfC2 u2|$tLfC 3u|$ u5H0fB6t#DHT$@D@ADAF Mt<$Xt2蟝LfC3t!DLL$@D@@A<AIA0&L$ADŽ$:E1L)$`AI AI@=#HT$8L9VIL9L$`.E1L$`L;|$8+IoMH$`E/tG,,A=uA]t(H9l$8t!AwAAD4pƄ$pAA=ƄpuWA]uP$ptEA>H9l$8AH|$@IAEL$`BL$ADŽ$=E1L)$`AI AI @.OL\$8M9)IM9L$`tE1QH$输IWMH$`A/tA,,@.t/H9T$8t;Ex,EAB,pL$`L;|$8uA]u Ƅ$pA@.Ƅ4puuA]un$ptcAtH$`H9T$8PAH|$@AIEADL$`AD$FWH$ADŽ$.AH)$`I I@+H|$@AADDD$1L$LT$@ML$AUtA|*uAUL]H$iIF0D$l$9D$hdH$7H$#H$|H$H$`H9t$8 A{1*H9L$8uH$肑IAH$`AY>p wK+w ()'nc1`9<NZ `sw B Wx ?#w wb  {|yH$~L$hɉω$Hk(H$肖HH$\$hME1L\$`Lk(M)L$H|$PMt Ld$PM)Iċt$lIMaM)LMiAq wvHIQIMFHH)HL9vEI2MHIIBIvҕHIH9tH)H륊L$lEHEMD$hHl$`HD$PHD$HHD$0H$|$huH$H|$PMLl$HIHl$PIMFLH)HL9vyIVMHIIBIvHI=H9tH)LD$0HD$`HTIItHHEMLELMIDHD$0rHHl$PLHELl$HH)MHňGG|$hu&H$H$WL$hM1DT$hMLMk(L$M]MeKtMLd$`HDI]Ht$PH\$HA] ]Dd$lMEA)G$M.INHL)HH9vvHHɾLHHBIv褓HII9tLL$PL)L\$HHHD$`MMMDLMIDLT$PHD$HtE]HDeHD$0gH$ f ZH$@_ Ll$PIMNHH)HL9vTI3MɾHIIBIvӒHIH9tH)HD$`HLMLE떉+L$`Ll$PLmH;l$`t H͊UULT$PMEMMtMAM)AEZAEZMI.IFMI)II9vMH=rHHH=HBIvHIZH9tH)ILMLEImLd$PHD$HHD$0Hl$`H${ LOML$`tADPA w5AAEDDDEk Gl H$`H;|$8uEiA1<,Eu\H$`H;L$8t?HAMH$`tAXЀ wAADDEk ETAAEEE9SEAFH|$pu6<\6L$`L;d$8#IL$MH$`A$tA<}H|$Hu6H$H uH$s H$Hl$HA~H$? ELd$HLl$PIIFHH)HH9v^H=AHHH=HBIvHI)H9tH)HD$`ITHMLELMLE댉LMLd$HLl$PD)H;l$Ht H@}@}@uE @uHD$0LA LEILEIH\$DIMIVI)LT$I9vxHZHҾHHHBIvHIAH9tLT$PLD$HH)IHD$`MIMMDLMIDL\$PHD$HqALMEE1AMEA+L$HHKtLE\1H;l$Ht H͊UU]DMDAE]DMHh HL;D$HtIA8H@9H|$HAGG@wDOv AAHPA)EHhAAIDH A@ DH D` I)DPHH;T$HtHD*HD+HD$HHD$0DXADXD`DPH$Pu*H${Lt$8L9$`@@Ń H|$pH$`{H$yIMIHl$PIMVMI)IM9vyIEMҾHIIBIvHI,H9tH)Ht$0HD$`LDIILHIEMLEHHHDHD$0rHl$PLLl$HEMHH$IMIHl$PIIFMI)II9vwH=HHH=HBIv HIgH9tH)HL$0HD$`LDIITHIEMLEHHHDHD$0tHl$PLLl$HEMHH$MLl$HIHl$PII~MI)II9vyHHHHBHIvWHIH9tH)HT$0HD$`LTIM\HIEMMEHHHDHD$0rHl$PLLl$HEMHH$$MLl$HIHl$PIM^MI)IM9vyIM۾HIIBIv莊HIH9tH)LL$0HD$`HLIItHHEMLELMIDHD$0rHl$PLLl$HEMHOH$[MLl$HIHl$PIIFMI)II9vwH=&HHH=HBIvljHIH9tH)H|$0HD$`HTIILHHEMLEHHHDHD$0tHl$PLLl$HEMHH$MLl$HIHl$PII~LH)HH9vyH^HHHBHIvHIEH9tH)L\$0HD$`LLIMTHIEMMELMIDHD$0rHl$PLLl$HEMHH$MLl$HIHl$PIIFMI)II9vwH=HHH=HBIv7HI~H9tH)LT$0HD$`H|IITHHEMLELMIDHD$0tHl$PLLl$HE MHH$MLl$HIHl$PIMNMI)IM9vyIMɾHIIBIvnHIH9tH)HT$0HD$`L\IItHIEMLEHHHDHD$0rHl$PLLl$HE MH/H$(;K;D$lvH$݀ DD$h1AIcHk(H$ExH(;DHALd$PHl$HMI@IMFLH)HL9IMHIIBIvIHIH9tLL$HH)L\$0I<IHD$`MMLEIMMDLMIDLT$HHD$0c@LLd$PEMMHH|$XVMtA)H|$0HtDALdI9uAuILd$HL$`EA*tA^tH|$Xt(1A\uAk@?A@+A Au A?tA+tH|$xfH|$pt A{TE1A\u E1A{{AEe/H*HHHBHIvʄHIH9t4H|$PH)Ll$HIHD$`LHLDLMIDLT$PHD$HI.I~LH)HH9uMT$A$AD$ILT$0IM۾LIIBIv!HIhI9tILD$PHt$HL)Hl$0IHD$`I ML IDHLDHHHDHL$PLL$HHD$0M.M^LL)HL9aA$H\$0Il$HD$0H|$PMtLT$PIM)AAErAEr|$htH$M}H$At_M/M_HL)HL9vCINMLIMCLM_HI7I9tL)HEHH$|I+/1IoH$dH3<%(t~H[]A\A]A^A_H*W+H=#W+xҊG8tG8HNLFÃG8HFHFH(T$LL$AD$HA11H(HAHT$L$1A1R[HH[QB8HуȀB8HyV+ t HHJ1ZHSHuH=6*JHEH=6*t= 06*1HHH V+HHHqktLHHJB舀HH5*uJ%H5*`HH5*u1[H(1HHE11HD$kHLAH1DD$D$H(AWЃAVAUATIUSHHHHHGHGHOL@HC t^HHC(RE1II7MLC(DBDvtLD$HLD$BHu7Ht2DO(1D;O,}(McAMkDO(LW MtA2IRLIJ1ËO(1;O,}HcHkO(HG HtHttHpP1AUAATIUHSHGHDAr@AV@tQHCA@t CP t CP CP11HHI$t]HsL`D뛄uAKtAFuDEu?L9t1HMttuHiH1L[]A\A]SHWH@2@R@Otu5tDOPEA _P DCHDGP1HWH[A[HW:SHBHG1zt HJHOBD@A v<_t DHAvx<_t[E1ҍp@ w Ek$E\D@A%Ak$D\E9HG8u1EHHHO<_uAE1D9_8G@H0JDWAAEtEuHwE1DACAAJ:LJ(Mt9O(1;O,DR0}'HcLkO(L_ MtAMKLESHwHEt LBR LBRWPDO(D;O,}6McAIkDO(HG HtL@PH8HJ^1USHRHu+ƇHH8HǃHHPH@,@X[]AT1IHHUSHHHlH9t3LHo[]A\SHH&JH0dH%(HD$(1HuzHHHD$(dH3%(t%uH0[USHRuYHGHHEH9sHH;HxHu(H;rHHCHCCHHkX[]ATIUHSHBHHtH9rsHs{u$HHSLHIHLLCAHk[]A\H1LAnuHPHLX1As@ wLLk MQKDLMYHH߅HEHW:_uHHHHH?SHGH_tnuH HhH1HK9_uHHK[SHGH8Tu@HHGHx/C@K(;K,}$HcHkK(Hs HtHFH1[USHuHG8u1YHPHW0hu H{)vuHkHHK9_uHHHKHs>_uHƸHs[]ËG(;G,}.SHcHkG(H_ Ht@H_HCH11[ATUSHH?HIHkHSHH)H9|}HCHCt 8$uHHCA ~NJH#tu8M.t _t$u&} Nu sPH߃D)sPJDHH1HCH1[]A\H Hu LJ0H@H61Hx)Ht?/u~ HHHt uHG1UHSHQH't}w tvw tpt9Ot[rYuC[DtVw2tF?tJ1u+CFt>r"Iw2HsH@Ht!8/tHsHxHu H[s1Z[]AUATIUSHH(HdH%(HD$1:t H L(H HLJ(I$H$HT$HRu HG>H:L(HD$dH3%(t#pH([]A\A]AWAVAUATUHSHHdH%(H$1Hz0 KbA$xJALcmHmuE1M9Bt%HIIL9MI)I~a}_u[}_uU}UuOLuE1M9sCADHA w0D@Aw7 PwWIHII<_,uH HvHU/J`HUAuDJH4 .HHm}E 5JH D]HEkIc.CJHHmY L(HD$ HLJ(LuE1IM A A6H(AL Lp@H(H NHxLH Mv@L(HLJ(LmtCA}uu HS>HFL(qHu>H 8/u@D48/ E~ H@AHuH E H@H} L DHIH HL ~hdJ NJ WJHUDHipJ)uJT JJ J@ J6 J, J" ؗJ J J J -JeHUDHQJ CJ YJ UJ LcuHmE1M9 Bt=HIL(MAxuIxq9i MLmA}u\IuiHI 8/uBD4A}/ E~ MmAMuM E MmM AU#t;Ut$u IUI I11L(L HH(Ll$D$L$L\$uIUDH|$LDH7 xAHmu'LcuHmE1M9 Bt=HIXLceLmE1M9y Ct5HI1AA tH(HUVHUHEtDH߃% A@ukL(L DH(HUHHl$D$L$L\$|$L<$L( H E H(DHUH L(L LL$ Hl$(D$0AL(ALt$ LD$8LHu"HUDH|$0L(te/ LPEAAw̓xuAAqDL(LHAHt HHLD LH(@HyAtADHDHHT(# H(HUDH H(H(H HUHl$D$H $H|$H|$uHDH L$$L(6 f}t pJOHUHz JtDH Hf}tvJH }JH HUHt|H} HHv&3HHH8HǃJHHUDHL8LL98N HL9> HH. HUHmHtH߾{DHH}HHmJDeHEDAaAw HLmMcC| AE1AA)McM9Ct5HIP侐JHHUDHdJHUDH FHUg8LuHmE.A1u]IvL>A?au(Adu!Au}uHM9u H}?)HD}7u+HUDH LDHA3tE1LDHMu0(hIVDHR)HL~EAgu)AsiA^HDHKAsAAt6A+(HHH}?7lHULBIxcDEQA;ArA(L]A;9%IS::L}MkLrHjIwH9quSyuuMyuGLDu LDHLDHY H߾JHDH> FJHcI}tDHL HLDHHHDH HME19'HyDoAAvALUA:u H,$H AEIB|40u HJT4(DH-EuL(DH<HYHUDHHR3(JHL}IWDH)HK:1uAxuMXA;>u (HHULuLzM/A}cu;A}lu4A}u-Iv>u$HN9)t ǃ0HVHDIVDHHUHzLAiu=AxxuIAxuBH߾[bLUDHIR<]HB1cuAxluAxt DHLMDHIQ9LeA<$1u;Il$}u0L]A;>u&IAHLH$dH3%(t]Hĸ[]A\A]A^A_AUATUHSAP:1u&HB1Lc`LhI9vAtHHkY[]A\A]JX[]A\A]ATIUSH*$J+J5JH[]A\}?J IT$@* &o PJ룾FJ뜾OJ땀(t IT$HZJiHR-^JIT$H_)H[]A\aLH߉[]A\=[]A\AVAAUATAUHSHHh0[}HEHUu12HMEL )H uHMHDHL *uHMHDH L L(Hǃ(DHRH`AL(uDJH .HJHUHj}Eu05JH}DGHIcCJHqHmDMAAwHmHDHL DHL Hm[]A\A]A^AWAVIֺAUATIUSHHAPHt7u1HO wHH1HH?E1L(1Hǃ(LHEt )H,(HIHt HH߾)LH߹L(X[]A\A]A^A_Ê<(t t H(HAAAWHHAVIAUAATIUSHAPu Hscxu#HP:*t)JH߽AHHuϽ1E11LDHEt )Hu[HIHt DHXH߾][]A\A]A^A_AUAATIUSHQv 0tu+LDHu"ZH߾)[]A\A](1~X[]A\A]1HtHttHwWHtuHt2wHW1HtHtN1wwHW1HtHtN1wwHW1AUATUSHHdH%(HD$1HGrt VtKuY1HHHIrHHI$](L $L@LHI$H$M$ JЀJ&$XJaDC(E1HcHD;C,H J}%McAMkDC(LS MtA'IjML$McHEl$HCDkPHHG#1H¾(HiH$nHhHoxYuHHGHWHHLSE1A:Eu IILSL$ b H$HpHw@h@_tM0@ w2LSIRHSEZA0A vH)HHIu}HIukE1H{?_[HH{HLH*Hs6HHGHHIHH HHHEH9t[DEZAwH<$HPHxHuH4$HUHM9)t-H$HDC8D;C<Lc0McAKDC8H $L+H}XHSH$:IH{8;{<HK0HcH{84@D@A v <_tA<wA1HLKH$A9IsH(H$HH(H$-o HH$8.HHGj1H¾$HH$HHGC1H¾"HH$HHG1H¾#HH$HHG1H¾%HlH$qHHG1H¾&HEH$JHHGHHH$HH¾!HH$HPHWx(HxH{@p@hD@a@F@Ttl@em@f@d@p@i @nE@tt@v@sH~1H¾AH9HH$:Hs>u H$$HNHK>EuHs1H¾IHH$FH&H$DK(1D;K,IcALkDK(Lc MA$'ID$`JLDk(1D;k,McAIkDk(Hk HE'HEJk(1;k,3LcMkk(L[ MA'ICJLDC(1D;C,McAMkDC(Lc MA$'ID$JLDc(1D;c,}*IcAHkDc(Hk HtE'HEJ1H,$LUEZD[PDk(1D;k,dMcAMkDk(LK MIA'IAJL2K(E1;K,}LcMkK(LC L$A,@0< AEfEfE`t H{H,$HUHEL$IzH{L[1A;t ISHSA;@sH $fqx_uHHHCI HIMt/H{1?_u&HH{HLH-H<1H$@{(1;{,}&HcHk{(HK Ht'HA JHH$HRBCP!H,$HtC8;C<}L[0LcK,ӉC8H$1Ht$dH34%(tOH[]A\A]USHHdH%(HD$1H$HHStHHHGWIž3GHLH¾H~CPI1HsL>Iu$Mu1{8;{<}HS0HcL$ʉ{8H! LHH"HTHLCHA8Iu?HtDK8D;K<}L[0McAHKDK8HHHHHt$dH34%(Ht EH[]A\A]A^AVAUATUSHGHTt GqsP~{P@(@T<LXL[xBHHHKD`ASbAH+ACAF H1H¾AIAJHi1H¾AW-ATtFAVH߉sP01H¾ AhtdAvAcu H߉sP1H¾ XH1H¾ AH1H¾ *hH,1H}1H¾vH1HO1H¾1H1H1H1H¾HH{IHxsHk}_uiHHHkCPLH¾ KH1H¾4H1H¾@GuL@LCx1AaHHtIEtDCu>MYwHmHLEA0~wM@LEHLKHEEAEHDAtr_AAvLSH@AIHt*Ƀ2w!LHLIu At H@ؾ1 H@Hu1H;HHH[]A\A]A^HLHLKDPATts0AAtRARH'HI2LHAVt ArtvH1H¾|1H1H¾c1xHt"LPLSxnu1H¾H61H¾G"H{&H L[A;IkHkA;_LhE1E<$tE1rUSt_t$/.{(;{,} LcIk{(HC Ht ?p1LKIHIiHku@j$tIM9} BL%uHDHLHkM)HHk/MtHL>H2HM~I1H¾=[]A\A]A^ATAUSHGH8_HHGHS:Zt1HDHHS EHCHs>.Ny@wLFEEQAwIA_t_t݃0 wZIA8.u$EXA0A wIE A0A wILLCHH)HHKHHbH ![]A\UHIHATISHH`dH%(HE1LELEH}HE@EHEELNHEEC KMcJ DM̉EHHULkHIL)IH)L]He8I1Mt8A:ww-$(JMRMRAR EJE $H]dH3%(t@=He[A\]ATUSHGH8Lt1HPHWHZt_u 1HwHHt˃8'uHp~t~){PLCA;A8nu IAAXu0HH{HLKA9EhILKHaHHD1H¾/HHI$%LSL`A:EeH$IHkHLSHt$dH34%(t0;H[]A\AUATUSHASHGLu AZ[]A\A]Tu AY[]A\A]@sD@Aru_HHGHHIHC8ItLHH5LHH6HHApHHGB1H¾Ifudxpu^HHHOxTu HHG1 Bg{(;{,HcXHcHk{(HC H?HpDJA vouHxnuBHHCH#HIL[A;IH2He[A\A]A^A_]SHӺڱAH0HH$HD$dH%(HD$(1HD$D$H<$u/H1|$uHD$HHHL$(dH3 %(t1H0[ATIHcUSHH0dH%(HD$(1HH$HD$HD$D$tH-HڱALH<$u-/H1|$uHD$HHHL$(dH3 %(t0H0[]A\Hq4H9HyHAq,A(QF ÿB!u H?uz H{*SHtЉ&UH1SPH)Ht y#H) o#H-kHB)H=)>FJII:HDξJ1#S&Huھ$Jk`&k[fUHHAWAVAUATSHHHHHdH%(HE1HHH| H9t}/twHwH9Htk~/teH~H9t\/tVH~H9tM/tGH~H9t>/t8H~H9t//t)H~H9t /tH~H9u HH9t/uH=)KGHH*H9 VKqKkk"PHLH-px0H=l)1bB3"Ht;@!!Ht;@!!Ht;@! !Ht;@ !1A?F!AFE kH')AA$@0HD11kiA$@0HD11kPL-A)LLcOD=L92)IMLMr#7m7N7I7E1At E!AD AtG)fF(IAt G )F (L=)IL=)MfMMW=ƿkI>"H=)LLL=p)L=i)MfMMIL9=V)Y6MuL5=)AEL=))L*)M9&6Lc2)H)L%)L=ݻ)AhFHDML)HL!IM)I9A?FHOIHλ)IH)1LLHHqLcO #L9 )5LLLIMMoL)MLx)uMSL9s)95ISHZ)ALG)HH)L96Lc=P)L%9)L5)L)LDLL)HH!IM)I9IOHHH)H)I95LhL-ݺ)L˺)L̺)M9y5HcԺ)L=)L)LO)LIL)HL!IM)I9IOLHH})Hn)M95HxH=b)H P)L-Q)I9L5Hc5Y)LB)L#)H Ĺ)M؉IM)HL!HL)L9IOLpH)H)M94fm6@4H)LcHH9۹)L%̹)4ML$L )A$H=)H )H9.0Lc-)L)H5y)MDLI)HH!Ho)H)L90L\)HAH=)L3)`D<H)Fn0U0=0D1HAHt D6D7AtD$fD$HAt D D \FE12=FHο=F1)t)1HϷ)\F=F1~)'?GkH)>tHIf/'?GHQ/1ҾL^}LW)1HF>FRFz?FpLy)A;0uH5|)>-H=,)?g-H=;).H=)?.H=)?!.H=)?0-H=)?/H=)?/L-)A}0uELp)H5))9HcE1H4HB)H+);< < |CLc< tt IA$< uML8)I)McK<+H9=/)HLLL-)I]H9 )L-)MEML )L)AEHΰ)Lϰ)L9Lcװ)H5)H=)HDMH)HL!H)H)H9L-)IL-q)IEyA<$H=)H5)H)>DžD3EA A ID{LcA EDDCLcA E(DKLcA E SLc DSLcA ttED[LcA t\ECLc< tG{Lc@ t1@s Lc @ tf@IA4$@ uLDžIH)AHE,$A;bE7EA }EL$MD$MA;A EAL$Mt$; AxMp@;t}@ tw@ApMp@;t_@ tY@APMp;tB t=}EPMpA;t&A t E_IEA;ufA!ILE1L)LA9AD[)EL [)AMcILE;iKDHu$I1LLL LIyH;D;ou%HIqHLR Ht~HOH;twD;ou%HwHHL HtFH H;u=HH;t0D;ouH7HHL HuAE1A> AME,$A;Eu\I\$>DXLHA{}LQMLLL)A7AnDž_I!DIL9s;:HL9u끃ku;.DžOLA~E.LIHH CD5:Le HtL-)DžLkMM9M{:LKM9MA9:LcM9A<$:LcM9A<$:LcM9A<$:mMaM9txA<$:YMaM9tdA<$:EMaM9tPA<$:1MaM9t(HIHQ)$Hx?#=')m-L )CD9m=)Hߢ)H1EL~L C)1IyI9hu=)=)h(u/D%i)H R)11A9~%A|=uH<tHH5Z)FąG=)}=)D5x)f1ɺAtI$HLHII$HLHII$HLHID9trI$HLHML$IHLD[MHDtnII$HLHtVIA0HLA[Ma0Ht=A[MaHD9u1ɺ^AFkYHHH)0xudDHHDt:LM:L=e)Lٕ)AC Ha)&J4ID9HQMIL )IAHt 8*H5P)11JHfF莕^AFeF1{lH5q)9AF19pAL rEL cIkH56)eF1AoL 7H5)heF1o랾kHH5)0eF1o끾kE1H{'Wt%Hf@PL`{tLH묀x{HPuHx1VEA;t$A tEtIH5)RF1iA!t.LH)$1A> @LqHGHLH)P$AAH5)H$H͙)Ht'l@F1<H=0)HtH@ H=()HuؿPJyDžH5)E1E1DEA I IA uA.DžH a)MVHLLLDHIE<$E-LLHDiHtMM)E9DDD)Mt$MLAEA;eEA!IE tIA;uH\E1 AM1ɺkRHHD6)HIL-)A>FMu L=)AFkr@FHHH11Ҿ>Fk}@FILH1Dž1ɺB@FkQHHm11A$@0HD`kHR)H)LPL9 )GN@FA%DE1HAtDAfDAt F F L%)L-ی)1HIT$LH)HcL4L95)HHLHb)H=S)H9tkDg)L P)L1)McAMIMcM)M!L=%)M)M9)H)H)'HAfHL )΀ )댿`k0Hє)L-)QHAH`kH)LkOHIDHmH5)(SF1(dLHDIMt$DDžMA$;ttsIDLMM9sEA7@:t;@H5)IgLH)ELExH5ٍ);/oE1!At1H5)@ A t#EfEIE$A;uA AAIu%L5~)MtAu!H5J) AMIt$ t5tH5)@qA>H5)a1IAu렿H5)A:DA E,$A;EtFMu$I߀~:S1~:?E7A;t$A tEtIHHSF1aLHL)HHHD/A;EHD+A;tKA tEEqHuIH[DLHJ`HHLH)H9HLAt8L/u&H{A HEN1E1A AML5)@F}*J*JHL1@F\hcFH1}L-&)cFFMIEDžAF1ZH=)=F@F11qTH=)`F@F1YTH=τ)@F@F1ATLcA*JtJADKD2H;)O2MKMA9*ICL%Ȋ)L*JLC<<H=6)*J*J@FS=c) )=)xH)Hozv%0RF1$]X1ҾLHzHQ))gE1E1;Fkh&HAHHAfHHAHL),H=)x11CbJzE1H5)HJD;~@EAJ|=F>΃=)jw]H )HMyEhRF1[2L5)MFL9)sktL5u)H%(sysrooIt_spec) 1IMfHL M)H5)MyHL=8)HHLcOT/L9()sqk L= )H5K)LLL-)IuH5)AEH5҇)LӇ)I9u )Hc؇)L5)L)LIL)HL!H)L)H9~L5)L )1ҿ:GL m)(HyH݇);F ;F Ivk2BHuIF1HjKM6E:*~kL)kL)\ ,)kL-م)L1HI1H0HH9rHIA HIIHAHIIfPzE$HIM_EUXkHO) {){kH(); T)kH) -)kL%ڄ)H=n)Mเ*J*J@dF1N.HE)HB)H?)H<)H9)ATUHS?@HM11D@ rA@ AEHy@u؅Ht\DLIc$E1IE1BT t uIcAA \BTIIcAD9A4}H=LH[]A\AW@AVAUATIUSHDD$ D$ D$ D$ A YA OA!?AA,L@IA<$@fJuOՀv@=t@@tLLH)@*@ @ |$ D ڀ)E~u|$ Lـ)3|$ AMrK IM|,DIM9t7MnHHLuA|uA>tAFIM9uDA4$@ED$ID$Etr@&@|@:uXEtbA;uZHDA;tIEtDA}tGA%uD@HxA<t$ Hx9DLH[]A\A]A^A_Et@HDEtۀx;uDI#|$ AMKIM|IM9M.HHLuA|uAFA{HAWH@ED$ML$A A MI~D$ AMrKIMl-IM9[I~HHuA~tAAMOIOlfIM9I?HHuAGID$ L x{u_t$ HxDIE$A tA (ID$ED$bEAMaA t A MHAWfDAWHcAVAUL,@ATIUSHL%})K,SL;u w;H[]A\A]A^A_[ AH[]A\A]AA^A_E7ANv C미HAI3GH|$OD})uD9}ALcO|,A)MIkMd,ME:3MWM9MtME:3IM9iME:3Mz0M9PMZ0E:3MzHM96MZHE:3Mz`M9MZ`E:3MzxM9MZxE:3}MM9ME:3taMM9ME:3tEMM9ME:3t)MM9uIM9ME:3uA{ntMIM9_WD{)E1HcLkMD97O IA;Ot+A{ouA{-uHt$I{;u{tCC1D-5{)IHcHkLE1HL$D9HD$J< D:7t IHLuf.AWAVIAUATUSHHA>*YLc%|)H.|)INdL9MM$I)IAA;@I L9MlIItpItYItAIt)ItI$:@I M$A8@rI M $A9@GI M<$A?@I I4$>@I I $9@I I<$?@I L91L,;FO1HL}Il$H}I?@H}Le?@H}Le?@H}Le?@H}Le?@H`L`?@ H@L@?@L L9?I<$?@\CI{LXLH[]A\A]A^A_fDHLtH}Le?@0HLstH}Le?@ HLRtH}Le?@HL1qH}Le?@HL GHL'HLHcHy)L=Qy)HITI9HT$WIHA3GH\$fL#ILM)ILALL$H9HLH)L6H I9L $MtIL#LLttLH9HLH)LH I9L#LLt+LUH9s`HLH)Lt_H z3GLtEH1LHHH9sHLH)LYtDH I91L9rHk}@uHIzE11HYHLN=HyL$$H~L ILIyLIxLzHzLlODf.AWAVAAUIATIUSHH-v)IljHugH[H59k uH;LuA}+HkLeL4MHEt {%Ds$C%H[]A\A]A^A_ø`kvHL@HPLHL`L8HHHHH@HpL@LxH-LLHHHhHp@HPHXHXkuHu)kkL5A}?J@Iu1L1($LHH5t)HKHD{ C%HKHC>FHsHt)UHAUAATISHdH%(HE1HHLHcHHH)H\$HHHr HHHE1ɨt DADtFfFIt FFH؀x/E.@u9H@H޿yq1HUdH3%(u}He[A\A]]D;/uHH)Ht`H uH{qFu{/uH{;D/Ho@X%=@AAtH{t>G[R5@f.UHAWAVAUATSHHH}udH%(HE1H=qo)D-To)EHTo)A}KTm9{LtLcuH3H}Lu HL9tuu9suH3H}LtLKM9tQD}D9{(uHsH}LtH0L9t*DUD9SuH3H}LqtHL9u@1HudH34%(He[A\A]A^A_]H5r)*HE1@AO<;DDHuIcHE1HkHHH)H\$H8McMkIDIA EDhL`LA tuE~DpHHA t]EfPHH tGQxHH@ t1@:ED$IL$A tE HDA uDiILqI)EZMrA;EA DiLaLEA;A DiHAEtoA;tiA DiHAEtQA;tKA t}El$ID$Et5A;t/A taEl$ID$EtA;tA tEHD(EuHAL)A;ARZIxHxt&HWLȿr;F1+AH5n)Ezl)HHkDn)HEHl)E"EgAH n)MkMkLqN\(Nd+L]AMnLE9CAHcBH{L9D9OHL9D9OHL9D9O=HL9tlD9OuHHuH7H}LDM H}HuDMuD%k)HOD_IcALkD k)LEIEXI@A@IL;u 19*k)yHL=h)HIL%k)HEA?9A? YM$Mcl$MLEHuLLUC4.;FHAAHHuH7H}LDM^H}VHHuDML9xHHuH3LEH]H}H{HuDML99fz)SHu H[yHH=Wg)@F16ߐAWAVAUATUSHHl)HPH9l);F  E1Ht .Af/t F F Ll)11I=j)LL|l)fDILi)EZAATM`L9%Ql)A'-fE(L52l)M*MvML5!l)'L|HL LcK4&H95k)~ILLMr@pHr"IMAIM9LLM1t A60t A<f<Ht EDL%hk)M|$L9=dk)L%Uk)A$'LCk)L h)IL1k)MdLM I<$MPL9k)/A ''fEHj)LxL=j)M,$MLHIHfxOAMHIIT$H&fDEMHIHfDHRfE}HIHDx7AMHIAINIL9h)H-h)H=uh)HH9t|h)H oh)LPh)LcILHcM)H!H-Eh)L)L9)1Hr I1IM9L8HL9rHI1E 1D 0H|$H|$ 1H|$ H$;H$fILAIM9Ls7L_AM9LXs$HwAM9HpsN N IM9rLLfE1fD0HKED2EHIHfD@A1HIHA4$A HIHHH|$uZAH|$ Ht.MHD$0HD$(HD$ HD$~HD$(D$OHD$MH|$H|$H-[)H|$@Hl$޻H[)HD$@qH|$H$迻H|$赻H|$@諻H$MDHHHD@7HHHfpI?HA@9I{HT$8H|$P1HH|$HLYHL$H|$@HHQHHT$8HHLaH\$`LL$0I9Hl$hICIHc3L9MBH|5H|$ 1HHHqHt$011\F4H|$HD$PH|$1H1E1D$OHHQHT$(HY)HuIL%Y)MPJL袾HD$ K1Ҿ\FL1HD$ 0PJHit1Ҿ\FH1H|$HHHD$11kH|$@HD$1H1UHD$@\HD$ f.AUATUHSHH~t1SuH1[]A\A]f{ L#ID$HPI9T$ IT$:HL+A t5HCDEt+A t"HCDEuHDEt A uDlASL`nAI}PEAIMkPN<0IKIHxHHtrHtZHtBHt*HtHPHxHPHxHPHxHPHxHPHxHPHxukuDH8tgHxPt]HtPHtCH@t6Ht)HtHHxt L9uP@EnAH= U)HT)Gu$A/uINJA EDH=S)DH5S)E1E1;FkVH5S)E1E1;Fk5GL1ʿE1A=FHƿkJL"DK)D9I)D=I)AAT=P))=%P)=P)Lc56L)IkH5;L)H/Hc=I)HH=K)HEdH3%(HHe[A\A]A^A_]LRPItIt Iy*ZL)LN)M IE1LDLLHJ49H5N).HHHLN)LDLN)NLL rN)C îOJM=FH)SH5H)1ҿ<=F1A111HmH)tH6J)HOKF11E0e1HHIHH HH)L|$IE$EtVA:tPILD)A;01HLMHH HH)L|$IA$ts:tnIMHLI)LI9A|$/C//CD/E11ALkA<$IL8MLLM)L跪M9t{A|$/tlC//CD/E11ALk"A<$IM$C/b1Ҿ\FPJ1NLH胪?C/1Ҿ\FPJ1$LHYuHHtHxHǾ3GLdu!LZL;F1x1L腯?˃=_)KF11pB_)GD)H D)1HHIHH HH)Ld$IEUEtLA:tFI1ҾNJ1ҹLLHH /H|$PHAHt$pHD$x>F@$HHB)HD$XHB)EDŽ$$HT$8HD$HD$HD$ H=VB)HH|$HD$H1E1D$G1IH|$ HD$(3H|$HH|$H$膤H|$8HHD$0tHILl$PL\$(LT$XMcML9LCK| LMmHM/HT$0H$It$Ht$hHHjHD$`IMHH $HIHH4$r HHHE1At DADAtFfFIAt FFENN#HHHt$Lr'AkK+H1t DDt <f<Ht DDHD$pHLD$HH$HL$LD$AUt*H=e@)ufA}HMHL$QHT$hHt$8LL$LD$蠥H4$HDHA}H=@)L$LD$tHT$`Ht$HLL$WH<$HHHYE]Eu@AEEu/MMHL$LT$pB#LHH MmMH|$ H|$1H9tHH$H$H$dH3%(HĨ[]A\A]A^A_f.|$GuLL$(HL$ LT$pMYIQILHr?G%Hr!HE1HN N II9rLLE1B !B H|$H|$ H|$ H$H$LIILAM9s7H~AM9Hxs$HNAM9HHsN N IM9rLL B4!fB4 IFDAD,1HHHpD!HHHfD`DHHLE$H|$H$H|$H|$8H$H|$uNAH|$ Ht(͝E1HD$(HD$ HD$E1D$GHD$H|$芝H|$耝L=9=)H|$8L|$jL=)LT$8DHHHDHHHHfH>I@HvA8HT$0}H|$H1HH|$HLaHL$$LH|$8HHiHHl$0HHLau4H\$PLT$(H9LD$XHCILckL9MBK|(L:HL\$PM+MEoH|$ 1HHHqHt$(11\FխH|$HD$HlH|$1H1E1D$GHHIUL-;)MunL=~;)MtTPJLLHD$ 1Ҿ\FL1ZHD$ HfuzHZHD$ PJL}1Ҿ\FL1H|$HIHD$11H|$8HD$1L1ҬHD$831^UHHHS1ۉRH=8)HHL)Le6)谱HIHs8)HljHHHcщ }8) g8)MM9t]A;.t_MSM9MtKA:.tMMZM9tMZM9t-A;.t/MZM9tA;.t MZM9tA;.tIM9uA>FLIL)Ή57)L7)7)X[]@AWAVAUATUSHdH%(H$1=SQ)H|$@t$ H|$111蓠~ Ht$HT$ b HD$PHxoT$PHƉInI8 HcЉADA~Hc7MHIpAM MLHփ%  IA MCA .HMHHHtuHtLHt# R IA IA MÀ / IA IA MÀ  IA IA MÀ  IA IA rMÀ  IA IA OMÀ  IA IA 'fA MMu IE9M@E#EA MP AM@E;LI< MZ- DqMBABLIEA M QM@E3LI MZyMBARLI@tm@ MqMBA;LI@tL@ MLIIMBA3t,MÀ A IIMCHIt D!EMLA@I݉l$ AE< TA} MeA$M< A|$ !AD$Ml$< -A} {AD$Ml$< A} Ml$AE< uA} IAE< t< tPv<#$0<%S<:Mt;< M@t@ IA?@:u@:L9EGLA A L)DNHIcjIHcLHLr HHHE1t DADtF&fF'It F,&F,'AIA< A $MGAM< %Ax ^A@Mx< eA A@Mx< A [MxA< uA IA< t< tp@v<#AuAMu fDIt AMuLL)D]Ic$IHcLHLr HHH1Ҩt DDtDfDHt D D AMLD]Et-A\A#IHE_D]EuA>*AY=FL8T$ I~LüA>L%+)MM< DXA/D< Pf DA} lIMLLF1H)@A Ia< h@9f.< /DPADAx tA@Mx< < DHADA|$ GAD$Ml$< < DxAfDA 0A@Mx< ;< >x@a,fA} AD$Ml$< z< }DpAj QI3A A} LfA} #VA nL%))=i1)wH=o1)HcH裺 M1)HV1)A LcуI 01)ND J1AL2Lbt LAIAt LAfIDLAItfIA6L-|$LHDuA tEu|=FL\LeuE]A A =FL)uEUA A =FLurAU t ucM}E/A IIA} uIH=())H$dH3%( H[]A\A]A^A_LLF1H)IEMIA tA tA<}>ELkHt}T$ 1H'A 3C-J!LDEECJ@uHA LpD)L$A< I=1F)LH=*)L꾔=F11L0MF1H)H}IA? uDM9sAy tAy tA II}A lIÐcH|$|HH=))e=FEE< H} tFIHAG\D]E"L4HH9'DFA HMF1I EEIA tA tA<}>LEkT$ HLHE1+A BH)ؿ0LFH1 < DJtAL8@t?J@uHH9uL-q,)LHt_t$9u tHmL0LF1H)H}L9uLL*#Mt:I}LtMmLhMF1[Ht$LLhLFF=C)tH=')LL=F1L]T$ LI3^}%t LUI:LHUH>FE%L0LF1H)fDAWAVAUATUSHHHkHdH %(HL$1HkHD$XKHH,$1 HkEEH;I%)4 H HHe Ht| HX|/I H5")HH ~ LFLnMthAxaMHMhMtTAyMMQMiMt@Az9MZMjMt,A{%MsMkMtA~MnMvMu@1HI覌;(")~ ") >L8I}@@@HxIEH!)H<$HxHhH@HtP~1aHI&;!)~!) 辭L HM@@@HHHEH5#!)H<$H~LnHvHt DFE~1ߴHI褋; )~ ) <L0MM@@@LHIE')Lk@Ls MeD')D9~L=')McIORMK,ALuAHEED}EEDo')HL$dH3 %(LH[]A\A]A^A_H H@]f. ')Lk@E1Ls MeD&)D9H=&)IcIH vMH,Lu;J<Ls(D&)L&)J HEHMcK[I,HuLk(L.HEAJED}EED[&)fDHhHH(HH(H&)!A1HK>FH))Q\Ht"fHHA%)Lk@Ls MetzD}%)D9t>McIIkH-v%)MLu F G;F?AH=A%)%)HHkD%)H"%)A$)&D$)H$)kH-l()R()^v()|=)HH!tWH<3=!)a()t>F >FE1跤>Fd')E1HZH,H11H$<,tnH݄uHcQJH"u11DTAEt$A,uD)HH|H,$CHΉ)HH|*)HcH:QJH趏{H$jHtnH;QJH臏L$E11G,0EEt$A,uD)HI<誣L$AFID)HI<茣H1HHHHq)lHHtxH=L=#)Iw=F1HI7~MMuH5)Ht >F1]16H1HHHHq٢=F譄1Ht+H6)E1t2=Ft땅H$=F=FH{@L<$MtdA?uR)E1A111L=)&1 F G;F F G;Fw)믺 FR G;FW FQ G;FC FJ G;F/H$>F<=F: F G;F 蕄HLsH{ F G;FH.HkH9H{i^GHH-)g"H)Ak.HzH~*1H=>F1IA111H覝k^1H\;I|$*H4$HH;BD%/BD%HH,$H5)HAk1H@>FnHfEHpz=)I#) >FE1躟 >FgD%V)D%)HHHH1ҿ ;F1QJH9HtDfw.HlHZH<$H?H+7)4>F/H=)Ht́H<$;>F迆H) >F=)!)t &>Fʞ &>FE1t &>F!}=H)L$HHLXuRH)Ht)A?HtiHC>FH薃u )E1H밾G>FHntFGH]u' )E1 )AHsMF1fUHAWAVAUATSHHdH%(HE1=)H=5)fL-)MEUAEE1A1AS>FAKtLAHEAD9Et[At8AtALHKtALHKtLHItD9tnALHKtsDHLHEDKtVLHAKt=AALHщIt$AAD9uIcHHH)H\$HE9UEEM]L[EPEUKDH=\4)IuH3u%1ɺkbHIEL-)MAtdA}t]E1E1A)fDS>FLMEFt0IE;Es&OLA~IqHuMtIA;}sAڃ=3)=3)H$)H54)u H=)褤E1HIIIOMAE1E9H}A1LLMH<$LM9LLU@E1E1D ;HHHuJA)IE9|McDLJ )HH)Ll$IL=2)H=+)HELE1E1oL]ICDƒu P5U2)ulH=)ubIII E9LkI}H;;t?zDH]dH3%(u#He[A\A]A^A_]údF! G;F6|DMMI*ICHH*^I{HXH*MCMI*^rf(fWXXf.z'tEIH=`)>Ff(˸f(L]]LUUL]LU]UH=)Hf(f(¾>FL]LU>~LUH}HEMIHH<"tM<\tI<$tEJ@u;HLAHL H*XIII I*XH )H}>FL]LUyL]LELMI "\$:H5)LMLEHUY|HULMLEHH}H=l)?J1LU}LUH}L]HEMZH5;)H} LU{L]LUMH5)\LMLEHU{LMLEHUJH5)"LMLE{H}LUtHƒHH H*XdLAHL H*X7tpA;=)=) u)D )Eu =)~AAD e)]MIJ#p}>FH1H7EuLs}/L]LUI> zH}LUL][Hx>Fw}LUL]5}H;LL]LU茇}LUL]LDLHHH)LD$ILLETOMFei>F[H;uHvDeE10U>F1$H H\$H1ҾkL-|)AD9AHX)1ɺkHpsHt H7)HBH=<-)藟L- )HM/EuHE1A8,nHEFIAIcH1ɿkDHDEItOlLhH0H}tIEAL-)IEj=)tH5{) xIE1=\)M~t!:tyH=M)?J1yIIHuAE9H5!) oxH=)Cz=)d)1HEuH}D 辒H )N>F{zH5)"xIIHeIA6J<_-<H `)>Ft{I:@t@"tg@\ta@$t[:H5%)HUtwHUHH )R>FI{H5) :wE9iH5)\HUwHUI:H )N>Fz,HuHoMG<4AMDk)DH5M)IcDHE1D~HH)D%G)HtRW9tKDjK>FDoH\HuD ut )[]A\A])A^Ð1ҾOAH=r)E1H4HtDwWDHM)HD(Dpc;-HDXqD- )^ `)L)LH޹kHHEH޿kHI11>F蹏LLc )L )KH=)Ht8HpHm)1%=rHxHHD%^k:vH;)HPH޿pNF1[]A\A]A^WAVH)AUHATUSt@11G )- ) ) ) ) )H )U5 )Åu[]A\A]A^fDH )HQH;)Hq)H-_)H=`)H9Lch)LQ)L 2)MDLM)HH!IH%)M)M9D5: )H)E5 )H )D% )D-' )HJ9 DqK>FHDrHlr.DD D )E )[]A\A]A^þkatH b)HQ )LF)L%Hk?HHEHkHI11>FL1ҾkOH )J}-Ht'DDƕ Lc )L)K,=pHxHHDD5L )HpNF1UHAWIAVAUATASH(HDdH%(HE1LELsEtEEtwH=)L_L; )L )6 )LD/ELsEEu )1HMdH3 %(He[A\A]A^A_]DA tp~hA\A|fBA%a{Lk@|D @$ FL#HHRD A uBMLP)6)))EfA H )Ht4DkEt+AS>FDH|ou=;")DkH e )Ht&ytU H F )HtA))Li)O)5))fDEM)C<)Lu@t H;@)uL5 )AE)MtdIcHDHfDMvM=A9^ uHI>LjuMV11HI:p ;HE]LA.tA6Jt~E]MULA.tAJt^EZIZA.tEC Jt@EZIZA.tA Jt#IZDA.tEC6JtHHHHDžL)A%A2=)L )M[= )#AjL)AÃ@UIcDAEHMnAu(DOL)IH)L@ DHErDLDLpLDIAUI:Ar LHH)H1HLHDžHIRH )AJHLgLL )ApLcO 3L9  )IpLL+)1)L5)H=^)11eLD[A{upMIA~}uLH{L)ZoH )IHtg1;Zs`LHHt^kHt,LHALNF1LAfDU1LHLLHHqLfkLlL)L3LM*E9r}I:HLDLfLD;A9J 1AucQHc m)DH59)EA@McЉh)HHHH)L\$ILLX)IcLH57)LCjrD^=)H5)`kBj)D)H5)H0DiDx$H0H9)uL8L9 )D-l)H=u)Aul5V)H_)H)LcJ0H9)skjH)H50)HL))L5)d=)sL(;F11DAuDIŋ{ODPHA.uAJcA>FDvGH5^)LLMcABD@)HHHH)L\$ILBhLLLHIL#hHB0Zk5)H=u)H)LcJ 7H9 h)skLiH=M)H5)LgL57)(k(MR LcDI~HMLLHHcLHDfA.oAFALNF1 (Ld(LR)(=s)u+E1D9Ln(KFDeDH@>FgDcL )Iq H95)s klfL m)H/dev/nulAAl(IHI) (L =(uyH5/(H )LcN0L9)rHH5q(HLO(LL5)H=)(11AkeH)1ۀ=)tN(L5e(E1H5(1D9LHML>MtA9*tI9t>AAI9~(IILH(HpHt>*t&L(L9PuH811~L(CD0HDRE11IcL IL)H|$HA9}0INHt9*tI9vuMHcڃLAFAI LcLJ7~hLEeA tEtI(L=I)AM}LIL)H\$HH{^HB+`?JH1cH5s(H5T(H(HcH H9 (rhH5(HHIL (L (=&(MYL9(skcL (fA.gAAkH(Dk{cH|(H=s(LcN7L9m(skQcH=R(H5(LaML 9(L 2(XH=(11`@H=(LمH=}(LŅLsDkAA%{OHKHDH5(LFMLDH(11L<H5(H5(`H=(t@1Ҿ>F11CbJH=t(1Ҿ11CbJH=2(H=d(t@1Ҿ>F11CbJH=<(1Ҿ11CbJr=k(H=m(L1ApBȻkkHDž?FHDž}=FHDž ƅ(ƅ)řL (HDž?FA9H1HLApB1ҾȻkLkHHH k1Ҿ>F11CbJH=(1Ҿt11CbJfH=(11QLApB1ɺkkHDž=>FHDž Lƅ(ƅ)躘!H=^(11`Ha(1ɾ\F?F1NkHH=(M1Ҿ>F11CbJH=(1ҾrH=K(Ht 1ҾZ11CbJL(LaHn(E1HtDj{@{uSH{HHL 7(E1MtEYE9AI1I|:@LNF1uLc5[(H(LJH=(11H5(H 1HHH=(HHHcLL9(sοk^H=(H54(H\Hm(H5(HIHY(1HHHHLcN3L9;(sοk^L (H5(LLL\L5(L(IpH95(fA.o-(LH(H5(HtZ1HHH=(HHHcHH9(sοk|]H=}(H5(H[Hg(L3L5X(MVL9U(s@k6]L57(M^LL)(A.H=Q(11S3k\L(= )L(IxH9=(sk\L(MH((LL (A-DA.tECJHE1DLD A+A%!AHH;11CbJLA>D‰C <  E1f.@ tAEK\53@uAxD(A|=*EtDL(DD)ڄEJHIpMkLHKD-MHH)LHLHHH LǃHUHLLH MCL;LMIItEI@HLLHHUHLHIMXHLLLLTLLGIMHHLLLLTLHIL;HHDLMM|$HLL,TYIM|$HLL TM\$HLM|$LLSLML$HLM|$0LLSH[IHL;YHLDApLZH (C<2A PAxAB<6DE KA{BIkHHLMt-LI)LLHHH I8HRLLHMrL;LMt}ItKIt&I~HLnRHII~HLHRII~HL)RIL;HHDMI|$HLQ II|$HLQI|$HLMt$QI|$HLMt$0Qt\IHL;uHDA FA~AA ~A~AA VA~tAD$0DE ^A~\AD$QDE T$A|$A$A L$A|$A$DE BAzBDE NA~!FB<0A xAxAB<0DE GAAD$0yC<2@A WA+AD$ C<7A t$A|$A$C<7A L$A|$A${DƿOF1tLcL-$(MEL9!(r]IEa(LH(AE|kTH (-(HYH(D)LrPkTL-(H=(11:(LGH=(LLHXaQI1ҾH@OF1LdVE1L>F1oH=(117A_?F1tAID9-9(L|$(|uދt$ DJ^tAD$1I1zg|/lTA|$A|-IGE!D$5L(MI+E1H}IH}LM)L=}B|-AnH-2(E1H[ILHM)LR=?B|-A0|$5L(QF14E{A|)I1yIEA tA tA:~1A|A}IA t A&@IA< t< L\$L+\$=.(L\$ 4\$ E1H$1@I;(ML-(H$Ht$I}u)fHSeuH1[]A\A]fFF DB<fB< It0A2tILAIM9LLLE1_H;1Ҿ{t11CbJE1H{t21ҾH11CbJH{,Fl%"HDHHLT LaE*A/uA릋8HHHz?/_0HHHfrHHJLdLPAM9LRN,N,IM9fSHĀdH%(HD$x111CbJB(H C(HRHAHt(HDH)HHLAAvHH9?MIItmItVIt?It(ItDA+HDAHDA HDAHDAHDAHDAHH9DALHELAHDAEQ0IA0AuxEQHIAHAujEQ`IA`Au\EQxIAxAuNEIAu:IH9rLm(MtASu2HD$xdH3%(uH[AHDPH9R8zHZL(E1HH>FMtAHHxIpHEHAyLD$HL$ H޺H߻6HD$0A@HD$8@BHD$@HD$HpBD$PHD$X`DD$` HD$hPVDD$p;\$r#b[Lc(IkH(HAIkPHT$ LIt;w[IIv,H (LL$0AkkH $1FHr@LJ(Hz A1LHvQIuHZ3GH9tH޿pQF15QF1)fDUHHAWAVAUATSHEE1t E AE tCfCIt GGMHXAu`AuCAu(HrH1HI< I< HH9rIIAIIHARE IIHfEJEMWM^I]E4AAA@AWAVAUATUSHL'HT$0H|$ Ht$(ˉωL$T$ VA\ EHMT$PAHHD$@MkP1I\$`MLT$HD$D$$1E1E1K,Ll$8AILL+H)HPHC<|HsHjH HHHDHPHL9 H?C<L+LSI$IS Iefg II@HPHL9f.II IIyHCP@<H}L(HH.HHHHHHHt{HXPHoL9C<L+L[IR#II&VILIA}tYA}tRE HLDHH| LcG\Ac AhA EHPHL9U$Dt$1LAAEELIkPRHHLD$8H\$HILl$@E1E1NfDDHH,HLMHEHKHMH{H}HsHuLC LE HS(HU(HC0HE0HK8HM8H{@H}@HsHHuHAmu @Mu @@HPAIL9YE7M<$M\$\$t(El$EMkP1EMoHl$(LL$ DT$ DeM1Lt$0EHĈ[]A\A]A^A_HHtHHJEDDIIIg>FLT$`LD$XDL$PN1DL$PLD$XT$`M$IqIt3I4VHtHt HyANfDHtHtHQ;ID$ H%HtfHHyHIZv9II=I`D$uIIIyE~!AI-EAI E1EADFLT$`LD$XDL$PAt/DL$PLD$XT$`DFLQ/DL$PLD$XT$`DFL./DL$PLD$XT$`DFLE1/DL$PLD$XANjT$`oHBFAAEEMFHHH1ALC1HLLL$HL\$@HLT$8HAHATh8icMEET$MkPDFDT$M|L$H|$8HHT$HHD$@H|$LkPDaHT$@HD$8EMLi^GMkPMLL$@L\$8LT$$DLLkPAMLGE5EMkPg>FL $AM跉D$ L $ELIkPALH|$6A,DEl$LkPFLL$8LT$Al$AM9MkPGMLkPFD$ MLL$8LT$%OJLT$`LD$XDL$Pj,DL$PLD$XT$`MEL$EMkPDFDL$MEAt$MkPt$DFMF*FLL$8EMkPGLT$AMD$ LT$LL$8CT$`KTCFLD$XDL$PHHT$hHL$xLT$pt+DL$PLD$XT$`LD$hyCFLL+DL$PLD$XT$`Ht$xHL$pDL$`LICFT$pLD$hK| LL$PHL$X*H|$XDL$`LD$hT$p]HGCFT$pLD$hDL$`I|HD$X*DL$`LD$hT$p!H|$PCFT$pLD$hDL$`LH|$P|*DL$`LD$hT$pH|$PCFW*DL$`LD$hT$pH|$PCF2*DL$`LD$hT$pH|$PDF *DL$`LD$hT$pwH|$XDFT$hLD$`DL$PL)DL$PLD$`T$hAA6C|.M~LQHt$`CFT$xLD$pK|DL$hHL$PLT$Xi)DL$hLD$pT$xL\$`AMHt$PHNHL$PEbE1t$E1nHkPXHLHID$$E1D$A|I*IIIz,HHHyf.DAWAVAUIATU1SH(D5B=t$MLH)HM<,LIKI WH4`G͔GHT$LMH)HM@G@t넸@HHu7t}vbu9BHfD1HO)9v*u߅tăw9BH@`JMJt1떐AUATIUSHHl(Ht+K9t\QSH|H[]A\A]11*Ato1H4HIH(HD(h}{Ld1ҾHƅAH4uH1X H(,%뵋,%묐f.H(HtaJtZAH9|u tAAAJ9|tt0AAJ9|tՅtAAJ9|tątAJ9|uÃDf.H)(HQHtPHtf.@f.@f.f.1f.1f.1f.1f.1f.ATUSH8B11HHHH (HsA0HH@1@@DHAItfIAtLϪLcC8C9N$kA~AGID$AHI+T$HI;D$|$$M|$HtMDMtAL$HLPID$DL}EWA?AE AGSL1u uAA~kAG@HLL-HA~ HLH@QHXf@|$El$FD/DD$XHpA7fAHAHHD$xD$t$iT$I\$։t$Hx1AK HtM+I9L[FLH+CIAUHL;[vIC(HHT$@Hl$xH]DCAHD$HP9T$8 @H{w?@A5EAE= ADAN0 EfDAB0P [IRI;R] -JL1舡!MI|$ L Hl$ .JL1HMFH$LAAnAFA0> H|$` AƆ1Ll$ DL$8-JL1IM٠AƆhEE_IH=z0LZ(uMM'AHH+IRT1L־xQt8@HD$@u-LvH|$@H@Qf@1HxLDCEVIt1LuxQt@tEHLAHsHHL5/J1L1H迟YHLAHuuHD$8HD$8D$tHD$xIZI;ZHK+IJ7HL u{D[HLC DXfxHCLEHEA5LLD$hHl$(tLD$(HEXEPIxA DPfDXI@H}LD$hHEE^ A5H< ID$(IhI;hLM]MHHAHBHt$HLbI^@HD$8I|$A|$AAA0AƆ0D$8cID$AAtJID$(^MET$I$Il$ HD$@MEjHT$BQA<CIHt {j1Hl$ EGH/JL1HM`  HWLLD$(rHHǹLD$(H\$`HMHtrHsLKI)IwH+sLHmwHHLSI*HC}PtH$LnxHuAFAFM}H\$`yLwH뢁D$4Ix t$4LD$(HkLD$(I@ yHt$@LLD$(謷LD$(LPHD$M:LvL@Iù01L$HD$`D$8LLD$XII{L蠚MutAFAAnHD$`EE4IHt%~0HV(uHHtA$E@H5L1LEuIH9S`AGoH}dNHl$8JHD$xD$tL]AH|$Xt$Aw<$Ht$PHHD$8I+rHt$8|$4LL$PA tE1HA$\vD$(E1tHLtLXHLILL\$@pHL$@)ȃ@\tH@{tOHy@"u\@{HMMLl$ Av0LLAEUfALLJHD$@A|$I$DoH|$PJ4@0H@(H@ HXHp[I|$HmE1AEH}GMl$M+l$IyL$LT$ I@0L` EKLP(LHHP^Itw1LLD$(xQHt$(t@t;Ht$(LHAHLD$(tJHHLLD$(*LD$(Ht$(LHAHLD$(uDUE^1LLD$(蓶xQLD$(t@HD$huLmLL$hH@Qf@1LLHӔLD$(H4LE19rLxIHD$(L$g1LڃL*H9HSHIH;Sv Dz1D9Ht$HkHLFA|&uAA\MH<HHH|$HHT$ t$pLAHT$ EDD$8L1H (.JHt$`L蒱HD$ L@A@HT$ L1H .JYA~5Df.AWAVAUIATE1USHHDHHxusH[{HD }5Mt0EEeA3DDSD[0DHH[]A\A]A^A_P0tHHH;HjUHx(H)HHwHD&HHwHHER{1DMAMA5"HuDVA?AE Fu(HHtx0HH(Hu }{F@ADHH{_VHIlj1H@QLxfpefDDeEeADDSD[0zEe`@H NHx(t(H {HHH{XHiD}D]HUHmA HhDXfDxHPHHhH;huLEDeL@Eu{=DMBH`1HxQt@t,HHHt1DHHH_HHHu1H蜱xQI@HhH@QLxf@1HEEEzLMTAx0MH(uM M=DEe-HDeHHH)HDeHHAVAUATUSDHHHxHc{HD(#}5tDH[]A\A]A^f.LuENA?AuE uAFqHu u{uAF@DHLHt{JAIHcgH@QLhf@PDP0HpH;ptUt}Hx(H.HHOHD)HHOHpEuZ{}MHx(t(H{HH.HDmHpEtHH蕑{ IHDmHpHhH;htLEDmL@IH@fE]EUHIUA DPfDXIEHUHEH1H覮xQt@t'HHHt,DHHHAHHHu1HSxQI@HeH@QLpf@1H藌efAWAVIAUATUHSH(HHXhH  pAV01HfHIljP@xA;@AAD @pMM Ayj`ADL DhHAAo@AGMn8AOIUIEDAH)DHtA4t(0J L1bL{xm0JL1ցA>tA4t`0J L1뫺/JL1蓁TI $/JL1v7 ļf.DUSHHPzP5u@H@t H9t0@u&H[]@uTt.6JH11ֺp5JH1H5JHHH1ÀHH5JH1H 覀먐SHHxt@u yxu[x@tH[mDUHSHHHX`Htm{t:SCU{CHCtX[]À2tZ[H1]k 6JH1wE1AH0L(H+IM)IL I L(M9D@HIIcAI)IIcI!LL(H)L9H(IAu4LMs0LHA1HIDHHtLH부`\H L(H0Hads0LHVH5JHHH1vHH5JH1H vAVAUATAUSHAŀAE)HG(GGƇQPJE?ƃMKu{@s0DCEAtEAID逻DHHLHAD{ uYEtTHH}LA{tH=nxuuHHHH#CCCHǃCEoE][]DA\A]A^Ð}<E eHh?J"K0wAEGCLC(CHCƃQEHJE@?=EkE_DCC}@{fDEDB{ ukH>JH4NyHh?JtT>HM=JH1Os+xHM`9JH1s["~Etm}JHM9JH1s-Hq!H^@H>Ju9JH1ZsDC}HM9J둃 E11C{ CCzHA7t=AuA1>t8JH1rCC y>=J?{09JH1qE{gHHAύ(:JHH11wqDf.HAUATUHSHHLk`LcPMuPGHCHLk(HH{0۰H;H;0MH H(u|H[]A\A]IcU1Ax=JHHkAUL>J1sMmMuEHsHH{0Lk(HuWH;vEH;0sJLL>JIeCHD{ uSHHxH~tHgxuuHLLH#CHCCHǃCH[]A\fHHAIAMP@\fAITHAрD{ ukH>JFHXH9HHT$舳H(L H0HT$HL9H(2D@LMcALIcIH!M)HH(L)L9H 1ALAt LAǪH@t HAfHDHAItfIAtLߪAHiIPHIPLLc(IP HHcA@hIPHLCCED$<ƃQDC09LkI>JDLu,M IeCzHksH(HHcXLÀ`HUf.UHAWAVIHAUIATSHdH%(HE1肭IIH@!LHH)H\$HIIr"L1HIL=H ;HH9rL;LE1At 7AA0AtFfGIAt FG=LVHt:L) 1LHLB; HEdH3%(u!He[A\A]A^A_]B# M|$BD#1谬HSt HE11E11E1E1Ht8HD<3I$FJHHHBt HfDI9HLLH IM~LƸH MMHMHf[߀D)|LB@Rtv@kt@r@K HtiAJAA9DBIfDD^AuH([]A\A]A^A_A. 6@EEIGM)LLLT$MH0LT$<D9LLHMLT$AA0EAA@t=EAA + QH(D[]A\A]A^ A_A1tA A@J0@JT$LLT$LD1A< gLT$mAD$IT$tAhBJT$L1ɾ1LT$dLT$A>mT$LA@J1ɾ1LT$cLT$CA@H$EAAJT$1ɾL1c1z H$EA(BJA>AAJBUEA>AAAJua-uuHA:MJJtBH JuEM0A@JT$1ɾL1b1AAJT$1ɾL1b1+tLAEMtIA@A@EuA+A1@AX@JA>tT$ACJ1ɾL1EbDA>T$LABJ1ɾ1LT$ bLT${DAADVcLT$a{ELLIGLL)DD$L\$LT$1ҩ0LT$L\$DD$OA ADA>AT$LA@J1ɾ1LT$DaLT$EAALLT$/LT$@T$LH$EABJ1ɾ1LT$aLT$EM0A@JAL$0aIH$EABJA<)T$LA`AJ1ɾ1L\$LT$V`LT$L\$A0AJWAWI AVAAUATUSHHDjHGHGGHrAMp{I?HHA D$ IHL94D$$ E1MHHLAC J@jLCJI9MHL9N LKHHt{Ht:M6J@I9JMMHLHSMJ@LCJI9mMHLHSMACJ@LCJI90MHLL9HSM?J@ULCJI9MH}HN LK6J@I9JMMHILKMJ@I9JMuMHoILKOACJ@I9JM9MHoLL9HS fDE{u-ADI@L+Ls&EBMHĘH[]A\A]A^A_0HHGf.|$ uftLCJI9MLHSHL96QHnHAD$ HI?H1IIHL9DD$ E1DD$$HnHAD$ Ct$$H;D$Kt!J ILI=MHL$(H AH=H ȃ -K I?MxHIHT$(D\$LAHHt$pIHT$xHT$8T$KLEBHD$pHD$@D$ALLL$0$H|$PLLT$(qLT$0H|$pHt$PHD$8D\$LLLT$(H;D$xLD$pD$u HT$@L9AD@$HHt$p1D [@@I)D$0L$0LIMAHL$0HD$(LHHH E1HnHAD$ A3@CJL1WMABI@L+LcwMAJMIAIAE|$ uA<pCJL1փ8WCAJIAIA봹@HD)HYAWAAVEAUIATUSHLGdH%(H$1HLJt$DDŽ$AD$$D$CD$<fH$LD$<I@$<;Љ|$8wB$`HJE<%DŽ$<$@JJDBALcAC MJsE9A\$$AӍkt9C MJ)HcDMJD9$AA`Aj$JJ@I_I;AELMx1H@uLxHþ@5LsPMmM;ENA?AWAFf€aAmMA~?@JƄ$Ƅ$E1H$HDŽ$HDŽ$ID$ID$It$L$81LL$fAAA&  H$LLE1L$L$L$MT$M\$M|$oA|$$Mt$M t$uBAmfI(M;M<$D|$8AE\$$E|$ !MT$M T$tAEIT$I T$tA3MJJxAB$0KJA AT$ ML$It$LAT$I( ML$M L$MD$AmA|$ @ID$IL$AD$AD$A|$MDID$I D$I\$AmE1AT$ ML$ID$AD$AD$AT$IA\$$AEqA|$$wvAIcMJ)MIt|$CIdžM9Ml$M l$H$dH34%(H[]A\A]A^A_LRx2NJL1QAmAFAfAAM^AKAF@H$A1E1E1@$Il$L$L$D$HHE1AL$A:L$t{IpH@MD$ID$OLHHuAI4$LD\$PDT$HmAT$IAEJ11L1SA\$$DT$HD\$PDKAB$LJAЃ?AȀAD fAF?,wMMnAu0LLA\|$<D$C(H$It$HEL$HIL$I|$At$_H A1E1A1EL$EL$ It$IL$I|$A\$EL$A|$IA}FJL1D\$PDT$HOD\$PDT$HIT$I T$@VDT$`LT$D\$hAM\$It$LLICL\$XLLD$HHHHD$PH$LlH\$PLL$HH$AT$ DT$`D\$hHLAT$Ht$XMD$M D$AD\$PM\$ID$DT$HEL$MT$LL\$hAT$MpIt$HMLT$XHD$pL$Ht$`oDT$HD\$P'ID$AT$ I\$It$AD$AD$AT$aEHcAMJAxMM{E1It$I9t$I|$IT$uH9ADID$DDAWA !A:1E1E1$H$L$L$@$HH$MAD$}A|$ML$It$ID$H$0ALHt$pIpHLL$HML$HD$XLIt$H$PMD$At$@H@KLHH1H@H@sKLHHD$P1H|$H$H$pLΉ$LL$D$D$LD$xQiLT$xL$pH$L$xHt$HLL\$hLD$`iH$H$H$H$$AHT$XDDHt$HHDL$xhH|$HH$AHT$hH$ADD$xLLL$XH$pLHEEDD$HL$pL\$hH$HIdHD$XH$pH$AD$D$HH$H$xH9t$`H$puLD$hAI9DD$HEE3 E1ɀ|$Pu?EAu4H@KHHIAIEAE1D8zH$p|$PH$xHAT$ D$@$H|$pAT$It$]EAIcEMJmA|$$AK[MLLfAEJIT$81ɾL1L1@LL$`L9L$XHL$pH9L$hIH9t I;E1H9A1E1|$<AI4$LMSeAEJIHD$P1貊ID$I D$MD$tCAD$IT$AmIt$HAD$A|$uA\$A\$MEL$ I\$It$HEL$AkMJL1`HA8DJT$81ɾL11E1KE1D\$`DT$XMpH$HH$D$ H@$!HD$HHHT$PH$LzaH\$HHD$PH$DT$XD\$`HHH$H$D$ $!HL$Hfv~D$HH|$HD$HD\$`DT$XD$ MpHf@$!HT$PHHD$HH1f$H$LR`L\$PHT$HH$DT$XLHD\$`H$H$D$ A|$ED$IL$ML$It$I|$AD ` LI H A\$ IL$It$ML$AD$AD$A\$AT$ AML$LIt$H$T$hAT$LAt$ID$H$LL$PMD$AHD$XT$`E@t$xID$It$AT$wMpI@LL$HCt$HH|$XNHH@D$pH$D$xHD$D$H$L\$PLT$XL$AƄ$$LLD$PL$L$H$Ht$H^LL$PH$H$L$LD$pD$$L$H$L\$XDT$`D$xD$D$H$HT$PH|$H@|$HOMIAIAt$pEƄ$@$L$AD$D$L@$H$HL$Ƅ$H$H$Ht$H]H$H$H$D$D$HH$L$HMH|$H@Ht$HOHHHLu#HHOIIAIAH)D$D$IH$L$Ƅ$HH$LH$L\$`Ht$H^LD$`L$HT$H$$$HD$hL$HD$`LƄ$H$HLL$H$IH$Ht$XH|$PL $D$&dZHt0IH$HIHѬ$H?L HVH$E1ɋ$D$D$$|$pH|$XDT$`LT$PD\$hH$$Ƅ$HH$HL$H$Ht$Hr[H$H$HD\$hDT$`H$L$$D$HD$PLD$XH\$XH|$PI|$A|$ It$I\$AT$EL$A|$$D\$pDT$XH$L\$`LT$hHL$PƄ$HƄ$HHL$L$H$Ht$H}ZHD$PH$HD\$pDT$XHH$L$HT$h$LD$`H|$H@L$HCLL$`AIAIA$D8HD$hH D$`AH\$hH|$`$t$xHL$XL\$PL$H$H$@$@$L$H$L$H$HH$H$L]H$H$H?$D$H$L$HD$PLD$X$DL$xw9AIL \$hE1LL$hIAIAMAIL \$`~A}u/T$hAMJ1ɾL1D\$pDT$HAD\$pDT$HDL$xT$`H\$XH|$PIHt$HAHNHIIHIT$HH|$PJHHMpƄ$D$pƄ$LL$HqI1H1I!H!OHHGH@It$IT$OHHH]I4$LD\$PDT$H+ZAT$ IA(FJ11L1@A\$$D\$PDT$HAA|$$|$DAMJAQMJMAkMJMED\$xADT$hDD$`D$XHLL\$HHH$HVLT$HH$pH$D\$xDD$`H׋D$XLDT$hH$pH$xO1CJL<$ȃui qH$LLHSL$L$D$$)A>kDJ1L1qM$AMJ1ɾL1A>LD\$H)BD\$HI=MJL1:MAL$$MJL1:/MANJT$81ɾL1= H$H$LL1%~E1$AIIpHDŽ$M AƄ$L$Ƅ$LHH$H$HKSLH$H$L$L$$vA}u/A>uGA+tT$8AEJ1ɾL1D=H$L10D$E1T$8ADJ1ɾL1OD4:DA,>f,:Ht@A62tu;uLu^HuIMAIM9L6LMNAmHPIH@(EHIHfDBEHIHDJDKAAErAPLI?HDA$tPA8IG@L)kA$L@HpL)H9wkLLLHhE,$C(MD$A7tHHA9t&AuLAƇ9OJ1W"I?HHLMO@L@A $LIG@rMnAM9LjK >J :IM9A\D[AAUHW HCHH|$IHLUHT$uH*A'I?:f.Hu fUSHHHaHt9H+H{ aHt(H]H}`HtHHHx`HufH[]fAWAVAUATIUHHzSHHhdH%(HD$X1DAUALAu ARIA"@1HPINH+HHHfjDHHHDZfC?JqIAs\FTA$ASJ1ɾH1DL$ YDL$ *A>MA<AD$|DzLjA8u DzLjARA" 1LkD{뎹MLHDL$ iLM@HPLHE@DL$ uLEHD$@HD$PEp8IMp0IMMD$ @D$ > [L{L9LzL3L2HL9都 WDTJH1DL$ DL$ 1M;>AN t7\t2t(πk9AF%L$0ILLD$PHL$@H)HHHHD$(4HL$@LD$PDPJH3HL$(Nl)A~ u LD$PHL$@CbJHI3LD$PHL$@>FHMm3LbEM_A)&A }}tLuIF I9FI)LD$PHL$@HHLM23H}MH_ H9s3H}(W DGMLD$PHL$@I)HHLL\$( 1LT$(LD$PHL$@ JHM0D$0MOtA hPJL{(A^PJ|$ AuPJLEM+VHAW<1L~M|$ uARty"fAE5D$HL$Hu1HD$D$H?HT$IELH{ImE@ HL$(dH3 %(LH8[]A\A]A^A_H} H9}s3H{(DG LG#AEfAEfDAEfDAE{Hk(]=ILuAEHULHH AE)AE*LUAE A<&ILUAE{RLUAEE"A=.A<x&xA:A%dILUfAMAE)LL}AEA:>-& IL}fAMAE(H}AEDA=A>LOLMAE =HH}AE#H]AE D#A|VHH]AELeAE0A$6J .8*d WILeAE3ELuAEE>A>A-A=ILuAEL}AEA?=IL}AEAE'AE(H]AEDA+{A=HH]AEAEDEUeH{)H1H{(LMDGEi0TJH1 `TJH1 MiU5JH1 AE4 t vILUfAMAE'}Az:uEZAA:cILUAEOILuAE.=HH]AE-+AEP{!C kHUHLrHT$LuD$D$D$qHEHUA<LHH#L]AE A;=IL]AE"HM'6AR,D DLLH%HH3Ht ~jAE,A=uIL}AEfAMu@AuHL$LHAE5HT$IELH=jLMaEiX@Hu}iL]AEA =&r:t;>dIL]fAMAE*LPJ1H1kI.McLefAMAE%A{%A{: IL]AE&AEIL]AEAEfDAWAVAUATUSHH8dH%(HD$(1HHl$H$HLL;W L9WML9W IRHL E1fEEAyhM>H{(DGtA Hs(A^PJAhPJ|$ AuPJMEM+^HߋV<1L7M|$ vARt "fAE5D$HL$I4$1HD$D$HHIELH=MeAD$@, Au@@f{u{ u{ƃHL$(dH3 %(LH8[]A\A]A^A_@ IM1I|$ I9<$s2H{(W LG<L1OA+AKESAt4AD$hA}f_{ p {fMYMa M9H1L;uL,$LLIMH@fAu{zMMI4$AE%>#AuAE@@A}%u1{t+Ht"QL fD{ uHpHL{BSLH1AEfDAEfDAEfDIuHT$D$D$D$HAE7HLHf.M<$E7A*>H { fAMfAE+YfDAE{DLc(EL$R&EIM<$fAMAE(-f.M<$AEE7A=FA>MWM$AE A=IM<$AE#DI $AE |HI $AEM$AE0ADC6J<.<*| oIM$AE3]f.A/!pH3HK(H>Qb@-R@=IM<$AEvI $AE9=dHI $AERAE(HAE'>I<$AE+= HI<$AEAEAEM$AEA<=&<:<>IM$fAMAE*DAAEH{J1HL[(M<$EsAD$iw0TJH1`TJH1mAL$iDHI<$AE-`A=AELfAEAzIM<$AE..HI4$AE%HHH;HHHmH;HcuOHyIHJfAME\$AE]I4$AE >=HI4$AE"IMUL| tDGAvHI4$fAMAE'A~:uDNAA:(LMAzjMWAGiA|MasEqiiPJ1H1MAEP{!C kM<$HT$HMwM4$D$D$D$I$I$A<LHH:I<$DA'iMrM4$fAMAE%Az%Az:IM$AE&AEIM$AEDLLHKU5JH1AR&f;8AE4~IM<$AElHL$LHAE5/HIELHm;SHt@Hw1D< HFt< ~<#Dt<$uڃ1ɃHc([D EL[H"fA t]ASIHVEKEt5A t=~A#t,A$uH~$ECIHwDEKEu[H~\MI9rA:\uHF\IHHH9F8\=Hf.@AWAVAUATIUHSHH8HD.HHFAqH9H~ACvEH9El5ACDKLCEI9Gl ACCLSEI9ElACsH{EH9El5twACDKLCEI9Gl tZACCLSEI9Elt>CsL{DI9El5t#LC IACEHEI9Gl uE|$pAMT$XEA$l$$AA!EKJHHD;h ug;hub|$H8HHމL$ LT$HD$8|$LT$L$ u1HL$H8[]A\A]A^HA_f.E1UD|$DD|$ Hl$MEF .MH\$A!AEEEA!DLIAsH HKD;C ASEA!DILHHD;C tlEAsA!DILHHD;C t:AsEA!EKNHttHD;C D^tDT$$;SAHT$Ht$H;L$,DD$(q7DD$(L$,HH8H[]A\A]A^A_EMDt$ H\$Hl$AD;t$LT$LAW`MWXHt$II2Dh MohhMH}AHHIr#IL IL9LH LE1@t AA@tC<*fB<)I@t C4*B4)(Al$tIAD$pD<D @Al$tE9H8L[]A\A]A^A_Å1IL$LcND9M9D$ suL~8IL$HHLM|$MWMT$AI\$Il$H9uAL$PMcL$0IT$ M\$IDLM)HH!ID$L)L9~IT$MD$MD$IAk\$pET$tLAET$tAA9L{LT$HHT$LAT$`M\$XHT$IIDh Ml$hhMH}AHHH(IsDt$T|$D$ A9AEƉD$dL[L9LXLLHL9@AWIAVAUATAEUHSHH8OpLOXDqE!DMHMIE9b uVA9juPI:HDD$LL$L$LT$ 24L$LL$DD$u HL$ H8[]A\A]A^HA_fL$EAEE!AE݋E!DMpHM$I-E9b PE݉E!EJOMIE9b tmEݍpE!DMHMIE9b tI|$xLAՅHxLAՅcI|$xLAՅI|$xLAՅI|$xLAՅ@AWIAVAUIDATIUHHISHH$dH%(H$1(}$C}H$H$ˉL$H$HD$H$ULLcþ AIHMIFH$L|$IHDŽ$MII IF1L\$(HD\$0IIIAHD$ D$4M9IV*@uz@U@LIA8RA>IHl:I9&A8\IpH9HAx\IXH9Ax\IXH9Ax\IXH9Ax\H^H9t|~\H^H9ti~\H^H9tV~\H^H9tC~\{H^H9t0~\hH^ H9t~ \uT;\KHH9uHH$LL)H|$$EH<$'II9IItI$xDD$I$H$1Ll$''H$H$OL$IEEeH$dH34%(H[]A\A]A^A_EHA\DL$@A7 A0IXE1IH9wLLD$ M!E9I$xDD$I$H$D`&II9L9tDEZAwHGLArAefAfAngD$@ H|$$ELD$8H$Ht$@H<$b%LL$8IYLHA.IM)N\HL9rILH)H$H<$HD$ЄpJLH$$1Kz8LBHZLE(tJLLL$8LL$8]H\$LL$8DILƀ>(EHLB7HD$efD;&`sJL1DL$8eDL$8D#L$4AU<A[ALD$8Hc?Jt*ѾsJL1LD$8hD$@ ^H$'J1*H$tJL1LD$8$AatKAbvD$@ A$>t"AɺsJL1LD$8LD$8D$@A$0tsJL1LD$8LD$8D$@AvRAtuD$@ D$@ vAuIH$Ht$PLD$PL$HHL$`L1HD$pDŽ$Ƅ$DŽ$HT$pHt$`t uEH+T$pH$H$H<$HD$ЄurJL)H\$PJu"rJLAx)A$0IX1E1E1H9v:DEJAct(DAHEA D$@ :EHL$(L!D9 8sJL1DL$8DL$8D#L$0\rJL1LD$8,LD$8HA%tHw1A"fAEA?A'A(A$>kA{f޺sJL1DUHHAWAVAUATSH8L?HX0H@HH0HuDLd$LHxHP(D@LKIHH`dH4%(Hu1HDHD;@kID;@kID:@kID9@kHL9uă<SDLcDHM|DE׉DSIH DKD[OcMcOfDE"LQDqDEIMcLDI{L)L4I@uIwHuAGAWHI|H}?L9hmL90`LELuMDCDDk='MD9D D< 1҉LDHHHHHHH)HD$HHHI DD})L9A9 E1DLHHHHHHH)HD$HHHIA DD})L9A9 E1DHHHLHH)HD$HHH DHAA)M9MIIH@kIDIL;}LL}IAGt<MwLuAGAOHMTLUA:LML;Mt$IAA8IILLUL9(L(LML`xHuI9A9HMLzMq89HuMeAGEwISILL)LRDDuIELEA)L;H}LUIDuLI9DsH4׉I4Iҍs[IILHI DɃDH0HD`L9t-<t$Ay H~8nM>HM@8 *MHcE{sكEELIKLMLDk ''LE9r G$6A1EJIDHHH)H|$HHH0 ELLLMIWH9Uv IwHuAOhsG tBIEBLMHuMSL(I9NLL`EwEWIGHEAEMcLuELLuyA>uA~uEVE:WvKD8@ALyISDUHL}qL)DyHRHMHHEALEA)L;eLMLDk 'LEE9G$A1EJIDHHH)H|$HHHELLELMwAEWIwHuAL(L]HEH}IDULI9DsH4ЉI4L׍s[MILHI DɃ@8AW1EWD4DD9v5HHHMLPJJK H9wH}J AWHMaMcEDCGLUD[OO jHc@L0HHIHUmL0L`L(LH0DL0DžDHDž0<1IQH9h@L;`#AA`kL;L;hL;EA`kML;Mu@H(L9H}L`L;MuZH(L9HUL`L;hL;A `kO}LtFIL;ht\L;tEA1`k}MuM9rCLII9r ALHELhArH`1LhAO_H` PL;L;htyL;tbA `k|DH0HD`L9<IyH9htCL;`t)EQZ LhAOH` HhDV*L`EHhGH`AGEwDHI|IH}EWAwAADHMADQeAGAWAGAG5AwAIAwAwM{LM)OD}ILUEA)L;erwHELUID}MM9Sr2J4I4KDk%o'D9D< HDH1HHH)Ld$IMLLDDH0HD`L9{<nL;uMLAF8@L;htA9 @@L`A: @f.fAWAHIHAVI AUATUHHHSDWD_DGHT$DO _I9DD$DW@DL$DT$EH9Dg8Lm@L)Ll$H?HLt@Lt$DI@LL$ЋL$|$D]D|$DEDUA1C;xjA1!EVA:p $1EDT$ЋU Dt$A!AʼnT$A1A1ݍνEEDMADmAE!DF|A11DL$DAD}Dl$DA!D|$A1AD1B>F0A D}$AD!DD11G,*ƇGDDUDm D!Dl$1DD1F(ؘiDm,!։D11GFAB:DDl$A!A1E1DE(A AD!B[DD$1DG)\D1D!1D1΋}0!D8"kD1A΋M4A1A!D qA1E1DM8A AD!1DD1FCyD!Eb%1DD1!D1AuMu'H.HI9vlH+HvIHH=1DtIt?AsDXAHH )AA)DډI9vI4HHtHuD)‰MfHMtPLAԸZ[]A\A]A^A_HH9H 1DI~PHAI^`HtI~PLӸ뢸f.AUATIUSVHH_ LoxoHcIlfH}HEKHUɉHCH:H$H)H}H Hj HzHHjHzHHjHzHHj؃HzHHjЃHzHw|HjȃHzHwcHjxjHzHwNHj xUHzHw9Hj x@HzHw$ Hjy)@HxH}HvAT$HIt$HHtLMT$HLY[]A\A]AMD$`Mt"I|$PLAI|$PML$`LZ[]A\A]AX[]A\A]fDAWAVAUIATAUSHHDOhG8Lw LHJIH )ȋ JJH{)ANLHAԅ~HHfAԅKfLHAԅPLHAԅ:LHAԅ$LHAԅeLHfAԅ>LHAԅLHAԅ@y7@ 0$@JDOD_G?AAGy7DЍ8Ga)) 1A))AA1ED)D)A A1DD)E) 1A)A)D1؉A))D1A))AAA1DE)D) D1)1w D_ ADDGADDWADDOADwD_DDGADDWADDOAD?) D>WODA)A D)D1A))AA1ED)D)A A1ED)E)A A1DE)E)D1щA)A)D1ʉA))AD1A) D1)H AEډA)A)D1A [AA @B$ՠJD 7EA)A vD_DGDWDAD_AOADDAO EDW DD_W AAAOD GAE)E)E)A1DE)E)D1EAA)ȉA E1A)H EE)D)A DE1ED)D)AA1DD)E)1ʉA)A)ED1A)) AD1щA)D1@AWHAVE1AUATIUHSQHPJHЅ/HX/tqHBxtx/t`HBD@EteA/tLHBDHEtQA/t8HBDPEt=A/t$HBDXEu'HDXEtA/uA8/QHAvE1HcHqI1MJH]KEH/HHH]DCEA/HH]DKEA/tsHH]DSEA/tXHH]C/t@H_D[HWEt|A/t(HH_stg/tHHZKtS/u;/II)EWIcyMcHHLKIBK|JtiHHMcH)H+McK|Kt]MLtE<$Z[]A\A]A^A_Í{AHcLcHHLBKIL1H4L1f.fUSHHHuHHu HH[]þHDf.@AWAVAUATUSHH(Hcw09wPH@HII( HC@SP;S0AE1HcLMHL$AT$DMIHsHH1HHB uvH|$LK@LS8M?HKC4ML4$EЋT$AAHDI9S0ASPDH([]A\A]A^A_Hcs0H{HHbHCH>HL$LHHvDSH@H!z'D$8H|$4$HT$HL$ LD$DL$HD$(D$<T$</u{|$|$P|$X|$`X$H|$$H\$Ht$ HL\$iJHI{)|$H|$(H=?y'uu|$Pu_|$Xu+H@[Ë|$8L$8ɉL$8t$<t$<|$X+y2LD$pLL$hAIWyJ먋|$Pyы|$@v뺐{HT$HHzbJgLT$Lx'Ht$]JH~Ht$ |$`nqHL$Ht$WyJHy|$X)x|$X,J뼋|$Pv|$P듋|$1P|$jH|$pLD$hIWJRHSHt Ht[ÿ|HuH}Df.USHHHtHHt5Ht%H[]þHuHH1I^HHPTI:FH :FHpBfDkUH-kHHw]øHt]kkUH-kHHHH?HHu]úHt]Hƿk=Yv'uUH~]Fv'@H=T'tHtU8kH]{sR9y't ;?y'tXÿy'WH0y'XH=%y'x'HHkH y'XÐf.Ryx't ;u'tXÿ\x'H`x'XH=Ux'HcFDH|t'? H u'Htyt []A\tW[]A\DcUHAWAVAUATSHH(dH%(HE1D#A$t A@Hs1IEIMHIA/tEu1HHHLHH)L|$IL#A@C/1ҾuFL1HIXHu{L-n'LdApFMMELL11HIL:(HUdH3%(Hu&He[A\A]A^A_]LApFHLELHELUfDATIH5n'1HUSHHHHHHjHcH,tjH@IL.HHtBx.tH}x/uI9tx/u=m'LuzE.[]LA\Hu@MtA<$$t>1L濴>F1HHH11HHHIGH1L1UHHHL9t?/tL9t /tH@/v?.tDA.A>H}/uHE1FT FIEuf.USR=u'u]HH5u'HH=u'HWHu'Hyu'HHHHHHr HHHHHHku'X[]úp G5{FB>P GpH!l'ZfDu'AWAVAUATUSH(t$ HT$HL$tIL-t'L5t'E1IM9ttILLI HuދE 9D$ U9|x=t'DtXHt$T$ H|$H([]A\A]A^A_ú` Gq{F[=H(L濎F[]A\A]A^A_1SF@ G`{F*=9T$ ~H޿(FH(1[]A\A]A^A_FH޿Fff.Hcǃ<u=s't4P@ G`{F<=s't,H s'H5s'1HHDDDHH9uP G{FuEMEEIU@e>AA B$ GDT$7EtlH$EEIMD$Ht$(H|$ HD$L|$Dt$$08I nDT$<뭃|$8ADT$=뚀|$>ttI}uLkXAGxA}H$D$L|$Dt$$H|$H|$ @1DHt$(7s|$8A#ApGz@G:|$?mdE|$8AE |$8pGH@G`:|$8ufك|$8u@tpGF@G-:pGD@G:HH[]A\A]A^A_Ðf.H1HtHDH)@f.ARHg'H9D$uEu"Htg'DAXຐG@Gx9G@Gd9DATUHSH11A$@0HD kIU1@@>IHHHHA@ DHAHItIAtLfIAtLϪJ<LHHHDf'Df'HǃǃlH5Tf'DD[]A\HA?H9HAH;HAfH!AWIAVAAUIATEUDSHHHIAIPA9sZMGPIt'vIt/Iufo xAfouAforAE1AH$H$ALAE1AHT$HD$ Gl$Dd$A1A@Ɖ4$HAHIudkHMHL$0HL$0LALMAALLE1AAH$HYd'HAE1Al$H$H|$ Dd$LHl$AE1AAD$HH[]A\A]A^A_I`?L$0L$0A=ADžDBADžADžEHIAkHT$8HL$0HL$0HT$8ƿksHM|.G1]/ HXH LHM>FLAEM}Lǃǃ=_'tAAu00GD1=ǃǃD`)Pu>ǃPPu3ǃǃPPt8/GD1f8먃P뾃,i.G1I7XPtPth.GD18ǃPu.GD17ǃ1L1HPHg' h'Z k[LHHg'Hg'#ǃǃD /GD1M<ǃǃǃ 0`KH޿]'50GD6x0GD16ǃǃHHdHH(zVDAWIAVAUIATUSHH:LRdH%(H$1I}@L$ DD$$L$H$RH ID 1 L :f !@,D|  iAAA|$ AhA E1T$(d$(D;%lDDD$8DD$ L1D\$0D! t$(!DD$8D\$0AL1ALJIAuAAuAAuAAuAAuAAuAALuALA\uA\A`utA\tA`AuAAuAAuAAuAAuAA(uA(DD$$L$ AHl$L$$LLL +H$dH3%(Q HĘ[]A\A]A^A_ÁU% N #hwDN<5|TDAwGT L)HPG@G+R? uExx`wP^D=MN%LEA<  LF\LLҾ1e\LHH1HAHHLcANTE9~ALIAz.k:kIH2@LIAuAAuAALuALApA-ALJplALJ\I j9P!pD|$  AG(pTr71MF\@LLҿILhR\|AHFAIƉD$(DT$(IFIDHEPE9]OAAG+nrfGLLT$(9HL$(AGxb1MF\@LLҿ_1E12U*EAAEt{H}։T$(67L$(HKEyDD$ EoHt$Hl$L<$Mپ27bU|ZEzNLF\L>F1_1LF\LL1DADEE8EnDJAwAt 2G1,H8A1A>FIEI;EFHHL$(KL\$(u,AGxxLcʃMOAG/dEdYGLL\$(Ht$("AGx-|$ T$8LLT$01HHH L\$0HxWHD$(Lt$ H|$(6=LT$0T$8Hl$Lt$EL<$A҉AAqMADD$ ^H|$(DRAwuA MF\AL>F1|NElCAAG+0HL$(LҾG1+H`2G112Q2GD1*ALJAoA8 u1@AA7 u1AA0 uAA4 AzHMHL$(!3H|$(G3]HcIw AG0IDD$ A7L1ҾALJLF\LL1LF\LLҾ1Ll$(LMMIDH@uEAA9tEIkPLGLuHA9v܉HkXHGyxA@uAHcHkXG9wA9tA+H|$0AKIkPLoLl$@H|$HIE/H$dH3%(QHĘ[]A\A]A^A_AE1OFLDX2GE4G2G14G2GI~ u9I~(uD$pE1@|4G2G 4G2G |$d@A4Gy2G EvDMk0IƠHI|$pI~L$HT$pLDL$PL\$ L\$ DL$PI~L$H$T$pHDŽ$xL\$ DL$P<H$A4Gk2G LDL$PL\$ DL$PD$pEAEDL\$ 1HLLC'LC'LHHQL)HcH9HT$ }8ο kHD$hDL$XL\$PGLC'LC'HD$hDL$XL\$PH C'LH9u C'=C'L_C'HcHHcLH!L)HTC'L)H9~LEC'L>C'1L-C'H;t$ t$E7AJ@<1HL$H1IAFAA4Gd2G M<$D$p1D$cK4"B"HH B' B'JD k LnB'H oB'T$1DBE(AKHtDMHD(H9l$(wAE9uL{@4G{2G 4G2G HkXSI8I@IpLAPHAG!u DCLHyHS@Hu-HK HK[E0t֩tρEAHuHS(H{ 1ɾCbJ1FHC[úP4G2G ff.AWAVAUATLcUIkXSH8H`GDt$pLl$xBBft6HIt.zHH1HHE؃w$3GHAu-ERH8[]A\A]A^A_BAu5t$rPA7HtHMtH>F1HzP@҅LBPMąAD8 BADZPAE!HjBAHRP UMMu.DL$LD$L$QDL$LD$I‹L$I:H\1ҾDL$(LD$L$LT${LT$L$LD$DL$(1HkI:HHDL$,LD$ L$(LT$T$D$DL$L$LT$LD$ IDHDL$,L$(MACHkpAsIHMcMCAKMOLGDBDDL$LMk0A$HIIĠHIHDL$HAT$ DL$E1HzPANW&I:H_LT$L$LD$DL$(I;D_D9)MH8L[]A\A]DDA^A_H vHBPHI!BAHzPtI ?A ?@f.AWIIAVAUIATUSDH8HHt$L$$DD$(DL$,HcLd$p|$xHkXMGAOHLkXGM`Gft*Lt%1@D $IDL$ALLT$VL1I;l$sFS AVht5L\$hHD$`ED|$D4$E1ɺHL\$HD$Hbu5HT$hHL$`ED|$D4$EHHHT$HL$1$Ht$hH|$`ED|$D4$E1ɺHt$H|$HHLD$hLL$`D|$D4$LD$LL$EA1dff.AUEATEUHSHH( ~0 2tm?H([]A\A]Áu܃`uHT$`L$Xt$PHD$hHT$L$4$HD$1H럃u@AHT$`L$Xt$PHD$hEAHT$L$A4$HD$1ɺ Hu?LD$hH|$`1DL$PDT$X)HLD$H|$ED $DT$EHZ@T$XL$PEL\$hHD$`EHHT$ $6L\$HD$1xuPE1EtE1=r='ALL$`LT$h1D\$XD$PHHLL$LT$ED\$$|uNE1EtE1=='AHT$hHL$`Et$X|$PHT$HL$t$<$1HH]uPE1EtE1=<'ALL$`LT$h1D\$XD$PHHLL$LT$ED\$$uNE1EtE1=i<'AHT$hHL$`Et$X|$PHT$HL$t$<$1HHuPE1EtE1=<'ALL$`LT$h1D\$XD$PHHLL$LT$ED\$$TuNE1EtE1=;'AHT$hHL$`Et$X|$PHT$HL$t$<$1HHE1EtE1=^;'ADL$XLd$h1LT$`D\$P HHDL$Ld$ELT$D$MuH!}L E#EtCDoWfDqDWEtEDo_fDrD_II?L!OL WIAL!_L gEtCDogfD%qDgoEt9DoofD-JrDoKHgHO@1HgHO EtCDowfD5qDwEt9DofD=qDHgHOHgHOEt=oGfpGzEt6oOf qOYHgHO?HgHO%EtBoWfpWHIH!EL mHgHOEt=o_fp_Et6ogf%pngHgHO@hHgHO NEt=oof- oo-Et6owf5ow HgHOHgHOEt@of=UoEt9DoGfDRnDGHgHOyHHH!WH OSEtCDoOfD mDO/Et9DoWfDnDW HgHO@HgHO EtCDo_fDnD_Et9DogfD%mDgHgHOuHgHO[ALDJ1?DžP ,EtgDoofD-mDoEt]DowfD5lDwEtSDofD=?lDHgHOHgHOHgHOrEtLoGfkGQ11Ju A@D牽!HHH!_H wDJD111J APADAD11XJ A>ADAD|tD(JD1\SD⾐JD1;2Et=oOf kOEt0oWflWHgHO@HgHO Et#o_fj_1HgHODf.1f.f.1f.1f.1f.1f.f.1f.1f.1f.1f.1f.USHRu)HHHrpuKhX[]ÃO`GnHt1 H{sOuǐAVAUEATAUHSHHpInHkDc(C,Dk8C<CL3[]A\A]A^ÐUHAWAVAUATSHHhdH%(HE1dv(~;rLeLELHEA HI91HLDkhA HHED) DNE)E9 H;E1H;1LwLuA H; + H;@ ADI DD)~ C4<@uH;L+YGA}3L#IA|$3nIIL1LDULHLA^DH҃H)LHHt J1L^IL)Lt$/L$EILpoH;LeOHuH;HEdH3%(u.He[A\A]A^A_]A9D]DME)McMwnUHAWAVAUATISHHHDn8Dv(dH%(HE1A {yuhH=$'Dc_uyA|$8 t|AT$8{9usA|$<=;{t4H1HMdH3 %(He[A\A]A^A_]À{zt|{oEAAEl$8kA|$8uAD$8wuKuFH;H;]H@1KA`!H;KH;L#AD$1H='#J1Hn)kD{PECMct$u0W@t0LUpMJL9Mx(MZIL]pEnE*A6@%u@EFMnA<  A% A'j E HupHVH9Ux LN;LMp HUhHMpDSADT$ OH9h HcLMxHu`MʉHI)HH!HEpH)L9 HMpHMhIEvC6J |$8EGDD$< D$(A^ DH|`; T$ MILmpM]L9]xXMELEpAEHUhHMpH9+HcHuxL}`IHM)HH!HEpL)L9hL]pLl$@D|$;<.DBHzA J_ A*A zsv Ht$LNE)A0DIQAE)ADEN;T`EA0DIqAEH6IcHHeLHIyHxgts>HL$LYEA0sKEMCAEHEA&JHIqHNIIzn'J@&JMCIPISLL$Iy0zAL_LEI&JIIQHzIyH|$N]LMpn'Js&J`n'Jr&JLn'Jp&J8Ht$PL ]Ll$PA}$u:|$(MmuD|$LD$0Ax3HHI1HUpHHqLcN L9Mx'HLLLUpH5!&H1LEpHHHLcO(L9]xrJLLILmpHEpHHH9MxsH|$[HEpHxIH}p%H|$h[LEpH5&H5&H1LMpHHHLcO)L9ExLLHT$0V{GLmpz3hHHI1L]pHHqLcOL9Uxr5LLLILEpH|$LT$ ZHUpLT$ H|$LD$ ZL]pLD$ H|$ZLMpH5&PLL$Ay4HHI1H}pHHqLcJ/H9UxsH|$LT$ :ZH}pLT$ LLIXLmpQL\$0A{3HSpEin'J&JEu8A@#tc@+-Eu@An'J&J豾n'J&J蝾n'J&J艾EurAHF#T>FT}'JNJONJ[O'JOQJHE&OH$&SHHH:'t"'JHMtQ'JHMt@H=&'JQu)H=&QJQu='H&QJu ['H&'JH&'J[f.AUATUSQH|$0HGGSHHAIH='ta1ۋ5'HH=o'H)PHLU'1LI<HH\ It> uOLHt:D;l$8}3A땿H 'oH'1ZH[]A\A]1HMH5'LHGuH%'H'EHtH'fDAWAAVAUIATAUSHHG8DH5CW$9W HwHADW Ik(HL[ELDAC MDet A}AAD}LmDEDC DMAEDCEDK8DKA\t8IEYAuA"AA0-J1HD HCX2J[A\EYIHHHXWDbD1IHH$Hu A}HDHIH ?IcT$At$HAL$ Hp1Dl+2JHՠ4JJH >AL$AT$HE$Hx82J1J?H(w9;JL1m1Hu(LHEZMV8HE6JL13At+Au UA;J1ɾL1듾LAx6J1ɾL11 f.AUIATUHoSQH]Ht=E1AE9Cu,D;csDHkHIt=H-uD;ct H]HZ[H]A\A]A뾐f.UHSVHHX`HtD{tR{C u1EH{tEHCX[]ɃUCY[];J1;J1SA;J1ɾH1fAUIATUSHHdH%(HD$1HHtlH$H@?<tqKIDaHFhMkI(HtxLHH$HLH$DEH]1LAADErtHD$dH3%(u,H[]A\A]HH,H8uHUH$Hn6I}8LgHM;J1L1Hff.SHG(Hx0t1sHCH1Ҿ[#*[7J11g@AWAVAUATUHSH8GH$Ll$dH%(HD$(1]x5LHIHPHhHHH;Su{tMD{EHRax5IH@H[HHtH;CuE(H{LpMt 1LHAр{LSHI0D{mHD$(dH3%(u4H8[]A\A]A^A_HtHu0H4Ed$D$ƅODfDDkE DDsDu!{qEhAfTm2HGHHxuaE0UHLHL@LLHHfH 1HfH !1xmAf.AWAVIAUIATIUHSHLn_xQHtES=C+D[A{UHSHŋCHE1HHrD{ABD={CAEI$?JHt Mt A$#t^LpHH[]A\A]A^A_LKA9RsM$I?J-IJ7JL11벿@bTI$Iƀ{E1LDHIAAMI$6JLHH1뺀YA1SHL]HQtHH$'H<$H4L9vIHML!YH<$HGt D HHTHLHH)zbHL}I.H]Z[]A\A]A^A_ÄLhSHѺ 8JH1M1LAfIHAIsAyu7Mt(MLẠ8JH11L7JL8JH `8J눾 H4'IH1A uWuEH@ItfI@tLǪLhMLhIYAAEyeH׃fHL@H@f.UDAHщSHAQH(HHtpH{(HxHt ZHH[]X[]ÐUDSAARnHt @@hXX[]f.HpATAUHSHHH0H(HH)HL HH(L9D@LHIcAL)HMcL!H(L)H9H(MAH 1Au{AugDLAHuLAu@IhIhHAPiAIh ELD APiH+A@hIhHLH[]A\HfHLAfILAǪIvH(K` HHT$d/H(H0HT$ff.UHHAWIAVAAUIH=ATSHdH%(HE1LII +IT$I\$LHHH)HT$HHHtL)L(BD") HDLxHEdH3%(uHe[A\A]A^A_]L*ff.6fDUIHHHHdH%(HE1IIIRMBHLH)HT$HH1BD LLwHEdH3%(u)f.SHHHT$@HL$HLD$PLL$Xt:)D$`)L$p)$)$)$)$)$)$HT$0HdH%(HD$(1H$HT$ HT$H$D$D$0HD$(H4$H;{H<$&HD$(dH3%(u H[(@ATIU>JS1UHuLHTPu[]A\H@HHT$H|$w!u5H|$HT$HHt$HNH?wܾHHH!AIIL!f.AVHAUATUHSH8Ll$pLt$hHHt$hLd$LLHHHHD$pHHL$hHHL4H|$hLH|$xLD$hLL$pu;M9Au M9uM ADT$yHHt$hHH8[]A\A]A^E1fDATIUHSH8H@LD$XHD$`NHHH1|$hu HI9I?Iw AIIIM H?H@L)HHIH HLIHI лHt$`LD$XHHt$XHLd$LLH|$XLHD$iHHt$XHHH8[]A\ÍNLHHHHLH@IDIDIL I&I^Df.AWIAVAUATIUHSHxH9L$L$D$,H?7LMHtLƉIH@)II HH$L$HH$HL|$0LLL$(LLH$H1D$L$L$EuMLL$ L\$HH$HHH|$PLT$(LL9l$XL\$LL$ uL9t$PD$$LL$L$H$LHx[]A\A]A^A_1EuM E1E1HRM1AH IH HLLIHLII IHL9LPw*II MM9LXw H H @H@H0ILHڐf.AWAVAUATUHHSHxLpL$L$$L$H$D$LT$0@OIHL$PML\$(IHL$ ADALD$PT$`LL$XHD$aHLLLLT$LT$ L\$LLL|$`LD$PHD$XT$auLI@LL$(AL$MIHAIHAA8HHD8ˆT$aHLHxH[]A\A]A^A_ÍB>EI@AL$HHH@Ll$0IMALDà HH$LLLLLH$LD$L$H$L$H$D$HH$L$AL\$(D$ LHLLL$0LLLL$hLT$LLL\$(D$ LL$H$D$0>t <tu?J1aH$H$AL$MIIAAIIAE8uLHH 1 Ll$0fAL$LHH> L$AHLL \$LLGLLLT$L$H$IHD$u2Eu-H@w@HLHHHHH8uL9׸wuL9ÍHLHHHHH@HfDHHGtH8*HxQHHGtH8l*ZHxff.SH(H8t0NHHD0[ÿ@H(HPH(f.AVAUAATUHHSH)H H1/LIMtIxu}I@[]A\A]A^þ@@IHHI^HI1HEnIF(HHANH](I$H@s8HLppI$LMof.SHH?t71"u'r8tsh1[ǃ1HSHƿ!u+C`%=@tǃ[ǃf VfDAWAVAUATUSHHDEIC`%=`J=/LcxD$ I|$1>INjLI4/H)HHL9uـ|$ IIXHSxIL$LK0ILH$LA!ƃHC(ADǃH[]A\A]A^A_H1HLD$ D$ Ld-LIt$NCIu\L9C|$ 8HKjNJ1L1-D$ A HKUNJL1(HSLL f.AU1IATUHSQHHLaJ|#=IuHHHHt|/t HT/IL$HHZ[]A\A]Df.ATUHSHH>/t-HHHXPtHHHH[]A\Ãttu_1HtPjH{tHsHH[]A\H{T$ //IL+cI|$M>ILb(NJL1L!axLuOJL1jkIW@Ht$LHIGt^LtIIIG MI>tFLfHI ALJIG8M4IMM_M>ILL'HmSLHLt$0@AWAVAUATUSHHHDdH%(HD$81EnHAApHC8H@HsHHHA-H=f&HL}MJL[@E1MtAWjACD8DG1E9hfƃE1?HSxHs(AHYD`jHs0EHSHXPHEHp(ƅ1HDžH|$8dH3<%(Du|HH[]A\A]A^A_fbu*HsHU DP?E1띀nt!fƇƆt DA E1HKHH{ǃ HCLMaL9t)Eu AtAuLM9tiMm Ef HsxHA@ D$(H\$0D$)Ht$HwH|$HƅƃLKxM9MxuI}(LtgAu]MUM]@L$L\$/H}HT$H<$ǀHD$HP@O5H|$IMHHOHH<$HE1҄L$t!IPxH;SxuIx(Hs(>L$AI}(tAAu7Ix0I@DT$L$9 H4$H>- L $L! DT$EpHKxHHwH|$A@D$(H\$0D$)HL$ JHoff.AVAAUIATUSHHtLEAH1EHAHHA uPH~uuUvHK(i81҃HdtA[]DA\A]A^Hs(F8E1Df.HG(E1H DIMk(Lt EAHDBjHw(AJIRD^à t_ "1A|1A+A%tA.tA71A*A%eA<[A:1A&A@HLbJENA1A:à @A-AD @AA58A.A+A-A11ɀEA5IA\JLZAJf LVA2@\t1ɀ"@@AA5f.UHSHQHW@HBHJH)H9r HHZZ[]3HHE@HHU@HBDf.UHSHQHW8HBHJH)H9r HHZZ[]HHE8HHU8HBDf.OH\J1tu>1&@ƍD6øÃtuNtQt1Oøf.@AUATE1UHSHQH u%;.t ZH[]A\A]À{/uH;/uHD;e0sHE(HM EHJJ<uHU(J4H<3?/tAĀ.u .u/tH\3Df.USHRUH SH;StHCJKH,X[]ÍtH{sH+SHCAWBIAVAUA"ATUHSH DGE11IA;_HM(H;M0HQHU(:A17Et^H@bJ L$E`IWHJH|$8I;|$tH|$XdH3<%(u@Hh[]A\A]A^A_D!Hw HXtJ11AD 뉀/t%tJH1LD$pHLD$MI1$11`tJHLT$LL$苺LT$LL$IHAt$DH|$@LD$8\$0t$HLD$D|$(T$PHx HLT$IH\$LcT$,I LIBH HB1H|$ H11HHHL HM)MMLD$DD$(MH9t&EHHETDH! L9L$wkDL$IEYv"AvA>AEL$ AIIAvu t$,rD!AD 믺`tJ1H1HD$D[AWIHHAVIAUIպGuJATMULSHhH|$ H$dH%(HD$X1vLT$ LL$(I$ELl$@L|$HLd$PL|$PL\$HMIwM9I9L|$@1AAADLAItfIAtLLT$PLL$@MtC| tlC HT$PLD$@HHLv A87H\$XdH3%(LEHh[]A\A]A^A_LAIaLAfIZC H|$@ L|$PHD$@ILT$ICLL$H|$HLD$HD$@HL$@HD$LHD$PLLD$HHD$AЄHT$HL$u3HL$IXAGuJHT$tJLHT$HL$LHT$HL$Ht$HA6H|$'rAxAxHI@Hf.fATUHSDA IwJIwJjSH3HPPx?f΃ fx{ u 5tD@A?A fD@DK HDHL9r[]A\Ao=MII YfAWAVAUIATIUSHHDrEt6DH)HTH9HGHLHHAl$H@IwH)H@wvHuZH[]A\A]A^A_IM|$LIHD$ALLL$LL$L$A?LA?KtLEt$M\$LHLA\$ILLI?LMj@f.AUIATIUSHdH%(H$1$#EgD$D$ܺD$ vT2D$D$D$1۽H$HLH)ھH< HHvHtH$HHtLuIHItH$LH%LL+H$dH3 %(uH[]A\A]ý[f.AWAAVIAUIATE1USH8IcA61H IUH,HL H 9@tAA\$9|H8[]A\A]A^A_AHyGGLL$HH$1HtH<$"HD$HH<$11F|LT$IzH $HT$HǾHD$tH9D$IH|$QHD$B0@6J@t&HH=<&HJ1u1H|$H|$_HD$HD$I}HD$Ht$IE1HT$H<H|$H<t(HH|$;HD$HHD$McHt$(HHL$ Jt HAHtIE)H\$ HcHHHHMD0sHV>H:LHVLRLVff.III1Ht3HLLHHDA0IsDHrADH6ALHrHNHJfDHHt$(HT$0HL$8LD$@LL$Ht7)D$P)L$`)T$p)$)$)$)$)$dH%(HD$1HT$ H$HHT$$D$0HD$HT$dH3%(uHZf.HHt$(HT$0HL$8LD$@LL$Ht7)D$P)L$`)T$p)$)$)$)$)$HHT$ dH%(HD$1H$H=~'HT$H$D$0HD$=HL$dH3 %(HH'uHfUSHHt$(HT$0HL$8LD$@LL$Ht7)D$P)L$`)T$p)$)$)$)$)$HT$ HHdH%(HD$1H$HT$$D$0HD$"HxyHt$ H$HHH$Ht$HHL$D$02HL$dH3 %(Hu H[]f.QH=&Ht H=b&Ht H=d&Ht ZXf.Hf19t+AA)AE 0EIEJI9rDAqщHJH9wHPH=&J1!ff.HG Ðf.HG(H+G0AWIAVIAUMATMUSHHL$LÉpHJAHItbHAHID$t>HT$HL$PLIl$ A\$hM<$Mt$IT$Ml$@IL$HH[]A\A]A^A_H|$PtLT$P1HL $M@HÐf.HApHDH$$@MHÐAWAVAUIATUSRHLw Lu?IwaJ Hr H1LHIE0IE(X[]A\A]A^A_An1HcM$H9xLkK< HvAU俀IuHHcЉHHcJHt/I}MeXMt6I}PHAIEI] AmhgME`MtIuI}PAHAU@IEDf.SHHHH=p7EuHHHH[YHHt$Ht$fDS1HHH8HtHSHuHHC0H[HD$HD$UHSHRHGH9w7HW H H9s*H>Ht"HtHsHtHEHC0X[]fSHHHG(H+G0HO HH9vH w HH[HT$H4$HT$H4$HHW /HDHJuSHHHdH%(H$1HHDHH$dH3%(u H[f.UHHSQt"HHH{HuZ[H]X[]Df.UHAWAVAUATSHHdH%(HE1HHIAHIvAH9EHIMHHLLI M%HLHHDE1A];H LHID A9͉ANE1A9D}#HK4JFSHHIHEH1HLHHL$HMcHL4IcI|4 LHHN#IccXXXXXXJ|#HMA@|DHtu6H[]A\A]A^8H=}&HLJ1fDAUIATIUHSPHhL`@H@ @(@,@0H@8H@@H@H@PH@XH@`H@h@pH@xLHǀZ[]A\A]fDAWIIAVMAUATUSHHxHXdH%(HD$h1L$L$HH{ DkEt@1MACE[M'{,@@A{HHT$PLL$ |$D|$HT$D$$ELLHPK0H{8qs0HcH LcK0HC8Bl1HL$hdH3 %(uRHx[]A\A]A^A_LL$@LD$8HL$0HT$(LT$(L\$0LD$8LL$@HCX +LLL$@LD$8L\$0LT$(Ht$`HAW(LT$(L\$0LD$8LL$@D$`D|$dC,1EtH|$(DHP|$(Au=AutLHD$PExL|$(DHAT$|$(ExL|$(DHAU|$(HD$P>JLL$(ALD$((1HD$P=GA(MAHD$PJ1A2@@{,uHLL$@LD$8L\$0LT$(LHPALT$(L\$0LD$8LL$@LL$(LT$(D1HD$PJELLL$@LD$8L\$0LT$(PLL$@LD$8L\$0LT$(LL$@LD$8L\$0LT$(H{LHILT$(L\$0LD$8LL$@I9AEDLc K(M1LLL$HLD$@L\$8LT$0t$(LHAT$Aċt$(LT$0L\$8LD$@LL$HPLL$0L|$0DHD$PJ|$(EAAHD$PءJ1AtA@H{L11LL$@LD$8L\$0LT$(|ILL$@LD$8L\$0LT$(AHD$PnJAHT$PL1HLD$@L\$8LT$0LL$(pLL$(LT$0L\$8LD$@HLL$@LD$8L\$0LT$(Hs HALT$(L\$0LD$8LL$@xK{(t8H{ LL$@LD$8L\$0LT$(LL$@LD$8L\$0LT$(C(HC LL$(HLt$(HD$PZJAKCpH{xLL$@LD$8L\$0LT$(CpHH4EHCxLT$(LL\$0LD$8LL$@uLLL$@LD$8L\$0LT$(Hc{pHSx1HD{AAHD$PJE11EuLHt$`H߃AT$(LT$(L\$0LD$8LL$@xT$`Dd$d1SLL$(A:Ht$(1HD$P=GE@f.HHD$ L $ME1HD$H@f.ATIUSHH dH%(HD$1H@uHT$1HtHcC09|.HcHs@LHH|$dH3<%(u$H []A\ÉI<1)HcH k0USHH(wdH%(HD$1s,H{`HH{hHH{@{(H{8H{@H{Hw{pHHLG@MtHAHD$dH3%(uH(H[]=HPb)1HSxHHui1LE1x9H$dH3 %(DuHĠ[]A\A]A^þDKAAIEoJH1L)H$HL$Ht$H|$HHKHsH{mfJ6fDSHH HdH%(HD$1u+H$Ht!H9sHT$Hu'H$HHD$dH3%(uH [H9sH9HFH$f.DH=ؒ&H=q&uP1H&Z@f.HSHEHuHHt [HHf.UHSHHPZHHHZ[]f.UHHSP1HHHHHHZ[]DUSHHHHDHSHu&H-'HEHtH-HtH[]ÿ7H[&H5Y[&HHHH HHt HE11HxHHI @x?w@t HHI LfATIUHHSHHdH%(HD$1HH$HPt H$HH$HEHHHP tH$I$HL$dH3 %(u H[]A\ATIUSH dH%(HD$1@P!@  LAW@HIcIA@LHBMtكpHEIЄy MfDHt$dH34%(M$H []A\LHBfDHE11HDPMAIM ExtDDHBbDHBS@LcHBC@Ht$HHT$LD$HT$HBHLHof.DHIdH%(HD$1G(<t~<tgvE<tN<u>HHIPIpH?HL$dH3 %(H$u?HfDt7HHH6H1AUIATUHSHHHH_Ld$HT$@11@HSHЃHH ƄxHt%HLLHtH[]A\A]H1[]A\A]f.@H@t.p< tMv+<@t7aLfDH I&H=GBHL落HHHHRH H=B HH3HLH3 f.{HqH&H=B-HXH~Hlf.KwcHBANcLHtCDO(1D;O,}9McAO@LG DO(OMtA0IPLIH@Hu 1@HtDO(1D;O,}f.O(;O,}#HcL@HG O(JHt Htu 1HpPf.AUIATAUHSHGHFDuI_j1nfHHW1H¾%HH$0HBHGzYZHHHHSH1:E H$HHWk1H¾&HIH$HBHGzHBHGBF<0H0Hc H@HHWHHIHHHHHHEH9t=0F)t*H$HC8;C<HK0HcHC8H $L+HfHHWc1H¾$HAH$HHW31H¾"HH$HHW1H¾#HH$PBPЀ v<_t A<~1HHSH$:IDHH$HH~H$DHHWHHH$dHH¾!HAH$aH v'&w(HHH;w,WH %1HIKPHS@HSH$:IRHyS8;S<mHK0HcHS8z_HHHS1:_HHHSHH-HbW(;W,HcƒH @HG W(HHH=<*&'HxHRSP1H¾IH}W(;W,XHcƒH @HG W(HH"H=*&'HxH뙋W(;W,HcƒH @HG W(HHH=)&'HxHVW(;W,HcƒH @HG W(HHH=-)&'HxHW(;W,HcƒH @HG W(HH\H=(&'HxHW(;W,OHcƒH @HG W(HHH=(&'HxHW(;W, HcƒH @HG W(HHH=$(&'HxHJH5HG(1;G,}HcȃH4IHO G(H,H,$E,B0< ffE:HHEH$HxH{HC1Ҁ8tHPHS1Ҁ8sH$fPdHcƃH<@HC s(HH'HHH%1f1HHHs|HH*HYHHHSHHWHH$8 HH 1H$HAHQHU0H$HE(謣H{sH,$HHW- HH%H %f.USHHHWdH%(HD$1H$H)HI Mt1L=DHH1H¾{fH(HHHHOD1H1H¾11xHAHPHUxn/b1H¾HvH<1H41H¾1Hk1HY1H1H¾H@1H¾shH1H1H¾EHMP1H¾ ( HMP1H¾ H1H¾ Hj1H¾HS1H¾ H|1H¾H%1H¾HH}HHHU:_HHHUEPHH¾ JAD$@8܍P@@vu@cuH HH1[]H¾3@K(1;K,}HcуH4RHS K(HHt1LJH[H]1ATUSHWHHЀ HHIHHHEHxcHWIA $cA|$lH2ILL7HHH6DHHO1(HEHHC<h1H4;fH5%A|$LEHIIHLHHHHH1Hs\~iHHHsExH5p%HH=!HPH>ƃ>L(hMt$HMH-AL->)HPHHD$L9DHH=DeuHƃHH81LJ0ID$87ǃ0Ml$Md$AE13L>LHk?nfDIT$>YHL-L=/fHPIHD4M9DHH=EuuHƃHH81HL-L=/fHPIHD4M9DHH=EuuHƃHH81M|$HH-L5Eo&HPHHD$L9DHH=DeuHƃHH81IT$Md$Ht(HH=HPH{Lƃ{HV(HH=xHPH}ƃ}`IT$Ht(I|$=HHL-H'L~ILD43I9DpLHEuuHD$ƃHHAH81HD$@fA|$IT$H%H9BHC'HH{ HBH ƃ fA|$H-L-*@HPHHD$L9D HH=DeuHƃHH81HL-L=/fHPIHD4M9D HH=EuuHƃHH81HL-L=/fHPIHD4M9D- HH=EuuHƃHH81HAl$H=HPH@,@DIT$N%IT$H?%rf.IT$L$H5pz1LM?AUI!%tDIULDIM) HLM)HPHHD$L9DHH=DeuHƃHH81LJ0ID$89HH9:M|$LhLqLaIGH8qxuxL(9LH[8LH9H5HLH8DIT$E1:'u3HRDjAr%AAuIT$ u z<"HH=HPH(ƃ(IT$H@#HH=9HPH)ƃ)A<$<LAIT$H"&fDHH-ZL5a'HPHHD,L9D=HH=DmuHƃHH81HL-L=/fHPIHD4M9DHH=EuuHƃHH81HL-9L=N/fHPIHD4M9Dm HH=EuuHƃHH81HL-L=/fHPIHD4M9D HH=EuuHƃHH81@ 2I|$t @@tH(IT$H{/fDIT$ ID$ LchL0MH1-HPHHD$I9DHH=E$.uHƃHH81ID$#ZA9$P$HPH(Ld$(D$0HD$ HD$ HH(H HD$8H(Ld$(D$0HD$ HD$ H(H IT$HD$8e|$0u LHHD$ H(wH(H Ht$@Ld$HD$PH(IHL$@HD$XMHIF}LAHPw`DHEuOAH8DAHH|@HxH|HHxH|PHxHL@H H|XH(@HHuIT$H[DD$PL(E~A@AHDHHTHNAuH(IT$H"*5DHL-L='HPIHD4M9DHH=EuuHƃHH81It$ƼHDD$D8/J Hx? H@D$HuID$HD$D$L5E1D$HT$D4HD;d$HL=-HrIHD,M9DHHE/uHƃHH81HL-;L=J/fHPIHD4M9DmHH=EuuHƃHH81ǃ0)AD;d$@MmMoH AaHDIT$HHH=HPH]ƃ]IT$L$H5p1LMH{uAUI!%tDIULDIM)tnHLM%HPHHD$L9DtIHH=DeuHƃHH81HDH HBH}ƃ}IT$HaHH=p HPH)ƃ)kIT$HH-L5H,f.HPHHD,L9DtAHH=DmuHƃHH81@AT$L$H5n1LMHcsAUI!%tDIULDIM)tlHLM#HPHHD$L9DtIHH=DeuHƃHH81HDHj HBH}ƃ}IT$HH=HPH.ƃ.Mt$A>E: LHNfIT$H1d@IT$HL@IoEa<IcՀ| HHLl.HPHHD$L9DHH=DeuHƃHH81IT$Ha@IT$H )|@IT$H1d@IT$HL@IT$HHH= HPH]ƃ] IT$H@IT$H@IT$H@IT$HL-WL=TkH$fHPIHD4M9DtAHH=EuuHƃHH81@IT$H$@IT$H @IT$H@IT$H@IT$H@IT$Hy@IT$Ha@IT$HL-L=;H$fHPIHD4M9DtAHH=EuuHƃHH81@IT$H@IT$H@IT$H@IT$Hy@IT$Haǃ0IT$HL87L;8bL9UILEID$HD$D$*H-L-(fHPHHD$L9DHH=DeuHƃHH81LchLpMH1*@HPHHD$I9DuHH=E$.uHƃHH81H-+L-*"HHHHD$L9Dt=HH=DeuƃHHH81L$H5gL1LMlAUI!%tDIULDIM)tpHLM'DHPHHD$L9DtDHH=DeuHƃHH81HH HBH}ƃ}H(IeIT$HrHyc :1 9cyl|yHPu : Ho&IT$HBHi7 xxu H%ID$HHP0&ID$81*H@xH@8>)H*DHH(IT$^IT$HHHL-SL=Q0f.HPIHD4M9DHH=EuuHƃHH81H HBH ƃ IoAUHcIEL0A>aA~dA~A$u P 72LH#Agu(A~s&A~LHVsA~tA~HH= HPHH(Lƃ(HH=H HPH)ƃ)HH= HPHIU(ƃ(HT HH=k HPH)ƃ)3HHHǃH81GIT$H)\4@H@H8/}rH@H`fHPA$3HƃHH81\HƃHH81HƃHH81QHƇH81HƃHH81THƃHH81dHƇH81 HƃHH81HƃHH81jHL%L=0f.HPIHD,M9D)HH=E,$uHƃHH81Mcl$Il$IL9rDfHH=HPHD$DHI9LDeH)H~A_u}_u}UuLuM9v10HHIHM9 AHЀ vۍH!7HƃHH81KAFL$H5_LMP1HcdAI!%tDIWLDIM)tsHM,f.HAIHD, M9DtEHHE,$uƃHHH81HL%L=&@HPIHD,M9Dt=HH=E,$uHƃHH81MvHƃHH81HƃHH81pǃ0,ƃHHH8)ƃ)A<$JcHH5zyHH5HrH5hH^lH̢uH躢DHp'H/34H@H8/H@HucxlxHWHƃHH81YHHHBH ƃ HH6HBH ƃ HH=HPHH[ƃ[IT$HH=(HPH]ƃ]HHƃHH81L(9DGAv r@HH߾<諠ID$HHP8H5H ID$HHP)Hib(H$ID$H@HID$?fDxH߾[ID$HHP~]HўlHB8)t ǃ0HRH{HƃHH81'HƃHH81iHƇH81HD$ LD$ Ll$(H ƃHHH81ƃHHH81,ID$8IT$:)LDIT$HJH5{H>1HD$ H A_cVHƃHH81CƃHHH81ƃHHH81JIT$H~LHt;HB<0 <1H5~CHƃHH81ƃHHH81M9A_&<_HAHu/ƃHHH8HǃHHPH@,@L-聛IT$>H5}>fDHt0u l@fDLJ0DAWAVAAUATIUSHH*H @HcHHH-XL=['HHHHD,L9DHH=DmuƃHHH81HRH0&DH[]A\A]A^A_ÐHH-}L-+fHPHHD$L9DtHH=DeuHƃHH81@HH-L-/fHPHHD$L9D-HH=DeuHƃHH81HHHBH ƃ H=jHPH&ƃ&H[]A\A]A^A_DHH-'L-)/fHPHHD$L9DMHH=DeuHƃHH81HH HBH ƃ H-|L-|,fDHPHHD$L9DHH=DeuHƃHH81HH==HPH ƃ IT$H&ǃ0*f.AHH=HPH*ƃ*H@H@HH-hL-i/fHPHHD$L9D}HH=DeuHƃHH81HH-L-/fHPHHD$L9DHH=DeuHƃHH81뤀(t)HH=YHPH ƃ IT$HD0EHH-,L-(/fHPHHD$L9D-HH=DeuHƃHH81뤋0LHHD[]A\A]A^A_FfDIT$HX0t(HHAH )ƃ)DHH@DHݿHƃHH81jHƇH81HƇH81HƇH81ƃHHH81ǃ0ǃ0HƇH81~HƇH81AWAVAUATUSHHHdH%(HD$81H|A͋0HAt g0u\CuMHSEuHv:HK)CL H tG*t]tsDHL HHuHD$8dH3%(KHH[]A\A]A^A_H HDHL H HDHL L(HDž(DHRHAL(Hu{L-iH d'@HPIHD|I9DtfHH=E}uHL$HƅHH81HL$H=tQHPHD.ƅ.HCHXEu YH[vHDHL HƅHH81HL-OH U#HPIHD|I9DtGHH=E}uHL$HƅHH81HL$띋CLl$H5JLP1HcKOLH!%tDHQHDHL)ttHL#HBIHD|I9DtOHHE}uHL$HƅHH81HL$HL-H 'HPIHD|I9D"HH=E}uHL$HƅHH81HL$HfDAWHIAVAUIATAUSHHHt)fDPHHu1LDHHH=]HPH ƃ HHBH[ƃ[IUHtDH5HH=bHPH]ƃ]H[]A\A]A^A_DH@8*HH-H &@HpHHD4H9DtQHH=DuuHL$ƃHHH81HL$f.1LDH`HHtKHBH)ƃ)HƃHH81wHƃHH81HƃHH81rHƃHH81L1DH`H@AVHAUIATIUSHyHȿ*HHpHpwHH1t< oHH4HBH=H ƃ LHƃHH81 @L(1LHǃ(H?HHLHBH(ƃ(I$Ht 0tBH=tSHPH)Lƃ)H߹L([]A\A]A^fH&HH=uHƃHH81ƒ(HH=HPHL(1(Lƃ(Hǃ(HHH=tSHPHH)ƃ)HƃHH81HƃHH81HƃHH81fAUATAUHSHH(HdH%(HD$1:t50HD$dH3%(ZH([]A\A]L(H HLJ(H HUH$HT$HRHf0ƃ>L( H舳DHu>HuH=HPH Hƃ |D0H$HƃHH81AHƃHH81LJ0ǃ0HH=tKHPH ƃ yHƃHH81HƃHH81@@AVAUATUS:1Ht(0t[]A\A]A^D[]A\A]A^۱HBLchLpMtH1&@HPHHD$I9DvHH=E$.uHƃHH81ff.AUAATIUSHHv0u0tLtZH[]A\A]tHH=HPH(1틃0ƃ(uLDHȰuHH=t%HPH)ƃ)H[]A\A]@HƃHH81HƃHH81H\H Dž0H8H(HHDžHDžXLHcDž`HRHHDžhDžpHH)HH)AH@HP_AU{ _L{ L8u { ZH L+=LH~H1AH@1ɃB4~H8HHwEIEHHIIL9uHD$ Lt$sHI!H8[]A\A]A^A_fH{11HWHЃHH ƄxHL$HT$HcHt$H@HREIfDH{11HWHЃHH ƄxHL$HT$HA>@HSHc€u_Ht$H@HD@HrfHt$HD$H@HCH?fDgHt$(H@H$HD@N8H=HD$ H0$@H&HL\@H\$(t"tHD$ L(`Mf.HI $@HD$0tƄ$HD$0HD$x~@AUAATIUHSHHH$@@D1AHt HAt 1HfGAtLl$H@HHHLu7H=%tH5>H=W&t =W&t=U&@&=9&+&%&&&& &&&&&&&&&&&t@L$$tƃHc8LHDŽ$PHDŽ$@HDŽ$8HHĘ[]A\A]ÐAHnDH{A@K@1HAfO4f.UHSHHHhHH|tR)@H&HH t ut WH HH[]HǃH[]fDAUATIUSHHIEH$PHt ILI$Ѓt`uBuiLHLH1fLHI?L)I9T$@tHĈ[]A\A]fDHĈ[]A\A]`AWAVAUIATUHSHLwLIfDLHuf}MILIU AօuGH$PHt"ILIU ЃtUuLHt@HĈ[]A\A]A^A_ÐMILIUAօufff.ATIUHSH@tQtH1fDAImarch=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)}--no-add-needed %{!static:--eh-frame-hdr} -pipe ignored because -save-temps specified%<-x %s%> after last input file has no effectunrecognized command line option %qsspecs %%rename syntax malformed after %ld characters%s: attempt to rename spec %qs to already defined spec %qsspecs unknown %% command after %ld charactersspecs file malformed after %ld charactersspec file has no spec for linkingspecs %%include syntax malformed after %ld charactersspecs %s spec was not found to be renamed%qs is an unknown -save-temps optionfailed to get process times: %mcould not open temporary response file %scould not write to temporary response file %scould not close temporary response file %sunable to locate default linker script %qs in the library search pathsspec %qs has invalid %<%%0%c%>spec %qs has invalid %<%%W%c%>spec %qs has invalid %<%%x%c%>error in args to spec function %qsspec failure: %<%%*%> has not been initialized by pattern matchspec failure: unrecognized spec option %qcno arguments for spec functionmalformed spec function argumentstoo many arguments to %%:compare-debug-self-opt%spec-generated switch is just %<-%>%{fdump-final-insns:-fdump-final-insns=.} %multilib select %qs is invalidmultilib exclusion %qs is invalidnot configured with sysroot headers suffix -pass-exit-codes Exit with highest error code from a phase --help Display this information --target-help Display target specific command line options --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...] Display specific types of command line options (Use '-v --help' to display command line options of sub-processes) --version Display compiler version information -dumpspecs Display all of the built in spec strings -dumpversion Display the version of the compiler -dumpmachine Display the compiler's target processor -print-search-dirs Display the directories in the compiler's search path -print-libgcc-file-name Display the name of the compiler's companion library -print-file-name= Display the full path to library -print-prog-name= Display the full path to compiler component -print-multiarch Display the target's normalized GNU triplet, used as a component in the library path -print-multi-directory Display the root directory for versions of libgcc -print-multi-lib Display the mapping between command line options and multiple library search directories -print-multi-os-directory Display the relative path to OS libraries -print-sysroot Display the target libraries directory -print-sysroot-headers-suffix Display the sysroot suffix used to find headers -Wa, Pass comma-separated on to the assembler -Wp, Pass comma-separated on to the preprocessor -Wl, Pass comma-separated on to the linker -Xassembler Pass on to the assembler -Xpreprocessor Pass on to the preprocessor -Xlinker Pass on to the linker -save-temps Do not delete intermediate files -save-temps= Do not delete intermediate files -no-canonical-prefixes Do not canonicalize paths when building relative prefixes to other gcc components -pipe Use pipes rather than intermediate files -time Time the execution of each subprocess -specs= Override built-in specs with the contents of -std= Assume that the input sources are for --sysroot= Use as the root directory for headers and libraries -B Add to the compiler's search paths -v Display the programs invoked by the compiler -### Like -v but options quoted and commands not executed -E Preprocess only; do not compile, assemble or link -S Compile only; do not assemble or link -c Compile and assemble, but do not link -o Place the output into -pie Create a position independent executable -shared Create a shared library -x Specify the language of the following input files Permissible languages include: c c++ assembler none 'none' means revert to the default behavior of guessing the language based on the file's extension Options starting with -g, -f, -m, -O, -W, or --param are automatically passed on to the various sub-processes invoked by %s. In order to pass other options on to these processes the -W options must be used. For bug reporting instructions, please see: Copyright %s 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. gcc driver version %s %sexecuting gcc version %s cannot specify -o with -c, -S or -E with multiple files%s: %s compiler not installed on this systemrecompiling with -fcompare-debugduring -fcompare-debug recompilation%s: could not determine length of compare-debug file %s%s: -fcompare-debug failure (length)%s: could not open compare-debug file %s-fuse-linker-plugin, but %s not found Linker options ============== Use "-Wl,OPTION" to pass "OPTION" to the linker. %s: linker input file unused because linking not done For bug reporting instructions, please see:%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)} %{!E:%{!M:%{!MM: %{traditional:%eGNU C no longer supports -traditional without -E} %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} %(cc1_options)} %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp: cc1 %(cpp_unique_options) %(cc1_options)}}} %{!fsyntax-only:%(invoke_as)}}}}%{!E:%e-E or -x required when input is from standard input} %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)} %{!E:%{!M:%{!MM: %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} %(cc1_options) %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}}%V} %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp: cc1 %(cpp_unique_options) %(cc1_options) %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}}%V}}}}}}%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only %{E|M|MM:%(cpp_debug_options)} %{!M:%{!MM:%{!E:%{!S:-o %|.s | as %(asm_debug) %(asm_options) %m.s %A }}}} %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %{!S:%{!c:%e-c or -S required for Ada}} gnat1 %{I*} %{k8:-gnatk8} %{Wall:-gnatwa} %{w:-gnatws} %{!Q:-quiet} %{nostdinc*} %{nostdlib*} -dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}} %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}} %{O*} %{W*} %{w} %{p} %{pg:-p} %{d*} %{f*} %{coverage:-fprofile-arcs -ftest-coverage} %{gnatea:-gnatez} %{g*&m*} %{fRTS=rtp:-mrtp} %{fRTS=rtp-smp:-mrtp} %{fRTS=ravenscar-cert-rtp:-mrtp}%1 %{!S:%{o*:%w%*-gnatO}} %i %{S:%W{o*}%{!o*:-o %b.s}} %{gnatc*|gnats*: -o %j} %{-param*} %{!gnatc*:%{!gnats*:%(invoke_as)}} %{!c:%e-c required for gnat2why} gnat1why %{I*} %{k8:-gnatk8} %{!Q:-quiet} %{nostdinc*} %{nostdlib*} -dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}} %{o*:-auxbase-strip %*}%{!o*:-auxbase %b} %{a} %{d*} %{f*} %{gnatea:-gnatez} %{g*&m*} %1 %{o*:%w%*-gnatO} %i %{gnatc*|gnats*: -o %j} %{-param*} %{!c:%e-c required for gnat2scil} gnat1scil %{I*} %{k8:-gnatk8} %{!Q:-quiet} %{nostdinc*} %{nostdlib*} -dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}} %{o*:-auxbase-strip %*}%{!o*:-auxbase %b} %{a} %{d*} %{f*} %{gnatea:-gnatez} %{g*&m*} %1 %{o*:%w%*-gnatO} %i %{gnatc*|gnats*: -o %j} %{-param*} %{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)} %{!E:%{!M:%{!MM: %{save-temps*|no-integrated-cpp:cc1plus -E %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} } cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}} %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}} %(cc1_options) %2 %{!fsyntax-only:%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}}%V}}}}%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)} %{!E:%{!M:%{!MM: %{save-temps*|no-integrated-cpp:cc1plus -E %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} } cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}} %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}} %(cc1_options) %2 %{!fsyntax-only:%(invoke_as)}}}}%{!M:%{!MM:%{!E: cc1plus -fpreprocessed %i %(cc1_options) %2 %{!fsyntax-only:%(invoke_as)}}}}f951 %i %{!ffree-form:-ffixed-form} %{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) %{E|M|MM:%(cpp_debug_options) %1 %{m*} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{O*} %{undef} -fsyntax-only};: %{i*} %{I*} %{M*}} %{!E:%(cc1_options) %{J*} %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}f951 %i %{!ffree-form:-ffixed-form} %{E:%{!cpp:%egfortran does not support -E without -cpp}} %{cpp:%{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) %{E|M|MM:%(cpp_debug_options) %1 %{m*} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{O*} %{undef} -fsyntax-only};: %{i*} %{I*} %{M*}};: %{i*} %{I*} %{M*}} %{!E:%(cc1_options) %{J*} %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}f951 %i %{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) %{E|M|MM:%(cpp_debug_options) %1 %{m*} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{O*} %{undef} -fsyntax-only};: %{i*} %{I*} %{M*}} %{!E:%(cc1_options) %{J*} %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}f951 %i %{E:%{!cpp:%egfortran does not support -E without -cpp}} %{cpp:%{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) %{E|M|MM:%(cpp_debug_options) %1 %{m*} %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{O*} %{undef} -fsyntax-only};: %{i*} %{I*} %{M*}};: %{i*} %{I*} %{M*}} %{!E:%(cc1_options) %{J*} %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}go1 %i %(cc1_options) %{I*} %{L*} %D %{!fsyntax-only:%(invoke_as)}%{fjni:%{femit-class-files:%e-fjni and -femit-class-files are incompatible}} %{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}} %{femit-class-file:%{!fsyntax-only:%e-femit-class-file should used along with -fsyntax-only}} %{femit-class-files:%{!fsyntax-only:%e-femit-class-file should used along with -fsyntax-only}} %{E:%{e-E is not valid for gcj}} %{.java|fsaw-java-file:ecj1 %i %{W*} %{w} %{g*} %{fbootclasspath*} %{fenable-assertions*} %{fdisable-assertions*} %{fencoding*} %{ffilelist-file} %{foutput-class-dir*} %{g*} %{fsource*} %{!fsource*:-fsource=1.5} %{ftarget*} %{!femit-class-files|!ftarget*:-ftarget=1.5} %{!findirect-dispatch:-fzip-dependency %U.zip} %{!fsyntax-only:-fzip-target %U.jar}} %{.class|.zip|.jar|!fsyntax-only:jc1 %{.java|fsaw-java-file:%U.jar -fsource-filename=%i % unknown%<-femit-struct-debug-detailed=dir:...%> must allow at least as much as %<-femit-struct-debug-detailed=ind:...%>argument %qs to %<-femit-struct-debug-detailed%> not recognizedargument to %<-O%> should be a non-negative integer, %, % or %section anchors must be disabled when unit-at-a-time is disabledtoplevel reorder must be disabled when unit-at-a-time is disabledtransactional memory is not supported with non-call exceptionssection anchors must be disabled when toplevel reorder is disabled-freorder-blocks-and-partition does not work with exceptions on this architecture-freorder-blocks-and-partition does not support unwind info on this architecture-freorder-blocks-and-partition does not work on this architectureonly one -flto-partition value can be specified%<-fsplit-stack%> is not supported by this compiler configuration%s: --param arguments should be of the form NAME=VALUE--help argument %q.*s is ambiguous, please be more specificunrecognized argument to --help= option: %q.*sgetting core file size maximum limit: %msetting core file size limit to maximum: %munrecognized gcc debugging option: %cstructure alignment must be a small power of two, not %dunknown stack check parameter "%s"dwarf version %d is not supported../../gcc/opts-common.cmissing argument to %qs-Wno--W-fno--f-mno---debug=-g--machine---machine-no---machine=--machine=no---machine--optimize=-O--std=--std--warn---warn-no-----no-GDgDDDDDDZq@Zq@q@q@q@q@q@read_cmdline_optiongenerate_optionprune_optionsgenerate_canonical_optiondecode_cmdline_optionopt_enum_arg_to_value 3G&3G)3G/3G23GmF83GA3GD3GmFO3GmF]3GmFh3GmFv3G>FmFv3G3GmF3G3G3G3G3G>F3G3G&3G3G&3G3G/3G3G/3Gcommand line option %qs is not supported by this configurationargument to %qs should be a non-negative integerunrecognized argument in option %qsvalid arguments to %qs are: %soptions.cglobal-dynamicinitial-execlocal-dynamiclocal-execgnu2internalprotectedbyte_looplibcallrep_4byterep_8byterep_byteunrolled_loopnamed_varsacmlsvmlmixedCBprioritykeepthunkthunk-externthunk-inline387+sse387,ssebothsse+387sse,387standardevery-lineonceneverkernellargemediumsmallsysvattintel-###--CLASSPATH--all-warnings--ansi--assemble--assertassertion missing after %qs--assert=--bootclasspath--classpath--comments--comments-in-macros--compile--coverage--debug--define-macromacro name missing after %qs--define-macro=--dependencies--dump--dump=--dumpbase--dumpdir--encoding--entry--entry=--extdirs--extra-warnings--for-assembler--for-assembler=--for-linker--for-linker=--force-link--force-link=Display this information--help=--imacrosmissing filename after %qs--imacros=--include--include-barrier--include-directorymissing path after %qs--include-directory-after--include-directory-after=--include-directory=--include-prefix--include-prefix=--include-with-prefix--include-with-prefix-after--include-with-prefix-after=--include-with-prefix-before--include-with-prefix-before=--include-with-prefix=--include=--language--language=--library-directory--library-directory=--no-canonical-prefixes--no-integrated-cpp--no-line-commands--no-standard-includes--no-standard-libraries--no-sysroot-suffix--no-warnings--optimize--output--output-class-directory--output-class-directory=--output-pch=--output=--param--param=--pass-exit-codes--pedantic--pedantic-errors--pie--pipe--prefix--prefix=--preprocess--print-file-name--print-file-name=--print-libgcc-file-name--print-multi-directory--print-multi-lib--print-multi-os-directory--print-multiarch--print-prog-name--print-prog-name=--print-search-dirs--print-sysroot--profile--resource--resource=--save-temps--shared--specs--specs=--static--symbolic--sysroot--sysroot=Alias for --help=target--time--trace-includes--traditional--traditional-cpp--trigraphs--undefine-macro--undefine-macro=--user-dependencies--verbose--write-dependencies--write-user-dependencies-A-BDo not discard comments-CC-D-H-I-J-MGenerate make dependencies-MD-MD_-MF-MG-MM-MMD-MMD_-MP-MQ-MT-N-Ofast-Og-Os-P-Q-Qn-Qy-R-S-T-Tbss-Tbss=-Tdata-Tdata=-Ttext-Ttext=-U-U Undefine -Wa,-Wabi-Wabi-tag-Waddress-Waggregate-return-Waliasing-Walign-commons-WallEnable most warning messages-Wall-deprecation-Wall-javadoc-Wampersand-Warray-bounds-Warray-temporaries-Wassert-identifier-Wassign-intercept-Wattributes-Wbad-function-cast-Wboxing-Wbuiltin-macro-redefined-Wc++-compat-Wc++0x-compat-Wc++11-compat-Wc-binding-type-Wcast-align-Wcast-qual-Wchar-concat-Wchar-subscripts-Wcharacter-truncation-Wclobbered-WcommentsSynonym for -Wcomment-Wcompare-reals-Wcondition-assign-Wconstructor-name-Wconversion-Wconversion-extra-Wconversion-null-Wcoverage-mismatch-Wcpp-Wctor-dtor-privacy-Wdeclaration-after-statement-Wdelete-non-virtual-dtor-Wdep-ann-Wdeprecated-Wdeprecated-declarations-Wdisabled-optimization-Wdiscouraged-Wdiv-by-zero-Wdouble-promotion-Weffc++-Wempty-block-Wempty-body-Wendif-labels-Wenum-compare-Wenum-identifier-Wenum-switch-WerrorTreat all warnings as errorsimplicit-function-declaration-Werror=-Wextra-Wextraneous-semicolon-Wfallthrough-Wfatal-errors-Wfield-hiding-Wfinal-bound-Wfinally-Wfloat-equal-Wforbidden-Wformat-Wformat-contains-nul-Wformat-extra-args-Wformat-nonliteral-Wformat-security-Wformat-y2k-Wformat-zero-length-Wformat=-Wframe-larger-than=-Wfree-nonheap-object-Wfunction-elimination-Whiding-Wignored-qualifiers-Wimplicit-Wimplicit-int-Wimplicit-interface-Wimplicit-procedure-Wimport-Windirect-static-Winherited-variadic-ctor-Winit-self-Winline-Wint-to-pointer-cast-Wintf-annotation-Wintf-non-inherited-Wintrinsic-shadow-Wintrinsics-std-Winvalid-memory-model-Winvalid-offsetof-Winvalid-pch-Wjavadoc-Wjump-misses-init-Wl,-Wlarger-than--Wlarger-than=-Wline-truncation-Wliteral-suffix-Wlocal-hiding-Wlogical-op-Wlong-long-Wmain-Wmasked-catch-block-Wmaybe-uninitialized-Wmissing-braces-Wmissing-declarations-Wmissing-field-initializers-Wmissing-format-attribute-Wmissing-include-dirs-Wmissing-noreturn-Wmissing-parameter-type-Wmissing-prototypes-Wmudflap-Wmultichar-Wnarrowing-Wnested-externs-Wnls-Wno-effect-assign-Wnoexcept-Wnon-template-friend-Wnon-virtual-dtor-Wnonnull-Wnormalized=-Wnull-Wold-style-cast-Wold-style-declaration-Wold-style-definition-Wout-of-date-Wover-ann-Woverflow-Woverlength-strings-Woverloaded-virtual-Woverride-init-Wp,-Wpacked-Wpacked-bitfield-compat-Wpadded-Wparam-assign-Wparentheses-Wpedantic-Wpkg-default-method-Wpmf-conversions-Wpointer-arith-Wpointer-sign-Wpointer-to-int-cast-WpragmasWarn about misuses of pragmas-Wproperty-assign-default-Wprotocol-Wpsabi-Wraw-Wreal-q-constant-Wrealloc-lhs-Wrealloc-lhs-all-Wredundant-decls-Wredundant-modifiers-Wreorder-Wreturn-local-addr-Wreturn-type-Wselector-Wsequence-point-Wserial-Wshadow-Wsign-compare-Wsign-conversion-Wsign-promo-Wsizeof-pointer-memaccess-Wspecial-param-hiding-Wstack-protector-Wstack-usage=-Wstatic-access-Wstatic-receiver-Wstrict-aliasing-Wstrict-aliasing=-Wstrict-null-sentinel-Wstrict-overflow-Wstrict-overflow=-Wstrict-prototypes-Wstrict-selector-match-Wsuggest-attribute=const-Wsuggest-attribute=format-Wsuggest-attribute=noreturn-Wsuggest-attribute=pure-Wsuppress-Wsurprising-Wswitch-Wswitch-default-Wswitch-enum-Wsync-nand-Wsynth-Wsynthetic-access-Wsystem-headers-Wtabs-Wtarget-lifetime-Wtasks-Wtraditional-Wtraditional-conversion-Wtrampolines-Wtrigraphs-Wtype-hiding-Wtype-limits-Wuncheck-Wundeclared-selector-Wundef-Wunderflow-Wuninitialized-Wunknown-pragmas-Wunnecessary-else-Wunqualified-field-Wunreachable-code-Wunsafe-loop-optimizations-Wunsuffixed-float-constants-WunusedEnable all -Wunused- warnings-Wunused-argument-Wunused-but-set-parameter-Wunused-but-set-variable-Wunused-dummy-argument-Wunused-function-Wunused-import-Wunused-labelWarn when a label is unused-Wunused-local-Wunused-local-typedefs-Wunused-macros-Wunused-parameter-Wunused-private-Wunused-result-Wunused-thrown-Wunused-value-Wunused-variable-Wuseless-castWarn about useless casts-Wuseless-type-check-Wvarargs-Wvarargs-cast-Wvariadic-macros-Wvirtual-move-assign-Wvla-Wvolatile-register-var-Wwarning-token-Wwrite-strings-Xassembler-Xlinker-Xpreprocessor-Z-aux-info-aux-info=-auxbase-auxbase-stripEnable preprocessing-cpp=-d-dumpmachine-dumpspecs-dumpversion-e-export-dynamic-fCLASSPATH=-fPIC-fPIE-fRTS=Select the runtime-fabi-version=-faccess-control-fada-spec-parent=-falign-commons-falign-functionsAlign the start of functions-falign-functions=-falign-jumps-falign-jumps=-falign-labelsAlign all labels-falign-labels=-falign-loopsAlign the start of loops-falign-loops=-fall-intrinsics-fall-virtual-fallow-leading-underscore-falt-external-templatesNo longer supported-fargument-alias-fargument-noalias-fargument-noalias-anything-fargument-noalias-global-fasmRecognize the "asm" keyword-fassert-fassociative-math-fassume-compiled-fassume-compiled=-fasynchronous-unwind-tables-fauto-inc-dec-fautomatic-faux-classpath-fbackslash-fbacktrace-fblas-matmul-limit=-fbootclasspath=-fbootstrap-classes-fbounds-check-fbranch-count-reg-fbranch-probabilities-fbranch-target-load-optimize-fbtr-bb-exclusive-fbuilding-libgcc-fbuiltinRecognize built-in functions-fbuiltin--fcall-saved--fcall-used--fcaller-saves-fcanonical-system-headers-fcheck-array-temporaries-fcheck-data-deps-fcheck-newCheck the return value of new-fcheck-references-fcheck=-fclasspath=-fcoarray=-fcombine-stack-adjustments-fcommon-fcompare-debug-fcompare-debug-second-fcompare-elim-fcompile-resource=-fcond-mismatch-fconserve-space-fconserve-stack-fconstant-string-class=-fconstexpr-depth=-fconvert=big-endian-fconvert=little-endian-fconvert=native-fconvert=swap-fcprop-registers-fcray-pointer-fcrossjumping-fcse-follow-jumps-fcse-skip-blocks-fcx-fortran-rules-fcx-limited-range-fd-lines-as-code-fd-lines-as-comments-fdata-sections-fdbg-cnt-list-fdbg-cnt=-fdce-fdebug-cpp-fdebug-prefix-map=-fdebug-types-section-fdeduce-init-list-fdefault-double-8-fdefault-inline-fdefault-integer-8-fdefault-real-8-fdefer-pop-fdelayed-branch-fdelete-dead-exceptions-fdelete-null-pointer-checks-fdevirtualize-fdiagnostics-color-fdiagnostics-color=-fdiagnostics-show-caret-fdiagnostics-show-location=-fdiagnostics-show-option-fdirectives-onlyPreprocess directives only.-fdisable--fdisable-assertions-fdisable-assertions=-fdollar-ok-fdollars-in-identifiers-fdse-fdump--fdump-ada-spec-fdump-ada-spec-slim-fdump-core-fdump-final-insns-fdump-fortran-optimized-fdump-fortran-original-fdump-go-spec=-fdump-noaddr-fdump-parse-tree-fdump-passesDump optimization passes-fdump-unnumbered-fdump-unnumbered-links-fdwarf2-cfi-asm-fearly-inliningPerform early inlining-felide-constructors-feliminate-dwarf2-dups-femit-class-debug-alwaysOutput a class file-femit-class-filesAlias for -femit-class-file-femit-struct-debug-baseonly-femit-struct-debug-detailed=-femit-struct-debug-reduced-fenable--fenable-assertions-fenable-assertions=-fencoding=-fenforce-eh-specs-fenum-int-equiv-fexceptionsEnable exception handling-fexcess-precision=-fexec-charset=-fexpensive-optimizations-fext-numeric-literals-fextdirs=-fextended-identifiers-fextern-tls-init-fexternal-blas-fexternal-templates-ff2cUse f2c calling convention-ffast-math-ffat-lto-objects-ffilelist-file-ffinite-math-only-ffixed--ffixed-form-ffixed-line-length--ffixed-line-length-none-ffloat-store-ffor-scope-fforce-addr-fforce-classes-archive-check-fforward-propagate-ffp-contract=-ffpe-trap=-ffree-form-ffree-line-length--ffree-line-length-none-ffreestanding-ffriend-injection-ffrontend-optimizeEnable front end optimization-ffunction-cse-ffunction-sections-fgcse-fgcse-after-reload-fgcse-las-fgcse-lm-fgcse-sm-fgnu-keywords-fgnu-runtime-fgnu-tm-fgnu-unique-fgnu89-inline-fgo-check-divide-overflow-fgo-check-divide-zero-fgo-dump--fgo-optimize--fgo-pkgpath=-fgo-prefix=-fgo-relative-import-path=-fgraphite-fgraphite-identity-fguess-branch-probability-fguiding-decls-fhandle-exceptions-fhash-synchronization-fhelp-fhelp=-fhoist-adjacent-loads-fhonor-std-fhosted-fhuge-objects-fidentProcess #ident directives-fif-conversion-fif-conversion2-fimplement-inlines-fimplicit-inline-templates-fimplicit-none-fimplicit-templates-findirect-classes-findirect-dispatch-findirect-inliningPerform indirect inlining-finhibit-size-directive-finit-character=-finit-integer=-finit-local-zero-finit-logical=-finit-real=-finline-finline-atomics-finline-functions-finline-limit--finline-limit=-finline-small-functions-finput-charset=-finstrument-functions-finteger-4-integer-8-fintrinsic-modules-path-fintrinsic-modules-path=-fipa-cp-fipa-cp-clone-fipa-matrix-reorg-fipa-profile-fipa-pta-fipa-pure-const-fipa-reference-fipa-sra-fipa-struct-reorg-fira-algorithm=-fira-hoist-pressure-fira-loop-pressure-fira-region=-fira-share-save-slots-fira-share-spill-slots-fira-verbose=-fivopts-fjni-fjump-tables-fkeep-inline-dllexport-fkeep-inline-functions-fkeep-static-consts-flabels-ok-flax-vector-conversions-fleading-underscore-floop-block-floop-flatten-floop-interchange-floop-nest-optimize-floop-optimize-floop-parallelize-allMark all loops as parallel-floop-strip-mine-flto-flto-compression-level=-flto-partition=1to1-flto-partition=balanced-flto-partition=max-flto-partition=none-flto-report-flto=-fltrans-fltrans-output-list=-fmain=-fmath-errno-fmax-array-constructor=-fmax-errors=-fmax-identifier-length=-fmax-stack-var-size=-fmax-subrecord-length=-fmem-report-fmem-report-wpa-fmerge-all-constants-fmerge-constants-fmerge-debug-strings-fmessage-length=-fmodule-private-fmodulo-sched-fmodulo-sched-allow-regmoves-fmove-loop-invariants-fms-extensions-fmudflap-fmudflapir-fmudflapth-fname-mangling-version--fnew-abi-fnext-runtime-fnil-receivers-fnon-call-exceptions-fnonansi-builtins-fnonnull-objects-fnothrow-opt-fobjc-abi-version=-fobjc-call-cxx-cdtors-fobjc-direct-dispatch-fobjc-exceptions-fobjc-gc-fobjc-nilcheck-fobjc-sjlj-exceptions-fobjc-std=objc1-fomit-frame-pointer-fopenmp-foperator-names-fopt-info-fopt-info--foptimize-register-move-foptimize-sibling-calls-foptimize-strlen-foptional-diags-foutput-class-dir=-fpack-derived-fpack-struct-fpack-struct=-fpartial-inliningPerform partial inlining-fpcc-struct-return-fpch-deps-fpch-preprocess-fpeel-loopsPerform loop peeling-fpeephole-fpeephole2-fpermissive-fpic-fpie-fplan9-extensions-fplugin-arg--fplugin=Specify a plugin to load-fpost-ipa-mem-report-fpre-ipa-mem-report-fpredictive-commoning-fprefetch-loop-arrays-fpreprocessed-fpretty-templates-fprofile-fprofile-arcs-fprofile-correction-fprofile-dir=-fprofile-generate-fprofile-generate=-fprofile-report-fprofile-use-fprofile-use=-fprofile-values-fprotect-parens-frandom-seed-frandom-seed=-frange-check-freal-4-real-10-freal-4-real-16-freal-4-real-8-freal-8-real-10-freal-8-real-16-freal-8-real-4-frealloc-lhs-freciprocal-math-frecord-gcc-switches-frecord-marker=4-frecord-marker=8-frecursive-freduced-reflection-free-freg-struct-return-fregmove-frename-registers-freorder-blocks-freorder-functions-frepack-arrays-freplace-objc-classes-frepo-frequire-return-statement-frerun-cse-after-loop-frerun-loop-opt-fresolution=The resolution file-frounding-math-frtti-fsanitize=address-fsanitize=thread-fsaw-java-file-fsched-dep-count-heuristic-fsched-group-heuristic-fsched-interblock-fsched-last-insn-heuristic-fsched-pressure-fsched-rank-heuristic-fsched-spec-fsched-spec-insn-heuristic-fsched-spec-load-fsched-spec-load-dangerous-fsched-stalled-insns-fsched-stalled-insns-dep-fsched-stalled-insns-dep=-fsched-stalled-insns=-fsched-verbose=-fsched2-use-superblocks-fsched2-use-traces-fschedule-insns-fschedule-insns2-fsecond-underscore-fsection-anchors-fsee-fsel-sched-pipelining-fselective-scheduling-fselective-scheduling2-fshort-double-fshort-enums-fshort-wchar-fshow-column-fshrink-wrap-fsign-zero-fsignaling-nans-fsigned-bitfields-fsigned-charMake "char" signed by default-fsigned-zeros-fsingle-precision-constant-fsource-filename=-fsource=-fsplit-ivs-in-unroller-fsplit-stack-fsplit-wide-types-fsquangle-fstack-arrays-fstack-check-fstack-check=-fstack-clash-protection-fstack-limit-fstack-limit-register=-fstack-limit-symbol=-fstack-protector-fstack-protector-all-fstack-protector-strong-fstack-reuse=-fstack-usage-fstats-fstore-check-fstrength-reduce-fstrict-aliasing-fstrict-enums-fstrict-overflow-fstrict-prototype-fstrict-volatile-bitfields-fsync-libcalls-fsyntax-only-ftabstop=-ftarget-help-ftarget=Set the target VM version-ftemplate-backtrace-limit=-ftemplate-depth--ftemplate-depth=-ftest-coverage-fthis-is-variable-fthread-jumps-fthreadsafe-statics-ftls-model=-ftoplevel-reorder-ftracer-ftrack-macro-expansion-ftrack-macro-expansion=-ftrapping-math-ftrapv-ftree-bit-ccp-ftree-builtin-call-dce-ftree-ccp-ftree-ch-ftree-coalesce-inlined-vars-ftree-coalesce-vars-ftree-copy-prop-ftree-copyrename-ftree-cselim-ftree-dce-ftree-dominator-opts-ftree-dseEnable dead store elimination-ftree-forwprop-ftree-fre-ftree-loop-distribution-ftree-loop-if-convert-ftree-loop-if-convert-stores-ftree-loop-im-ftree-loop-ivcanon-ftree-loop-linear-ftree-loop-optimize-ftree-lrs-ftree-parallelize-loops=-ftree-partial-pre-ftree-phiprop-ftree-pre-ftree-pta-ftree-reassoc-ftree-salias-ftree-scev-cprop-ftree-sink-ftree-slp-vectorize-ftree-slsr-ftree-sra-ftree-store-ccp-ftree-store-copy-prop-ftree-switch-conversion-ftree-tail-mergeEnable tail merging on trees-ftree-ter-ftree-vect-loop-version-ftree-vectorize-ftree-vectorizer-verbose=-ftree-vrp-funderscoring-funit-at-a-time-funroll-all-loops-funroll-loops-funsafe-loop-optimizations-funsafe-math-optimizations-funsigned-bitfields-funsigned-char-funswitch-loopsPerform loop unswitching-funwind-tables-fuse-atomic-builtins-fuse-boehm-gc-fuse-cxa-atexit-fuse-cxa-get-exception-ptr-fuse-divide-subroutine-fuse-ld=bfd-fuse-ld=gold-fuse-linker-plugin-fvar-trackingPerform variable tracking-fvar-tracking-assignments-fvar-tracking-uninit-fvect-cost-model-fverbose-asm-fversion-fvisibility-inlines-hidden-fvisibility-ms-compat-fvisibility=-fvpt-fvtable-gc-fvtable-thunks-fweak-fweb-fwhole-file-fwhole-program-fwide-exec-charset=-fworking-directory-fwpa-fwrapv-fxref-fzee-fzero-initialized-in-bss-fzero-link-gantCatch typos-gcoff-gdwarf--gen-decls-ggdb-gnat-gnatO-gno-pubnames-gno-record-gcc-switches-gno-split-dwarf-gno-strict-dwarf-gpubnames-grecord-gcc-switches-gsplit-dwarf-gstabs-gstabs+-gstrict-dwarf-gvms-gxcoff-gxcoff+-h-idirafter-iquote-iwithprefix-iwithprefixbefore-k8Synonym of -gnatk8-lang-asm-m128bit-long-doublesizeof(long double) is 16-m32Generate 32bit i386 code-m3dnow-m3dnowa-m64Generate 64bit x86-64 code-m80387Use hardware fp-m8bit-idiv-m96bit-long-doublesizeof(long double) is 12-mabi=-maccumulate-outgoing-args-maddress-mode=Use given address mode-malign-double-malign-functions=-malign-jumps=-malign-loops=-malign-stringops-mandroid-march=Generate code for given CPU-masm=Use given assembler dialect-mavx256-split-unaligned-load-mbionicUse Bionic C library-mbranch-cost=-mcld-mcmodel=Use given x86-64 code model-mcpu=-mcrc32-mdispatch-scheduler-mfancy-math-387-mfentry-mforce-drap-mfp-ret-in-387-mfpmath=-mfunction-return=-mfused-madd-mglibcUse GNU C library-mhard-float-mieee-fp-mincoming-stack-boundary=-mindirect-branch-register-mindirect-branch=-minline-all-stringops-mintel-syntax-mlarge-data-threshold=-mlong-double-64Use 64-bit long double-mlong-double-80Use 80-bit long double-mmmx-mms-bitfields-mno-align-stringops-mno-fancy-math-387-mno-push-args-mno-red-zone-mno-sse4-momit-leaf-frame-pointer-mpc32-mpc64-mpc80-mprefer-avx128-mpreferred-stack-boundary=Support PREFETCHW instruction-mpush-argsSupport RDSEED instruction-mrecip-mrecip=-mred-zone-mregparm=-mrtdAlternate calling convention-msoft-floatDo not use hardware fp-msse-msse2-msse2avx-msse3-msse4-msse4a-msse5%<-msse5%> was removed-msseregparm-mssse3-mstack-arg-probeEnable stack probing-mstackrealignRealign stack in prologue-mstringop-strategy=-mtls-dialect=-mtls-direct-seg-refs-mtune=Schedule code for given CPU-muclibcUse uClibc C library-mveclibabi=Vector library ABI to use-mvect8-ret-in-mem-mvzeroupper-mx32Generate 32bit x86-64 codeSupport XSAVEOPT instruction-n-nocppDisable preprocessing-nodefaultlibs-nostartfiles-nostdinc-nostdinc++-nostdlib-pEnable function profiling-pg-posix-print-objc-runtime-info-print-sysroot-headers-suffix-pthread-r-rdynamic-remap-s-s-bc-abi-save-temps=Create a shared library-shared-libgcc-static-libasan-static-libgcc-static-libgcj-static-libgfortran-static-libgo-static-libstdc++-static-libtsan-std=c++03-std=c++0x-std=c++11-std=c++1y-std=c++98-std=c11-std=c1x-std=c89-std=c90-std=c99-std=c9x-std=f2003-std=f2008-std=f2008ts-std=f95-std=gnu-std=gnu++03-std=gnu++0x-std=gnu++11-std=gnu++1y-std=gnu++98-std=gnu11-std=gnu1x-std=gnu89-std=gnu90-std=gnu99-std=gnu9x-std=iso9899:1990-std=iso9899:199409-std=iso9899:1999-std=iso9899:199x-std=iso9899:2011-std=legacy-t-time=-tno-android-cc-tno-android-ld-u-undef-vEnable verbose output-wSuppress warnings-x-zAdaSCILAdaWhyLTOObjCObjC++Valid arguments to -mfpmath=:unknown IRA algorithm %qsunknown IRA region %qsunknown Stack Reuse Level %qsunknown TLS model %qscommon_handle_option_auto7G7G7G7GG7GGtyG8G 8G8G 8GmG(8G28G<8GE8GeGS8Gi^G=J]J^8Gc8GeGh8G+Jn8Gq8Gz8G8G8G8G8G8G8G8G8G8G8G@GkzG tG@G8G8G8G[GF8GFQJ8G8G8G8GsF8G9G9G 9G9G 9G ,9G39G >9GG9Gs8c9GG9Gs8@m9G}9G 9Gu 89Gv89G9G 9G 9G9Gx 89G9Gx8@:G :G8:G8` :G +:G5:G@ @:GH:GHQ:GH[:G"l:G|:GH:G :G H:G :G H>F:G(:GLIh:G:G ;G:G @;G:G;G3G|?0;GD;G|[;GD;G8u;GD;G8@;GD;G|@;G 8;G 8@;G ;G ;G @Gy 8>G">GH5>GMI 8N>Gf>Gx>G>G>G>GH>G>G(MI>G >G ?G @?G ?G%?G-?GH6?G??G J?GeT?G H&>F_?G (w?G~?G{8?G ?G?G ?G9G8?G9G8@?G?G8(>F(?G:G8 @G:G8 +@GHMIG9G8.@GBF1@G8I@GMI89G M@GMI9G8;F8@>FhNID;GP@GNI8S@GNID;GV@GOI =>F@Y@G\@Gw@GHOI:G8 {@G@@GpOI:G@GOI8@GOI@GPI:G8 @G@@G(PI@GPPIxPI8@GPIxPI@G3GPId@GPI$@G8QI$@GxQI$@GQI8@G@G@G@G@G@G@G@GH@G@GH@G@GH@G@G9G8&3GQI"AGHAGQI AGPRI*AGRI4AGRI"SI8SI"GAGSI RAGSI bAGhAGAGAG AGSI AG TI "AGPTI AGAGTIAGTI "BGUI BG%BG@UI?BGUI LBGUI [BGUI jBGPVI {BGVI "BGVI BG BGWI BG0WI BG`WI $BGWIBGBG BGXI CGCG.CGXXI 8(;CGXI NCGXI,`CGXI"0tCG0YI"4zCG`YI8CGYI<CGYI@CGCGZI DCG`ZI"HCGZI"LDG DGZI P+DG[IT>DGH[IXGDG UDG[I \bDG[I qDG[I `DGDG DGDG d\I@\IDG$DG\I`DG\I "hDG\Il EG EG]I p(EG 7EG EEGOEG@]I t]EG iEGx]IvJ?vJrEG]IxEG]I|EG@^IEGp^IEG^I EG^IEGx]IBEG_I`FGh_I"FG_I 0FG9FG_INFG_I `I8`IYFGh`I hFG`I }FG`I FGFGFGaIFGXaI FGaI"FGaIFGGGGGbI ,GGXbI =GGbI"TGGbIgGGcI uGGGGPcIGGHGG bGGcI bGGcI GGcIGG GGhdI GGdI HGdI HG HG eI"2HGXeICHGeIZHGeIwHGZHGfIHG[ HGHfIHGfIHGfIHGgI IG@gI  IGgIIG#IG6IGgI AIG0hIWIGhIjIGhI tIGhI !BIG"IG@iI#IGpiI$IGiI% IGiI &IG 'IGjI ("IG0jI)JGjI*JGjI+ 'JG,H,JGjI-"$5JG0kI.(NJGpkI/",WJG 0fJGkI 10tJGkI 2"4JG3JGlI48JGXlI5<JGlI 6@JGlI7DJGJG8HKGmI9LKGPmI :P(KG;T0KG<6KGmI= HKGmI > VKGnI? hKG8nI@XzKGpnIA\KGnIB`KGnICdKG oI D8hKGoI ElKGoIFpKGGKGoIH"tKGpI IxKG@pIJ| LGpI KLGL3LGMJLGpIN"\LGqI bkLGP{LGQLG@qIR"LG@qIbLGxqITLGqIU"LGqIbLGqIWMG rIXMGhrIY"4MGrIZOMGsI["lMGPsI\"MG ]MGsI ^ MGsI_MGtI`MGHtI aMGtI bMGtIcMGdMGuIe"MG8uIf NGhuIg NGhNGuI i,NGuIjENGXvI k"SNGvI l_NG mmNGvI n"{NGoNG0wIpNGpwIqNGwI r NGwIs"NGxItNGuNGvNG0xIw OGhxIx"'OGxIyDOGMOGz"kOG{}OGxI|"OGyI}"OGPyI~ OGxyI"OGOGOG "PG &PGyI>PGyINPGzI" aPGrPGHzIPGPGzI "PGzI"PGPG PGPGzI PG  QGH{I$p{I{I"(QG{I,1QG|I07QG@|I4OQG_QGx|I88}IX}I<oQG {QGQG QG-9G}IQG}I@QG `QG@HQG @n9G oDF~9G 9G\G=?@\GI @\GIA\G`IB\G]G C$]G(I`.]GI@>]GIF$X]GIGo]GI @z]GII]G IJ]GIK ]G`IL]G]GM ]G N ]GIO ^G0IP^GpIQ$*^GI`3^GIR @^GIR @U^G`IT n^GI V$|^GI W^GpI X ^G IY^GXIZ$^GI `^G؞I @^GI ^GHI @_GI^ _GȟI `)_GIa<_GP_Gb n_G@I c }_GxId _GIe$_GؠIf$_G0I g$_GIh$_GIi$_G(I j_GHI _GxIl _GI m _GI n `GIo@(`GXIp@?`GI @@J`GI @@Y`GI @@g`G8I @@t`GI@@`GФI v `GIw$ `G(Ix$`G`Iy`GPICz`GI{aG |( aG!}haGI~$*aG`I 6aGPI?aGSG`I NaGVaG paGxI$ aGI$$aGI(aG8I,aGpI aGЧI0aGI4aG(I8 bG!bG <;bGXI @TbGI @fbGШI @vbGI bG@I @bGI @bGI$DbGI$HbG`I$LIЪI$PbG`bGI`bGXI$T cGI@cGI X0I`I(`ȬII,`3cGXI IcGI bcGI @|cGI$\cGI $`cG0xI cG8I $dcGhI$hcGI$lcGI$pcGI$tcG0xI cG(I`x dGhI$|#dGI 7dGI ` EdG0I \dGhI tdGI `dGI$dGIdG@I $dGIdGI dGI dG`I dG0I eGI eGвI $,eG0xI  ;eGI$NeG I$ceGpI seGeG$eGPI$eGxI eGI`eGI eG@I fGI fGI -fGI  :fG I`AfGhIJfGI@`fGHhfGI $ufG I @fGpI `fGI @fGI @fGHI @fGI  fGI gGI$gG(I$)gGhI  ?gGI`QgG I bgG`I $qgGI gGI$gGIgGHI gGI $gGкI  gG`I@gG`IgGI  hGXI(hGI$,0hG0ChG`IUhGI 4chGI@8whG`I<hGI@hGIDhG IHhGhILhGIPhGIThG8I$XiGhI8\iGI(iGȾI $`3iGI `?iG8I$dXiGhI$hII%lqiGI$piGpIiG@iG(I  iG`I $tiGI diGiG xjGI |jG jGI0jG=jG $RjGHI $]jGxI $ijGI vjGI `|jGI djGhIjGI `jGjG`jGI  jGI  jG(I $kGPI $kGI 8.kGIAkG@I KkGhI  ZkGI okGI `~kG I kGI`kGI kG I  kGpI `kGI kGI kG  lG0I `lGpI  lGI 1lGI BlGI RlGI clG@I tlGhI lGI $ lGI% lGI& lG8I lGpI lGI ) lGI*lG(I+ mGXI,$|mGI-$d#mGI.$6mGI/$I(I0$GmGhI1$[mGI2 kmGI3mG8I4mG`I5@mGI6$mGpI7 II"8$mGmG 9@mGpI:$mGI;nGI< nGI= *nGHIhI?$ :nGI@$VnGIA$nnGIB$nG0IC$nGhID$ nGIE$$nGI F$(nGIG$,nG8IH$0oG`II$4oGIJ$82oGIK$<LoGI`goGxI`~oGI`@oG IO$DoGpIP oGXIQ$HoGIR$LoGIS oGIT$PpGpIU pGPIV$TII!W$XI0IX$\"pG`IY$`9pGIZ$dQpGI [h`pGI \8lnpG8I ]p|pGxI ^ tpGI _$xpG(I ` pGPIa$|pGIbpGpG cpGI d$qG Ie$qGf@2qG`Ig@FI @ >F(I 8;GpI:GX=FI `( >FI8T{G8ID;G8>FxID;G8?FID;G8\{GI i{GHI |{G{G ;F{G@{G{G{G{G{GI{GI{G|G|G#|G3|GI ?|GS|Gm|G@IP0 ZFpIt|GI|G|GP4 FI F0I@|GhI |GIP |GI P |GI P |GI }GHI%8 }G}GP@ 6}G=}GPH FpI(FI)Y}GHI*@pII+w}G}GBL FI-FI.}G(I PP }G`I0}G}GPT }GIP}GI3FI4}GHIX FI6 }GI~GI8\ |FHI9@FI:~GI ;` ~G0J<+~G`JPd FJ >5~GJPh H~GJ@GkzG[ @FPJAU~G]~GL o~G#|G MFxJD|~GJE~GJPl ~GJGp ~G0JPt ~GpJIJJJ ~GJ9G9G' K~GJPx GG@5GFG@kFJO8FJP]GPJQ FpJR@cGJ SrG GG G GJGJYG8J$ GhJ( GJ, ,FJ]4FJ^CF8J_GhJ`GJP| FGb;GJ coF8JdFGGe bGpJfjGJP sGJ ~GJ P GGj ^F0Jk@FhJlGG mЀGJnրGJo݀G8 Jp G` JqG J!F Js F JtG` JuGG(vG J @(G Jx 0GBGyWGfG z G8 JP Fh J|@G J P G J~GGP ށGG,L G G P #G J6G( J CGIGF JF JFdG GF J:Gx ނGG =G =G2 =G J G=GJ=G G#>GH 6>GO>G g>G y>G >G G8J>GH >G >G  G >G=G;FhJ @ FGIGSGJZG]G?G gG H?GtGG &?G.?GH7?GGG G ɃGJ ݃G GG GJ GXJ #GJ .GJ 9GJ DG(JMGxJVGJ_GJhGJqGJzGJ G8J GhJ GJ GJ GJ G`J ɄGJ քGJ GJ GXJ GJ GJ GJ GJ 'GPJ 2GJDGxJXGJjGJ|G(JGJ @?GGx?G GHGG?G ?GJ?G8J ąGDžG`J8 ΅GхG8( >FJ @ GG  E@F GG BFG GBFBFBFsCFXCFGGG  J Gr@r@JGr@r@8JGr@r@@Gr@r@Gr@r@pJGr@r@JGr@r@!GGr@r@JGr@r@?G`Gr@r@YG Gr@r@(JGr@r@xJGr@r@pG`Gr@r@JGr@r@JGr@r@J@Gs@s@GGs@ s@--help= Display descriptions of a specific class of options. is one or more of optimizers, target, warnings, undocumented, params--param = Set parameter to value. See below for a complete list of parameters--print-missing-file-dependencies--print-sysroot-headers-suffix-A= Assert the to . Putting '-' before disables the to Do not discard comments in macro expansions-D[=] Define a with as its value. If just is given, is taken to be 1-F Add to the end of the main framework include pathPrint the name of header files as they are used-I Add to the end of the main include path-J Put MODULE files in 'directory'Generate make dependencies and compile-MF Write dependency output to the given fileTreat missing header files as generated filesLike -M but ignore system header filesLike -MD but ignore system header filesGenerate phony targets for all headers-MQ Add a MAKE-quoted targetmissing makefile target after %qs-MT Add an unquoted target-O Set optimization level to Optimize for speed disregarding exact standards complianceOptimize for debugging experience rather than speed or sizeOptimize for space rather than speedDo not generate #line directivesThis switch is deprecated; use -Wextra insteadWarn about things that will change when compiling with an ABI-compliant compilerWarn if a subobject has an abi_tag attribute that the complete object type does not haveWarn about suspicious uses of memory addressesWarn about returning structures, unions or arrays-Waggressive-loop-optimizationsWarn if a loop with constant number of iterations triggers undefined behaviorWarn about possible aliasing of dummy argumentsWarn about alignment of COMMON blocksWarn about missing ampersand in continued character constantsWarn if an array is accessed out of boundsWarn about creation of array temporariesWarn whenever an Objective-C assignment is being intercepted by the garbage collectorWarn about inappropriate attribute usageWarn about casting functions to incompatible typesWarn when a built-in preprocessor macro is undefined or redefinedWarn about C constructs that are not in the common subset of C and C++Deprecated in favor of -Wc++11-compatWarn about C++ constructs whose meaning differs between ISO C++ 1998 and ISO C++ 2011Warn if the type of a variable might be not interoperable with CWarn about pointer casts which increase alignmentWarn about casts which discard qualifiersWarn about subscripts whose type is "char"Warn about truncated character expressionsWarn about variables that might be changed by "longjmp" or "vfork"Warn about possibly nested block comments, and C++ comments spanning more than one physical lineWarn about equality comparisons involving REAL or COMPLEX expressionsWarn for implicit type conversions that may change a valueWarn about most implicit conversionsWarn for converting NULL from/to a non-pointer typeWarn in case profiles in -fprofile-use do not matchWarn when a #warning directive is encounteredWarn when all constructors and destructors are privateWarn when a declaration is found after a statementWarn about deleting polymorphic objects with non-virtual destructorsWarn if a deprecated compiler feature, class, method, or field is usedWarn about uses of __attribute__((deprecated)) declarationsWarn when an optimization pass is disabledWarn about compile-time integer division by zeroWarn about implicit conversions from "float" to "double"Warn about violations of Effective C++ style rulesWarn about an empty body in an if or else statementWarn about stray tokens after #elif and #endifWarn about comparison of different enum types-Werror-implicit-function-declarationThis switch is deprecated; use -Werror=implicit-function-declaration insteadTreat specified warning as errorPrint extra (possibly unwanted) warningsWarn if deprecated empty statements are foundExit on the first error occurredWarn if testing floating point numbers for equalityWarn about printf/scanf/strftime/strfmon format string anomaliesWarn about format strings that contain NUL bytesWarn if passing too many arguments to a function for its format stringWarn about format strings that are not literalsWarn about possible security problems with format functionsWarn about strftime formats yielding 2-digit yearsWarn about zero-length formats-Wframe-larger-than= Warn if a function's stack frame requires more than bytesWarn when attempting to free a non-heap objectWarn about function call eliminationWarn whenever type qualifiers are ignored.Warn about implicit declarations-Wimplicit-function-declarationWarn about implicit function declarationsWarn when a declaration does not specify a typeWarn about calls with implicit interfaceWarn about called procedures not explicitly declaredWarn about C++11 inheriting constructors when the base has a variadic constructorWarn about variables which are initialized to themselvesWarn when an inlined function cannot be inlinedWarn when there is a cast to a pointer from an integer of a different sizeWarn if a user-procedure has the same name as an intrinsicWarn on intrinsics not part of the selected standardWarn when an atomic memory model parameter is known to be outside the valid range.Warn about invalid uses of the "offsetof" macroWarn about PCH files that are found but not usedWarn when a jump misses a variable initialization-Wlarger-than= Warn if an object is larger than bytesWarn about truncated source linesWarn when a string or character literal is followed by a ud-suffix which does not begin with an underscore.Warn when a logical operator is suspiciously always evaluating to true or falseDo not warn about using "long long" when -pedanticWarn about suspicious declarations of "main"Warn about maybe uninitialized automatic variablesWarn about possibly missing braces around initializersWarn about global functions without previous declarationsWarn about missing fields in struct initializersWarn about user-specified include directories that do not existWarn about function parameters declared without a type specifier in K&R-style functionsWarn about global functions without prototypesWarn about constructs not instrumented by -fmudflapWarn about use of multi-character character constantsWarn about narrowing conversions within { } that are ill-formed in C++11Warn about "extern" declarations not at file scopeWarn when a noexcept expression evaluates to false even though the expression can't actually throwWarn when non-templatized friend functions are declared within a templateWarn about non-virtual destructorsWarn about NULL being passed to argument slots marked as requiring non-NULL-Wnormalized= Warn about non-normalised Unicode stringsWarn if a C-style cast is used in a programWarn for obsolescent usage in a declarationWarn if an old-style parameter definition is usedWarn if .class files are out of dateWarn about overflow in arithmetic expressionsWarn if a string is longer than the maximum portable length specified by the standardWarn about overloaded virtual function namesWarn about overriding initializers without side effectsWarn when the packed attribute has no effect on struct layoutWarn about packed bit-fields whose offset changed in GCC 4.4Warn when padding is required to align structure membersWarn about possibly missing parenthesesIssue warnings needed for strict compliance to the standardWarn when converting the type of pointers to member functionsWarn about function pointer arithmeticWarn when a pointer differs in signedness in an assignmentWarn when a pointer is cast to an integer of a different sizeWarn if a property for an Objective-C object has no assign semantics specifiedWarn if inherited methods are unimplementedWarn about real-literal-constants with 'q' exponent-letterWarn when a left-hand-side array variable is reallocatedWarn when a left-hand-side variable is reallocatedWarn about multiple declarations of the same objectWarn if modifiers are specified when not necessaryWarn when the compiler reorders codeWarn about returning a pointer/reference to a local or temporary variable.Warn whenever a function's return type defaults to "int" (C), or about inconsistent return types (C++)Warn if a selector has multiple methodsWarn about possible violations of sequence point rulesWarn when one local variable shadows anotherWarn about signed-unsigned comparisonsWarn for implicit type conversions between signed and unsigned integersWarn when overload promotes from unsigned to signedWarn when not issuing stack smashing protection for some reasonWarn if stack usage might be larger than specified amountWarn about code which might break strict aliasing rulesWarn about uncasted NULL used as sentinelWarn about optimizations that assume that signed overflow is undefinedWarn about unprototyped function declarationsWarn if type signatures of candidate methods do not match exactlyWarn about functions which might be candidates for __attribute__((const))Warn about functions which might be candidates for format attributesWarn about functions which might be candidates for __attribute__((noreturn))Warn about functions which might be candidates for __attribute__((pure))Warn about "suspicious" constructsWarn about enumerated switches, with no default, missing a caseWarn about enumerated switches missing a "default:" statementWarn about all enumerated switches missing a specific caseWarn when __sync_fetch_and_nand and __sync_nand_and_fetch built-in functions are usedDeprecated. This switch has no effectDo not suppress warnings from system headersPermit nonconforming uses of the tab characterWarn if the pointer in a pointer assignment might outlive its targetWarn about features not present in traditional CWarn of prototypes causing type conversions different from what would happen in the absence of prototypeWarn whenever a trampoline is generatedWarn if trigraphs are encountered that might affect the meaning of the programWarn if a comparison is always true or always false due to the limited range of the data typeWarn about @selector()s without previously declared methodsWarn if an undefined macro is used in an #if directiveWarn about underflow of numerical constant expressionsWarn about uninitialized automatic variablesWarn about unrecognized pragmasDoes nothing. Preserved for backward compatibility.Warn if the loop cannot be optimized due to nontrivial assumptions.Warn about unsuffixed float constantsWarn when a function parameter is only set, otherwise unusedWarn when a variable is only set, otherwise unusedWarn about unused dummy arguments.Warn when a function is unusedWarn when typedefs locally defined in a function are not usedWarn about macros defined in the main file that are not usedWarn when a function parameter is unusedWarn if a caller of a function, marked with attribute warn_unused_result, does not use its return valueWarn when an expression value is unusedWarn when a variable is unusedWarn about questionable usage of the macros used to retrieve variable argumentsWarn about using variadic macros-Wvector-operation-performanceWarn when a vector operation is compiled outside the SIMDWarn if a virtual base has a non-trivial move assignment operatorWarn if a variable length array is usedWarn when a register variable is declared volatileIn C++, nonzero means warn about deprecated conversion from string literals to 'char *'. In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard.-Wzero-as-null-pointer-constantWarn when a literal '0' is used as null pointerA synonym for -std=c89 (for C) or -std=c++98 (for C++)-aux-info Emit declaration information into -d Enable dumps from specific passes of the compiler-dumpbase Set the file basename to be used for dumps-dumpdir Set the directory name to be used for dumps--CLASSPATH Deprecated; use --classpath insteadGenerate position-independent code if possible (large mode)Generate position-independent code for executables if possible (large mode)Enforce class member access control semantics-fada-spec-parent=unit Dump Ada specs as child units of given parent-faggressive-function-eliminationEliminate multiple function invokations also for impure functions-faggressive-loop-optimizationsAggressively optimize loops using language constraintsEnable alignment of COMMON blocksAlign labels which are only reached by jumpingAll intrinsics procedures are available regardless of selected standardswitch %qs is no longer supported-fallow-parameterless-variadic-functionsAllow variadic functions without named parameterPermit the use of the assert keywordAllow optimization for floating-point arithmetic which may change the result of the operation due to rounding.Generate unwind tables that are exact at each instruction boundaryGenerate auto-inc/dec instructionsDo not treat local variables and COMMON blocks as if they were named in SAVE statementsSpecify that backslash in string introduces an escape characterProduce a backtrace when a runtime error is encountered-fblas-matmul-limit= Size of the smallest matrix for which matmul will use BLAS--bootclasspath= Replace system pathGenerated should be loaded by bootstrap loaderGenerate code to check bounds before indexing arraysReplace add, compare, branch with branch on count registerUse profiling information for branch probabilitiesPerform branch target load optimization before prologue / epilogue threading-fbranch-target-load-optimize2Perform branch target load optimization after prologue / epilogue threadingRestrict target load migration not to re-use registers in any basic block-fcall-saved- Mark as being preserved across functions-fcall-used- Mark as being corrupted by function callsSave registers around function callsWhere shorter, use canonicalized paths to systems headers.Produce a warning at runtime if a array temporary has been created for a procedure argumentCompare the results of several data dependence analyzers.Generate checks for references to NULL-fcheck=[...] Specify which runtime checks are to be performed--classpath= Set class path-fcoarray=[...] Specify which coarray parallelization should be usedLooks for opportunities to reduce stack adjustments and stack references.Do not put uninitialized globals in the common sectionRun only the second compilation of -fcompare-debug-fcompare-debug[=] Compile with and without e.g. -gtoggle, and compare the final-insns dumpPerform comparison elimination after register allocation has finishedAllow the arguments of the '?' operator to have different typesDoes nothing. Preserved for backward compatibility.Do not perform optimizations increasing noticeably stack usage-fconst-string-class= Use class for constant stringsno class name specified with %qs-fconstexpr-depth= Specify maximum constexpr recursion depthUse big-endian format for unformatted filesUse little-endian format for unformatted filesUse native format for unformatted filesSwap endianness for unformatted filesPerform a register copy-propagation optimization passUse the Cray Pointer extensionPerform cross-jumping optimizationWhen running CSE, follow jumps to their targetsComplex multiplication and division follow Fortran rulesOmit range reduction step when performing complex divisionIgnore 'D' in column one in fixed formTreat lines with 'D' in column one as commentsPlace data items into their own sectionList all available debugging counters with their limits and counts.-fdbg-cnt=:[,:,...] Set the debug counter limit. Use the RTL dead code elimination passEmit debug annotations during preprocessingMap one directory name to another in debug informationOutput .debug_types section when using DWARF v4 debuginfo.-fdeduce-init-list enable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-listSet the default double precision kind to an 8 byte wide typeSet the default integer kind to an 8 byte wide typeSet the default real kind to an 8 byte wide typeDefer popping functions args from stack until laterAttempt to fill delay slots of branch instructionsDelete dead instructions that may throw exceptionsDelete useless null pointer checksTry to convert virtual calls to direct ones.-fdiagnostics-color=[never|always|auto] Colorize diagnosticsShow the source line with a caret indicating the column-fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnosticsAmend appropriate diagnostic messages with the command line option that controls them-fdisable-[tree|rtl|ipa]-=range1+range2 disables an optimization passAllow dollar signs in entity namesPermit '$' as an identifier characterUse the RTL dead store elimination pass-fdump- Dump various compiler internals to a fileWrite all declarations as Ada code transitivelyWrite all declarations as Ada code for the given file only-fdump-final-insns=filename Dump to filename the insns at the end of translationDisplay the code tree after front end optimizationDisplay the code tree after parsing-fdump-go-spec=filename Write all declarations to file as Go codeSuppress output of addresses in debugging dumpsDisplay the code tree after parsing; deprecated optionSuppress output of instruction numbers, line number notes and addresses in debugging dumpsSuppress output of previous and next insn numbers in debugging dumpsEnable CFI tables via GAS assembler directives.Perform DWARF2 duplicate elimination-feliminate-unused-debug-symbolsPerform unused type elimination in debug info-feliminate-unused-debug-typesDo not suppress C++ class debug information.-femit-struct-debug-baseonly Aggressive reduced debug info for structs-femit-struct-debug-detailed= Detailed reduced debug info for structs-femit-struct-debug-reduced Conservative reduced debug info for structs-fenable-[tree|rtl|ipa]-=range1+range2 enables an optimization pass--encoding= Choose input encoding (defaults from your locale)Generate code to check exception specifications-fexcess-precision=[fast|standard] Specify handling of excess floating-point precision-fexec-charset= Convert all strings and character constants to character set Perform a number of minor, expensive optimizationsInterpret imaginary, fixed-point, or other gnu number suffix as the corresponding number literal rather than a user-defined number literal.--extdirs= Set the extension directory pathPermit universal character names (\u and \U) in identifiersSupport dynamic initialization of thread-local variables in a different translation unitSpecify that an external BLAS library should be used for matmul calls on large-size arraysOutput lto objects containing both the intermediate language and binary output.Input file is a file with a list of filenames to compileAssume no NaNs or infinities are generated-ffixed- Mark as being unavailable to the compilerAssume that the source file is fixed form-ffixed-line-length- Use n as character line width in fixed modeAllow arbitrary character line width in fixed modeDon't allocate floats and doubles in extended-precision registersScope of for-init-statement variables is local to the loopAlways check for non gcj generated classes archivesPerform a forward propagation pass on RTL-ffp-contract=[off|on|fast] Perform floating-point expression contraction.-ffpe-trap=[...] Stop on following floating point exceptionsAssume that the source file is free form-ffree-line-length- Use n as character line width in free modeAllow arbitrary character line width in free modeDo not assume that standard C libraries and "main" existInject friend functions into enclosing namespaceAllow function addresses to be held in registersPlace each function into its own sectionPerform global common subexpression eliminationPerform global common subexpression elimination after register allocation has finishedPerform redundant load after store elimination in global common subexpression eliminationPerform enhanced load motion during global common subexpression eliminationPerform store motion after global common subexpression eliminationRecognize GNU-defined keywordsGenerate code for GNU runtime environmentEnable support for GNU transactional memoryUse STB_GNU_UNIQUE if supported by the assemblerUse traditional GNU semantics for inline functionsAdd explicit checks for division overflow in INT_MIN / -1Add explicit checks for division by zero-fgo-dump- Dump Go frontend internal information-fgo-optimize- Turn on optimization passes in the frontend-fgo-pkgpath= Set Go package path-fgo-prefix= Set package-specific prefix for exported Go names-fgo-relative-import-path= Treat a relative import as relative to pathEnable in and out of Graphite representationEnable Graphite Identity transformationEnable guessing of branch probabilities-fhandle-exceptions has been renamed -fexceptions (and is now on by default)Assume the runtime uses a hash table to map an object to its synchronization structureEnable hoisting adjacent loads to encourage generating conditional move instructionsAssume normal C execution environmentPerform conversion of conditional jumps to branchless equivalentsPerform conversion of conditional jumps to conditional executionExport functions even if they can be inlinedEmit implicit instantiations of inline templatesSpecify that no implicit typing is allowed, unless overridden by explicit IMPLICIT statementsEmit implicit instantiations of templatesGenerate instances of Class at runtimeUse offset tables for virtual method callsDo not generate .size directives-finit-character= Initialize local character variables to ASCII value n-finit-integer= Initialize local integer variables to nInitialize local variables to zero (from g77)-finit-logical= Initialize local logical variables-finit-real= Initialize local real variablesEnable inlining of function declared "inline", disabling disables all inliningInline __atomic operations when a lock free instruction sequence is available.Integrate functions not declared "inline" into their callers when profitable-finline-functions-called-onceIntegrate functions only required by their single caller-finline-limit= Limit the size of inlined functions to Integrate functions into their callers when code size is known not to grow-finput-charset= Specify the default character set for source filesInstrument function entry and exit with profiling calls-finstrument-functions-exclude-file-list=-finstrument-functions-exclude-file-list=filename,... Do not instrument functions listed in files-finstrument-functions-exclude-function-list=-finstrument-functions-exclude-function-list=name,... Do not instrument listed functionsInterpret any INTEGER(4) as an INTEGER(8)Specify where to find the compiled intrinsic modulesPerform Interprocedural constant propagationPerform cloning to make Interprocedural constant propagation strongerPerform interprocedural profile propagationPerform interprocedural points-to analysisDiscover pure and const functionsDiscover readonly and non addressable static variablesPerform interprocedural reduction of aggregates-fira-algorithm=[CB|priority] Set the used IRA algorithmUse IRA based register pressure calculation in RTL hoist optimizations.Use IRA based register pressure calculation in RTL loop optimizations.-fira-region=[one|all|mixed] Set regions for IRAShare slots for saving different hard registers.Share stack slots for spilled pseudo-registers.-fira-verbose= Control IRA's level of diagnostic messages.Optimize induction variables on treesAssume native functions are implemented using JNIUse jump tables for sufficiently large switch statementsDon't emit dllexported inline functions unless neededGenerate code for functions even if they are fully inlinedEmit static const variables even if they are not usedAllow implicit conversions between vectors with differing numbers of subparts and/or differing element types.Give external symbols a leading underscoreEnable Loop Blocking transformationEnable Loop Interchange transformationEnable the ISL based loop nest optimizerEnable Loop Strip Mining transformationEnable link-time optimization.-flto-compression-level= Use zlib compression level for ILPartition symbols and vars at linktime based on object files they originate fromPartition functions and vars at linktime into approximately same sized bucketsPut every symbol into separate partitionDisable partioning and streamingReport various link-time optimization statisticsLink-time optimization with number of parallel jobs or jobserver.Run the link-time optimizer in local transformation (LTRANS) mode.Specify a file to which a list of files output by LTRANS is written.Set errno after built-in math functions-fmax-array-constructor= Maximum number of objects in an array constructor-fmax-errors= Maximum number of errors to report-fmax-identifier-length= Maximum identifier length-fmax-stack-var-size= Size in bytes of the largest array that will be put on the stack-fmax-subrecord-length= Maximum length for subrecordsReport on permanent memory allocationReport on permanent memory allocation in WPA onlyAttempt to merge identical constants and constant variablesAttempt to merge identical constants across compilation unitsAttempt to merge identical debug strings across compilation units-fmessage-length= Limit diagnostics to characters per line. 0 suppresses line-wrappingSet default accessibility of module entities to PRIVATE.Perform SMS based modulo scheduling before the first scheduling passPerform SMS based modulo scheduling with register moves allowedMove loop invariant computations out of loopsDon't warn about uses of Microsoft extensionsAdd mudflap bounds-checking instrumentation for single-threaded programIgnore read operations when inserting mudflap instrumentationAdd mudflap bounds-checking instrumentation for multi-threaded programGenerate code for NeXT (Apple Mac OS X) runtime environmentAssume that receivers of Objective-C messages may be nilSupport synchronous non-call exceptionsTreat a throw() exception specification as noexcept to improve code sizeSpecify which ABI to use for Objective-C family code and meta-data generation.Generate special Objective-C methods to initialize/destroy non-POD C++ ivars, if neededAllow fast jumps to the message dispatcherEnable Objective-C exception and synchronization syntaxEnable garbage collection (GC) in Objective-C/Objective-C++ programsEnable inline checks for nil receivers with the NeXT runtime and ABI version 2.Enable Objective-C setjmp exception handling runtimeConform to the Objective-C 1.0 language as implemented in GCC 4.0When possible do not generate stack framesEnable OpenMP (implies -frecursive in Fortran)Recognize C++ keywords like "compl" and "xor"Enable all optimization info dumps on stderr-fopt-info[-=filename] Dump compiler optimization detailsDo the full register move optimization passOptimize sibling and tail recursive calls-foptimize-static-class-initializationEnable optimization of static class initialization codeEnable string length optimizations on treesTry to lay out derived types as compactly as possiblePack structure members together without holes-fpack-struct= Set initial maximum structure member alignmentReturn small aggregates in memory, not registersLook for and use PCH files even when preprocessingEnable machine specific peephole optimizationsEnable an RTL peephole pass before sched2Downgrade conformance errors to warningsGenerate position-independent code if possible (small mode)Generate position-independent code for executables if possible (small mode)Enable Plan 9 language extensions-fplugin-arg--[=] Specify argument = for plugin Report on memory allocation before interprocedural optimizationRun predictive commoning optimization.Generate prefetch instructions, if available, for arrays in loopsTreat the input file as already preprocessed-fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the argumentsEnable basic program profiling codeInsert arc-based program profiling codeEnable correction of flow inconsistent profile data inputSet the top-level directory for storing the profile data. The default is 'pwd'.Enable common options for generating profile info for profile feedback directed optimizationsEnable common options for generating profile info for profile feedback directed optimizations, and set -fprofile-dir=Report on consistency of profileEnable common options for performing profile feedback directed optimizationsEnable common options for performing profile feedback directed optimizations, and set -fprofile-dir=Insert code to profile values of expressionsProtect parentheses in expressions-frandom-seed= Make compile reproducible using Enable range checking during compilationInterpret any REAL(4) as a REAL(10)Interpret any REAL(4) as a REAL(16)Interpret any REAL(4) as a REAL(8)Interpret any REAL(8) as a REAL(10)Interpret any REAL(8) as a REAL(16)Interpret any REAL(8) as a REAL(4)Reallocate the LHS in assignmentsSame as -fassociative-math for expressions which include division.Record gcc command line switches in the object file.Use a 4-byte record marker for unformatted filesUse an 8-byte record marker for unformatted filesAllocate local variables on the stack to allow indirect recursionReduce the amount of reflection meta-data generatedTurn on Redundant Extensions Elimination pass.Return small aggregates in registersEnables a register move optimizationPerform a register renaming optimization passReorder basic blocks to improve code placement-freorder-blocks-and-partitionReorder basic blocks and partition into hot and cold sectionsReorder functions to improve code placementCopy array sections into a contiguous block on procedure entryUsed in Fix-and-Continue mode to indicate that object files may be swapped in at runtimeEnable automatic template instantiationFunctions which return values must end with return statementsAdd a common subexpression elimination pass after loop optimizations-freschedule-modulo-scheduled-loopsEnable/Disable the traditional scheduling in loops that already passed modulo schedulingDisable optimizations that assume default FP rounding behaviorGenerate run time type descriptor informationEnable AddressSanitizer, a memory error detectorEnable ThreadSanitizer, a data race detector-fsched-critical-path-heuristicEnable the critical path heuristic in the schedulerEnable the dependent count heuristic in the schedulerEnable the group heuristic in the schedulerEnable scheduling across basic blocksEnable the last instruction heuristic in the schedulerEnable register pressure sensitive insn schedulingEnable the rank heuristic in the schedulerAllow speculative motion of non-loadsEnable the speculative instruction heuristic in the schedulerAllow speculative motion of some loadsAllow speculative motion of more loadsAllow premature scheduling of queued insnsSet dependence distance checking in premature scheduling of queued insns-fsched-stalled-insns-dep= Set dependence distance checking in premature scheduling of queued insns-fsched-stalled-insns= Set number of queued insns that can be prematurely scheduled-fsched-verbose= Set the verbosity level of the schedulerIf scheduling post reload, do superblock schedulingReschedule instructions before register allocationReschedule instructions after register allocationAppend a second underscore if the name already contains an underscoreAccess data in the same section from shared anchor pointsPerform software pipelining of inner loops during selective scheduling-fsel-sched-pipelining-outer-loopsPerform software pipelining of outer loops during selective scheduling-fsel-sched-reschedule-pipelinedReschedule pipelined regions without pipeliningSchedule instructions using selective scheduling algorithmRun selective scheduling after reloadUse the same size for double as for floatUse the narrowest integer type possible for enumeration typesForce the underlying type for "wchar_t" to be "unsigned short"Show column numbers in diagnostics, when available. Default onEmit function prologues only before parts of the function that need it, rather than at the top of the function.Apply negative sign to zero valuesDisable optimizations observable by IEEE signaling NaNsWhen "signed" or "unsigned" is not given make the bitfield signedDisable floating point optimizations that ignore the IEEE signedness of zeroConvert floating point constants to single precision constantsSet the source language versionSplit lifetimes of induction variables when loops are unrolledGenerate discontiguous stack framesSplit wide types into independent registersPut all local arrays on stack.Insert stack checking code into the program. Same as -fstack-check=specific-fstack-check=[no|generic|specific] Insert stack checking code into the program.Insert code to probe each page of stack space as it is allocated to protect from stack-clash style attacks.-fstack-limit-register= Trap if the stack goes past -fstack-limit-symbol= Trap if the stack goes past symbol Use propolice as a stack protection methodUse a stack protection method for every functionUse a smart stack protection method for certain functions-fstack-reuse=[all|named_vars|none] Set stack reuse level for local variables.Output stack usage information on a per-function basisDisplay statistics accumulated during compilationEnable assignability checks for stores into object arraysAssume strict aliasing rules applyAssume that values of enumeration type are always within the minimum range of that typeTreat signed overflow as undefinedForce bitfield accesses to match their type widthImplement __atomic operations via libcalls to legacy __sync functionsCheck for syntax errors, then stop-ftabstop= Distance between tab stops for column reportingSet the maximum number of template instantiation notes for a single warning or error-ftemplate-depth= Specify maximum template instantiation depthCreate data files needed by "gcov"Perform jump threading optimizations-fno-threadsafe-statics Do not generate thread-safe code for initializing local staticsReport the time taken by each compiler pass-ftls-model=[global-dynamic|local-dynamic|initial-exec|local-exec] Set the default thread-local storage code generation modelReorder top level functions, variables, and asmsPerform superblock formation via tail duplication-ftrack-macro-expansion=<0|1|2> Track locations of tokens coming from macro expansion and display them in error messagesAssume floating-point operations can trapTrap for signed overflow in addition, subtraction and multiplicationEnable SSA-BIT-CCP optimization on treesEnable conditional dead code elimination for builtin callsEnable SSA-CCP optimization on treesEnable loop header copying on treesEnable coalescing of copy-related user variables that are inlinedEnable coalescing of all copy-related user variablesEnable copy propagation on treesReplace SSA temporaries with better names in copiesTransform condition stores into unconditional onesEnable SSA dead code elimination optimization on treesEnable dominator optimizationsEnable forward propagation on treesEnable Full Redundancy Elimination (FRE) on trees-ftree-loop-distribute-patternsEnable loop distribution for patterns transformed into a library callEnable loop distribution on treesConvert conditional jumps in innermost loops to branchless equivalentsAlso if-convert conditional jumps containing memory writesEnable loop invariant motion on treesCreate canonical induction variables in loopsEnable loop interchange transforms. Same as -floop-interchangeEnable loop optimizations on tree levelPerform live range splitting during the SSA->normal passEnable automatic parallelization of loopsIn SSA-PRE optimization on trees, enable partial-partial redundancy eliminationEnable hoisting loads from conditional pointers.Enable SSA-PRE optimization on treesPerform function-local points-to analysis on trees.Enable reassociation on tree levelEnable copy propagation of scalar-evolution information.Enable SSA code sinking on treesEnable basic block vectorization (SLP) on treesPerform straight-line strength reductionPerform scalar replacement of aggregatesPerform conversions of switch initializations.Replace temporary expressions in the SSA->normal passEnable loop versioning when doing loop vectorization on treesEnable loop vectorization on trees-ftree-vectorizer-verbose= This switch is deprecated. Use -fopt-info instead.Perform Value Range Propagation on treesAppend underscores to externally visible namesCompile whole compilation unit at a timePerform loop unrolling for all loopsPerform loop unrolling when iteration count is knownAllow loop optimizations to assume that the loops behave in normal wayAllow math optimizations that may violate IEEE or ISO standardsWhen "signed" or "unsigned" is not given make the bitfield unsignedMake "char" unsigned by defaultJust generate unwind tables for exception handlingGenerate code for built-in atomic operationsGenerate code for the Boehm GCUse __cxa_atexit to register destructorsUse __cxa_get_exception_ptr in exception handlingCall a library routine to do integer divisionsUse the bfd linker instead of the default linkerUse the gold linker instead of the default linkerPerform variable tracking by annotating assignments-fvar-tracking-assignments-toggleToggle -fvar-tracking-assignmentsPerform variable tracking and also tag variables that are uninitialized-fvariable-expansion-in-unrollerApply variable expansion when loops are unrolledEnable use of cost model in vectorizationAdd extra commentary to assembler outputMarks all inlined functions and methods as having hidden visibilityChanges visibility to match Microsoft Visual Studio by default-fvisibility=[default|internal|hidden|protected] Set the default symbol visibilityUse expression value profiles in optimizationsEmit common-like symbols as weak symbolsConstruct webs and split unrelated uses of single variableCompile all program units at once and check all interfacesPerform whole program optimizations-fwide-exec-charset= Convert all wide strings and character constants to character set Generate a #line directive pointing at the current working directoryRun the link-time optimizer in whole program analysis (WPA) mode.Assume signed arithmetic overflow wraps aroundPut zero initialized data in the bss sectionGenerate lazy class lookup (via objc_getClass()) for use in Zero-Link modeGenerate debug information in default formatGenerate debug information in COFF formatGenerate debug information in DWARF v2 (or later) formatDump declarations to a .decl fileGenerate debug information in default extended format-gnat Specify options to GNATSet name of output ALI file (internal switch)Don't generate DWARF pubnames and pubtypes sections.Don't record gcc command line switches in DWARF DW_AT_producer.Don't generate debug information in separate .dwo filesEmit DWARF additions beyond selected versionGenerate DWARF pubnames and pubtypes sections.Record gcc command line switches in DWARF DW_AT_producer.Generate debug information in separate .dwo filesGenerate debug information in STABS formatGenerate debug information in extended STABS formatDon't emit DWARF additions beyond selected versionToggle debug information generationGenerate debug information in VMS formatGenerate debug information in XCOFF formatGenerate debug information in extended XCOFF format-idirafter Add to the end of the system include path-imacros Accept definition of macros in -imultiarch Set to be the multiarch include subdirectory-imultilib Set to be the multilib include subdirectory-include Include the contents of before other files-iplugindir= Set to be the default plugin directory-iprefix Specify as a prefix for next two options-iquote Add to the end of the quote include path-isysroot Set to be the system root directory-isystem Add to the start of the system include path-iwithprefix Add to the end of the system include path-iwithprefixbefore Add to the end of the main include pathSupport 3DNow! built-in functionsSupport Athlon 3Dnow! built-in functionsExpand 32bit/64bit integer divide into 8bit unsigned integer divide with run-time checkGenerate code that conforms to the given ABISupport code generation of Advanced Bit Manipulation (ABM) instructions.Reserve space for outgoing arguments in the function prologueSupport flag-preserving add-carry instructionsSupport AES built-in functions and code generationAlign some doubles on dword boundaryFunction starts are aligned to this power of 2Jump targets are aligned to this power of 2Loop code aligned to this power of 2Align destination of the string operationsGenerate code for the Android platform.Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2 and AVX built-in functions and code generationSupport MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX and AVX2 built-in functions and code generationSplit 32-byte AVX unaligned load-mavx256-split-unaligned-storeSplit 32-byte AVX unaligned storeSupport BMI built-in functions and code generationSupport BMI2 built-in functions and code generationBranches are this expensive (1-5, arbitrary units)Generate cld instruction in the function prologue.%<-mcpu=%> is deprecated; use %<-mtune=%> or %<-march=%> insteadSupport code generation of crc32 instruction.Support code generation of cmpxchg16b instruction.Do dispatch scheduling if processor is bdver1 or bdver2 or bdver3 and Haifa scheduling is selected.Support F16C built-in functions and code generationGenerate sin, cos, sqrt for FPUEmit profiling counter call at function entry before prologue.Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX and FMA built-in functions and code generationSupport FMA4 built-in functions and code generation Always use Dynamic Realigned Argument Pointer (DRAP) to realign stackReturn values of functions in FPU registersGenerate floating point mathematics using given instruction setSupport FSGSBASE built-in functions and code generationConvert function return to call and return thunk.%<-mfused-madd%> is deprecated; use %<-ffp-contract=%> insteadSupport FXSAVE and FXRSTOR instructionsSupport Hardware Lock Elision prefixesUse IEEE math for fp comparisonsAssume incoming stack aligned to this power of 2Force indirect call and jump via register.Convert indirect call and jump to call and return thunks.Inline all known string operations-minline-stringops-dynamicallyInline memset/memcpy string operations, but perform inline version only for small blocks%<-mintel-syntax%> and %<-mno-intel-syntax%> are deprecated; use %<-masm=intel%> and %<-masm=att%> insteadData greater than given threshold will go into .ldata section in x86-64 medium modelSupport LWP built-in functions and code generation Support LZCNT built-in function and code generationSupport MMX built-in functionsSupport code generation of movbe instruction.Use native (MS) bitfield layoutDo not support SSE4.1 and SSE4.2 built-in functions and code generationOmit the frame pointer in leaf functionsSet 80387 floating-point precision to 32-bitSet 80387 floating-point precision to 64-bitSet 80387 floating-point precision to 80-bitSupport PCLMUL built-in functions and code generationSupport PKU built-in functions and code generationSupport code generation of popcnt instruction.Use 128-bit AVX instructions instead of 256-bit AVX instructions in the auto-vectorizer.Attempt to keep stack aligned to this power of 2Use push instructions to save outgoing argumentsSupport RDRND built-in functions and code generationGenerate reciprocals instead of divss and sqrtss.Control generation of reciprocal estimates.Use red-zone in the x86-64 codeNumber of registers used to pass integer argumentsSupport RTM built-in functions and code generationSupport code generation of sahf instruction in 64bit x86-64 code.Support MMX and SSE built-in functions and code generationSupport MMX, SSE and SSE2 built-in functions and code generationEncode SSE instructions with VEX prefixSupport MMX, SSE, SSE2 and SSE3 built-in functions and code generationSupport MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2 built-in functions and code generationSupport MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 built-in functions and code generationSupport MMX, SSE, SSE2, SSE3 and SSE4A built-in functions and code generationUse SSE register passing conventions for SF and DF modeSupport MMX, SSE, SSE2, SSE3 and SSSE3 built-in functions and code generationChose strategy to generate stringop usingSupport TBM built-in functions and code generationUse given thread-local storage dialectUse direct references against %gs when accessing tls dataReturn 8-byte vectors in memoryGenerate vzeroupper instruction before a transfer of control flow out of the function.Support XOP built-in functions and code generation Support XSAVE and XRSTOR instructionsDo not search standard system include directories (those specified with -isystem will still be used)Do not search standard system include directories for C++Do not look for object files in standard path-o Place output into Like -pedantic but issue them as errorsCreate a position independent executableGenerate C header of platform-specific featuresDo not display functions compiled or elapsed timeRemap file names when including filesStatically link the GNU Fortran helper library (libgfortran)Conform to the ISO 1998 C++ standard revised by the 2003 technical corrigendumDeprecated in favor of -std=c++11Conform to the ISO 2011 C++ standard (experimental and incomplete support)Conform to the ISO 201y(7?) C++ draft standard (experimental and incomplete support)Conform to the ISO 2011 C standard (experimental and incomplete support)Deprecated in favor of -std=c11Conform to the ISO 1990 C standardConform to the ISO 1999 C standardDeprecated in favor of -std=c99Conform to the ISO Fortran 2003 standardConform to the ISO Fortran 2008 standardConform to the ISO Fortran 2008 standard including TS 29113Conform to the ISO Fortran 95 standardConform to nothing in particularConform to the ISO 1998 C++ standard revised by the 2003 technical corrigendum with GNU extensionsDeprecated in favor of -std=gnu++11Conform to the ISO 2011 C++ standard with GNU extensions (experimental and incomplete support)Conform to the ISO 201y(7?) C++ draft standard with GNU extensions (experimental and incomplete support)Conform to the ISO 2011 C standard with GNU extensions (experimental and incomplete support)Deprecated in favor of -std=gnu11Conform to the ISO 1990 C standard with GNU extensionsConform to the ISO 1999 C standard with GNU extensionsDeprecated in favor of -std=gnu99Conform to the ISO 1990 C standard as amended in 1994Deprecated in favor of -std=iso9899:1999Accept extensions to support legacy codeEnable traditional preprocessing-trigraphs Support ISO C trigraphsDo not predefine system-specific and GCC-specific macrosDisplay the compiler's versionKnown assembler dialects (for use with the -masm-dialect= option):Known ABIs (for use with the -mabi= option):Known code models (for use with the -mcmodel= option):unknown excess precision style %qsunknown floating point contraction style %qsKnown indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):Known vectorization library ABIs (for use with the -mveclibabi= option):Known address mode (for use with the -maddress-mode= option):Valid arguments to -mstringop-strategy=:unrecognized visibility value %qsKnown TLS dialects (for use with the -mtls-dialect= option):../../gcc/vec.ccalculate_allocationregister_overhead-malign-loops is obsolete, use -falign-loops-malign-loops=%d is not between 0 and %d-malign-jumps is obsolete, use -falign-jumps-malign-jumps=%d is not between 0 and %d-malign-functions is obsolete, use -falign-functions-malign-functions=%d is not between 0 and %d-mbranch-cost=%d is not between 0 and 5&DuDDDDDDTDDD DDDuDBD˲DDDDDD8DDDDDDDDDDiDEDDDDDɰDeDDDDDDDDDDDDDDDDDDDDDDίDDyDXDDDDDDDDDDDDDDDD)DDDDDDDDDDDDDDDeDثD@DӫDDDDEDDDD$DDDDDDDDDDDDD+Q   ''''//////@/@/@@????@@@@@@ / /  ../../gcc/hooks.chook_int_rtx_unreachable???0x%lx %s %s:%d %s%s%s locus%s%s:%s %s %*c%sin %s, at %s:%dSee %s for instructions. compilation terminated. ../../gcc/diagnostic.c%s%s:%s %s%s%s%s%s:%d:%d:%s %s%s%s%s%s:%d:%s %s%s%s[warningnotefatal error: internal compiler error: sorry, unimplemented: warning: anachronism: note: debug: pedwarn: permerror: must-not-happentoplev_mainexecute_one_passcompile_file%s: all warnings being treated as errors%s: some warnings being treated as errorsIn file included from %r%s:%d:%d%RIn file included from %r%s:%d%R, from %r%s:%d%Rcompilation terminated due to -Wfatal-errors. compilation terminated due to -fmax-errors=%u. Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. Internal compiler error: Error reporting routines re-entered. %s:%d: confused by earlier errors, bailing out Q@@K@K@@@@@internal_errorfatal_error../../gcc/diagnostic.cdiagnostic_action_after_outputdiagnostic_build_prefixDGDGDGDGP!JP!JX!JX!J>F>F]!Jk!Jc!J!J!J!J!J!J!J!J!JHG!J!J"JGCC_COLORSTERMdumb../../gcc/diagnostic-color.ccolorize_init\l\ ../../gcc/pretty-print.cqwl+#%ld%lld%lo%o%llo%p%lu%u%llu%x%lx%llx\%03o\U%08xdecode_utf8_charpp_base_output_formatted_textpp_base_format/usr/share/locale`utf-8utf8‘’Number of expanded macros: %5ld Average number of tokens per macro expansion: %5ld Line Table allocations during the compilation process Number of ordinary maps used: %5ld%c Ordinary map used size: %5ld%c Number of ordinary maps allocated: %5ld%c Ordinary maps allocated size: %5ld%c Number of macro maps used: %5ld%c Macro maps used size: %5ld%c Macro maps locations size: %5ld%c Macro maps size: %5ld%c Duplicated maps locations size: %5ld%c Total allocated maps size: %5ld%c Total used maps size: %5ld%c (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)line-map.c: file "%s" entered but not left line-map.c: file "%s" left but not entered Map #%u [%p] - LOC: %u - REASON: %s - SYSP: %s {P:%s;F:%s;L:%d;C:%d;S:%d;M:%p;E:%d,LOC:%d,R:%d}yesNoneLC_ENTERLC_LEAVELC_RENAMELC_RENAME_VERBATIMLC_ENTER_MACROFile: %s:%d Included from: [%d] %s Macro: %s (%u tokens) N/A# of ordinary maps: %d # of macro maps: %d Include stack depth: %d Highest location: %u Ordinary line maps Macro line maps macro argument "%s" would be stringified in traditional Ccould not determine file timestampcould not determine date and time__COUNTER__ expanded inside directive with -fdirectives-onlyISO C99 requires rest arguments to be usedmacro "%s" requires %u arguments, but only %u givenmacro "%s" passed %u arguments, but takes just %upasting "%s" and "%s" does not give a valid preprocessing tokenunterminated argument list invoking macro "%s"function-like macro "%s" must be used with arguments in traditional Cinvalid string literal, ignoring final '\'invoking macro %s argument %d: empty macro arguments are undefined in ISO C90 and ISO C++98duplicate macro parameter "%s""%s" may not appear in macro parameter listmacro parameters must be comma-separatedanonymous variadic macros were introduced in C99ISO C does not permit named variadic macrosmissing ')' in macro parameter listISO C99 requires whitespace after the macro namemissing whitespace after the macro name'#' is not followed by a macro parameter'##' cannot appear at either end of a macro expansionthis is the location of the previous definitioninvalid hash type %d in cpp_macro_definitionmacro "%s" is not usedinvalid built-in macro "%s""??? ??? ?? ??:??:?? ????""%s %2d %4d""%02d:%02d:%02d""??? ?? ????""??:??:??"parameter name missing!"#%&'()*+,-./:;<=>?[\]^{|}~__STDC_"%s" redefined__STDC_FORMAT_MACROS__STDC_LIMIT_MACROS__STDC_CONSTANT_MACROSJanFebMarAprMayJunJulAugSepOctNovDecDoDDD^DoDDDDrDYCWaCMYCbCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCWaCbCWaCWaCWaCWaCWaCWaCWaCWaCXC2J2J2J2J2J3J3J 3J 3J3J3J3Jdetected recursion whilst expanding macro "%s"syntax error in macro parameter listunterminated comment"defined" cannot be used as a macro name"%s" cannot be used as a macro name as it is an operator in C++no macro name given in #%s directivemacro names must be identifiersinvalid flag "%s" in line directiveinvalid #pragma GCC poison directivepredicate must be an identifiermissing ')' to complete answerinvalid "#pragma GCC %s" directiveextra tokens at end of #%s directive#pragma system_header ignored outside include fileinvalid #pragma push_macro directivemissing terminating > character#%s expects "FILENAME" or #include_next in primary source fileregistering pragmas in namespace "%s" with mismatched name expansionregistering pragma "%s" with name expansion and no namespaceregistering "%s" as both a pragma and a pragma namespace#pragma %s %s is already registered#pragma %s is already registeredembedding a directive within macro arguments is not portablestyle of line directive is a GCC extension#%s is a deprecated GCC extensionsuggest not using #elif in traditional Ctraditional C ignores #%s with the # indentedsuggest hiding #%s from traditional C with an indented #invalid preprocessing directive #%s"%s" after # is not a positive integerunexpected end of file after #line"%s" after #line is not a positive integerregistering pragma with NULL handler_Pragma takes a parenthesized string literalinvalid #pragma pop_macro directivepoisoning existing macro "%s"assertion without predicatemissing '(' after predicatepredicate's answer is empty#elif without #if#elif after #elsethe conditional began here"%s" re-asserted#else without #if#else after #else#pragma once in main fileinvalid #%s directivepragma dependencycannot find source file %scurrent file is older than %sempty filename in #%s#include nested too deeplyundefining "%s"#endif without #if#%s is a GCC extension"%s" is not a valid filenameline number out of rangepush_macropop_macropoisonsystem_headerunterminated #%s( defineendififdefifndefpragmainclude_nextunassertsccs@AJeC=JD}=FeC=JPhC=JfCMJpdC-><<&&||EOF==!=+=-=*=/=%=&=|=^=>>=<<=...->->*.*AT_NAMENUMBERWCHARCHAR16CHAR32OTHERWSTRINGSTRING16STRING32UTF8STRINGOBJC_STRINGHEADER_NAMEWCHAR_USERDEFCHAR16_USERDEFCHAR32_USERDEFWSTRING_USERDEFSTRING16_USERDEFSTRING32_USERDEFUTF8STRING_USERDEFCOMMENTMACRO_ARGPRAGMAPRAGMA_EOLPADDING%:%:<::><%%>__VA_ARGS__ can only appear in the expansion of a C99 variadic macroidentifier "%s" is a special operator name in C++backslash and newline separated by spacebackslash-newline at end of filetrigraph ??%c ignored, use -trigraphs to enableraw string delimiter longer than 16 charactersinvalid character '%c' in raw string delimiterinvalid suffix on literal; C++11 requires a space between literal and identifiernull character(s) preserved in literalmissing terminating %c characterC++ style comments are not allowed in ISO C90(this will be reported only once per input file)CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC0C^CCzC:C:C:C:C:C:C:C:C:C:CWCCC{CCCCPCPCPCPCPCPCPCPCPCPCPCCPCPCPCPCPCCPCPCCPCPCPCPCPCCCCCPCCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCCPCPCPCPCPCCCCCCCCCCCCCCCPCCCCCCCCCCCCCCCCCCCCCCCmCC(CFCCCCCCCCC0C7C@CCCCCCCCCCCpCC CCCCZCCCCCCCCCCCCCCCCCCCCCCCCCCCCFCC'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC \\\\\\\\\\\\\\\\????????????????PJPJRJPJBF3GQJ;FRJPJS>F/JPJPJ2JPJPJ J RJAGJ@@FPJPJPJPJPJPJPJPJPJPJPJPJPJPJPJAJ9GN!JGJNJ9EFQEFPJBF3GPJPJDJPJQJ>F+JQJQJQJQJQJ"QJ)QJMQJ/QJ7QJ@QJIQJTQJ`QJmQJlQJzQJQJQJQJQJQJQJQJQJQJQJRJ RJ RJRJRJRJRJ ?\ \ String pool entries %lu identifiers %lu (%.2f%%) slots %lu deleted %lu table size %lu%c coll/search %.4f ins/search %.4f longest entry %lu bytes %lu%c (%lu%c overhead) avg. entry %.2f bytes (+/- %.2f) Y@-C6?$E$E$Er$Er$E$E$E$E$E88898=8=8=13=>@=HI=~===8=8O=889898988yz89=8=8=8=88=8=8=8=8=== < 9=O8P=\8]=8=8=8=8=8=8=80=V8X9Y8`=89 9 9 9 9999998999898998=8=<8 =:8?=J=K=L=M=N=O= P=!Q="Rx_;i8o=tx=8=8=8999999998==9899998;8 9 8 =9 8< 9L 9 M 8O 9P 9Q 9R 8W _ =b 9c 8e ;o 8 9 8 = 8 = 8 = 8 = 8 = 8 = 8 y 9 8 9 8 1 9 9 8 8 = 9 8 ; = 8 9 8 = 8 = 8 =( 8) =0 81 =2 3 84 =5 6 87 =9 8= 9B 8F 9H 8J 9L 9 M 8X [ =\ 8] ^ 8e ;o 8s 9t 8 9 8 = 8 = 8 = 8 = 8 = 8 = 8 = 8 9 8 9 8 9 9 8 9 8 = 8 ; 8 9 8 = 8 = 8 =( 8) =0 81 =3 85 =9 8< 9= y> 9C 8F 9H 8J 1K 9L 9 M 8[ ] 8^ =a 8e ;o 8 9 8 = 8 = 8 = 8 = 8 = 8 = 8 = 8 = 8 = 8 = 8 y 9 8 9 8 1 9 9 8 ; 8 9 8 = 8 = 8 =( 8) =3 84 =9 8= 9D 8E 9H 8I 9L 9 M 8_ =a 8e ;o 8 9 8 = 8 = 8 = 8 = 8 = 8 9 y 9 8 9 8 1 9 9 8 9 8 = 8 ; 8 9 8 = 8 = 8 =( 8) =9 8= y> 9C 8E 9H 8I 1K 9L 9 M 8_ =a 8e ;o 8=091=23979g89g99 :8?=F9G9kH9kI8N<O?Y=[8=8=8=8=8=8=8=8=8=8=8=8=<=9=99v9v89=8=8=89z9z9z98;8898998;38495869788998=9BC9G8H9LM9QR9VW9[\9hi8p9q9rs9tvwxy9z9{9|99999 899899898999998988=8=8<Y8`|u<8|<8=8=8=8=8=E8G=M8O=W8X=Y8Z=[8\=]8^=pq=rs=tu=vw=xy=z{=|}8=8===8====8=8====8===> 9@ 8~  !!!!8 !!8!!!9!!8#!$!8%!&!8'!(!8)! *!+!-!9.!1!82!8!_!!;!8090;08 0;)08@0=0<0800<00=0<0=0<01=,18M=898 <<<< <!"<$&<)-8 ) 687 <8= >8? A<B D8E N8=<?8O88or8st8u8 :@Ze88888tJlAuJlAuJA uJA/uJ@A>uJ@AMuJVA\uJVAconversion from %s to %s not supported by iconvcharacter 0x%lx is not in the basic source character set converting to execution character setcharacter 0x%lx is not unibyte in execution character setuniversal character names are only valid in C++ and C99the meaning of '\%c' is different in traditional CIn _cpp_valid_ucn but not a UCNincomplete universal character name %.*s%.*s is not a valid universal characterCharacter %x might not be NFKCuniversal character %.*s is not valid at the start of an identifieruniversal character %.*s is not valid in an identifierconverting UCN to source character setconverting UCN to execution character setthe meaning of '\x' is different in traditional C\x used with no following hex digitshex escape sequence out of rangeoctal escape sequence out of rangethe meaning of '\a' is different in traditional Cnon-ISO-standard escape sequence, '\%c'unknown escape sequence: '\%c'unknown escape sequence: '\%s'converting escape sequence to execution character setcharacter constant too long for its typemulti-character character constanticonv_openempty character constantfailure to convert %s to %sUTF-8/UTF-32LEUTF-8/UTF-32BEUTF-8/UTF-16LEUTF-8/UTF-16BEUTF-32LE/UTF-8UTF-32BE/UTF-8UTF-16LE/UTF-8UTF-16BE/UTF-8__STDC__ 1__cplusplus 201103L__cplusplus 199711L__ASSEMBLER__ 1__STDC_VERSION__ 199409L__STDC_VERSION__ 201112L__STDC_VERSION__ 199901L__STDC_UTF_16__ 1__STDC_UTF_32__ 1__STDC_HOSTED__ 1__STDC_HOSTED__ 0__OBJC__ 1and_eqbitandbitorcomplnotnot_eqxorxor_eq__TIMESTAMP____TIME____DATE____FILE____BASE_FILE____LINE____INCLUDE_LEVEL____COUNTER___Pragma__STDC__=FLvJ SvJ ZvJ `vJfvJjvJBFvvJ!qvJ uvJ"|vJ vJvJvJvJ vJvJvJ vJvJmmap/proc/curproc/file/proc/self/exefailed to read executable informationlibbacktrace could not find executable to opencloseno debug info in ELF executableno symbol table in ELF executableexecutable file is unrecognized ELF versionexecutable file is unexpected ELF classexecutable file has unknown endiannessELF symbol table strtab link out of rangesymbol string index out of rangeexecutable file is not ELFELF section name out of range.debug_info.debug_line.debug_abbrev.debug_ranges.debug_strmunmapinvalid abbreviation code%s in %s at %dDWARF underflowLEB128 overflows uint64_tunrecognized address sizeDW_FORM_strp out of rangeunrecognized DWARF formunit line offset out of rangeunrecognized DWARF versionabbrev offset out of rangeranges offset out of rangesigned LEB128 overflows uint64_tabstract origin or specification out of rangeinvalid abstract origin or specificationinvalid file number in DW_AT_call_file attributefunction ranges offset out of rangeunsupported line number versioninvalid directory index in line number program headerinvalid directory index in line number programinvalid file number in line number programMu^uxvAyAvAwAvAwAyAyAvAxvAxvAxvAxvAwAwASxASxAwAwAwAxvAxAwA yAkwAwAxvAxvAxvAxvADD D&D D D? D DDjDA(D(D'D D DDD D D$DDDDGD{DXDlDD D#DJJJJ؀JJJJ1JCJPJhJJȁJJzJJalnumalphablankcntrlgraphlowerprintpunctxdigitMemory exhaustedSuccessNo matchInvalid regular expressionInvalid collation characterInvalid character class nameTrailing backslashInvalid back referenceUnmatched [ or [^Unmatched ( or \(Unmatched \{Invalid content of \{\}Invalid range endRegular expression too bigUnmatched ) or \)No previous regular expressionInvalid preceding regular expressionPremature end of regular expressionEAEAEAEAAAAALALAEALALALALALALALALALALALALAAXAXAXAXAXAXAXAXAEALALALALALAALAXASAEAAEAXAXASAAALALAEAEAEAEAEALAEAEALAEAAALALALAAAALALALAEAEA϶AAA AAQADAJAӹAAAAA#A-A7AAAKAUA_AiAsA}AAAAAAAAAAAAAAAAAAA\A,A0AA0AAAAӿA=A^A|AAA%AA%A%AAAsA}AAeAAkArAA%AAAAAAAQAcAuAAAA*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*AWA^AoAWA^AoAAAvAAAAAA*A*A*A*AA*AA$A$A$A$A$A$A$A$A$A$AkAkAkAkAkAkAkA2AkAA1AkAAAkAkAkAkAkAA$A7A^AkAAAAAkAkAkAkA$AkAkAkAkAkAkAOAOAOAOAOAOAOAOAOAOAkAOAOAOAOAkAkAkAOAOAAOAOAOAOAOA_AAAAAAAlAA_AAAAAUAAAAAFRJPJcvJBFUJPJ( restrict volatile constcomplex imaginary ::* __vector(string literalstd::allocatorstd::basic_stringstd::stringstd::istreambasic_istreamstd::ostreambasic_ostreamstd::iostreambasic_iostreamboolboolean__float128unsigned charunsigned intunsignedunsigned longunsigned __int128unsigned shortvoidwchar_tunsigned long longdecimal32decimal64decimal128halfchar16_tchar32_tdecltype(nullptr)aNaSaaalignof azconst_castclcmcodVdelete[] dcdynamic_castdldelete dtdveOeogtlSlioperator"" mImLnew[]nwoRoopLpmqurMrSrcreinterpret_caststatic_castsizeof szthrowtwthrow std::basic_string, std::allocator >std::basic_istream >std::basic_ostream >std::basic_iostream >%s: error: too many @-files encountered Cannot find prime bigger than %lu ?D?D?Dv?Dx>Db?DY?DM?DA?D5?D)?D ?D?D?Dv?Dj?Db?DY?DM?DA?D5?D)?D ?D%I$ <;G]tB{= 0$~`2fCOmA oE!a  0P AA ?  &*"@ `0PHX? "A!)?cccccccccccccccccccccccccccccccccccccccccccccccc ccccccc cccccccccccccccccccccccccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccTMPDIRTMPTEMP/tmpCannot create temporary file in %s: %s /var/tmp/usr/tmp/tmpXXXXXXclosing pipeline input fileopen temporary filepipeline already completeopen temporary output fileopen error filewbcould not create temporary fileboth ERRNAME and PEX_STDERR_TO_PIPE specified.PEX_STDERR_TO_PIPE used in the middle of pipeline: error trying to exec '': vforkdup2execvpexecvwait}BiBEDbBLEZBNB#BLE  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~  !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~CBBBBQ00000000000000000000000000000000 %s%sout of memory allocating %lu bytes after a total of %lu bytes undocumented error #%dԨ4l|Ԩĩĩĩĩ$Ԩstd::bad_allocSt9bad_alloc__gnu_cxx::__concurrence_lock_error__gnu_cxx::__concurrence_unlock_errorN9__gnu_cxx24__concurrence_lock_errorEN9__gnu_cxx26__concurrence_unlock_errorEstd::exceptionstd::bad_exceptionSt9exceptionSt13bad_exceptionN10__cxxabiv115__forced_unwindEN10__cxxabiv119__foreign_exceptionEN10__cxxabiv120__si_class_type_infoEterminate called recursively ' what(): terminate called after throwing an instance of 'terminate called without an active exception XPPPPXXXXPXPX`PXP`XXPPPPPPPPXXXXXPP@ P@11 @ @ @1 @ @ @ @@T,xX(Xh(((((((((((((((((((((D{;}VVVVVVVVVVVVVVVVVVhVVVVVVVVVVVVVVVVVVVVVVVVVVVlU>' k=00p`````````x@@ `PPX @@00PD!t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t&t!"!t!"!t"T##D$$$$$%t&t&t&t&%t& pure virtual method called deleted virtual method called N10__cxxabiv117__class_type_infoESt9type_info>@F@@@@AAABABBBC}CCC4DDE~EE(FF9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@9@>@GGFGGyGFy?y?y?y?=G2GoGFKOdOWOKKKKKOrOOKO3PPPOKKKKbP)PPOQRRRRRtR\RDR4R$RQQVUUUVLVUTRRUUUUURRUURUUUUTUUUUUUUDU4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4U4UQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTSRtSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR|UoUcURXNXNXNXNU UVURETSTcTqTS$N$NSS$NS TT&T$N4TTTTTTVXW WVWhhi(ihpipipipiHih8ih;!5l"ptX"t"t"t"Nu#Av$vX%.w%w%%x%x&x &yH&{&;|h'|'|'k(x)P)A)e8*҉@+X+[+zX,Ŋ, ,M,-6.(/pH/x,H-px-H1`1x1112(2H2x2y(3H4٩`44Ȫ@5 5506.P7_h7777cP8ѷ9 9:θ;;b;e<h <k8<nP<qh<t<w<z<}<<<=(=@=X=p======>>0>H>`>x>>>>>º>ź?Ⱥ ?˺8?κ?Ѻ?Ժ?׺h@ں@ݺ@@@AhAAAAA BBCCCCD8DPDhDDDDDDE(E@EpEE EE$E'E*F-0F.`F/F2G5 G8PG;hG>GBGFGIHL@HOXHRHUHVIWIX0I!PIYIIhJ+Jr@K!pKKKpLLXLLLlLMHMMMMMN@N`NO0OPOIO4OPPPPWP_PyP`Q7Q[QQRR#RKS@Tu0Tb`TTU(UU+V]V(W@W$`WoWxX(Y@Y XYlpYtYZPZoZ_Z[P[[ \h\%\]]=]s(_x_@`0a$Haxaaa+b8bb bEbvb(cHc`cjxc&coddpddd-eeeef(fxfTffg-Hg`hh8h iFisi}k lo hla"l"m#0m#Xm#xm$m$m$n'n6(n*o+ox+p+p,qD-0q-Xq.qi/q!0q0q1 rU2Hr2t2t2t2t 3t*3uK38uU3Pu3 v3vh4w)5w45 x6hx6x7yR9z]9zl9{98{ :h{:{L;{t;{;|;|<8| =h|=|%=|)=|.=|3=}8=(}<=@}A=X}F=p}>}{?}d@~VA(~A`~Ax~A~&B~BB0CCCDЀDD EhE8E4FHG@dGЃGH(HhH1I J`KKKpKGLLkM8(NNX1PP؉%QKQpQQ.U@_VhWWaXY0Zx \]],] B]8X]@^r_a`Џdexef~gБFjKj(khkmmnHroo\pȓpp rHrr6sȔt4u`u vؕ=vQv`v0vvHv`vؖAtPTЗkǃ(@XpGИ y`ș L0PÈp#ؚ0(c@x0%@7xʙȜ`F؝8Sx؞(x;؟@ch 8BXp^(HM`xbСK@1`=Тb(aPxXD8 pPu8PhFmMئ k 8!pK%R).8/h11)3X8p99ة!<<(c=X=p==>)>Ъo>>>>ȫ?@X@@ȬBC&CCDE.E>EP^Ep~EEȯE^F@{FpFFhFFFȴ.G5GGȷ{H^I8 J`HJJ0KPKh"K)K=KIKȹLLM0M10`p(" #`#8$P$$&&0'@'p (h((P*P***+,0,-H..@."/#/01@0P306091@H8J@BPKhB LBLBL DLFLHFLFMGM(H MpH0MH@MHPM8JN@LNR0QTVxUpW8VWPVWhVWVXV ZV@ZW`ZW\@X]XX0_X_YaY eZ f[`f]Pg^__x`@@d(g0gЬjHjjjpkk0m@Hn`oos8thu0uPvvw~X0 xP(PX p%p4P5 p;? C K`p0@yPyy`{P}8~@0@X @0 !p%Б0%0(H)x+p00 2p2P3333К04x4P4`4H6`6`667`88к09`9990:::;0X;Pp;P??(@B C8CPxC`CpCDXExFFFF8GGGH JJKpM NNN8PPPQ0QQ0Rp `R 0SSPTP8U` W#X$X%\%\@)\)0])`]+^P+(^+X^`-^0(` 0`P3d3e5@e@6@f6pg7g08h:h =HiP>i`>i?@k@AkAlAmAnPCPoDo DoD(pEPpExr0FrFrPHsI`s`JxsNxtN uNvNwN8w@OXwPwPxPyRPy0Sy`Tzp]hzaz@b{b|b|PcH~pc~cddgg@hȆhPiixk l`lPlmЎPoop ps(vvxwyP{{Э@|}0}P~Ю~00@`xذ(XЁPг@p ص 8h(`Б`Г(pPȺPp 0Hؼ0(X0 `Hh@PpоУ0P0ppп`P0 x0pШ 80P@hPpЩ8X0xP`Ъ`(Hp8p`xPH x0H0p `HH``0pP0@xP`!`p%(+@-./ P3P45 5@555 586X`667(7H7`8x8 8@888B(PC@pLUXhZ[@\00]^^_P_(`_@_X_p____`a( a@b`c0de00eHex f@fgg80hh`ipjjpkH mmPoXpw`x8}}}}P~ `~8~XPX`pzRx n*zRx $IpFJ w?;*3$",D@fBAD AB$tR)ACG [AA$R-F^CER*EaD R^BEE B(D0C8A@}8A0A(B BBBL,fBFB B(D0A8DP 8A0A(B BBBA d|iBEB F(E0C8DPc 8A0A(B BBBH Q 8A0A(B BFBA D~QBFJ E(A0A8FP8D0A(B BBB$,)RACA AALTkaBBE B(A0A8DP 8A0A(B BBBG LpBBE E(D0A8D@t 8A0A(B BBBA ,0rrAC BEK F $$`lUAS A \ A b$LlVAS A \ A c$tQ5ADD iAA$QADA ~AD,RmBCA aAD,ERsBDA fAD$R9Aw$<RANGpAALdjSBBB B(A0A8DP8A0A(B BBB,UKAD sAE,qgAC M A y/GK E L4y BBB B(A0A8DP 8A0A(B BBBE $TARrA*UA[-AX A ,UAC Pw c[#A]D<HBHE E(A0C8G@b8A0A(B BBBLBBB E(A0A8G@ 8A0A(B BBBB <piBIG D(DP4 (A ABBA LBBA D(G0U (C ABBC  (A ABDA ,djAAD U MAO $ZAQJ`AAZVDy^$BEE E(D0D8B@8A0A(B BBB,$@}AC Pw A T%_mAk<lx+BBA D(J (A ABBA \hBBB A(D0 (A BBBA  (A BBBA r(A BBBL _BBB B(A0C8J 8A0A(B BBBK \ ^MCpt ^<CxL 0iBED A(A0Z (A ABBA {(A DBB$ @AKE AA c^AL$ *BBB B(A0C8GN 8A0A(B BBBA t ^KCG4 cBBD A(D0x(A ABB ^DD  9^DD  e^DD L 0N BBB B(A0A8GP- 8A0A(B BBBA ,d bYBDA NAB b'Ea, K AC M A L ]BBD C(E0g (I ABBE T(A ABB4, ^BJA A(A0(A ABBTd RIM A(A0 (A BBLB (A BBBT BIE A(A0h (A BBBG  (A BBBA , @^#AC BIK F D ]Cz G C4d ^BAA DP  AAB< EBLB A(A0 (A BBBA L (5 BBE B(A0A8D 8A0A(B BBBG ,,Xe<ACD F AAA <\BBA D(G0 (C ABBC $AD AA ,0AK I A <diBAA P ABE A CBA ,4:AG Ib A dG_|3_ _ _^LQBBB B(A0A8G 8A0A(B BBBH ,^D^^A\,d^AJNAAL7_BEB B(A0A8G8A0A(B BBB,PcJAC I A ,pdBQA  AEA $DIv0ACG bAA,le}AAA c AAA eAWf|eBBB B(A0A8D` 8A0A(B BBBA X 8I0A(B BBBG f 8C0A(B BBBE Lf-YdYu0JT|qufJvfLfUBBB E(D0D8D38A0A(B BBBDtBKE F(D0A8B@8A0A(B BBBL\uDBEB B(A0A8G%8A0A(B BBB4t|ACG@ FAE GAAd}BEB B(A0D8D@A 8A0A(B BBLE 8A0A(B BBBL~+dpgB|gKB_ B ,g8BAD  ABB LhBEH E(D0D8G 8A0A(B BBBA LkBBB B(D0D8D@ 8A0A(B BBBA l}1}+~}gK,NuHAA gAB47~BBD A(G@(A ABBLXp4BEB E(A0A8G 8A0A(B BBBA Dl nBEL E(D0D8B@A8A0A(B BBBL|BBB E(A0C8D`? 8A0A(B BBBA -[M~:RT4~y,LAAGpw AAA <|HBHB K(H0s (A BBBA LmBEE B(A0A8G 8A0A(B BBBA $ EE A D A 4d~JdLxBBB B(D0G8DpU 8A0A(B BBBA P 8F0A(B BHBE D0BHB E(A0A8Gp8A0A(B BBB,ؖAF BGED A D,xBBB J(J0Gq 0A(A BBBA tЙؙ>}GD~BDB B(A0E8Dp8A0A(B BBB j~$U~<@~T+~l~~}}}}}},n}DY}\D}t/}}}|||||4|Lr|d]||H|3|| |{{ {${<{T{LlBBB B(A0A8D`~ 8F0A(B BBBA &{{z< BED D(GPr (F ABBA <Dg BED D(GPj (F ABBA gzRz=z(zLz4 BBB B(A0D8Gp 8C0A(B BBBL4BBB B(A0D8Gp8C0A(B BBBRAQE$Q E L6xBEE E(D0D8DP8A0A(B BBB< ^DA~$\ xDe G G I g I < BBD A(D0d (A ABBA  p q   !$!AC HD A +qG+CG+G ,G,,, AALAA\,G$|,_AGA$,AI AA $,XAI AA $, AI AA ,- AALAAL-G,l-a1ACI!AAL-,BGB B(A0A8A@8A0A(B BBB,-\TLGD yAB.4.z[DN E CT.B4l.bBED G(D@E(A ABB.Ǘ.8Al A .AX.AZ,/BSD  ABA ,L/HOADA s AAA 4|/-BED A(A0(A AEB/$A^/$AW/ 0 $$0|OADA FAA,L0{BDA x ABA ,|0jBAA M ABA ,0CHBDD vAB,0[(BAD ]AB< 1;BEB A(D0 (A BBBA LL1BBB B(A0D8GD 8A0A(B BBBA L1BBE A(A0m (A BBBA U(H BBB,1sAAJAA,285BAA mAB,L2=AAJAA|2A[L2BBB B(A0D8D 8A0A(B BBBA 2xA A `$ 3AH BLi 43(Af<T3 BBA A(A0 (D ABBA 43VBAD F0  AABF ,3pBDD F0 AAB3,A` G C44#2BFA D  AABT40l4(40 4($4GAJI pAA44BAA GP  AABD 5 ,5(D5t \5ewGo$|5KADA BAAL5BEB E(D0A8GP 8A0A(B BBBA 5 L 6hqBEB E(D0A8GP 8A0A(B BBBA \6<t6.BBB D(A0 (A BBBC ,6ZACG V AAA 66,7MBKF e ABA D7a\7YiD dt7bD ]7,7CKN CA  EH 7&,7AKF0 CAH L8vBIG E(D0A8C@L8A0A(B BBB,l8_BKF HAB,8BDD F@ AAB8h G A D8VBBE D(A0Fp-0I(A BBB449BDD F` AABDl9xBEB B(A0A8 0A(B BBBA L9$BEB A(D0 (A BBBE A(A BBB:0 7:Al A D<:BHB E(D0D8I`8A0A(B BBB:-gE,:]BAA PAGD:BBB A(D0G@w 0A(A BBBA ;@6,;jyAw,L;HdBGD M ABA $|;AC BD A ,;kBBKD mAB<;BIA A(D0 (A ABBH <=6,<J,D< ZA A A E F A F A ,t<PAC DEF A L<BBB B(A0D8DP 8A0A(B BBBA L<p.BBE B(A0A8G 8A0A(B BBBB LD=C!BBE B(D0C8A@8A0A(B BBB=@Al A L=p6BBB E(D0A8G@x 8D0A(B BBBD <> :BBB A(A0F (A BBBK D> 4\>BBD A(D0(A ABBd>p8#BBE B(D0A8DP 8A0A(B BBBA L?tx,d?ԡ`BEA TAB<?vBBE D(A0\(A BBB<?:BBB D(D0(A BBB@ԢWCS$,@\ADA SAADT@GBBE B(A0D8D@8A0A(B BBB$@lAFD ^AA@[:@}1L@ BBB B(A0A8G 8D0A(B BBBDAP6AtdAfA|As<ABBD A(D0(A ABBDAfIBBB D(A0G@.0A(A BBBBg$4B_+ACD ^AC,\BFACG j AAA $B2rACD gAA,B|BAA ABB9Am A $CȱuADA lAA,,Cx5AC DEEHJ A <\CeBEA E(A0G (A DBBA $CACG@AAC3 C%4CBEF A(G@(D ABB,DDD4\DADA @ AAA N AAQ ,DDBAA AB4DoBFD D(D0Q(A DBB,D۲NBAD @DB,EDED;Aa A S$dEݲAID0~AA<EhBJA A(D@ (A ABBA <ExDADD s AAA J AFE nAA F<Ag E AL,FEBBB B(A0D8Dp 8A0A(B BBBA ,|FTFAC HH1 Fj6AlFSAMLFBBE E(D0D8DP 8A0A(B BBBA $"oBBF E(D0A8GI8A0A(B BBBLD}]$:,BKB B(A0A8G,8A0A(B BBB}GP}>P}+P8}KP(D0c}[P ~HP#D ^$~SP<~@P0AnT~XPDt~PFD0~L~QoBGB B(D0C8GPF8D0A(B BBBL~/RgBKE B(H0A8J58A0A(B BBB,FSMFED{SKAIdSW|S94TBED D( ABBTUAM E AT$[VaACD VAA,,V7BMA cAB\VNAO@|A$|ViAAD `AA, WSBDD EABԀ-WPeW%rW<Az$WQAO$DWrAClA$l X=ImCC,XBAA ABāXP$܁XADD AA4TYBBD C(GP(A ABBL<ZtBBB B(A0D8JR8A0A(B BBBL4lJBBA D(B0l (A ABBE A(A ABBL܂.l BDC h ABE  ABE I ABE AAB<,lBEB D(D0u(A BBBLl6nBBJ B(D0C8H@ 8A0A(B BBBA DoBHE E(D0A8E@8I0A(B BBBLobBED A(D0i (I ABBE O(A ABBTo!lo'o'o'<oBBA A(G@(A ABB$mxAAG0AA4y[AAE y JAJ AAC4T+y<ACE  IAJ xAA,/zBAA ABD}BBB A(A0G@0A(A BBBLbBBB A(A0 (A BBBE (A BBB,T BDA AB$AJ BD  ,BAA AB<܆GBAA G0W  EABJ  AABl!/BBA A(E0M (A ABBE G (A ABBE # (D ABBE (A ABB<BDA G0  EABJ ] AAB$̇aAGA, 6AC BEGD $AL@A,DBGC GP AABt@+6D qI6;D vԈYQFD0AGD0B14Ǔ DL(BOF B(A0J80A(B BBBL`BBB E(D0A8GPN 8A0A(B BBBA $!ADD AA$ AJ|A<4BED A(G" (A ABBA 4tzBGA D(A0d(A ABB41ADD Z DAE AAALBEB B(A0A8D`8D0A(B BBB44bBED A(D0u(A ABBLlBHE E(D0A8Dp{ 8A0A(B BBBA fԋDZPG A $$AJALG A ,lxAAG AAA 4ZBAD G AABԌ*AN4LFAy J Al A^ A^ A^̍xΕ h*@dLL,hBBE B(A0A8A@d 8A0A(B BBBA |H@ DBEE B(A0D8GP8A0A(B BBBLBEE E(D0A8DPu 8A0A(B BBBA DPD P\t@D ZD Z\BBD A(A0 (A ABBC c (A ABBC A(A ABBLBBB E(A0A8A@C 8A0A(B BBBA LTGBDB E(D0C8GP 8A0A(B BBBA $@:AG V DE |̐BBE E(A0A8GP 8E0A(B BBBA 2 8A0A(B BBBC T 8C0A(B BBBA LL5BEB B(A0A8GP 8A0A(B BBBA $@AI f AA $đADG CIA,xNADD } AAA <xBBE D(A0I (A BBBA $\XIAG _ DE H,4̒ >$VAJ D AA 4<H1AGA Z ADE AAALtBEE B(D0D8A@! 8A0A(B BBBA ,ē[AC I A 0  6,$2AAG Q DAA ,TOFA AA<BBB A(F0 (A BBBA LĔpBGB B(A0C8G` 8A0A(B BBBA ,5DR G  H H E D4DBED D(H0(A ABBL|8BHE B(A0C8G! 8A0A(B BBBA ̕"D ]4BBA A(D0|(A ABB4sBBA A(G@(A ABB$TACG@AA|(Af4HBDC G@[  AABA ,ԖBDC G@ AAB,pWAAG@ DAE 4L+Aa E Cl ̗ 4y=BKE E(D0H8A@$8AGP CA DDBBE D(C0JU 0A(A BBBA 8 $0AL0[ AA ̘ΑH"ROdAFA 1DP A ,<QAAG [ AAA l(3D\ A $H%AIG QAA$P+AHA ^AAܙ:%AczPLRx-K  ,${AFG ~ AAA LxG4dBDG G0a  AABA 4aBDA F@  AABH Ԛ0D e G LBEA D(J@X (A ABBA D(C ABB,DlDi K F B W I G<t@BGD A(G0 (A ABBK LqBBB B(A0A8GI 8A0A(B BBBD 4 @BBB A(A0Gp$<;D_ M A A dsBDD p[A̜AL4L HSl HS2I2I,+BAH e ABE ,lC A g A ,$XAFD ^ DAB ,TcU A n A |89DĞܞoD D$ D<DTl̟AL4ALTALtAL$ĠfAm B c E $Dy C O I g E `DQ,hDpALddp#BEE E(A0A8D`s 8A0A(B BBBL b 8C0A(B BBBB 4̡8uADG@W AAK }FALPBED D(G0M (A ABBG X(A ABB$\BAA D0|FD2BED D(  ABDH Y  DBBG \$ ADm AJ ,4^O A L,d`jACG i AAJ e$KLn F C$ԣ BAl C K A H_AO H F(,4BAA k ABF $d`ACQ AJ l4{BDA L ABJ WABLܤXBED D(D0] (A ABBJ i (A ABBA 4,^BAA M ADJ r ABK DdUBAA G0  AABE ^  EABJ D(BBB A(D0D@ 0A(A BBBE <e BBA A(G@ (A ABBH ,4AAG0 AAJ 4diAAG ` GAO dCAdBBB A(D0 (A BBBH D (A BBBE  (D BBBK Dp oAAG  AAG p FAQ r ADA <L BAA  DBD  ADB x[BBA A(G0V (A ABBG  (D ABBE P (C ABBD d (A ABBF D (A ABBF DPBDA G0u  AABI j  EABJ 4\BBA D(J0(A ABBLPz9BBB B(D0A8J 8A0A(B BBBH N+|NBBE B(D0A8G@ 8A0A(B BBBB P 8A0A(B BBBF  8G0A(B BBBK L|U BBB B(A0A8G 8A0A(B BBBA L̩YBHB E(D0A8GP 8A0A(B BBBF <\BEE D(C0s (A BBBC <\^BBD D(GP~ (A ABBI L8aBBB A(A0S (A BBBF A (A BBBH La BED F(G0^ (A ABBD u (A ABBE ,<xbAC DEF A DlerBBB A(A0G`N 0A(A BBBK 0g&NN̫HgKPgK$XgzAG0k AA $g <gTgAL4tgOBDD ` ABC [AB\g|BBA D(G0m (A ABBE D (F ABBI T(A ABB4 gAAF0n CAF V CAF Dph4DZ B dh|hhxhĭphALph6XNhG,h AF DGH D Drx\s BGB B(G0D8D 8A0A(B BBBE H 8F0A(B BBBA  8C0A(B BBBA L{BEB B(D0A8G 8A0A(B BBBI L4BGE B(A0A8G 8A0A(B BBBC <pBHD D(J (A ABBB 4į@ADG b AAH OAALBBD A(J (F ABBG G (F ABBA LLBBB E(A0D8G 8A0A(B BBBB LbBDD D0  AABF g  AABA A AABȋHDz B G $PD~ F GD \t $D0Z B ܱ4 AOJ DAA GCAD<\،TAC HIHHP } F  <AC DIEDS Q A Q 4ܲAC JEHS  40AC IL i F Q L؏,dAC BEIJp B PGDijBBE E(D0A8H`8A0A(B BBBD BEE F(D0A8DP8A0A(B BBB,TgDg E Y G I G F<,BDA F@]  AABB  AAB4Ĵ ADH0c AAF  AAG $hD^ F n J G<$ГBII A(A0G@f0A(A BBBdd BEE B(D0A8KZ 8D0A(B BBBK D8C0A(B BBB<̵hBBI I(D0G@0A(A BBBd ؕrBEB B(A0A8Dp8 8A0A(B BBBE D 8H0A(B BBBA Lt_BBE I(A0D8J38A0A(B BBBdĶ7BBB B(D0A8G 8A0A(B BBBC  8A0A(B BBBA $,؞hD^ F n J GdT BBB B(A0A8G 8A0A(B BBBE  8C0A(B BBBH $h~[J E S *AJ E RȣrAX E S<( T AU<t BDD  ABJ V ABG ̸%TIDBBB D(D0D` 0A(A BBBA D,ȦeBEE E(H0H8M@l8A0A(B BBBt 9D} |+    =Bg 3 pu~  )^T-!}* IDp@B`IDzJzJzJzJzJt3G3GaxJxJ}J bJJJ sJ JFJ iJ J1J oJ J1͙J dۙJ XJ2J˚JPJΚJPJњJPJnFPJ2JPJBGԚJݚJԚJGJ J?@FJAGJ2JJPJBFJ JJ aGQJJJBFQJJPJJ;F"JPJ%J/JPvJPJ9GPJiGDJ(JRJ=GFJ+JPJ'JPJ.J1J CGPJGPJ=JPJ@JPJBF3G`8GQJBF3GFCJ=JPJTG3GYzGPJIJWVGLJPJOJPJBFS>FRJPJcvJBFUJPJFpkEF(k EF`kEFPkFFHkFFk:G kt>Gk"FFk)FFk/FFk Gk9FFмk CFFk {J k>FkQFFkcFFkrFFkFFkFFkFFk:GkFFkFFk FFkFFk FFkFFk GFk#GFk9GFxk FGFpkZGF`k@FPk >F>F>F}=F9FF7GF@FFsGFFXF8F>F>F>FyGF>FGFpF>F>F>FUAFFFIFHFpFPFPFFFGFpF>FFhFF?vJGF>FpFDDJD D @`kDGy&JP!J&JX!J&JYG&J J&JV{G&J$@0HDQJQJAp7E>F kSEfEaE0k6stapsdtZE -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/unordered_map * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_UNORDERED_MAP #define _GLIBCXX_UNORDERED_MAP 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include #include #include #include #include #include // equal_to, _Identity, _Select1st #include #include #include #include #ifdef _GLIBCXX_DEBUG # include #endif #ifdef _GLIBCXX_PROFILE # include #endif #endif // C++11 #endif // _GLIBCXX_UNORDERED_MAP 4.8.2/cstdbool000064400000002571147547540550006776 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/cstdbool * This is a Standard C++ Library header. */ #pragma GCC system_header #ifndef _GLIBCXX_CSTDBOOL #define _GLIBCXX_CSTDBOOL 1 #if __cplusplus < 201103L # include #else # include # if _GLIBCXX_HAVE_STDBOOL_H # include # endif #endif #endif 4.8.2/x86_64-redhat-linux/ext/opt_random.h000064400000011224147547540550013710 0ustar00// Optimizations for random number extensions, x86 version -*- C++ -*- // Copyright (C) 2012-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/random.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ext/random} */ #ifndef _EXT_OPT_RANDOM_H #define _EXT_OPT_RANDOM_H 1 #pragma GCC system_header #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __SSE2__ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace { template inline __m128i __sse2_recursion(__m128i __a, __m128i __b, __m128i __c, __m128i __d) { __m128i __y = _mm_srli_epi32(__b, __sr1); __m128i __z = _mm_srli_si128(__c, __sr2); __m128i __v = _mm_slli_epi32(__d, __sl1); __z = _mm_xor_si128(__z, __a); __z = _mm_xor_si128(__z, __v); __m128i __x = _mm_slli_si128(__a, __sl2); __y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1)); __z = _mm_xor_si128(__z, __x); return _mm_xor_si128(__z, __y); } } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1 template void simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>:: _M_gen_rand(void) { __m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]); __m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]); size_t __i; for (__i = 0; __i < _M_nstate - __pos1; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } for (; __i < _M_nstate; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } _M_pos = 0; } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1 template bool operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __lhs, const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __rhs) { __m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]); for (size_t __i = 1; __i < __lhs._M_nstate; ++__i) __res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i], __rhs._M_state[__i])); return (_mm_movemask_epi8(__res) == 0xffff && __lhs._M_pos == __rhs._M_pos); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __SSE2__ #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #endif // _EXT_OPT_RANDOM_H 4.8.2/x86_64-redhat-linux/bits/c++config.h000064400000273661147547540550013464 0ustar00#ifndef _CPP_CPPCONFIG_WRAPPER #define _CPP_CPPCONFIG_WRAPPER 1 #include #if __WORDSIZE == 32 // Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The current version of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20150623 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) #else # define _GLIBCXX_DEPRECATED #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __EXCEPTIONS # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif // Macro for extern template, ie controling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __profile { } namespace __cxx1998 { } namespace __detail { } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } namespace placeholders { } namespace regex_constants { } namespace this_thread { } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION namespace std { inline namespace __7 { } namespace rel_ops { inline namespace __7 { } } namespace tr1 { inline namespace __7 { } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace tr2 { inline namespace __7 { } } namespace decimal { inline namespace __7 { } } namespace chrono { inline namespace __7 { } } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace this_thread { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace __gnu_cxx { inline namespace __7 { } namespace __detail { inline namespace __7 { } } } # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 { # define _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel, profile. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \ || defined(_GLIBCXX_PROFILE) namespace std { // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { #if _GLIBCXX_INLINE_VERSION inline namespace __7 { } #endif } // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif // Inline namespaces for profile mode # ifdef _GLIBCXX_PROFILE inline namespace __profile { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_CONTAINER \ _GLIBCXX_END_NAMESPACE_VERSION } # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_ALGO \ _GLIBCXX_END_NAMESPACE_VERSION } #endif #ifndef _GLIBCXX_STD_A # define _GLIBCXX_STD_A std #endif #ifndef _GLIBCXX_STD_C # define _GLIBCXX_STD_C std #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_BEGIN_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_END_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Inline namespace for long double 128 mode. #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif // Assert. #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL) # define __glibcxx_assert(_Condition) #else namespace std { // Avoid the use of assert, because we're trying to keep the // include out of the mix. inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert(_Condition) \ do \ { \ if (! (_Condition)) \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include // Pick up any CPU-specific definitions. #include // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, is known to #define min and max as macros... #undef min #undef max // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define if EBADMSG exists. */ #define _GLIBCXX_HAVE_EBADMSG 1 /* Define if ECANCELED exists. */ #define _GLIBCXX_HAVE_ECANCELED 1 /* Define if ECHILD exists. */ #define _GLIBCXX_HAVE_ECHILD 1 /* Define if EIDRM exists. */ #define _GLIBCXX_HAVE_EIDRM 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define if ENODATA exists. */ #define _GLIBCXX_HAVE_ENODATA 1 /* Define if ENOLINK exists. */ #define _GLIBCXX_HAVE_ENOLINK 1 /* Define if ENOSPC exists. */ #define _GLIBCXX_HAVE_ENOSPC 1 /* Define if ENOSR exists. */ #define _GLIBCXX_HAVE_ENOSR 1 /* Define if ENOSTR exists. */ #define _GLIBCXX_HAVE_ENOSTR 1 /* Define if ENOTRECOVERABLE exists. */ #define _GLIBCXX_HAVE_ENOTRECOVERABLE 1 /* Define if ENOTSUP exists. */ #define _GLIBCXX_HAVE_ENOTSUP 1 /* Define if EOVERFLOW exists. */ #define _GLIBCXX_HAVE_EOVERFLOW 1 /* Define if EOWNERDEAD exists. */ #define _GLIBCXX_HAVE_EOWNERDEAD 1 /* Define if EPERM exists. */ #define _GLIBCXX_HAVE_EPERM 1 /* Define if EPROTO exists. */ #define _GLIBCXX_HAVE_EPROTO 1 /* Define if ETIME exists. */ #define _GLIBCXX_HAVE_ETIME 1 /* Define if ETIMEDOUT exists. */ #define _GLIBCXX_HAVE_ETIMEDOUT 1 /* Define if ETXTBSY exists. */ #define _GLIBCXX_HAVE_ETXTBSY 1 /* Define if EWOULDBLOCK exists. */ #define _GLIBCXX_HAVE_EWOULDBLOCK 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in . */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in . */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG */ /* Define if int64_t is a long long. */ #define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ #define _GLIBCXX_HAVE_ISINF 1 /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ #define _GLIBCXX_HAVE_ISNAN 1 /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in . */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define if poll is available in . */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ #define _GLIBCXX_HAVE_SLEEP 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in . */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in . */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define if strxfrm_l is available in . */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in . */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_IFREG is available in . */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Defined if usleep exists. */ #define _GLIBCXX_HAVE_USLEEP 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in . */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for -mlong-double-64. */ /* Define if ptrdiff_t is int. */ #define _GLIBCXX_PTRDIFF_T_IS_INT 1 /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ #define _GLIBCXX_SIZE_T_IS_UINT 1 /* Define if the compiler is configured for setjmp/longjmp exceptions. */ /* #undef _GLIBCXX_SJLJ_EXCEPTIONS */ /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C99 functions or macros from , , , , and can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in should be imported in in namespace std. */ #define _GLIBCXX_USE_C99_MATH 1 /* Define if C99 functions or macros in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ #define _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if __float128 is supported on this host. */ #define _GLIBCXX_USE_FLOAT128 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in . */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ /* #undef _GLIBCXX_USE_INT128 */ /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Defined if nanosleep is available. */ /* #undef _GLIBCXX_USE_NANOSLEEP */ /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in . */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Defined if sched_yield is available. */ /* #undef _GLIBCXX_USE_SCHED_YIELD */ /* Define if _SC_NPROCESSORS_ONLN is available in . */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in . */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H #else // Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The current version of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20150623 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) #else # define _GLIBCXX_DEPRECATED #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __EXCEPTIONS # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif // Macro for extern template, ie controling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __profile { } namespace __cxx1998 { } namespace __detail { } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } namespace placeholders { } namespace regex_constants { } namespace this_thread { } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION namespace std { inline namespace __7 { } namespace rel_ops { inline namespace __7 { } } namespace tr1 { inline namespace __7 { } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace tr2 { inline namespace __7 { } } namespace decimal { inline namespace __7 { } } namespace chrono { inline namespace __7 { } } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace this_thread { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace __gnu_cxx { inline namespace __7 { } namespace __detail { inline namespace __7 { } } } # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 { # define _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel, profile. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \ || defined(_GLIBCXX_PROFILE) namespace std { // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { #if _GLIBCXX_INLINE_VERSION inline namespace __7 { } #endif } // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif // Inline namespaces for profile mode # ifdef _GLIBCXX_PROFILE inline namespace __profile { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_CONTAINER \ _GLIBCXX_END_NAMESPACE_VERSION } # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_ALGO \ _GLIBCXX_END_NAMESPACE_VERSION } #endif #ifndef _GLIBCXX_STD_A # define _GLIBCXX_STD_A std #endif #ifndef _GLIBCXX_STD_C # define _GLIBCXX_STD_C std #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_BEGIN_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_END_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Inline namespace for long double 128 mode. #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif // Assert. #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL) # define __glibcxx_assert(_Condition) #else namespace std { // Avoid the use of assert, because we're trying to keep the // include out of the mix. inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert(_Condition) \ do \ { \ if (! (_Condition)) \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include // Pick up any CPU-specific definitions. #include // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, is known to #define min and max as macros... #undef min #undef max // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define if EBADMSG exists. */ #define _GLIBCXX_HAVE_EBADMSG 1 /* Define if ECANCELED exists. */ #define _GLIBCXX_HAVE_ECANCELED 1 /* Define if ECHILD exists. */ #define _GLIBCXX_HAVE_ECHILD 1 /* Define if EIDRM exists. */ #define _GLIBCXX_HAVE_EIDRM 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define if ENODATA exists. */ #define _GLIBCXX_HAVE_ENODATA 1 /* Define if ENOLINK exists. */ #define _GLIBCXX_HAVE_ENOLINK 1 /* Define if ENOSPC exists. */ #define _GLIBCXX_HAVE_ENOSPC 1 /* Define if ENOSR exists. */ #define _GLIBCXX_HAVE_ENOSR 1 /* Define if ENOSTR exists. */ #define _GLIBCXX_HAVE_ENOSTR 1 /* Define if ENOTRECOVERABLE exists. */ #define _GLIBCXX_HAVE_ENOTRECOVERABLE 1 /* Define if ENOTSUP exists. */ #define _GLIBCXX_HAVE_ENOTSUP 1 /* Define if EOVERFLOW exists. */ #define _GLIBCXX_HAVE_EOVERFLOW 1 /* Define if EOWNERDEAD exists. */ #define _GLIBCXX_HAVE_EOWNERDEAD 1 /* Define if EPERM exists. */ #define _GLIBCXX_HAVE_EPERM 1 /* Define if EPROTO exists. */ #define _GLIBCXX_HAVE_EPROTO 1 /* Define if ETIME exists. */ #define _GLIBCXX_HAVE_ETIME 1 /* Define if ETIMEDOUT exists. */ #define _GLIBCXX_HAVE_ETIMEDOUT 1 /* Define if ETXTBSY exists. */ #define _GLIBCXX_HAVE_ETXTBSY 1 /* Define if EWOULDBLOCK exists. */ #define _GLIBCXX_HAVE_EWOULDBLOCK 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in . */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in . */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ #define _GLIBCXX_HAVE_INT64_T_LONG 1 /* Define if int64_t is a long long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG_LONG */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ #define _GLIBCXX_HAVE_ISINF 1 /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ #define _GLIBCXX_HAVE_ISNAN 1 /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in . */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define if poll is available in . */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ #define _GLIBCXX_HAVE_SLEEP 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in . */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in . */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define if strxfrm_l is available in . */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in . */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_IFREG is available in . */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Defined if usleep exists. */ #define _GLIBCXX_HAVE_USLEEP 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in . */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for -mlong-double-64. */ /* Define if ptrdiff_t is int. */ /* #undef _GLIBCXX_PTRDIFF_T_IS_INT */ /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ /* #undef _GLIBCXX_SIZE_T_IS_UINT */ /* Define if the compiler is configured for setjmp/longjmp exceptions. */ /* #undef _GLIBCXX_SJLJ_EXCEPTIONS */ /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C99 functions or macros from , , , , and can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in should be imported in in namespace std. */ #define _GLIBCXX_USE_C99_MATH 1 /* Define if C99 functions or macros in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ #define _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if __float128 is supported on this host. */ #define _GLIBCXX_USE_FLOAT128 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in . */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ #define _GLIBCXX_USE_INT128 1 /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Defined if nanosleep is available. */ /* #undef _GLIBCXX_USE_NANOSLEEP */ /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in . */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Defined if sched_yield is available. */ /* #undef _GLIBCXX_USE_SCHED_YIELD */ /* Define if _SC_NPROCESSORS_ONLN is available in . */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in . */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H #endif #endif 4.8.2/x86_64-redhat-linux/bits/gthr-posix.h000064400000057255147547540550014031 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include #ifdef HAVE_SCHED_H # include #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ 4.8.2/x86_64-redhat-linux/bits/cpu_defines.h000064400000002465147547540550014202 0ustar00// Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/cpu_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CPU_DEFINES #define _GLIBCXX_CPU_DEFINES 1 #endif 4.8.2/x86_64-redhat-linux/bits/stdc++.h000064400000005332147547540550012775 0ustar00// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif 4.8.2/x86_64-redhat-linux/bits/ctype_inline.h000064400000004354147547540550014377 0ustar00// Locale support -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/ctype_inline.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION bool ctype:: is(mask __m, char __c) const { return _M_table[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) *__vec++ = _M_table[static_cast(*__low++)]; return __high; } const char* ctype:: scan_is(mask __m, const char* __low, const char* __high) const { while (__low < __high && !(_M_table[static_cast(*__low)] & __m)) ++__low; return __low; } const char* ctype:: scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high && (_M_table[static_cast(*__low)] & __m) != 0) ++__low; return __low; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/bits/extc++.h000064400000004524147547540550013005 0ustar00// C++ includes used for precompiling extensions -*- C++ -*- // Copyright (C) 2006-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file extc++.h * This is an implementation file for a precompiled header. */ #if __cplusplus < 201103L #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _GLIBCXX_HAVE_ICONV #include #include #endif 4.8.2/x86_64-redhat-linux/bits/opt_random.h000064400000014041147547540550014051 0ustar00// Optimizations for random number functions, x86 version -*- C++ -*- // Copyright (C) 2012-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/opt_random.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{random} */ #ifndef _BITS_OPT_RANDOM_H #define _BITS_OPT_RANDOM_H 1 #include #pragma GCC system_header namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __SSE3__ template<> template void normal_distribution:: __generate(typename normal_distribution::result_type* __f, typename normal_distribution::result_type* __t, _UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef uint64_t __uctype; if (__f == __t) return; if (_M_saved_available) { _M_saved_available = false; *__f++ = _M_saved * __param.stddev() + __param.mean(); if (__f == __t) return; } constexpr uint64_t __maskval = 0xfffffffffffffull; static const __m128i __mask = _mm_set1_epi64x(__maskval); static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); static const __m128d __three = _mm_set1_pd(3.0); const __m128d __av = _mm_set1_pd(__param.mean()); const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __uerngrange = __urngrange + 1; while (__f + 1 < __t) { double __le; __m128d __x; do { union { __m128i __i; __m128d __d; } __v; if (__urngrange > __maskval) { if (__detail::_Power_of_2(__uerngrange)) __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), __urng()), __mask); else { const __uctype __uerange = __maskval + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; uint64_t __v1; do __v1 = __uctype(__urng()) - __urngmin; while (__v1 >= __past); __v1 /= __scaling; uint64_t __v2; do __v2 = __uctype(__urng()) - __urngmin; while (__v2 >= __past); __v2 /= __scaling; __v.__i = _mm_set_epi64x(__v1, __v2); } } else if (__urngrange == __maskval) __v.__i = _mm_set_epi64x(__urng(), __urng()); else if ((__urngrange + 2) * __urngrange >= __maskval && __detail::_Power_of_2(__uerngrange)) { uint64_t __v1 = __urng() * __uerngrange + __urng(); uint64_t __v2 = __urng() * __uerngrange + __urng(); __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), __mask); } else { size_t __nrng = 2; __uctype __high = __maskval / __uerngrange / __uerngrange; while (__high > __uerngrange) { ++__nrng; __high /= __uerngrange; } const __uctype __highrange = __high + 1; const __uctype __scaling = __urngrange / __highrange; const __uctype __past = __highrange * __scaling; __uctype __tmp; uint64_t __v1; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v1 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v1; __v1 *= __uerngrange; __v1 += __uctype(__urng()) - __urngmin; } } while (__v1 > __maskval || __v1 < __tmp); uint64_t __v2; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v2 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v2; __v2 *= __uerngrange; __v2 += __uctype(__urng()) - __urngmin; } } while (__v2 > __maskval || __v2 < __tmp); __v.__i = _mm_set_epi64x(__v1, __v2); } __v.__i = _mm_or_si128(__v.__i, __two); __x = _mm_sub_pd(__v.__d, __three); __m128d __m = _mm_mul_pd(__x, __x); __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); } while (__le == 0.0 || __le >= 1.0); double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) * __param.stddev()); __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); _mm_storeu_pd(__f, __x); __f += 2; } if (__f != __t) { result_type __x, __y, __r2; __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> __aurng(__urng); do { __x = result_type(2.0) * __aurng() - 1.0; __y = result_type(2.0) * __aurng() - 1.0; __r2 = __x * __x + __y * __y; } while (__r2 > 1.0 || __r2 == 0.0); const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); _M_saved = __x * __mult; _M_saved_available = true; *__f = __y * __mult * __param.stddev() + __param.mean(); } } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _BITS_OPT_RANDOM_H 4.8.2/x86_64-redhat-linux/bits/gthr-single.h000064400000015204147547540550014134 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H #define _GLIBCXX_GCC_GTHR_SINGLE_H /* Just provide compatibility for mutex handling. */ typedef int __gthread_key_t; typedef int __gthread_once_t; typedef int __gthread_mutex_t; typedef int __gthread_recursive_mutex_t; #define __GTHREAD_ONCE_INIT 0 #define __GTHREAD_MUTEX_INIT 0 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 #define _GLIBCXX_UNUSED __attribute__((unused)) #ifdef _LIBOBJC /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { /* No thread support available */ return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { /* No thread support available */ return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) { /* No thread support available */ return NULL; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) { /* No thread support available */ return -1; } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { return; } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { /* No thread support available */ /* Should we really exit the program */ /* exit (&__objc_thread_exit_status); */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { /* No thread support, use 1. */ return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { thread_local_storage = value; return 0; } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } #else /* _LIBOBJC */ static inline int __gthread_active_p (void) { return 0; } static inline int __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) { return 0; } static inline int _GLIBCXX_UNUSED __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) { return 0; } static int _GLIBCXX_UNUSED __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline void * __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #endif /* _LIBOBJC */ #undef _GLIBCXX_UNUSED #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */ 4.8.2/x86_64-redhat-linux/bits/stdtr1c++.h000064400000003315147547540550013423 0ustar00// C++ includes used for precompiling TR1 -*- C++ -*- // Copyright (C) 2006-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file stdtr1c++.h * This is an implementation file for a precompiled header. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 4.8.2/x86_64-redhat-linux/bits/c++locale.h000064400000006350147547540550013443 0ustar00// Wrapper for underlying C-language localization -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++locale.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.8 Standard locale categories. // // Written by Benjamin Kosnik #ifndef _GLIBCXX_CXX_LOCALE_H #define _GLIBCXX_CXX_LOCALE_H 1 #pragma GCC system_header #include #define _GLIBCXX_C_LOCALE_GNU 1 #define _GLIBCXX_NUM_CATEGORIES 6 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION extern "C" __typeof(uselocale) __uselocale; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __locale_t __c_locale; // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise // fall back to the unsafe vsprintf which, in general, can be dangerous // and should be avoided. inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __gnu_cxx::__uselocale(__cloc); #else char* __old = std::setlocale(LC_NUMERIC, 0); char* __sav = 0; if (__builtin_strcmp(__old, "C")) { const size_t __len = __builtin_strlen(__old) + 1; __sav = new char[__len]; __builtin_memcpy(__sav, __old, __len); std::setlocale(LC_NUMERIC, "C"); } #endif __builtin_va_list __args; __builtin_va_start(__args, __fmt); #ifdef _GLIBCXX_USE_C99 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); #endif __builtin_va_end(__args); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __gnu_cxx::__uselocale(__old); #else if (__sav) { std::setlocale(LC_NUMERIC, __sav); delete [] __sav; } #endif return __ret; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/bits/c++allocator.h000064400000003471147547540550014165 0ustar00// Base to std::allocator -*- C++ -*- // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++allocator.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{memory} */ #ifndef _GLIBCXX_CXX_ALLOCATOR_H #define _GLIBCXX_CXX_ALLOCATOR_H 1 #include #if __cplusplus >= 201103L namespace std { /** * @brief An alias to the base class for std::allocator. * @ingroup allocators * * Used to set the std::allocator base class to * __gnu_cxx::new_allocator. * * @tparam _Tp Type of allocated object. */ template using __allocator_base = __gnu_cxx::new_allocator<_Tp>; } #else // Define new_allocator as the base class to std::allocator. # define __allocator_base __gnu_cxx::new_allocator #endif #endif 4.8.2/x86_64-redhat-linux/bits/messages_members.h000064400000010003147547540550015222 0ustar00// std::messages implementation details, GNU version -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/messages_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.7.1.2 messages functions // // Written by Benjamin Kosnik #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-virtual member functions. template messages<_CharT>::messages(size_t __refs) : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), _M_name_messages(_S_get_c_name()) { } template messages<_CharT>::messages(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_messages = __tmp; } else _M_name_messages = _S_get_c_name(); // Last to avoid leaking memory if new throws. _M_c_locale_messages = _S_clone_c_locale(__cloc); } template typename messages<_CharT>::catalog messages<_CharT>::open(const basic_string& __s, const locale& __loc, const char* __dir) const { bindtextdomain(__s.c_str(), __dir); return this->do_open(__s, __loc); } // Virtual member functions. template messages<_CharT>::~messages() { if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; _S_destroy_c_locale(_M_c_locale_messages); } template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __s, const locale&) const { // No error checking is done, assume the catalog exists and can // be used. textdomain(__s.c_str()); return 0; } template void messages<_CharT>::do_close(catalog) const { } // messages_byname template messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { if (this->_M_name_messages != locale::facet::_S_get_c_name()) { delete [] this->_M_name_messages; if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); this->_M_name_messages = __tmp; } else this->_M_name_messages = locale::facet::_S_get_c_name(); } if (__builtin_strcmp(__s, "C") != 0 && __builtin_strcmp(__s, "POSIX") != 0) { this->_S_destroy_c_locale(this->_M_c_locale_messages); this->_S_create_c_locale(this->_M_c_locale_messages, __s); } } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/bits/atomic_word.h000064400000003604147547540550014221 0ustar00// Low-level type for atomic operations -*- C++ -*- // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file atomic_word.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _GLIBCXX_ATOMIC_WORD_H #define _GLIBCXX_ATOMIC_WORD_H 1 typedef int _Atomic_word; // Define these two macros using the appropriate memory barrier for the target. // The commented out versions below are the defaults. // See ia64/atomic_word.h for an alternative approach. // This one prevents loads from being hoisted across the barrier; // in other words, this is a Load-Load acquire barrier. // This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h. // #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory") // This one prevents stores from being sunk across the barrier; in other // words, a Store-Store release barrier. // #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory") #endif 4.8.2/x86_64-redhat-linux/bits/gthr-default.h000064400000057255147547540550014313 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include #ifdef HAVE_SCHED_H # include #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ 4.8.2/x86_64-redhat-linux/bits/time_members.h000064400000005565147547540550014372 0ustar00// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/time_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.5.1.2 - time_get functions // ISO C++ 14882: 22.2.5.3.2 - time_put functions // // Written by Benjamin Kosnik namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_timepunct = __tmp; } else _M_name_timepunct = _S_get_c_name(); __try { _M_initialize_timepunct(__cloc); } __catch(...) { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; __throw_exception_again; } } template __timepunct<_CharT>::~__timepunct() { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h000064400000004062147547540550014545 0ustar00// Control various target specific ABI tweaks. Generic version. // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/cxxabi_tweaks.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{cxxabi.h} */ #ifndef _CXXABI_TWEAKS_H #define _CXXABI_TWEAKS_H 1 #ifdef __cplusplus namespace __cxxabiv1 { extern "C" { #endif // The generic ABI uses the first byte of a 64-bit guard variable. #define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) #define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 #define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) #define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) #define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) __extension__ typedef int __guard __attribute__((mode (__DI__))); // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return // Constructors and destructors do not return a value. typedef void __cxa_cdtor_return_type; #ifdef __cplusplus } } // namespace __cxxabiv1 #endif #endif 4.8.2/x86_64-redhat-linux/bits/os_defines.h000064400000003367147547540550014036 0ustar00// Specific definitions for GNU/Linux -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/os_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_OS_DEFINES #define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. // This keeps isanum, et al from being propagated as macros. #define __NO_CTYPE 1 #include // Provide a declaration for the possibly deprecated gets function, as // glibc 2.15 and later does not declare gets for ISO C11 when // __GNU_SOURCE is defined. #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) # undef _GLIBCXX_HAVE_GETS #endif #endif 4.8.2/x86_64-redhat-linux/bits/basic_file.h000064400000005512147547540550013772 0ustar00// Wrapper of C-language FILE struct -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // // ISO C++ 14882: 27.8 File-based streams // /** @file bits/basic_file.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ #ifndef _GLIBCXX_BASIC_FILE_STDIO_H #define _GLIBCXX_BASIC_FILE_STDIO_H 1 #pragma GCC system_header #include #include // for __c_lock and __c_file #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Generic declaration. template class __basic_file; // Specialization. template<> class __basic_file { // Underlying data source/sink. __c_file* _M_cfile; // True iff we opened _M_cfile, and thus must close it ourselves. bool _M_cfile_created; public: __basic_file(__c_lock* __lock = 0) throw (); __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); __basic_file* sys_open(__c_file* __file, ios_base::openmode); __basic_file* sys_open(int __fd, ios_base::openmode __mode) throw (); __basic_file* close(); _GLIBCXX_PURE bool is_open() const throw (); _GLIBCXX_PURE int fd() throw (); _GLIBCXX_PURE __c_file* file() throw (); ~__basic_file(); streamsize xsputn(const char* __s, streamsize __n); streamsize xsputn_2(const char* __s1, streamsize __n1, const char* __s2, streamsize __n2); streamsize xsgetn(char* __s, streamsize __n); streamoff seekoff(streamoff __off, ios_base::seekdir __way) throw (); int sync(); streamsize showmanyc(); }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/bits/c++io.h000064400000003110147547540550012602 0ustar00// Underlying io library details -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++io.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ // c_io_stdio.h - Defines for using "C" stdio.h #ifndef _GLIBCXX_CXX_IO_H #define _GLIBCXX_CXX_IO_H 1 #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __gthread_mutex_t __c_lock; // for basic_file.h typedef FILE __c_file; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/bits/error_constants.h000064400000012071147547540550015135 0ustar00// Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/error_constants.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{system_error} */ #ifndef _GLIBCXX_ERROR_CONSTANTS #define _GLIBCXX_ERROR_CONSTANTS 1 #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, address_not_available = EADDRNOTAVAIL, already_connected = EISCONN, argument_list_too_long = E2BIG, argument_out_of_domain = EDOM, bad_address = EFAULT, bad_file_descriptor = EBADF, #ifdef _GLIBCXX_HAVE_EBADMSG bad_message = EBADMSG, #endif broken_pipe = EPIPE, connection_aborted = ECONNABORTED, connection_already_in_progress = EALREADY, connection_refused = ECONNREFUSED, connection_reset = ECONNRESET, cross_device_link = EXDEV, destination_address_required = EDESTADDRREQ, device_or_resource_busy = EBUSY, directory_not_empty = ENOTEMPTY, executable_format_error = ENOEXEC, file_exists = EEXIST, file_too_large = EFBIG, filename_too_long = ENAMETOOLONG, function_not_supported = ENOSYS, host_unreachable = EHOSTUNREACH, #ifdef _GLIBCXX_HAVE_EIDRM identifier_removed = EIDRM, #endif illegal_byte_sequence = EILSEQ, inappropriate_io_control_operation = ENOTTY, interrupted = EINTR, invalid_argument = EINVAL, invalid_seek = ESPIPE, io_error = EIO, is_a_directory = EISDIR, message_size = EMSGSIZE, network_down = ENETDOWN, network_reset = ENETRESET, network_unreachable = ENETUNREACH, no_buffer_space = ENOBUFS, no_child_process = ECHILD, #ifdef _GLIBCXX_HAVE_ENOLINK no_link = ENOLINK, #endif no_lock_available = ENOLCK, #ifdef _GLIBCXX_HAVE_ENODATA no_message_available = ENODATA, #endif no_message = ENOMSG, no_protocol_option = ENOPROTOOPT, no_space_on_device = ENOSPC, #ifdef _GLIBCXX_HAVE_ENOSR no_stream_resources = ENOSR, #endif no_such_device_or_address = ENXIO, no_such_device = ENODEV, no_such_file_or_directory = ENOENT, no_such_process = ESRCH, not_a_directory = ENOTDIR, not_a_socket = ENOTSOCK, #ifdef _GLIBCXX_HAVE_ENOSTR not_a_stream = ENOSTR, #endif not_connected = ENOTCONN, not_enough_memory = ENOMEM, #ifdef _GLIBCXX_HAVE_ENOTSUP not_supported = ENOTSUP, #endif #ifdef _GLIBCXX_HAVE_ECANCELED operation_canceled = ECANCELED, #endif operation_in_progress = EINPROGRESS, operation_not_permitted = EPERM, operation_not_supported = EOPNOTSUPP, operation_would_block = EWOULDBLOCK, #ifdef _GLIBCXX_HAVE_EOWNERDEAD owner_dead = EOWNERDEAD, #endif permission_denied = EACCES, #ifdef _GLIBCXX_HAVE_EPROTO protocol_error = EPROTO, #endif protocol_not_supported = EPROTONOSUPPORT, read_only_file_system = EROFS, resource_deadlock_would_occur = EDEADLK, resource_unavailable_try_again = EAGAIN, result_out_of_range = ERANGE, #ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE state_not_recoverable = ENOTRECOVERABLE, #endif #ifdef _GLIBCXX_HAVE_ETIME stream_timeout = ETIME, #endif #ifdef _GLIBCXX_HAVE_ETXTBSY text_file_busy = ETXTBSY, #endif timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, too_many_symbolic_link_levels = ELOOP, #ifdef _GLIBCXX_HAVE_EOVERFLOW value_too_large = EOVERFLOW, #endif wrong_protocol_type = EPROTOTYPE }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/bits/gthr.h000064400000012750147547540550012660 0ustar00/* Threads compatibility routines for libgcc2. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_H #define _GLIBCXX_GCC_GTHR_H #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility push(default) #endif /* If this file is compiled with threads support, it must #define __GTHREADS 1 to indicate that threads support is present. Also it has define function int __gthread_active_p () that returns 1 if thread system is active, 0 if not. The threads interface must define the following types: __gthread_key_t __gthread_once_t __gthread_mutex_t __gthread_recursive_mutex_t The threads interface must define the following macros: __GTHREAD_ONCE_INIT to initialize __gthread_once_t __GTHREAD_MUTEX_INIT to initialize __gthread_mutex_t to get a fast non-recursive mutex. __GTHREAD_MUTEX_INIT_FUNCTION to initialize __gthread_mutex_t to get a fast non-recursive mutex. Define this to a function which looks like this: void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) Some systems can't initialize a mutex without a function call. Don't define __GTHREAD_MUTEX_INIT in this case. __GTHREAD_RECURSIVE_MUTEX_INIT __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION as above, but for a recursive mutex. The threads interface must define the following static functions: int __gthread_once (__gthread_once_t *once, void (*func) ()) int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) int __gthread_key_delete (__gthread_key_t key) void *__gthread_getspecific (__gthread_key_t key) int __gthread_setspecific (__gthread_key_t key, const void *ptr) int __gthread_mutex_destroy (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); int __gthread_mutex_lock (__gthread_mutex_t *mutex); int __gthread_mutex_trylock (__gthread_mutex_t *mutex); int __gthread_mutex_unlock (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); The following are supported in POSIX threads only. They are required to fix a deadlock in static initialization inside libsupc++. The header file gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra features are supported. Types: __gthread_cond_t Macros: __GTHREAD_COND_INIT __GTHREAD_COND_INIT_FUNCTION Interface: int __gthread_cond_broadcast (__gthread_cond_t *cond); int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); int __gthread_cond_wait_recursive (__gthread_cond_t *cond, __gthread_recursive_mutex_t *mutex); All functions returning int should return zero on success or the error number. If the operation is not supported, -1 is returned. If the following are also defined, you should #define __GTHREADS_CXX0X 1 to enable the c++0x thread library. Types: __gthread_t __gthread_time_t Interface: int __gthread_create (__gthread_t *thread, void *(*func) (void*), void *args); int __gthread_join (__gthread_t thread, void **value_ptr); int __gthread_detach (__gthread_t thread); int __gthread_equal (__gthread_t t1, __gthread_t t2); __gthread_t __gthread_self (void); int __gthread_yield (void); int __gthread_mutex_timedlock (__gthread_mutex_t *m, const __gthread_time_t *abs_timeout); int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, const __gthread_time_t *abs_time); int __gthread_cond_signal (__gthread_cond_t *cond); int __gthread_cond_timedwait (__gthread_cond_t *cond, __gthread_mutex_t *mutex, const __gthread_time_t *abs_timeout); */ #if __GXX_WEAK__ /* The pe-coff weak support isn't fully compatible to ELF's weak. For static libraries it might would work, but as we need to deal with shared versions too, we disable it for mingw-targets. */ #ifdef __MINGW32__ #undef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #ifndef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 1 #endif #endif #include #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility pop #endif #endif /* ! _GLIBCXX_GCC_GTHR_H */ 4.8.2/x86_64-redhat-linux/bits/ctype_base.h000064400000004302147547540550014024 0ustar00// Locale support -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/ctype_base.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // Information as gleaned from /usr/include/ctype.h namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @brief Base class for ctype. struct ctype_base { // Non-standard typedefs. typedef const int* __to_type; // NB: Offsets into ctype::_M_table force a particular size // on the mask type. Because of this, we don't use an enum. typedef unsigned short mask; static const mask upper = _ISupper; static const mask lower = _ISlower; static const mask alpha = _ISalpha; static const mask digit = _ISdigit; static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; static const mask alnum = _ISalpha | _ISdigit; }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/32/ext/opt_random.h000064400000011224147547540550014134 0ustar00// Optimizations for random number extensions, x86 version -*- C++ -*- // Copyright (C) 2012-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/random.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ext/random} */ #ifndef _EXT_OPT_RANDOM_H #define _EXT_OPT_RANDOM_H 1 #pragma GCC system_header #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __SSE2__ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace { template inline __m128i __sse2_recursion(__m128i __a, __m128i __b, __m128i __c, __m128i __d) { __m128i __y = _mm_srli_epi32(__b, __sr1); __m128i __z = _mm_srli_si128(__c, __sr2); __m128i __v = _mm_slli_epi32(__d, __sl1); __z = _mm_xor_si128(__z, __a); __z = _mm_xor_si128(__z, __v); __m128i __x = _mm_slli_si128(__a, __sl2); __y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1)); __z = _mm_xor_si128(__z, __x); return _mm_xor_si128(__z, __y); } } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1 template void simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>:: _M_gen_rand(void) { __m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]); __m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]); size_t __i; for (__i = 0; __i < _M_nstate - __pos1; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } for (; __i < _M_nstate; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } _M_pos = 0; } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1 template bool operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __lhs, const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __rhs) { __m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]); for (size_t __i = 1; __i < __lhs._M_nstate; ++__i) __res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i], __rhs._M_state[__i])); return (_mm_movemask_epi8(__res) == 0xffff && __lhs._M_pos == __rhs._M_pos); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __SSE2__ #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #endif // _EXT_OPT_RANDOM_H 4.8.2/x86_64-redhat-linux/32/bits/c++config.h000064400000135625147547540550013705 0ustar00// Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The current version of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20150623 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) #else # define _GLIBCXX_DEPRECATED #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __EXCEPTIONS # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif // Macro for extern template, ie controling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __profile { } namespace __cxx1998 { } namespace __detail { } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } namespace placeholders { } namespace regex_constants { } namespace this_thread { } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION namespace std { inline namespace __7 { } namespace rel_ops { inline namespace __7 { } } namespace tr1 { inline namespace __7 { } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace tr2 { inline namespace __7 { } } namespace decimal { inline namespace __7 { } } namespace chrono { inline namespace __7 { } } namespace placeholders { inline namespace __7 { } } namespace regex_constants { inline namespace __7 { } } namespace this_thread { inline namespace __7 { } } namespace __detail { inline namespace __7 { } } } namespace __gnu_cxx { inline namespace __7 { } namespace __detail { inline namespace __7 { } } } # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 { # define _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel, profile. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \ || defined(_GLIBCXX_PROFILE) namespace std { // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { #if _GLIBCXX_INLINE_VERSION inline namespace __7 { } #endif } // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif // Inline namespaces for profile mode # ifdef _GLIBCXX_PROFILE inline namespace __profile { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG) # error illegal use of multiple inlined namespaces # endif # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_CONTAINER \ _GLIBCXX_END_NAMESPACE_VERSION } # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_ALGO \ _GLIBCXX_END_NAMESPACE_VERSION } #endif #ifndef _GLIBCXX_STD_A # define _GLIBCXX_STD_A std #endif #ifndef _GLIBCXX_STD_C # define _GLIBCXX_STD_C std #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_BEGIN_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_END_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Inline namespace for long double 128 mode. #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif // Assert. #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL) # define __glibcxx_assert(_Condition) #else namespace std { // Avoid the use of assert, because we're trying to keep the // include out of the mix. inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert(_Condition) \ do \ { \ if (! (_Condition)) \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include // Pick up any CPU-specific definitions. #include // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, is known to #define min and max as macros... #undef min #undef max // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define if EBADMSG exists. */ #define _GLIBCXX_HAVE_EBADMSG 1 /* Define if ECANCELED exists. */ #define _GLIBCXX_HAVE_ECANCELED 1 /* Define if ECHILD exists. */ #define _GLIBCXX_HAVE_ECHILD 1 /* Define if EIDRM exists. */ #define _GLIBCXX_HAVE_EIDRM 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define if ENODATA exists. */ #define _GLIBCXX_HAVE_ENODATA 1 /* Define if ENOLINK exists. */ #define _GLIBCXX_HAVE_ENOLINK 1 /* Define if ENOSPC exists. */ #define _GLIBCXX_HAVE_ENOSPC 1 /* Define if ENOSR exists. */ #define _GLIBCXX_HAVE_ENOSR 1 /* Define if ENOSTR exists. */ #define _GLIBCXX_HAVE_ENOSTR 1 /* Define if ENOTRECOVERABLE exists. */ #define _GLIBCXX_HAVE_ENOTRECOVERABLE 1 /* Define if ENOTSUP exists. */ #define _GLIBCXX_HAVE_ENOTSUP 1 /* Define if EOVERFLOW exists. */ #define _GLIBCXX_HAVE_EOVERFLOW 1 /* Define if EOWNERDEAD exists. */ #define _GLIBCXX_HAVE_EOWNERDEAD 1 /* Define if EPERM exists. */ #define _GLIBCXX_HAVE_EPERM 1 /* Define if EPROTO exists. */ #define _GLIBCXX_HAVE_EPROTO 1 /* Define if ETIME exists. */ #define _GLIBCXX_HAVE_ETIME 1 /* Define if ETIMEDOUT exists. */ #define _GLIBCXX_HAVE_ETIMEDOUT 1 /* Define if ETXTBSY exists. */ #define _GLIBCXX_HAVE_ETXTBSY 1 /* Define if EWOULDBLOCK exists. */ #define _GLIBCXX_HAVE_EWOULDBLOCK 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in . */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in . */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG */ /* Define if int64_t is a long long. */ #define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ #define _GLIBCXX_HAVE_ISINF 1 /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ #define _GLIBCXX_HAVE_ISNAN 1 /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in . */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define if poll is available in . */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ #define _GLIBCXX_HAVE_SLEEP 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in . */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in . */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define if strxfrm_l is available in . */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in . */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_IFREG is available in . */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Defined if usleep exists. */ #define _GLIBCXX_HAVE_USLEEP 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in . */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for -mlong-double-64. */ /* Define if ptrdiff_t is int. */ #define _GLIBCXX_PTRDIFF_T_IS_INT 1 /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ #define _GLIBCXX_SIZE_T_IS_UINT 1 /* Define if the compiler is configured for setjmp/longjmp exceptions. */ /* #undef _GLIBCXX_SJLJ_EXCEPTIONS */ /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C99 functions or macros from , , , , and can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX 1 /* Define if C99 functions in should be used in . Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in should be imported in in namespace std. */ #define _GLIBCXX_USE_C99_MATH 1 /* Define if C99 functions or macros in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in should be imported in in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ #define _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if __float128 is supported on this host. */ #define _GLIBCXX_USE_FLOAT128 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in . */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ /* #undef _GLIBCXX_USE_INT128 */ /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Defined if nanosleep is available. */ /* #undef _GLIBCXX_USE_NANOSLEEP */ /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in . */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Defined if sched_yield is available. */ /* #undef _GLIBCXX_USE_SCHED_YIELD */ /* Define if _SC_NPROCESSORS_ONLN is available in . */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in . */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H 4.8.2/x86_64-redhat-linux/32/bits/gthr-posix.h000064400000057255147547540550014255 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include #ifdef HAVE_SCHED_H # include #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ 4.8.2/x86_64-redhat-linux/32/bits/cpu_defines.h000064400000002465147547540550014426 0ustar00// Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/cpu_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CPU_DEFINES #define _GLIBCXX_CPU_DEFINES 1 #endif 4.8.2/x86_64-redhat-linux/32/bits/stdc++.h000064400000005332147547540550013221 0ustar00// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif 4.8.2/x86_64-redhat-linux/32/bits/ctype_inline.h000064400000004354147547540550014623 0ustar00// Locale support -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/ctype_inline.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION bool ctype:: is(mask __m, char __c) const { return _M_table[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) *__vec++ = _M_table[static_cast(*__low++)]; return __high; } const char* ctype:: scan_is(mask __m, const char* __low, const char* __high) const { while (__low < __high && !(_M_table[static_cast(*__low)] & __m)) ++__low; return __low; } const char* ctype:: scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high && (_M_table[static_cast(*__low)] & __m) != 0) ++__low; return __low; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/32/bits/extc++.h000064400000004524147547540550013231 0ustar00// C++ includes used for precompiling extensions -*- C++ -*- // Copyright (C) 2006-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file extc++.h * This is an implementation file for a precompiled header. */ #if __cplusplus < 201103L #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _GLIBCXX_HAVE_ICONV #include #include #endif 4.8.2/x86_64-redhat-linux/32/bits/opt_random.h000064400000014041147547540550014275 0ustar00// Optimizations for random number functions, x86 version -*- C++ -*- // Copyright (C) 2012-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/opt_random.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{random} */ #ifndef _BITS_OPT_RANDOM_H #define _BITS_OPT_RANDOM_H 1 #include #pragma GCC system_header namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __SSE3__ template<> template void normal_distribution:: __generate(typename normal_distribution::result_type* __f, typename normal_distribution::result_type* __t, _UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef uint64_t __uctype; if (__f == __t) return; if (_M_saved_available) { _M_saved_available = false; *__f++ = _M_saved * __param.stddev() + __param.mean(); if (__f == __t) return; } constexpr uint64_t __maskval = 0xfffffffffffffull; static const __m128i __mask = _mm_set1_epi64x(__maskval); static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); static const __m128d __three = _mm_set1_pd(3.0); const __m128d __av = _mm_set1_pd(__param.mean()); const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __uerngrange = __urngrange + 1; while (__f + 1 < __t) { double __le; __m128d __x; do { union { __m128i __i; __m128d __d; } __v; if (__urngrange > __maskval) { if (__detail::_Power_of_2(__uerngrange)) __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), __urng()), __mask); else { const __uctype __uerange = __maskval + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; uint64_t __v1; do __v1 = __uctype(__urng()) - __urngmin; while (__v1 >= __past); __v1 /= __scaling; uint64_t __v2; do __v2 = __uctype(__urng()) - __urngmin; while (__v2 >= __past); __v2 /= __scaling; __v.__i = _mm_set_epi64x(__v1, __v2); } } else if (__urngrange == __maskval) __v.__i = _mm_set_epi64x(__urng(), __urng()); else if ((__urngrange + 2) * __urngrange >= __maskval && __detail::_Power_of_2(__uerngrange)) { uint64_t __v1 = __urng() * __uerngrange + __urng(); uint64_t __v2 = __urng() * __uerngrange + __urng(); __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), __mask); } else { size_t __nrng = 2; __uctype __high = __maskval / __uerngrange / __uerngrange; while (__high > __uerngrange) { ++__nrng; __high /= __uerngrange; } const __uctype __highrange = __high + 1; const __uctype __scaling = __urngrange / __highrange; const __uctype __past = __highrange * __scaling; __uctype __tmp; uint64_t __v1; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v1 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v1; __v1 *= __uerngrange; __v1 += __uctype(__urng()) - __urngmin; } } while (__v1 > __maskval || __v1 < __tmp); uint64_t __v2; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v2 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v2; __v2 *= __uerngrange; __v2 += __uctype(__urng()) - __urngmin; } } while (__v2 > __maskval || __v2 < __tmp); __v.__i = _mm_set_epi64x(__v1, __v2); } __v.__i = _mm_or_si128(__v.__i, __two); __x = _mm_sub_pd(__v.__d, __three); __m128d __m = _mm_mul_pd(__x, __x); __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); } while (__le == 0.0 || __le >= 1.0); double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) * __param.stddev()); __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); _mm_storeu_pd(__f, __x); __f += 2; } if (__f != __t) { result_type __x, __y, __r2; __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> __aurng(__urng); do { __x = result_type(2.0) * __aurng() - 1.0; __y = result_type(2.0) * __aurng() - 1.0; __r2 = __x * __x + __y * __y; } while (__r2 > 1.0 || __r2 == 0.0); const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); _M_saved = __x * __mult; _M_saved_available = true; *__f = __y * __mult * __param.stddev() + __param.mean(); } } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _BITS_OPT_RANDOM_H 4.8.2/x86_64-redhat-linux/32/bits/gthr-single.h000064400000015204147547540550014360 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H #define _GLIBCXX_GCC_GTHR_SINGLE_H /* Just provide compatibility for mutex handling. */ typedef int __gthread_key_t; typedef int __gthread_once_t; typedef int __gthread_mutex_t; typedef int __gthread_recursive_mutex_t; #define __GTHREAD_ONCE_INIT 0 #define __GTHREAD_MUTEX_INIT 0 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 #define _GLIBCXX_UNUSED __attribute__((unused)) #ifdef _LIBOBJC /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { /* No thread support available */ return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { /* No thread support available */ return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) { /* No thread support available */ return NULL; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) { /* No thread support available */ return -1; } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { return; } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { /* No thread support available */ /* Should we really exit the program */ /* exit (&__objc_thread_exit_status); */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { /* No thread support, use 1. */ return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { thread_local_storage = value; return 0; } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } #else /* _LIBOBJC */ static inline int __gthread_active_p (void) { return 0; } static inline int __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) { return 0; } static inline int _GLIBCXX_UNUSED __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) { return 0; } static int _GLIBCXX_UNUSED __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline void * __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #endif /* _LIBOBJC */ #undef _GLIBCXX_UNUSED #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */ 4.8.2/x86_64-redhat-linux/32/bits/stdtr1c++.h000064400000003315147547540550013647 0ustar00// C++ includes used for precompiling TR1 -*- C++ -*- // Copyright (C) 2006-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file stdtr1c++.h * This is an implementation file for a precompiled header. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 4.8.2/x86_64-redhat-linux/32/bits/c++locale.h000064400000006350147547540550013667 0ustar00// Wrapper for underlying C-language localization -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++locale.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.8 Standard locale categories. // // Written by Benjamin Kosnik #ifndef _GLIBCXX_CXX_LOCALE_H #define _GLIBCXX_CXX_LOCALE_H 1 #pragma GCC system_header #include #define _GLIBCXX_C_LOCALE_GNU 1 #define _GLIBCXX_NUM_CATEGORIES 6 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION extern "C" __typeof(uselocale) __uselocale; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __locale_t __c_locale; // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise // fall back to the unsafe vsprintf which, in general, can be dangerous // and should be avoided. inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __gnu_cxx::__uselocale(__cloc); #else char* __old = std::setlocale(LC_NUMERIC, 0); char* __sav = 0; if (__builtin_strcmp(__old, "C")) { const size_t __len = __builtin_strlen(__old) + 1; __sav = new char[__len]; __builtin_memcpy(__sav, __old, __len); std::setlocale(LC_NUMERIC, "C"); } #endif __builtin_va_list __args; __builtin_va_start(__args, __fmt); #ifdef _GLIBCXX_USE_C99 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); #endif __builtin_va_end(__args); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __gnu_cxx::__uselocale(__old); #else if (__sav) { std::setlocale(LC_NUMERIC, __sav); delete [] __sav; } #endif return __ret; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/32/bits/c++allocator.h000064400000003471147547540550014411 0ustar00// Base to std::allocator -*- C++ -*- // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++allocator.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{memory} */ #ifndef _GLIBCXX_CXX_ALLOCATOR_H #define _GLIBCXX_CXX_ALLOCATOR_H 1 #include #if __cplusplus >= 201103L namespace std { /** * @brief An alias to the base class for std::allocator. * @ingroup allocators * * Used to set the std::allocator base class to * __gnu_cxx::new_allocator. * * @tparam _Tp Type of allocated object. */ template using __allocator_base = __gnu_cxx::new_allocator<_Tp>; } #else // Define new_allocator as the base class to std::allocator. # define __allocator_base __gnu_cxx::new_allocator #endif #endif 4.8.2/x86_64-redhat-linux/32/bits/messages_members.h000064400000010003147547540550015446 0ustar00// std::messages implementation details, GNU version -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/messages_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.7.1.2 messages functions // // Written by Benjamin Kosnik #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-virtual member functions. template messages<_CharT>::messages(size_t __refs) : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), _M_name_messages(_S_get_c_name()) { } template messages<_CharT>::messages(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_messages = __tmp; } else _M_name_messages = _S_get_c_name(); // Last to avoid leaking memory if new throws. _M_c_locale_messages = _S_clone_c_locale(__cloc); } template typename messages<_CharT>::catalog messages<_CharT>::open(const basic_string& __s, const locale& __loc, const char* __dir) const { bindtextdomain(__s.c_str(), __dir); return this->do_open(__s, __loc); } // Virtual member functions. template messages<_CharT>::~messages() { if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; _S_destroy_c_locale(_M_c_locale_messages); } template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __s, const locale&) const { // No error checking is done, assume the catalog exists and can // be used. textdomain(__s.c_str()); return 0; } template void messages<_CharT>::do_close(catalog) const { } // messages_byname template messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { if (this->_M_name_messages != locale::facet::_S_get_c_name()) { delete [] this->_M_name_messages; if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); this->_M_name_messages = __tmp; } else this->_M_name_messages = locale::facet::_S_get_c_name(); } if (__builtin_strcmp(__s, "C") != 0 && __builtin_strcmp(__s, "POSIX") != 0) { this->_S_destroy_c_locale(this->_M_c_locale_messages); this->_S_create_c_locale(this->_M_c_locale_messages, __s); } } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/32/bits/atomic_word.h000064400000003604147547540550014445 0ustar00// Low-level type for atomic operations -*- C++ -*- // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file atomic_word.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _GLIBCXX_ATOMIC_WORD_H #define _GLIBCXX_ATOMIC_WORD_H 1 typedef int _Atomic_word; // Define these two macros using the appropriate memory barrier for the target. // The commented out versions below are the defaults. // See ia64/atomic_word.h for an alternative approach. // This one prevents loads from being hoisted across the barrier; // in other words, this is a Load-Load acquire barrier. // This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h. // #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory") // This one prevents stores from being sunk across the barrier; in other // words, a Store-Store release barrier. // #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory") #endif 4.8.2/x86_64-redhat-linux/32/bits/gthr-default.h000064400000057255147547540550014537 0ustar00/* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include #ifdef HAVE_SCHED_H # include #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ 4.8.2/x86_64-redhat-linux/32/bits/time_members.h000064400000005565147547540550014616 0ustar00// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/time_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.5.1.2 - time_get functions // ISO C++ 14882: 22.2.5.3.2 - time_put functions // // Written by Benjamin Kosnik namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_timepunct = __tmp; } else _M_name_timepunct = _S_get_c_name(); __try { _M_initialize_timepunct(__cloc); } __catch(...) { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; __throw_exception_again; } } template __timepunct<_CharT>::~__timepunct() { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/x86_64-redhat-linux/32/bits/cxxabi_tweaks.h000064400000004062147547540550014771 0ustar00// Control various target specific ABI tweaks. Generic version. // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/cxxabi_tweaks.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{cxxabi.h} */ #ifndef _CXXABI_TWEAKS_H #define _CXXABI_TWEAKS_H 1 #ifdef __cplusplus namespace __cxxabiv1 { extern "C" { #endif // The generic ABI uses the first byte of a 64-bit guard variable. #define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) #define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 #define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) #define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) #define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) __extension__ typedef int __guard __attribute__((mode (__DI__))); // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return // Constructors and destructors do not return a value. typedef void __cxa_cdtor_return_type; #ifdef __cplusplus } } // namespace __cxxabiv1 #endif #endif 4.8.2/x86_64-redhat-linux/32/bits/os_defines.h000064400000003367147547540550014262 0ustar00// Specific definitions for GNU/Linux -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/os_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_OS_DEFINES #define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. // This keeps isanum, et al from being propagated as macros. #define __NO_CTYPE 1 #include // Provide a declaration for the possibly deprecated gets function, as // glibc 2.15 and later does not declare gets for ISO C11 when // __GNU_SOURCE is defined. #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) # undef _GLIBCXX_HAVE_GETS #endif #endif 4.8.2/x86_64-redhat-linux/32/bits/basic_file.h000064400000005512147547540550014216 0ustar00// Wrapper of C-language FILE struct -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // // ISO C++ 14882: 27.8 File-based streams // /** @file bits/basic_file.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ #ifndef _GLIBCXX_BASIC_FILE_STDIO_H #define _GLIBCXX_BASIC_FILE_STDIO_H 1 #pragma GCC system_header #include #include // for __c_lock and __c_file #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Generic declaration. template class __basic_file; // Specialization. template<> class __basic_file { // Underlying data source/sink. __c_file* _M_cfile; // True iff we opened _M_cfile, and thus must close it ourselves. bool _M_cfile_created; public: __basic_file(__c_lock* __lock = 0) throw (); __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); __basic_file* sys_open(__c_file* __file, ios_base::openmode); __basic_file* sys_open(int __fd, ios_base::openmode __mode) throw (); __basic_file* close(); _GLIBCXX_PURE bool is_open() const throw (); _GLIBCXX_PURE int fd() throw (); _GLIBCXX_PURE __c_file* file() throw (); ~__basic_file(); streamsize xsputn(const char* __s, streamsize __n); streamsize xsputn_2(const char* __s1, streamsize __n1, const char* __s2, streamsize __n2); streamsize xsgetn(char* __s, streamsize __n); streamoff seekoff(streamoff __off, ios_base::seekdir __way) throw (); int sync(); streamsize showmanyc(); }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/32/bits/c++io.h000064400000003110147547540550013026 0ustar00// Underlying io library details -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/c++io.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ // c_io_stdio.h - Defines for using "C" stdio.h #ifndef _GLIBCXX_CXX_IO_H #define _GLIBCXX_CXX_IO_H 1 #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __gthread_mutex_t __c_lock; // for basic_file.h typedef FILE __c_file; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/32/bits/error_constants.h000064400000012071147547540550015361 0ustar00// Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/error_constants.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{system_error} */ #ifndef _GLIBCXX_ERROR_CONSTANTS #define _GLIBCXX_ERROR_CONSTANTS 1 #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, address_not_available = EADDRNOTAVAIL, already_connected = EISCONN, argument_list_too_long = E2BIG, argument_out_of_domain = EDOM, bad_address = EFAULT, bad_file_descriptor = EBADF, #ifdef _GLIBCXX_HAVE_EBADMSG bad_message = EBADMSG, #endif broken_pipe = EPIPE, connection_aborted = ECONNABORTED, connection_already_in_progress = EALREADY, connection_refused = ECONNREFUSED, connection_reset = ECONNRESET, cross_device_link = EXDEV, destination_address_required = EDESTADDRREQ, device_or_resource_busy = EBUSY, directory_not_empty = ENOTEMPTY, executable_format_error = ENOEXEC, file_exists = EEXIST, file_too_large = EFBIG, filename_too_long = ENAMETOOLONG, function_not_supported = ENOSYS, host_unreachable = EHOSTUNREACH, #ifdef _GLIBCXX_HAVE_EIDRM identifier_removed = EIDRM, #endif illegal_byte_sequence = EILSEQ, inappropriate_io_control_operation = ENOTTY, interrupted = EINTR, invalid_argument = EINVAL, invalid_seek = ESPIPE, io_error = EIO, is_a_directory = EISDIR, message_size = EMSGSIZE, network_down = ENETDOWN, network_reset = ENETRESET, network_unreachable = ENETUNREACH, no_buffer_space = ENOBUFS, no_child_process = ECHILD, #ifdef _GLIBCXX_HAVE_ENOLINK no_link = ENOLINK, #endif no_lock_available = ENOLCK, #ifdef _GLIBCXX_HAVE_ENODATA no_message_available = ENODATA, #endif no_message = ENOMSG, no_protocol_option = ENOPROTOOPT, no_space_on_device = ENOSPC, #ifdef _GLIBCXX_HAVE_ENOSR no_stream_resources = ENOSR, #endif no_such_device_or_address = ENXIO, no_such_device = ENODEV, no_such_file_or_directory = ENOENT, no_such_process = ESRCH, not_a_directory = ENOTDIR, not_a_socket = ENOTSOCK, #ifdef _GLIBCXX_HAVE_ENOSTR not_a_stream = ENOSTR, #endif not_connected = ENOTCONN, not_enough_memory = ENOMEM, #ifdef _GLIBCXX_HAVE_ENOTSUP not_supported = ENOTSUP, #endif #ifdef _GLIBCXX_HAVE_ECANCELED operation_canceled = ECANCELED, #endif operation_in_progress = EINPROGRESS, operation_not_permitted = EPERM, operation_not_supported = EOPNOTSUPP, operation_would_block = EWOULDBLOCK, #ifdef _GLIBCXX_HAVE_EOWNERDEAD owner_dead = EOWNERDEAD, #endif permission_denied = EACCES, #ifdef _GLIBCXX_HAVE_EPROTO protocol_error = EPROTO, #endif protocol_not_supported = EPROTONOSUPPORT, read_only_file_system = EROFS, resource_deadlock_would_occur = EDEADLK, resource_unavailable_try_again = EAGAIN, result_out_of_range = ERANGE, #ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE state_not_recoverable = ENOTRECOVERABLE, #endif #ifdef _GLIBCXX_HAVE_ETIME stream_timeout = ETIME, #endif #ifdef _GLIBCXX_HAVE_ETXTBSY text_file_busy = ETXTBSY, #endif timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, too_many_symbolic_link_levels = ELOOP, #ifdef _GLIBCXX_HAVE_EOVERFLOW value_too_large = EOVERFLOW, #endif wrong_protocol_type = EPROTOTYPE }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/x86_64-redhat-linux/32/bits/gthr.h000064400000012750147547540550013104 0ustar00/* Threads compatibility routines for libgcc2. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _GLIBCXX_GCC_GTHR_H #define _GLIBCXX_GCC_GTHR_H #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility push(default) #endif /* If this file is compiled with threads support, it must #define __GTHREADS 1 to indicate that threads support is present. Also it has define function int __gthread_active_p () that returns 1 if thread system is active, 0 if not. The threads interface must define the following types: __gthread_key_t __gthread_once_t __gthread_mutex_t __gthread_recursive_mutex_t The threads interface must define the following macros: __GTHREAD_ONCE_INIT to initialize __gthread_once_t __GTHREAD_MUTEX_INIT to initialize __gthread_mutex_t to get a fast non-recursive mutex. __GTHREAD_MUTEX_INIT_FUNCTION to initialize __gthread_mutex_t to get a fast non-recursive mutex. Define this to a function which looks like this: void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) Some systems can't initialize a mutex without a function call. Don't define __GTHREAD_MUTEX_INIT in this case. __GTHREAD_RECURSIVE_MUTEX_INIT __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION as above, but for a recursive mutex. The threads interface must define the following static functions: int __gthread_once (__gthread_once_t *once, void (*func) ()) int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) int __gthread_key_delete (__gthread_key_t key) void *__gthread_getspecific (__gthread_key_t key) int __gthread_setspecific (__gthread_key_t key, const void *ptr) int __gthread_mutex_destroy (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); int __gthread_mutex_lock (__gthread_mutex_t *mutex); int __gthread_mutex_trylock (__gthread_mutex_t *mutex); int __gthread_mutex_unlock (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); The following are supported in POSIX threads only. They are required to fix a deadlock in static initialization inside libsupc++. The header file gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra features are supported. Types: __gthread_cond_t Macros: __GTHREAD_COND_INIT __GTHREAD_COND_INIT_FUNCTION Interface: int __gthread_cond_broadcast (__gthread_cond_t *cond); int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); int __gthread_cond_wait_recursive (__gthread_cond_t *cond, __gthread_recursive_mutex_t *mutex); All functions returning int should return zero on success or the error number. If the operation is not supported, -1 is returned. If the following are also defined, you should #define __GTHREADS_CXX0X 1 to enable the c++0x thread library. Types: __gthread_t __gthread_time_t Interface: int __gthread_create (__gthread_t *thread, void *(*func) (void*), void *args); int __gthread_join (__gthread_t thread, void **value_ptr); int __gthread_detach (__gthread_t thread); int __gthread_equal (__gthread_t t1, __gthread_t t2); __gthread_t __gthread_self (void); int __gthread_yield (void); int __gthread_mutex_timedlock (__gthread_mutex_t *m, const __gthread_time_t *abs_timeout); int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, const __gthread_time_t *abs_time); int __gthread_cond_signal (__gthread_cond_t *cond); int __gthread_cond_timedwait (__gthread_cond_t *cond, __gthread_mutex_t *mutex, const __gthread_time_t *abs_timeout); */ #if __GXX_WEAK__ /* The pe-coff weak support isn't fully compatible to ELF's weak. For static libraries it might would work, but as we need to deal with shared versions too, we disable it for mingw-targets. */ #ifdef __MINGW32__ #undef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #ifndef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 1 #endif #endif #include #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility pop #endif #endif /* ! _GLIBCXX_GCC_GTHR_H */ 4.8.2/x86_64-redhat-linux/32/bits/ctype_base.h000064400000004302147547540550014250 0ustar00// Locale support -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file bits/ctype_base.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // Information as gleaned from /usr/include/ctype.h namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @brief Base class for ctype. struct ctype_base { // Non-standard typedefs. typedef const int* __to_type; // NB: Offsets into ctype::_M_table force a particular size // on the mask type. Because of this, we don't use an enum. typedef unsigned short mask; static const mask upper = _ISupper; static const mask lower = _ISlower; static const mask alpha = _ISalpha; static const mask digit = _ISdigit; static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; static const mask alnum = _ISalpha | _ISdigit; }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace 4.8.2/ccomplex000064400000002446147547540550007000 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/ccomplex * This is a Standard C++ Library header. */ #pragma GCC system_header #ifndef _GLIBCXX_CCOMPLEX #define _GLIBCXX_CCOMPLEX 1 #if __cplusplus < 201103L # include #endif #include #endif 4.8.2/thread000064400000016124147547540550006433 0ustar00// -*- C++ -*- // Copyright (C) 2008-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/thread * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_THREAD #define _GLIBCXX_THREAD 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include #include #include #include #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @defgroup threads Threads * @ingroup concurrency * * Classes for thread support. * @{ */ /// thread class thread { public: typedef __gthread_t native_handle_type; struct _Impl_base; typedef shared_ptr<_Impl_base> __shared_base_type; /// thread::id class id { native_handle_type _M_thread; public: id() noexcept : _M_thread() { } explicit id(native_handle_type __id) : _M_thread(__id) { } private: friend class thread; friend class hash; friend bool operator==(thread::id __x, thread::id __y) noexcept { return __gthread_equal(__x._M_thread, __y._M_thread); } friend bool operator<(thread::id __x, thread::id __y) noexcept { return __x._M_thread < __y._M_thread; } template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id); }; // Simple base type that the templatized, derived class containing // an arbitrary functor can be converted to and called. struct _Impl_base { __shared_base_type _M_this_ptr; inline virtual ~_Impl_base(); virtual void _M_run() = 0; }; template struct _Impl : public _Impl_base { _Callable _M_func; _Impl(_Callable&& __f) : _M_func(std::forward<_Callable>(__f)) { } void _M_run() { _M_func(); } }; private: id _M_id; public: thread() noexcept = default; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2097. packaged_task constructors should be constrained thread(thread&) = delete; thread(const thread&) = delete; thread(thread&& __t) noexcept { swap(__t); } template explicit thread(_Callable&& __f, _Args&&... __args) { _M_start_thread(_M_make_routine(std::__bind_simple( std::forward<_Callable>(__f), std::forward<_Args>(__args)...))); } ~thread() { if (joinable()) std::terminate(); } thread& operator=(const thread&) = delete; thread& operator=(thread&& __t) noexcept { if (joinable()) std::terminate(); swap(__t); return *this; } void swap(thread& __t) noexcept { std::swap(_M_id, __t._M_id); } bool joinable() const noexcept { return !(_M_id == id()); } void join(); void detach(); thread::id get_id() const noexcept { return _M_id; } /** @pre thread is joinable */ native_handle_type native_handle() { return _M_id._M_thread; } // Returns a value that hints at the number of hardware thread contexts. static unsigned int hardware_concurrency() noexcept; private: void _M_start_thread(__shared_base_type); template shared_ptr<_Impl<_Callable>> _M_make_routine(_Callable&& __f) { // Create and allocate full data structure, not base. return std::make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f)); } }; inline thread::_Impl_base::~_Impl_base() = default; inline void swap(thread& __x, thread& __y) noexcept { __x.swap(__y); } inline bool operator!=(thread::id __x, thread::id __y) noexcept { return !(__x == __y); } inline bool operator<=(thread::id __x, thread::id __y) noexcept { return !(__y < __x); } inline bool operator>(thread::id __x, thread::id __y) noexcept { return __y < __x; } inline bool operator>=(thread::id __x, thread::id __y) noexcept { return !(__x < __y); } // DR 889. /// std::hash specialization for thread::id. template<> struct hash : public __hash_base { size_t operator()(const thread::id& __id) const noexcept { return std::_Hash_impl::hash(__id._M_thread); } }; template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id) { if (__id == thread::id()) return __out << "thread::id of a non-executing thread"; else return __out << __id._M_thread; } _GLIBCXX_END_NAMESPACE_VERSION /** @namespace std::this_thread * @brief ISO C++ 2011 entities sub-namespace for thread. * 30.3.2 Namespace this_thread. */ namespace this_thread { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// get_id inline thread::id get_id() noexcept { return thread::id(__gthread_self()); } /// yield inline void yield() noexcept { #ifdef _GLIBCXX_USE_SCHED_YIELD __gthread_yield(); #endif } void __sleep_for(chrono::seconds, chrono::nanoseconds); /// sleep_for template inline void sleep_for(const chrono::duration<_Rep, _Period>& __rtime) { auto __s = chrono::duration_cast(__rtime); auto __ns = chrono::duration_cast(__rtime - __s); #ifdef _GLIBCXX_USE_NANOSLEEP __gthread_time_t __ts = { static_cast(__s.count()), static_cast(__ns.count()) }; ::nanosleep(&__ts, 0); #else __sleep_for(__s, __ns); #endif } /// sleep_until template inline void sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) { sleep_for(__atime - _Clock::now()); } _GLIBCXX_END_NAMESPACE_VERSION } // @} group threads } // namespace #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 #endif // _GLIBCXX_THREAD 4.8.2/initializer_list000064400000005634147547540550010546 0ustar00// std::initializer_list support -*- C++ -*- // Copyright (C) 2008-2013 Free Software Foundation, Inc. // // This file is part of GCC. // // GCC is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3, or (at your option) // any later version. // // GCC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file initializer_list * This is a Standard C++ Library header. */ #ifndef _INITIALIZER_LIST #define _INITIALIZER_LIST #pragma GCC system_header #if __cplusplus < 201103L # include #else // C++0x #pragma GCC visibility push(default) #include namespace std { /// initializer_list template class initializer_list { public: typedef _E value_type; typedef const _E& reference; typedef const _E& const_reference; typedef size_t size_type; typedef const _E* iterator; typedef const _E* const_iterator; private: iterator _M_array; size_type _M_len; // The compiler can call a private constructor. constexpr initializer_list(const_iterator __a, size_type __l) : _M_array(__a), _M_len(__l) { } public: constexpr initializer_list() noexcept : _M_array(0), _M_len(0) { } // Number of elements. constexpr size_type size() const noexcept { return _M_len; } // First element. constexpr const_iterator begin() const noexcept { return _M_array; } // One past the last element. constexpr const_iterator end() const noexcept { return begin() + size(); } }; /** * @brief Return an iterator pointing to the first element of * the initilizer_list. * @param __ils Initializer list. */ template constexpr const _Tp* begin(initializer_list<_Tp> __ils) noexcept { return __ils.begin(); } /** * @brief Return an iterator pointing to one past the last element * of the initilizer_list. * @param __ils Initializer list. */ template constexpr const _Tp* end(initializer_list<_Tp> __ils) noexcept { return __ils.end(); } } #pragma GCC visibility pop #endif // C++11 #endif // _INITIALIZER_LIST 4.8.2/mutex000064400000047243147547540550006334 0ustar00// -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/mutex * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_MUTEX #define _GLIBCXX_MUTEX 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include #include #include #include #include #include #include // for std::swap #ifdef _GLIBCXX_USE_C99_STDINT_TR1 namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_HAS_GTHREADS // Common base class for std::mutex and std::timed_mutex class __mutex_base { protected: typedef __gthread_mutex_t __native_type; #ifdef __GTHREAD_MUTEX_INIT __native_type _M_mutex = __GTHREAD_MUTEX_INIT; constexpr __mutex_base() noexcept = default; #else __native_type _M_mutex; __mutex_base() noexcept { // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); } ~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); } #endif __mutex_base(const __mutex_base&) = delete; __mutex_base& operator=(const __mutex_base&) = delete; }; // Common base class for std::recursive_mutex and std::timed_recursive_mutex class __recursive_mutex_base { protected: typedef __gthread_recursive_mutex_t __native_type; __recursive_mutex_base(const __recursive_mutex_base&) = delete; __recursive_mutex_base& operator=(const __recursive_mutex_base&) = delete; #ifdef __GTHREAD_RECURSIVE_MUTEX_INIT __native_type _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT; __recursive_mutex_base() = default; #else __native_type _M_mutex; __recursive_mutex_base() { // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); } ~__recursive_mutex_base() { __gthread_recursive_mutex_destroy(&_M_mutex); } #endif }; /** * @defgroup mutexes Mutexes * @ingroup concurrency * * Classes for mutex support. * @{ */ /// mutex class mutex : private __mutex_base { public: typedef __native_type* native_handle_type; #ifdef __GTHREAD_MUTEX_INIT constexpr #endif mutex() noexcept = default; ~mutex() = default; mutex(const mutex&) = delete; mutex& operator=(const mutex&) = delete; void lock() { int __e = __gthread_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) if (__e) __throw_system_error(__e); } bool try_lock() noexcept { // XXX EINVAL, EAGAIN, EBUSY return !__gthread_mutex_trylock(&_M_mutex); } void unlock() { // XXX EINVAL, EAGAIN, EPERM __gthread_mutex_unlock(&_M_mutex); } native_handle_type native_handle() { return &_M_mutex; } }; /// recursive_mutex class recursive_mutex : private __recursive_mutex_base { public: typedef __native_type* native_handle_type; recursive_mutex() = default; ~recursive_mutex() = default; recursive_mutex(const recursive_mutex&) = delete; recursive_mutex& operator=(const recursive_mutex&) = delete; void lock() { int __e = __gthread_recursive_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) if (__e) __throw_system_error(__e); } bool try_lock() noexcept { // XXX EINVAL, EAGAIN, EBUSY return !__gthread_recursive_mutex_trylock(&_M_mutex); } void unlock() { // XXX EINVAL, EAGAIN, EBUSY __gthread_recursive_mutex_unlock(&_M_mutex); } native_handle_type native_handle() { return &_M_mutex; } }; #if _GTHREAD_USE_MUTEX_TIMEDLOCK /// timed_mutex class timed_mutex : private __mutex_base { #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC typedef chrono::steady_clock __clock_t; #else typedef chrono::high_resolution_clock __clock_t; #endif public: typedef __native_type* native_handle_type; timed_mutex() = default; ~timed_mutex() = default; timed_mutex(const timed_mutex&) = delete; timed_mutex& operator=(const timed_mutex&) = delete; void lock() { int __e = __gthread_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) if (__e) __throw_system_error(__e); } bool try_lock() noexcept { // XXX EINVAL, EAGAIN, EBUSY return !__gthread_mutex_trylock(&_M_mutex); } template bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { return _M_try_lock_for(__rtime); } template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_until(__atime); } void unlock() { // XXX EINVAL, EAGAIN, EBUSY __gthread_mutex_unlock(&_M_mutex); } native_handle_type native_handle() { return &_M_mutex; } private: template bool _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime); if (ratio_greater<__clock_t::period, _Period>()) ++__rt; return _M_try_lock_until(__clock_t::now() + __rt); } template bool _M_try_lock_until(const chrono::time_point<__clock_t, _Duration>& __atime) { chrono::time_point<__clock_t, chrono::seconds> __s = chrono::time_point_cast(__atime); chrono::nanoseconds __ns = chrono::duration_cast(__atime - __s); __gthread_time_t __ts = { static_cast(__s.time_since_epoch().count()), static_cast(__ns.count()) }; return !__gthread_mutex_timedlock(native_handle(), &__ts); } template bool _M_try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_for(__atime - _Clock::now()); } }; /// recursive_timed_mutex class recursive_timed_mutex : private __recursive_mutex_base { #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC typedef chrono::steady_clock __clock_t; #else typedef chrono::high_resolution_clock __clock_t; #endif public: typedef __native_type* native_handle_type; recursive_timed_mutex() = default; ~recursive_timed_mutex() = default; recursive_timed_mutex(const recursive_timed_mutex&) = delete; recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; void lock() { int __e = __gthread_recursive_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) if (__e) __throw_system_error(__e); } bool try_lock() noexcept { // XXX EINVAL, EAGAIN, EBUSY return !__gthread_recursive_mutex_trylock(&_M_mutex); } template bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { return _M_try_lock_for(__rtime); } template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_until(__atime); } void unlock() { // XXX EINVAL, EAGAIN, EBUSY __gthread_recursive_mutex_unlock(&_M_mutex); } native_handle_type native_handle() { return &_M_mutex; } private: template bool _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime); if (ratio_greater<__clock_t::period, _Period>()) ++__rt; return _M_try_lock_until(__clock_t::now() + __rt); } template bool _M_try_lock_until(const chrono::time_point<__clock_t, _Duration>& __atime) { chrono::time_point<__clock_t, chrono::seconds> __s = chrono::time_point_cast(__atime); chrono::nanoseconds __ns = chrono::duration_cast(__atime - __s); __gthread_time_t __ts = { static_cast(__s.time_since_epoch().count()), static_cast(__ns.count()) }; return !__gthread_mutex_timedlock(native_handle(), &__ts); } template bool _M_try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_for(__atime - _Clock::now()); } }; #endif #endif // _GLIBCXX_HAS_GTHREADS /// Do not acquire ownership of the mutex. struct defer_lock_t { }; /// Try to acquire ownership of the mutex without blocking. struct try_to_lock_t { }; /// Assume the calling thread has already obtained mutex ownership /// and manage it. struct adopt_lock_t { }; constexpr defer_lock_t defer_lock { }; constexpr try_to_lock_t try_to_lock { }; constexpr adopt_lock_t adopt_lock { }; /// @brief Scoped lock idiom. // Acquire the mutex here with a constructor call, then release with // the destructor call in accordance with RAII style. template class lock_guard { public: typedef _Mutex mutex_type; explicit lock_guard(mutex_type& __m) : _M_device(__m) { _M_device.lock(); } lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m) { } // calling thread owns mutex ~lock_guard() { _M_device.unlock(); } lock_guard(const lock_guard&) = delete; lock_guard& operator=(const lock_guard&) = delete; private: mutex_type& _M_device; }; /// unique_lock template class unique_lock { public: typedef _Mutex mutex_type; unique_lock() noexcept : _M_device(0), _M_owns(false) { } explicit unique_lock(mutex_type& __m) : _M_device(&__m), _M_owns(false) { lock(); _M_owns = true; } unique_lock(mutex_type& __m, defer_lock_t) noexcept : _M_device(&__m), _M_owns(false) { } unique_lock(mutex_type& __m, try_to_lock_t) : _M_device(&__m), _M_owns(_M_device->try_lock()) { } unique_lock(mutex_type& __m, adopt_lock_t) : _M_device(&__m), _M_owns(true) { // XXX calling thread owns mutex } template unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __atime) : _M_device(&__m), _M_owns(_M_device->try_lock_until(__atime)) { } template unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __rtime) : _M_device(&__m), _M_owns(_M_device->try_lock_for(__rtime)) { } ~unique_lock() { if (_M_owns) unlock(); } unique_lock(const unique_lock&) = delete; unique_lock& operator=(const unique_lock&) = delete; unique_lock(unique_lock&& __u) noexcept : _M_device(__u._M_device), _M_owns(__u._M_owns) { __u._M_device = 0; __u._M_owns = false; } unique_lock& operator=(unique_lock&& __u) noexcept { if(_M_owns) unlock(); unique_lock(std::move(__u)).swap(*this); __u._M_device = 0; __u._M_owns = false; return *this; } void lock() { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_device->lock(); _M_owns = true; } } bool try_lock() { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock(); return _M_owns; } } template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock_until(__atime); return _M_owns; } } template bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock_for(__rtime); return _M_owns; } } void unlock() { if (!_M_owns) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_device) { _M_device->unlock(); _M_owns = false; } } void swap(unique_lock& __u) noexcept { std::swap(_M_device, __u._M_device); std::swap(_M_owns, __u._M_owns); } mutex_type* release() noexcept { mutex_type* __ret = _M_device; _M_device = 0; _M_owns = false; return __ret; } bool owns_lock() const noexcept { return _M_owns; } explicit operator bool() const noexcept { return owns_lock(); } mutex_type* mutex() const noexcept { return _M_device; } private: mutex_type* _M_device; bool _M_owns; // XXX use atomic_bool }; /// Partial specialization for unique_lock objects. template inline void swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept { __x.swap(__y); } template struct __unlock_impl { template static void __do_unlock(tuple<_Lock&...>& __locks) { std::get<_Idx>(__locks).unlock(); __unlock_impl<_Idx - 1>::__do_unlock(__locks); } }; template<> struct __unlock_impl<-1> { template static void __do_unlock(tuple<_Lock&...>&) { } }; template unique_lock<_Lock> __try_to_lock(_Lock& __l) { return unique_lock<_Lock>(__l, try_to_lock); } template struct __try_lock_impl { template static void __do_try_lock(tuple<_Lock&...>& __locks, int& __idx) { __idx = _Idx; auto __lock = __try_to_lock(std::get<_Idx>(__locks)); if (__lock.owns_lock()) { __try_lock_impl<_Idx + 1, _Idx + 2 < sizeof...(_Lock)>:: __do_try_lock(__locks, __idx); if (__idx == -1) __lock.release(); } } }; template struct __try_lock_impl<_Idx, false> { template static void __do_try_lock(tuple<_Lock&...>& __locks, int& __idx) { __idx = _Idx; auto __lock = __try_to_lock(std::get<_Idx>(__locks)); if (__lock.owns_lock()) { __idx = -1; __lock.release(); } } }; /** @brief Generic try_lock. * @param __l1 Meets Mutex requirements (try_lock() may throw). * @param __l2 Meets Mutex requirements (try_lock() may throw). * @param __l3 Meets Mutex requirements (try_lock() may throw). * @return Returns -1 if all try_lock() calls return true. Otherwise returns * a 0-based index corresponding to the argument that returned false. * @post Either all arguments are locked, or none will be. * * Sequentially calls try_lock() on each argument. */ template int try_lock(_Lock1& __l1, _Lock2& __l2, _Lock3&... __l3) { int __idx; auto __locks = std::tie(__l1, __l2, __l3...); __try { __try_lock_impl<0>::__do_try_lock(__locks, __idx); } __catch(...) { } return __idx; } /** @brief Generic lock. * @param __l1 Meets Mutex requirements (try_lock() may throw). * @param __l2 Meets Mutex requirements (try_lock() may throw). * @param __l3 Meets Mutex requirements (try_lock() may throw). * @throw An exception thrown by an argument's lock() or try_lock() member. * @post All arguments are locked. * * All arguments are locked via a sequence of calls to lock(), try_lock() * and unlock(). If the call exits via an exception any locks that were * obtained will be released. */ template void lock(_L1& __l1, _L2& __l2, _L3&... __l3) { while (true) { unique_lock<_L1> __first(__l1); int __idx; auto __locks = std::tie(__l2, __l3...); __try_lock_impl<0, sizeof...(_L3)>::__do_try_lock(__locks, __idx); if (__idx == -1) { __first.release(); return; } } } #ifdef _GLIBCXX_HAS_GTHREADS /// once_flag struct once_flag { private: typedef __gthread_once_t __native_type; __native_type _M_once = __GTHREAD_ONCE_INIT; public: /// Constructor constexpr once_flag() noexcept = default; /// Deleted copy constructor once_flag(const once_flag&) = delete; /// Deleted assignment operator once_flag& operator=(const once_flag&) = delete; template friend void call_once(once_flag& __once, _Callable&& __f, _Args&&... __args); }; #ifdef _GLIBCXX_HAVE_TLS extern __thread void* __once_callable; extern __thread void (*__once_call)(); template inline void __once_call_impl() { (*(_Callable*)__once_callable)(); } #else extern function __once_functor; extern void __set_once_functor_lock_ptr(unique_lock*); extern mutex& __get_once_mutex(); #endif extern "C" void __once_proxy(void); /// call_once template void call_once(once_flag& __once, _Callable&& __f, _Args&&... __args) { #ifdef _GLIBCXX_HAVE_TLS auto __bound_functor = std::__bind_simple(std::forward<_Callable>(__f), std::forward<_Args>(__args)...); __once_callable = &__bound_functor; __once_call = &__once_call_impl; #else unique_lock __functor_lock(__get_once_mutex()); auto __callable = std::__bind_simple(std::forward<_Callable>(__f), std::forward<_Args>(__args)...); __once_functor = [&]() { __callable(); }; __set_once_functor_lock_ptr(&__functor_lock); #endif int __e = __gthread_once(&(__once._M_once), &__once_proxy); #ifndef _GLIBCXX_HAVE_TLS if (__functor_lock) __set_once_functor_lock_ptr(0); #endif if (__e) __throw_system_error(__e); } #endif // _GLIBCXX_HAS_GTHREADS // @} group mutexes _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 #endif // _GLIBCXX_MUTEX 4.8.2/sstream000064400000047112147547540550006643 0ustar00// String based streams -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/sstream * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.7 String-based streams // #ifndef _GLIBCXX_SSTREAM #define _GLIBCXX_SSTREAM 1 #pragma GCC system_header #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // [27.7.1] template class basic_stringbuf /** * @brief The actual work of input and output (for std::string). * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class associates either or both of its input and output sequences * with a sequence of characters, which can be initialized from, or made * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.) * * For this class, open modes (of type @c ios_base::openmode) have * @c in set if the input sequence can be read, and @c out set if the * output sequence can be written. */ template class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef basic_streambuf __streambuf_type; typedef basic_string __string_type; typedef typename __string_type::size_type __size_type; protected: /// Place to stash in || out || in | out settings for current stringbuf. ios_base::openmode _M_mode; // Data Members: __string_type _M_string; public: // Constructors: /** * @brief Starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * The default constructor initializes the parent class using its * own default ctor. */ explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) : __streambuf_type(), _M_mode(__mode), _M_string() { } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * This constructor initializes the parent class using its * own default ctor. */ explicit basic_stringbuf(const __string_type& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size()) { _M_stringbuf_init(__mode); } // Get and set: /** * @brief Copying out the string buffer. * @return A copy of one of the underlying sequences. * * If the buffer is only created in input mode, the underlying * character sequence is equal to the input sequence; otherwise, it * is equal to the output sequence. [27.7.1.2]/1 */ __string_type str() const { __string_type __ret; if (this->pptr()) { // The current egptr() may not be the actual string end. if (this->pptr() > this->egptr()) __ret = __string_type(this->pbase(), this->pptr()); else __ret = __string_type(this->pbase(), this->egptr()); } else __ret = _M_string; return __ret; } /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Deallocates any previous stored sequence, then copies @a s to * use as a new one. */ void str(const __string_type& __s) { // Cannot use _M_string = __s, since v3 strings are COW. _M_string.assign(__s.data(), __s.size()); _M_stringbuf_init(_M_mode); } protected: // Common initialization code goes here. void _M_stringbuf_init(ios_base::openmode __mode) { _M_mode = __mode; __size_type __len = 0; if (_M_mode & (ios_base::ate | ios_base::app)) __len = _M_string.size(); _M_sync(const_cast(_M_string.data()), 0, __len); } virtual streamsize showmanyc() { streamsize __ret = -1; if (_M_mode & ios_base::in) { _M_update_egptr(); __ret = this->egptr() - this->gptr(); } return __ret; } virtual int_type underflow(); virtual int_type pbackfail(int_type __c = traits_type::eof()); virtual int_type overflow(int_type __c = traits_type::eof()); /** * @brief Manipulates the buffer. * @param __s Pointer to a buffer area. * @param __n Size of @a __s. * @return @c this * * If no buffer has already been created, and both @a __s and @a __n are * non-zero, then @c __s is used as a buffer; see * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html * for more. */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n) { if (__s && __n >= 0) { // This is implementation-defined behavior, and assumes // that an external char_type array of length __n exists // and has been pre-allocated. If this is not the case, // things will quickly blow up. // Step 1: Destroy the current internal array. _M_string.clear(); // Step 2: Use the external array. _M_sync(__s, __n, 0); } return this; } virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out); // Internal function for correctly updating the internal buffer // for a particular _M_string, due to initialization or re-sizing // of an existing _M_string. void _M_sync(char_type* __base, __size_type __i, __size_type __o); // Internal function for correctly updating egptr() to the actual // string end. void _M_update_egptr() { const bool __testin = _M_mode & ios_base::in; if (this->pptr() && this->pptr() > this->egptr()) { if (__testin) this->setg(this->eback(), this->gptr(), this->pptr()); else this->setg(this->pptr(), this->pptr(), this->pptr()); } } // Works around the issue with pbump, part of the protected // interface of basic_streambuf, taking just an int. void _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off); }; // [27.7.2] Template class basic_istringstream /** * @brief Controlling input for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports reading from objects of type std::basic_string, * using the inherited functions from std::basic_istream. To control * the associated sequence, an instance of std::basic_stringbuf is used, * which this page refers to as @c sb. */ template class basic_istringstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_istream __istream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors: /** * @brief Default constructor starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::in is automatically included in @a __mode. * * Initializes @c sb using @c __mode|in, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_istringstream(ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_stringbuf(__mode | ios_base::in) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::in is automatically included in @a mode. * * Initializes @c sb using @a str and @c mode|in, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_istringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_istringstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const { return _M_stringbuf.str(); } /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } }; // [27.7.3] Template class basic_ostringstream /** * @brief Controlling output for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports writing to objects of type std::basic_string, * using the inherited functions from std::basic_ostream. To control * the associated sequence, an instance of std::basic_stringbuf is used, * which this page refers to as @c sb. */ template class basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_ostream __ostream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors/destructor: /** * @brief Default constructor starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::out is automatically included in @a mode. * * Initializes @c sb using @c mode|out, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_ostringstream(ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_stringbuf(__mode | ios_base::out) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::out is automatically included in @a mode. * * Initializes @c sb using @a str and @c mode|out, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_ostringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_ostringstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const { return _M_stringbuf.str(); } /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } }; // [27.7.4] Template class basic_stringstream /** * @brief Controlling input and output for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports reading from and writing to objects of type * std::basic_string, using the inherited functions from * std::basic_iostream. To control the associated sequence, an instance * of std::basic_stringbuf is used, which this page refers to as @c sb. */ template class basic_stringstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard Types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_iostream __iostream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors/destructors /** * @brief Default constructor starts with an empty string buffer. * @param __m Whether the buffer can read, or write, or both. * * Initializes @c sb using the mode from @c __m, and passes @c * &sb to the base class initializer. Does not allocate any * buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in) : __iostream_type(), _M_stringbuf(__m) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __m Whether the buffer can read, or write, or both. * * Initializes @c sb using @a __str and @c __m, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_stringstream(const __string_type& __str, ios_base::openmode __m = ios_base::out | ios_base::in) : __iostream_type(), _M_stringbuf(__str, __m) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_stringstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const { return _M_stringbuf.str(); } /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #include #endif /* _GLIBCXX_SSTREAM */ 4.8.2/profile/unordered_map000064400000035413147547540550011452 0ustar00// Profiling unordered_map/unordered_multimap implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/unordered_map * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_UNORDERED_MAP #define _GLIBCXX_PROFILE_UNORDERED_MAP 1 #if __cplusplus < 201103L # include #else # include #include #include #define _GLIBCXX_BASE unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::unordered_map wrapper with performance instrumentation. template, typename _Pred = std::equal_to<_Key>, typename _Alloc = std::allocator > > class unordered_map : public _GLIBCXX_STD_BASE, public _Unordered_profile, true> { typedef typename _GLIBCXX_STD_BASE _Base; _Base& _M_base() noexcept { return *this; } const _Base& _M_base() const noexcept { return *this; } public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; typedef typename _Base::allocator_type allocator_type; typedef typename _Base::key_type key_type; typedef typename _Base::value_type value_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::mapped_type mapped_type; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; explicit unordered_map(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __eql, __a) { } template unordered_map(_InputIterator __f, _InputIterator __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } unordered_map(const unordered_map&) = default; unordered_map(const _Base& __x) : _Base(__x) { } unordered_map(unordered_map&&) = default; unordered_map(initializer_list __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__l, __n, __hf, __eql, __a) { } unordered_map& operator=(const unordered_map&) = default; unordered_map& operator=(unordered_map&&) = default; unordered_map& operator=(initializer_list __l) { _M_base() = __l; return *this; } void clear() noexcept { __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); this->_M_profile_destruct(); _Base::clear(); } template std::pair emplace(_Args&&... __args) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::emplace(std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } template iterator emplace_hint(const_iterator __it, _Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace_hint(__it, std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } void insert(std::initializer_list __l) { size_type __old_size = _Base::bucket_count(); _Base::insert(__l); _M_profile_resize(__old_size); } std::pair insert(const value_type& __obj) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::insert(__obj); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, const value_type& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, __v); _M_profile_resize(__old_size); return __res; } template::value>::type> std::pair insert(_Pair&& __obj) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::insert(std::forward<_Pair>(__obj)); _M_profile_resize(__old_size); return __res; } template::value>::type> iterator insert(const_iterator __iter, _Pair&& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v)); _M_profile_resize(__old_size); return __res; } template void insert(_InputIter __first, _InputIter __last) { size_type __old_size = _Base::bucket_count(); _Base::insert(__first, __last); _M_profile_resize(__old_size); } // operator[] mapped_type& operator[](const _Key& __k) { size_type __old_size = _Base::bucket_count(); mapped_type& __res = _M_base()[__k]; _M_profile_resize(__old_size); return __res; } mapped_type& operator[](_Key&& __k) { size_type __old_size = _Base::bucket_count(); mapped_type& __res = _M_base()[std::move(__k)]; _M_profile_resize(__old_size); return __res; } void swap(unordered_map& __x) { _Base::swap(__x._M_base()); } void rehash(size_type __n) { size_type __old_size = _Base::bucket_count(); _Base::rehash(__n); _M_profile_resize(__old_size); } private: void _M_profile_resize(size_type __old_size) { size_type __new_size = _Base::bucket_count(); if (__old_size != __new_size) __profcxx_hashtable_resize(this, __old_size, __new_size); } }; template inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { return static_cast(__x) == __y; } template inline bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { return !(__x == __y); } #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE /// Class std::unordered_multimap wrapper with performance instrumentation. template, typename _Pred = std::equal_to<_Key>, typename _Alloc = std::allocator > > class unordered_multimap : public _GLIBCXX_STD_BASE, public _Unordered_profile, false> { typedef typename _GLIBCXX_STD_BASE _Base; _Base& _M_base() noexcept { return *this; } const _Base& _M_base() const noexcept { return *this; } public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; typedef typename _Base::allocator_type allocator_type; typedef typename _Base::key_type key_type; typedef typename _Base::value_type value_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; explicit unordered_multimap(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __eql, __a) { } template unordered_multimap(_InputIterator __f, _InputIterator __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } unordered_multimap(const unordered_multimap&) = default; unordered_multimap(const _Base& __x) : _Base(__x) { } unordered_multimap(unordered_multimap&&) = default; unordered_multimap(initializer_list __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__l, __n, __hf, __eql, __a) { } unordered_multimap& operator=(const unordered_multimap&) = default; unordered_multimap& operator=(unordered_multimap&&) = default; unordered_multimap& operator=(initializer_list __l) { _M_base() = __l; return *this; } void clear() noexcept { __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); this->_M_profile_destruct(); _Base::clear(); } template iterator emplace(_Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace(std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } template iterator emplace_hint(const_iterator __it, _Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace_hint(__it, std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } void insert(std::initializer_list __l) { size_type __old_size = _Base::bucket_count(); _Base::insert(__l); _M_profile_resize(__old_size); } iterator insert(const value_type& __obj) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__obj); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, const value_type& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, __v); _M_profile_resize(__old_size); return __res; } template::value>::type> iterator insert(_Pair&& __obj) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(std::forward<_Pair>(__obj)); _M_profile_resize(__old_size); return __res; } template::value>::type> iterator insert(const_iterator __iter, _Pair&& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v)); _M_profile_resize(__old_size); return __res; } template void insert(_InputIter __first, _InputIter __last) { size_type __old_size = _Base::bucket_count(); _Base::insert(__first, __last); _M_profile_resize(__old_size); } void swap(unordered_multimap& __x) { _Base::swap(__x._M_base()); } void rehash(size_type __n) { size_type __old_size = _Base::bucket_count(); _Base::rehash(__n); _M_profile_resize(__old_size); } private: void _M_profile_resize(size_type __old_size) { size_type __new_size = _Base::bucket_count(); if (__old_size != __new_size) __profcxx_hashtable_resize(this, __old_size, __new_size); } }; template inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { return static_cast(__x) == __y; } template inline bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { return !(__x == __y); } } // namespace __profile } // namespace std #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #endif // C++11 #endif 4.8.2/profile/unordered_set000064400000033064147547540550011470 0ustar00// Profiling unordered_set/unordered_multiset implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/unordered_set * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_UNORDERED_SET #define _GLIBCXX_PROFILE_UNORDERED_SET 1 #if __cplusplus < 201103L # include #else # include #include #include #define _GLIBCXX_BASE unordered_set<_Key, _Hash, _Pred, _Alloc> #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /** @brief Unordered_set wrapper with performance instrumentation. */ template, typename _Pred = std::equal_to<_Key>, typename _Alloc = std::allocator<_Key> > class unordered_set : public _GLIBCXX_STD_BASE, public _Unordered_profile, true> { typedef _GLIBCXX_STD_BASE _Base; _Base& _M_base() noexcept { return *this; } const _Base& _M_base() const noexcept { return *this; } public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; typedef typename _Base::allocator_type allocator_type; typedef typename _Base::key_type key_type; typedef typename _Base::value_type value_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; explicit unordered_set(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __eql, __a) { } template unordered_set(_InputIterator __f, _InputIterator __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } unordered_set(const unordered_set&) = default; unordered_set(const _Base& __x) : _Base(__x) { } unordered_set(unordered_set&&) = default; unordered_set(initializer_list __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__l, __n, __hf, __eql, __a) { } unordered_set& operator=(const unordered_set&) = default; unordered_set& operator=(unordered_set&&) = default; unordered_set& operator=(initializer_list __l) { _M_base() = __l; return *this; } void swap(unordered_set& __x) { _Base::swap(__x); } void clear() noexcept { __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); this->_M_profile_destruct(); _Base::clear(); } template std::pair emplace(_Args&&... __args) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::emplace(std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } template iterator emplace_hint(const_iterator __it, _Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace_hint(__it, std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } void insert(std::initializer_list __l) { size_type __old_size = _Base::bucket_count(); _Base::insert(__l); _M_profile_resize(__old_size); } std::pair insert(const value_type& __obj) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::insert(__obj); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, const value_type& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, __v); _M_profile_resize(__old_size); return __res; } std::pair insert(value_type&& __obj) { size_type __old_size = _Base::bucket_count(); std::pair __res = _Base::insert(std::move(__obj)); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, value_type&& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, std::move(__v)); _M_profile_resize(__old_size); return __res; } template void insert(_InputIter __first, _InputIter __last) { size_type __old_size = _Base::bucket_count(); _Base::insert(__first, __last); _M_profile_resize(__old_size); } void rehash(size_type __n) { size_type __old_size = _Base::bucket_count(); _Base::rehash(__n); _M_profile_resize(__old_size); } private: void _M_profile_resize(size_type __old_size) { size_type __new_size = _Base::bucket_count(); if (__old_size != __new_size) __profcxx_hashtable_resize(this, __old_size, __new_size); } }; template inline void swap(unordered_set<_Key, _Hash, _Pred, _Alloc>& __x, unordered_set<_Key, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline bool operator==(const unordered_set<_Key, _Hash, _Pred, _Alloc>& __x, const unordered_set<_Key, _Hash, _Pred, _Alloc>& __y) { return static_cast(__x) == __y; } template inline bool operator!=(const unordered_set<_Key, _Hash, _Pred, _Alloc>& __x, const unordered_set<_Key, _Hash, _Pred, _Alloc>& __y) { return !(__x == __y); } #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE #define _GLIBCXX_BASE unordered_multiset<_Value, _Hash, _Pred, _Alloc> /** @brief Unordered_multiset wrapper with performance instrumentation. */ template, typename _Pred = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class unordered_multiset : public _GLIBCXX_STD_BASE, public _Unordered_profile, false> { typedef _GLIBCXX_STD_BASE _Base; _Base& _M_base() noexcept { return *this; } const _Base& _M_base() const noexcept { return *this; } public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; typedef typename _Base::allocator_type allocator_type; typedef typename _Base::key_type key_type; typedef typename _Base::value_type value_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; explicit unordered_multiset(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __eql, __a) { } template unordered_multiset(_InputIterator __f, _InputIterator __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } unordered_multiset(const unordered_multiset&) = default; unordered_multiset(const _Base& __x) : _Base(__x) { } unordered_multiset(unordered_multiset&&) = default; unordered_multiset(initializer_list __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Base(__l, __n, __hf, __eql, __a) { } unordered_multiset& operator=(const unordered_multiset&) = default; unordered_multiset& operator=(unordered_multiset&&) = default; unordered_multiset& operator=(initializer_list __l) { _M_base() = __l; return *this; } void swap(unordered_multiset& __x) { _Base::swap(__x); } void clear() noexcept { __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); this->_M_profile_destruct(); _Base::clear(); } template iterator emplace(_Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace(std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } template iterator emplace_hint(const_iterator __it, _Args&&... __args) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::emplace_hint(__it, std::forward<_Args>(__args)...); _M_profile_resize(__old_size); return __res; } void insert(std::initializer_list __l) { size_type __old_size = _Base::bucket_count(); _Base::insert(__l); _M_profile_resize(__old_size); } iterator insert(const value_type& __obj) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__obj); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, const value_type& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, __v); _M_profile_resize(__old_size); return __res; } iterator insert(value_type&& __obj) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(std::move(__obj)); _M_profile_resize(__old_size); return __res; } iterator insert(const_iterator __iter, value_type&& __v) { size_type __old_size = _Base::bucket_count(); iterator __res = _Base::insert(__iter, std::move(__v)); _M_profile_resize(__old_size); return __res; } template void insert(_InputIter __first, _InputIter __last) { size_type __old_size = _Base::bucket_count(); _Base::insert(__first, __last); _M_profile_resize(__old_size); } void rehash(size_type __n) { size_type __old_size = _Base::bucket_count(); _Base::rehash(__n); _M_profile_resize(__old_size); } private: void _M_profile_resize(size_type __old_size) { size_type __new_size = _Base::bucket_count(); if (__old_size != __new_size) __profcxx_hashtable_resize(this, __old_size, __new_size); } }; template inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { return static_cast(__x) == __y; } template inline bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { return !(__x == __y); } } // namespace __profile } // namespace std #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #endif // C++11 #endif 4.8.2/profile/list000064400000040551147547540550007600 0ustar00// Profiling list implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/list * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_LIST #define _GLIBCXX_PROFILE_LIST 1 #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /** @brief List wrapper with performance instrumentation. */ template > class list : public _GLIBCXX_STD_C::list<_Tp, _Allocator> { typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base; public: typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef __iterator_tracker iterator; typedef __iterator_tracker const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // 23.2.2.1 construct/copy/destroy: explicit list(const _Allocator& __a = _Allocator()) : _Base(__a) { __profcxx_list_construct(this); // list2slist __profcxx_list_construct2(this); // list2vector } #if __cplusplus >= 201103L explicit list(size_type __n) : _Base(__n) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } list(size_type __n, const _Tp& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } #else explicit list(size_type __n, const _Tp& __value = _Tp(), const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } #endif #if __cplusplus >= 201103L template> #else template #endif list(_InputIterator __first, _InputIterator __last, const _Allocator& __a = _Allocator()) : _Base(__first, __last, __a) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } list(const list& __x) : _Base(__x) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } list(const _Base& __x) : _Base(__x) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } #if __cplusplus >= 201103L list(list&& __x) noexcept : _Base(std::move(__x)) { __profcxx_list_construct(this); __profcxx_list_construct2(this); } list(initializer_list __l, const allocator_type& __a = allocator_type()) : _Base(__l, __a) { } #endif ~list() _GLIBCXX_NOEXCEPT { __profcxx_list_destruct(this); __profcxx_list_destruct2(this); } list& operator=(const list& __x) { static_cast<_Base&>(*this) = __x; return *this; } #if __cplusplus >= 201103L list& operator=(list&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } list& operator=(initializer_list __l) { static_cast<_Base&>(*this) = __l; return *this; } void assign(initializer_list __l) { _Base::assign(__l); } #endif #if __cplusplus >= 201103L template> #else template #endif void assign(_InputIterator __first, _InputIterator __last) { _Base::assign(__first, __last); } void assign(size_type __n, const _Tp& __t) { _Base::assign(__n, __t); } using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin(), this); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin(), this); } iterator end() _GLIBCXX_NOEXCEPT { __profcxx_list_rewind(this); return iterator(_Base::end(), this); } const_iterator end() const _GLIBCXX_NOEXCEPT { __profcxx_list_rewind(this); return const_iterator(_Base::end(), this); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { __profcxx_list_rewind(this); return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { __profcxx_list_rewind(this); return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin(), this); } const_iterator cend() const noexcept { return const_iterator(_Base::end(), this); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // 23.2.2.2 capacity: using _Base::empty; using _Base::size; using _Base::max_size; #if __cplusplus >= 201103L void resize(size_type __sz) { _Base::resize(__sz); } void resize(size_type __sz, const _Tp& __c) { _Base::resize(__sz, __c); } #else void resize(size_type __sz, _Tp __c = _Tp()) { _Base::resize(__sz, __c); } #endif // element access: reference front() { return _Base::front(); } const_reference front() const { return _Base::front(); } reference back() { __profcxx_list_rewind(this); return _Base::back(); } const_reference back() const { __profcxx_list_rewind(this); return _Base::back(); } // 23.2.2.3 modifiers: void push_front(const value_type& __x) { __profcxx_list_invalid_operator(this); __profcxx_list_operation(this); _Base::push_front(__x); } #if __cplusplus >= 201103L using _Base::emplace_front; #endif void pop_front() { __profcxx_list_operation(this); _Base::pop_front(); } using _Base::push_back; #if __cplusplus >= 201103L using _Base::emplace_back; #endif void pop_back() { iterator __victim = end(); --__victim; _Base::pop_back(); __profcxx_list_rewind(this); } #if __cplusplus >= 201103L template iterator emplace(iterator __position, _Args&&... __args) { return iterator(_Base::emplace(__position.base(), std::forward<_Args>(__args)...), this); } #endif iterator insert(iterator __position, const _Tp& __x) { _M_profile_insert(this, __position, size()); return iterator(_Base::insert(__position.base(), __x), this); } #if __cplusplus >= 201103L iterator insert(iterator __position, _Tp&& __x) { _M_profile_insert(this, __position, size()); return iterator(_Base::emplace(__position.base(), std::move(__x)), this); } void insert(iterator __position, initializer_list __l) { _M_profile_insert(this, __position, size()); _Base::insert(__position.base(), __l); } #endif void insert(iterator __position, size_type __n, const _Tp& __x) { _M_profile_insert(this, __position, size()); _Base::insert(__position.base(), __n, __x); } #if __cplusplus >= 201103L template> #else template #endif void insert(iterator __position, _InputIterator __first, _InputIterator __last) { _M_profile_insert(this, __position, size()); _Base::insert(__position.base(), __first, __last); } iterator erase(iterator __position) { return iterator(_Base::erase(__position.base()), this); } iterator erase(iterator __position, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container return iterator(_Base::erase(__position.base(), __last.base()), this); } void swap(list& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { _Base::clear(); } // 23.2.2.4 list operations: void #if __cplusplus >= 201103L splice(iterator __position, list&& __x) #else splice(iterator __position, list& __x) #endif { this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); } #if __cplusplus >= 201103L void splice(iterator __position, list& __x) { this->splice(__position, std::move(__x)); } #endif #if __cplusplus >= 201103L void splice(iterator __position, list& __x, iterator __i) { this->splice(__position, std::move(__x), __i); } #endif void #if __cplusplus >= 201103L splice(iterator __position, list&& __x, iterator __i) #else splice(iterator __position, list& __x, iterator __i) #endif { // We used to perform the splice_alloc check: not anymore, redundant // after implementing the relevant bits of N1599. // _GLIBCXX_RESOLVE_LIB_DEFECTS _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), __i.base()); } void #if __cplusplus >= 201103L splice(iterator __position, list&& __x, iterator __first, iterator __last) #else splice(iterator __position, list& __x, iterator __first, iterator __last) #endif { // We used to perform the splice_alloc check: not anymore, redundant // after implementing the relevant bits of N1599. _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), __first.base(), __last.base()); } #if __cplusplus >= 201103L void splice(iterator __position, list& __x, iterator __first, iterator __last) { this->splice(__position, std::move(__x), __first, __last); } #endif void remove(const _Tp& __value) { for (iterator __x = begin(); __x != end(); ) { if (*__x == __value) __x = erase(__x); else ++__x; } } template void remove_if(_Predicate __pred) { for (iterator __x = begin(); __x != end(); ) { __profcxx_list_operation(this); if (__pred(*__x)) __x = erase(__x); else ++__x; } } void unique() { iterator __first = begin(); iterator __last = end(); if (__first == __last) return; iterator __next = __first; while (++__next != __last) { __profcxx_list_operation(this); if (*__first == *__next) erase(__next); else __first = __next; __next = __first; } } template void unique(_BinaryPredicate __binary_pred) { iterator __first = begin(); iterator __last = end(); if (__first == __last) return; iterator __next = __first; while (++__next != __last) { __profcxx_list_operation(this); if (__binary_pred(*__first, *__next)) erase(__next); else __first = __next; __next = __first; } } void #if __cplusplus >= 201103L merge(list&& __x) #else merge(list& __x) #endif { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 300. list::merge() specification incomplete if (this != &__x) { _Base::merge(_GLIBCXX_MOVE(__x._M_base())); } } #if __cplusplus >= 201103L void merge(list& __x) { this->merge(std::move(__x)); } #endif template void #if __cplusplus >= 201103L merge(list&& __x, _Compare __comp) #else merge(list& __x, _Compare __comp) #endif { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 300. list::merge() specification incomplete if (this != &__x) { _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); } } #if __cplusplus >= 201103L template void merge(list& __x, _Compare __comp) { this->merge(std::move(__x), __comp); } #endif void sort() { _Base::sort(); } template void sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); } using _Base::reverse; _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } void _M_profile_find() const { } void _M_profile_iterate(int __rewind = 0) const { __profcxx_list_operation(this); __profcxx_list_iterate(this); if (__rewind) __profcxx_list_rewind(this); } private: size_type _M_profile_insert(void* obj, iterator __pos, size_type __size) { size_type __shift = 0; typename _Base::iterator __it = __pos.base(); for ( ; __it!=_Base::end(); __it++) __shift++; __profcxx_list_rewind(this); __profcxx_list_operation(this); __profcxx_list_insert(this, __shift, __size); } }; template inline bool operator==(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } } // namespace __profile } // namespace std #endif 4.8.2/profile/impl/profiler_map_to_unordered_map.h000064400000017307147547540550016104 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_map_to_unordered_map.h * @brief Diagnostics for map to unordered_map. */ // Written by Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H #define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { inline int __log2(std::size_t __size) { for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0; -- __bit_count) if ((2 << __bit_count) & __size) return __bit_count; return 0; } inline float __map_insert_cost(std::size_t __size) { return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value * static_cast(__log2(__size))); } inline float __map_erase_cost(std::size_t __size) { return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value * static_cast(__log2(__size))); } inline float __map_find_cost(std::size_t __size) { return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value * static_cast(__log2(__size))); } /** @brief A map-to-unordered_map instrumentation line in the object table. */ class __map2umap_info : public __object_info_base { public: __map2umap_info() : _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { } __map2umap_info(__stack_t __stack) : __object_info_base(__stack), _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { } virtual ~__map2umap_info() { } __map2umap_info(const __map2umap_info& __o) : __object_info_base(__o), _M_insert(__o._M_insert), _M_erase(__o._M_erase), _M_find(__o._M_find), _M_iterate(__o._M_iterate), _M_umap_cost(__o._M_umap_cost), _M_map_cost(__o._M_map_cost), _M_valid(__o._M_valid) { } void __merge(const __map2umap_info& __o) { _M_insert += __o._M_insert; _M_erase += __o._M_erase; _M_find += __o._M_find; _M_umap_cost += __o._M_umap_cost; _M_map_cost += __o._M_map_cost; _M_valid &= __o._M_valid; } void __write(FILE* __f) const { std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n", _M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost, _M_umap_cost, _M_valid ? "valid" : "invalid"); } float __magnitude() const { return _M_map_cost - _M_umap_cost; } std::string __advice() const { return "change std::map to std::unordered_map"; } void __record_insert(std::size_t __size, std::size_t __count) { _M_insert += __count; _M_map_cost += __count * __map_insert_cost(__size); _M_umap_cost += (__count * _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value); } void __record_erase(std::size_t __size, std::size_t __count) { _M_erase += __count; _M_map_cost += __count * __map_erase_cost(__size); _M_umap_cost += (__count * _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value); } void __record_find(std::size_t __size) { _M_find += 1; _M_map_cost += __map_find_cost(__size); _M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value; } void __record_iterate(std::size_t __count) { _M_iterate += __count; _M_map_cost += (__count * _GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor).__value); _M_umap_cost += (__count * _GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor).__value); } void __record_invalidate() { _M_valid = false; } private: std::size_t _M_insert; std::size_t _M_erase; std::size_t _M_find; std::size_t _M_iterate; float _M_umap_cost; float _M_map_cost; bool _M_valid; }; /** @brief A map-to-unordered_map instrumentation line in the stack table. */ class __map2umap_stack_info : public __map2umap_info { public: __map2umap_stack_info(const __map2umap_info& __o) : __map2umap_info(__o) { } }; /** @brief Map-to-unordered_map instrumentation producer. */ class __trace_map2umap : public __trace_base<__map2umap_info, __map2umap_stack_info> { public: __trace_map2umap() : __trace_base<__map2umap_info, __map2umap_stack_info>() { __id = "map-to-unordered-map"; } }; inline void __trace_map_to_unordered_map_init() { _GLIBCXX_PROFILE_DATA(_S_map2umap) = new __trace_map2umap(); } inline void __trace_map_to_unordered_map_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_map2umap)) { _GLIBCXX_PROFILE_DATA(_S_map2umap)->__collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_map2umap)->__write(__f); } } inline void __trace_map_to_unordered_map_construct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_map2umap)-> __add_object(__obj, __map2umap_info(__get_stack())); } inline void __trace_map_to_unordered_map_destruct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_map2umap)->__retire_object(__obj); } inline void __trace_map_to_unordered_map_insert(const void* __obj, std::size_t __size, std::size_t __count) { if (!__profcxx_init()) return; __map2umap_info* __info = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj); if (__info) __info->__record_insert(__size, __count); } inline void __trace_map_to_unordered_map_erase(const void* __obj, std::size_t __size, std::size_t __count) { if (!__profcxx_init()) return; __map2umap_info* __info = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj); if (__info) __info->__record_erase(__size, __count); } inline void __trace_map_to_unordered_map_find(const void* __obj, std::size_t __size) { if (!__profcxx_init()) return; __map2umap_info* __info = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj); if (__info) __info->__record_find(__size); } inline void __trace_map_to_unordered_map_iterate(const void* __obj, std::size_t __count) { if (!__profcxx_init()) return; __map2umap_info* __info = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj); if (__info) __info->__record_iterate(__count); } inline void __trace_map_to_unordered_map_invalidate(const void* __obj) { if (!__profcxx_init()) return; __map2umap_info* __info = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj); if (__info) __info->__record_invalidate(); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H */ 4.8.2/profile/impl/profiler.h000064400000037424147547540550011643 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler.h * @brief Interface of the profiling runtime library. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_H #define _GLIBCXX_PROFILE_PROFILER_H 1 #include // Mechanism to define data with inline linkage. #define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \ inline __type& \ __get_##__name() \ { \ static __type __name; \ return __name; \ } #define _GLIBCXX_PROFILE_DEFINE_DATA(__type, __name, __initial_value...) \ inline __type& __get_##__name() { \ static __type __name(__initial_value); \ return __name; \ } #define _GLIBCXX_PROFILE_DATA(__name) \ __get_##__name() namespace __gnu_profile { /** @brief Reentrance guard. * * Mechanism to protect all __gnu_profile operations against recursion, * multithreaded and exception reentrance. */ struct __reentrance_guard { static bool __get_in() { if (__inside() == true) return false; else { __inside() = true; return true; } } static bool& __inside() { static __thread bool _S_inside(false); return _S_inside; } __reentrance_guard() { } ~__reentrance_guard() { __inside() = false; } }; #define _GLIBCXX_PROFILE_REENTRANCE_GUARD(__x...) \ { \ if (__gnu_profile::__reentrance_guard::__get_in()) \ { \ __gnu_profile::__reentrance_guard __get_out; \ __x; \ } \ } // Forward declarations of implementation functions. // Don't use any __gnu_profile:: in user code. // Instead, use the __profcxx... macros, which offer guarded access. bool __turn_on(); bool __turn_off(); bool __is_invalid(); bool __is_on(); bool __is_off(); void __report(void); void __trace_hashtable_size_resize(const void*, std::size_t, std::size_t); void __trace_hashtable_size_destruct(const void*, std::size_t, std::size_t); void __trace_hashtable_size_construct(const void*, std::size_t); void __trace_vector_size_resize(const void*, std::size_t, std::size_t); void __trace_vector_size_destruct(const void*, std::size_t, std::size_t); void __trace_vector_size_construct(const void*, std::size_t); void __trace_hash_func_destruct(const void*, std::size_t, std::size_t, std::size_t); void __trace_hash_func_construct(const void*); void __trace_vector_to_list_destruct(const void*); void __trace_vector_to_list_construct(const void*); void __trace_vector_to_list_insert(const void*, std::size_t, std::size_t); void __trace_vector_to_list_iterate(const void*, std::size_t); void __trace_vector_to_list_invalid_operator(const void*); void __trace_vector_to_list_resize(const void*, std::size_t, std::size_t); void __trace_vector_to_list_find(const void*, std::size_t); void __trace_list_to_slist_destruct(const void*); void __trace_list_to_slist_construct(const void*); void __trace_list_to_slist_rewind(const void*); void __trace_list_to_slist_operation(const void*); void __trace_list_to_vector_destruct(const void*); void __trace_list_to_vector_construct(const void*); void __trace_list_to_vector_insert(const void*, std::size_t, std::size_t); void __trace_list_to_vector_iterate(const void*, std::size_t); void __trace_list_to_vector_invalid_operator(const void*); void __trace_list_to_vector_resize(const void*, std::size_t, std::size_t); void __trace_list_to_set_destruct(const void*); void __trace_list_to_set_construct(const void*); void __trace_list_to_set_insert(const void*, std::size_t, std::size_t); void __trace_list_to_set_iterate(const void*, std::size_t); void __trace_list_to_set_invalid_operator(const void*); void __trace_list_to_set_find(const void*, std::size_t); void __trace_map_to_unordered_map_construct(const void*); void __trace_map_to_unordered_map_invalidate(const void*); void __trace_map_to_unordered_map_insert(const void*, std::size_t, std::size_t); void __trace_map_to_unordered_map_erase(const void*, std::size_t, std::size_t); void __trace_map_to_unordered_map_iterate(const void*, std::size_t); void __trace_map_to_unordered_map_find(const void*, std::size_t); void __trace_map_to_unordered_map_destruct(const void*); } // namespace __gnu_profile // Master switch turns on all diagnostics that are not explicitly turned off. #ifdef _GLIBCXX_PROFILE #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_SMALL #define _GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL #endif #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_LARGE #define _GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE #endif #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_SMALL #define _GLIBCXX_PROFILE_VECTOR_TOO_SMALL #endif #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_LARGE #define _GLIBCXX_PROFILE_VECTOR_TOO_LARGE #endif #ifndef _GLIBCXX_PROFILE_NO_INEFFICIENT_HASH #define _GLIBCXX_PROFILE_INEFFICIENT_HASH #endif #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TO_LIST #define _GLIBCXX_PROFILE_VECTOR_TO_LIST #endif #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_SLIST #define _GLIBCXX_PROFILE_LIST_TO_SLIST #endif #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_VECTOR #define _GLIBCXX_PROFILE_LIST_TO_VECTOR #endif #ifndef _GLIBCXX_PROFILE_NO_MAP_TO_UNORDERED_MAP #define _GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP #endif #endif // Expose global management routines to user code. #ifdef _GLIBCXX_PROFILE #define __profcxx_report() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__report()) #define __profcxx_turn_on() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_on()) #define __profcxx_turn_off() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_off()) #define __profcxx_is_invalid() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_invalid()) #define __profcxx_is_on() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_on()) #define __profcxx_is_off() \ _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_off()) #else #define __profcxx_report() #define __profcxx_turn_on() #define __profcxx_turn_off() #define __profcxx_is_invalid() #define __profcxx_is_on() #define __profcxx_is_off() #endif // Turn on/off instrumentation for HASHTABLE_TOO_SMALL and HASHTABLE_TOO_LARGE. #if (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \ || defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE)) #define __profcxx_hashtable_resize(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_hashtable_size_resize(__x)) #define __profcxx_hashtable_destruct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_hashtable_size_destruct(__x)) #define __profcxx_hashtable_construct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_hashtable_size_construct(__x)) #else #define __profcxx_hashtable_resize(__x...) #define __profcxx_hashtable_destruct(__x...) #define __profcxx_hashtable_construct(__x...) #endif // Turn on/off instrumentation for VECTOR_TOO_SMALL and VECTOR_TOO_LARGE. #if (defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \ || defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE)) #define __profcxx_vector_resize(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_size_resize(__x)) #define __profcxx_vector_destruct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_size_destruct(__x)) #define __profcxx_vector_construct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_size_construct(__x)) #else #define __profcxx_vector_resize(__x...) #define __profcxx_vector_destruct(__x...) #define __profcxx_vector_construct(__x...) #endif // Turn on/off instrumentation for INEFFICIENT_HASH. #if defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH) #define __profcxx_inefficient_hash_is_on() \ __gnu_profile::__is_on() #define __profcxx_hashtable_construct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_hash_func_construct(__x)) #define __profcxx_hashtable_destruct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_hash_func_destruct(__x)) #else #define __profcxx_inefficient_hash_is_on() false #define __profcxx_hashtable_destruct2(__x...) #define __profcxx_hashtable_construct2(__x...) #endif // Turn on/off instrumentation for VECTOR_TO_LIST. #if defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST) #define __profcxx_vector_construct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_construct(__x)) #define __profcxx_vector_destruct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_destruct(__x)) #define __profcxx_vector_insert(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_insert(__x)) #define __profcxx_vector_iterate(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_iterate(__x)) #define __profcxx_vector_invalid_operator(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_invalid_operator(__x)) #define __profcxx_vector_resize2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_resize(__x)) #define __profcxx_vector_find(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_vector_to_list_find(__x)) #else #define __profcxx_vector_destruct2(__x...) #define __profcxx_vector_construct2(__x...) #define __profcxx_vector_insert(__x...) #define __profcxx_vector_iterate(__x...) #define __profcxx_vector_invalid_operator(__x...) #define __profcxx_vector_resize2(__x...) #define __profcxx_vector_find(__x...) #endif // Turn on/off instrumentation for LIST_TO_VECTOR. #if defined(_GLIBCXX_PROFILE_LIST_TO_VECTOR) #define __profcxx_list_construct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_vector_construct(__x)) #define __profcxx_list_destruct2(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_vector_destruct(__x)) #define __profcxx_list_insert(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_vector_insert(__x)) #define __profcxx_list_iterate(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_vector_iterate(__x)) #define __profcxx_list_invalid_operator(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_vector_invalid_operator(__x)) #else #define __profcxx_list_destruct2(__x...) #define __profcxx_list_construct2(__x...) #define __profcxx_list_insert(__x...) #define __profcxx_list_iterate(__x...) #define __profcxx_list_invalid_operator(__x...) #endif // Turn on/off instrumentation for LIST_TO_SLIST. #if defined(_GLIBCXX_PROFILE_LIST_TO_SLIST) #define __profcxx_list_rewind(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_slist_rewind(__x)) #define __profcxx_list_operation(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_slist_operation(__x)) #define __profcxx_list_destruct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_slist_destruct(__x)) #define __profcxx_list_construct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_list_to_slist_construct(__x)) #else #define __profcxx_list_rewind(__x...) #define __profcxx_list_operation(__x...) #define __profcxx_list_destruct(__x...) #define __profcxx_list_construct(__x...) #endif // Turn on/off instrumentation for MAP_TO_UNORDERED_MAP. #if defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP) #define __profcxx_map_to_unordered_map_construct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_construct(__x)) #define __profcxx_map_to_unordered_map_destruct(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_destruct(__x)) #define __profcxx_map_to_unordered_map_insert(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_insert(__x)) #define __profcxx_map_to_unordered_map_erase(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_erase(__x)) #define __profcxx_map_to_unordered_map_iterate(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_iterate(__x)) #define __profcxx_map_to_unordered_map_invalidate(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_invalidate(__x)) #define __profcxx_map_to_unordered_map_find(__x...) \ _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ __gnu_profile::__trace_map_to_unordered_map_find(__x)) #else #define __profcxx_map_to_unordered_map_construct(__x...) \ #define __profcxx_map_to_unordered_map_destruct(__x...) #define __profcxx_map_to_unordered_map_insert(__x...) #define __profcxx_map_to_unordered_map_erase(__x...) #define __profcxx_map_to_unordered_map_iterate(__x...) #define __profcxx_map_to_unordered_map_invalidate(__x...) #define __profcxx_map_to_unordered_map_find(__x...) #endif // Set default values for compile-time customizable variables. #ifndef _GLIBCXX_PROFILE_TRACE_PATH_ROOT #define _GLIBCXX_PROFILE_TRACE_PATH_ROOT "libstdcxx-profile" #endif #ifndef _GLIBCXX_PROFILE_TRACE_ENV_VAR #define _GLIBCXX_PROFILE_TRACE_ENV_VAR "_GLIBCXX_PROFILE_TRACE_PATH_ROOT" #endif #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR #define _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR \ "_GLIBCXX_PROFILE_MAX_WARN_COUNT" #endif #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT #define _GLIBCXX_PROFILE_MAX_WARN_COUNT 10 #endif #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH 32 #endif #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR \ "_GLIBCXX_PROFILE_MAX_STACK_DEPTH" #endif #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC (1 << 28) #endif #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR \ "_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC" #endif // Instrumentation hook implementations. #include "profile/impl/profiler_hash_func.h" #include "profile/impl/profiler_hashtable_size.h" #include "profile/impl/profiler_map_to_unordered_map.h" #include "profile/impl/profiler_vector_size.h" #include "profile/impl/profiler_vector_to_list.h" #include "profile/impl/profiler_list_to_slist.h" #include "profile/impl/profiler_list_to_vector.h" #endif // _GLIBCXX_PROFILE_PROFILER_H 4.8.2/profile/impl/profiler_list_to_vector.h000064400000020604147547540550014752 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_list_to_vector.h * @brief diagnostics for list to vector. */ // Written by Changhee Jung. #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1 #include #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { /** @brief A list-to-vector instrumentation line in the object table. */ class __list2vector_info : public __object_info_base { public: __list2vector_info() : _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true), _M_max_size(0) { } __list2vector_info(__stack_t __stack) : __object_info_base(__stack), _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true), _M_max_size(0) { } virtual ~__list2vector_info() { } __list2vector_info(const __list2vector_info& __o) : __object_info_base(__o), _M_shift_count(__o._M_shift_count), _M_iterate(__o._M_iterate), _M_resize(__o._M_resize), _M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost), _M_valid(__o._M_valid), _M_max_size(__o._M_max_size) { } void __merge(const __list2vector_info& __o) { _M_shift_count += __o._M_shift_count; _M_iterate += __o._M_iterate; _M_vector_cost += __o._M_vector_cost; _M_list_cost += __o._M_list_cost; _M_valid &= __o._M_valid; _M_resize += __o._M_resize; _M_max_size = std::max( _M_max_size, __o._M_max_size); } void __write(FILE* __f) const { std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize, _M_iterate, _M_vector_cost, _M_list_cost); } float __magnitude() const { return _M_list_cost - _M_vector_cost; } std::string __advice() const { std::stringstream __sstream; __sstream << "change std::list to std::vector and its initial size from 0 to " << _M_max_size; return __sstream.str(); } std::size_t __shift_count() { return _M_shift_count; } std::size_t __iterate() { return _M_iterate; } float __list_cost() { return _M_list_cost; } std::size_t __resize() { return _M_resize; } void __set_list_cost(float __lc) { _M_list_cost = __lc; } void __set_vector_cost(float __vc) { _M_vector_cost = __vc; } bool __is_valid() { return _M_valid; } void __set_invalid() { _M_valid = false; } void __opr_insert(std::size_t __shift, std::size_t __size) { _M_shift_count += __shift; _M_max_size = std::max(_M_max_size, __size); } void __opr_iterate(std::size_t __num) { _M_iterate += __num;} void __resize(std::size_t __from, std::size_t) { _M_resize += __from; } private: std::size_t _M_shift_count; std::size_t _M_iterate; std::size_t _M_resize; float _M_list_cost; float _M_vector_cost; bool _M_valid; std::size_t _M_max_size; }; class __list2vector_stack_info : public __list2vector_info { public: __list2vector_stack_info(const __list2vector_info& __o) : __list2vector_info(__o) {} }; class __trace_list_to_vector : public __trace_base<__list2vector_info, __list2vector_stack_info> { public: __trace_list_to_vector() : __trace_base<__list2vector_info, __list2vector_stack_info>() { __id = "list-to-vector"; } ~__trace_list_to_vector() { } // Insert a new node at construct with object, callstack and initial size. void __insert(__object_t __obj, __stack_t __stack) { __add_object(__obj, __list2vector_info(__stack)); } // Call at destruction/clean to set container final size. void __destruct(const void* __obj) { if (!__is_on()) return; __list2vector_info* __res = __get_object_info(__obj); if (!__res) return; float __vc = __vector_cost(__res->__shift_count(), __res->__iterate()); float __lc = __list_cost(__res->__shift_count(), __res->__iterate()); __res->__set_vector_cost(__vc); __res->__set_list_cost(__lc); __retire_object(__obj); } // Find the node in the live map. __list2vector_info* __find(const void* __obj); // Collect cost of operations. void __opr_insert(const void* __obj, std::size_t __shift, std::size_t __size) { __list2vector_info* __res = __get_object_info(__obj); if (__res) __res->__opr_insert(__shift, __size); } void __opr_iterate(const void* __obj, std::size_t __num) { __list2vector_info* __res = __get_object_info(__obj); if (__res) __res->__opr_iterate(__num); } void __invalid_operator(const void* __obj) { __list2vector_info* __res = __get_object_info(__obj); if (__res) __res->__set_invalid(); } void __resize(const void* __obj, std::size_t __from, std::size_t __to) { __list2vector_info* __res = __get_object_info(__obj); if (__res) __res->__resize(__from, __to); } float __vector_cost(std::size_t __shift, std::size_t __iterate) { // The resulting vector will use a 'reserve' method. return (__shift * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value + __iterate * _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value); } float __list_cost(std::size_t __shift, std::size_t __iterate) { return (__shift * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value + __iterate * _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value); } }; inline void __trace_list_to_vector_init() { _GLIBCXX_PROFILE_DATA(_S_list_to_vector) = new __trace_list_to_vector(); } inline void __trace_list_to_vector_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_list_to_vector)) { _GLIBCXX_PROFILE_DATA(_S_list_to_vector)-> __collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__write(__f); } } inline void __trace_list_to_vector_construct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__insert(__obj, __get_stack()); } inline void __trace_list_to_vector_destruct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj); } inline void __trace_list_to_vector_insert(const void* __obj, std::size_t __shift, std::size_t __size) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_insert(__obj, __shift, __size); } inline void __trace_list_to_vector_iterate(const void* __obj, std::size_t __num = 1) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_iterate(__obj, __num); } inline void __trace_list_to_vector_invalid_operator(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__invalid_operator(__obj); } inline void __trace_list_to_vector_resize(const void* __obj, std::size_t __from, std::size_t __to) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__resize(__obj, __from, __to); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H__ */ 4.8.2/profile/impl/profiler_node.h000064400000010377147547540550012646 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_node.h * @brief Data structures to represent a single profiling event. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H #define _GLIBCXX_PROFILE_PROFILER_NODE_H 1 #include // FILE, fprintf #include #if defined _GLIBCXX_HAVE_EXECINFO_H #include #endif namespace __gnu_profile { typedef const void* __object_t; typedef void* __instruction_address_t; typedef std::_GLIBCXX_STD_C::vector<__instruction_address_t> __stack_npt; typedef __stack_npt* __stack_t; std::size_t __stack_max_depth(); inline __stack_t __get_stack() { #if defined _GLIBCXX_HAVE_EXECINFO_H std::size_t __max_depth = __stack_max_depth(); if (__max_depth == 0) return 0; __stack_npt __buffer(__max_depth); int __depth = backtrace(&__buffer[0], __max_depth); __stack_t __stack = new __stack_npt(__depth); __builtin_memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t)); return __stack; #else return 0; #endif } inline std::size_t __size(__stack_t __stack) { if (!__stack) return 0; else return __stack->size(); } // XXX inline void __write(FILE* __f, __stack_t __stack) { if (!__stack) return; __stack_npt::const_iterator __it; for (__it = __stack->begin(); __it != __stack->end(); ++__it) std::fprintf(__f, "%p ", *__it); } /** @brief Hash function for summary trace using call stack as index. */ class __stack_hash { public: std::size_t operator()(__stack_t __s) const { if (!__s) return 0; std::size_t __index = 0; __stack_npt::const_iterator __it; for (__it = __s->begin(); __it != __s->end(); ++__it) __index += reinterpret_cast(*__it); return __index; } bool operator() (__stack_t __stack1, __stack_t __stack2) const { if (!__stack1 && !__stack2) return true; if (!__stack1 || !__stack2) return false; if (__stack1->size() != __stack2->size()) return false; std::size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type); return __builtin_memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0; } }; /** @brief Base class for a line in the object table. */ class __object_info_base { public: __object_info_base() { } __object_info_base(__stack_t __stack) : _M_stack(__stack), _M_valid(true) { } __object_info_base(const __object_info_base& __o) : _M_stack(__o._M_stack), _M_valid(__o._M_valid) { } virtual ~__object_info_base() { } bool __is_valid() const { return _M_valid; } __stack_t __stack() const { return _M_stack; } virtual void __write(FILE* __f) const = 0; protected: __stack_t _M_stack; bool _M_valid; }; /** @brief Base class for a line in the stack table. */ template class __stack_info_base { public: __stack_info_base() { } __stack_info_base(const __object_info& __info) = 0; virtual ~__stack_info_base() {} void __merge(const __object_info& __info) = 0; virtual float __magnitude() const = 0; virtual const char* __get_id() const = 0; }; } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */ 4.8.2/profile/impl/profiler_trace.h000064400000051522147547540550013014 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_trace.h * @brief Data structures to represent profiling traces. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_TRACE_H #define _GLIBCXX_PROFILE_PROFILER_TRACE_H 1 #include // fopen, fclose, fprintf, FILE #include #include // atof, atoi, strtol, getenv, atexit, abort #if __cplusplus >= 201103L #define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_C::unordered_map #include #else #include #define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map #endif #include #include #include #include #include #include "profile/impl/profiler_algos.h" #include "profile/impl/profiler_state.h" #include "profile/impl/profiler_node.h" namespace __gnu_profile { /** @brief Internal environment. Values can be set one of two ways: 1. In config file "var = value". The default config file path is libstdcxx-profile.conf. 2. By setting process environment variables. For instance, in a Bash shell you can set the unit cost of iterating through a map like this: export __map_iterate_cost_factor=5.0. If a value is set both in the input file and through an environment variable, the environment value takes precedence. */ typedef _GLIBCXX_IMPL_UNORDERED_MAP __env_t; _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__env_t, __env); /** @brief Master lock. */ _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__gnu_cxx::__mutex, __global_lock); /** @brief Representation of a warning. */ struct __warning_data { float __magnitude; __stack_t __context; const char* __warning_id; std::string __warning_message; __warning_data() : __magnitude(0.0), __context(0), __warning_id(0) { } __warning_data(float __m, __stack_t __c, const char* __id, const std::string& __msg) : __magnitude(__m), __context(__c), __warning_id(__id), __warning_message(__msg) { } bool operator<(const __warning_data& __other) const { return __magnitude < __other.__magnitude; } }; typedef std::_GLIBCXX_STD_C::vector<__warning_data> __warning_vector_t; // Defined in profiler_.h. class __trace_hash_func; class __trace_hashtable_size; class __trace_map2umap; class __trace_vector_size; class __trace_vector_to_list; class __trace_list_to_slist; class __trace_list_to_vector; void __trace_vector_size_init(); void __trace_hashtable_size_init(); void __trace_hash_func_init(); void __trace_vector_to_list_init(); void __trace_list_to_slist_init(); void __trace_list_to_vector_init(); void __trace_map_to_unordered_map_init(); void __trace_vector_size_report(FILE*, __warning_vector_t&); void __trace_hashtable_size_report(FILE*, __warning_vector_t&); void __trace_hash_func_report(FILE*, __warning_vector_t&); void __trace_vector_to_list_report(FILE*, __warning_vector_t&); void __trace_list_to_slist_report(FILE*, __warning_vector_t&); void __trace_list_to_vector_report(FILE*, __warning_vector_t&); void __trace_map_to_unordered_map_report(FILE*, __warning_vector_t&); struct __cost_factor { const char* __env_var; float __value; }; typedef std::_GLIBCXX_STD_C::vector<__cost_factor*> __cost_factor_vector; _GLIBCXX_PROFILE_DEFINE_DATA(__trace_hash_func*, _S_hash_func, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_hashtable_size*, _S_hashtable_size, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_map2umap*, _S_map2umap, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_vector_size*, _S_vector_size, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_vector_to_list*, _S_vector_to_list, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_list_to_slist*, _S_list_to_slist, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__trace_list_to_vector*, _S_list_to_vector, 0); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_shift_cost_factor, {"__vector_shift_cost_factor", 1.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_iterate_cost_factor, {"__vector_iterate_cost_factor", 1.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_resize_cost_factor, {"__vector_resize_cost_factor", 1.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_shift_cost_factor, {"__list_shift_cost_factor", 0.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_iterate_cost_factor, {"__list_iterate_cost_factor", 10.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_resize_cost_factor, {"__list_resize_cost_factor", 0.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_insert_cost_factor, {"__map_insert_cost_factor", 1.5}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_erase_cost_factor, {"__map_erase_cost_factor", 1.5}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_find_cost_factor, {"__map_find_cost_factor", 1}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_iterate_cost_factor, {"__map_iterate_cost_factor", 2.3}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_insert_cost_factor, {"__umap_insert_cost_factor", 12.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_erase_cost_factor, {"__umap_erase_cost_factor", 12.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_find_cost_factor, {"__umap_find_cost_factor", 10.0}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_iterate_cost_factor, {"__umap_iterate_cost_factor", 1.7}); _GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor_vector*, __cost_factors, 0); _GLIBCXX_PROFILE_DEFINE_DATA(const char*, _S_trace_file_name, _GLIBCXX_PROFILE_TRACE_PATH_ROOT); _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_warn_count, _GLIBCXX_PROFILE_MAX_WARN_COUNT); _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_stack_depth, _GLIBCXX_PROFILE_MAX_STACK_DEPTH); _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_mem, _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC); inline std::size_t __stack_max_depth() { return _GLIBCXX_PROFILE_DATA(_S_max_stack_depth); } inline std::size_t __max_mem() { return _GLIBCXX_PROFILE_DATA(_S_max_mem); } /** @brief Base class for all trace producers. */ template class __trace_base { public: // Do not pick the initial size too large, as we don't know which // diagnostics are more active. __trace_base() : __object_table(10000), __stack_table(10000), __stack_table_byte_size(0), __id(0) { } virtual ~__trace_base() { } void __add_object(__object_t object, __object_info __info); __object_info* __get_object_info(__object_t __object); void __retire_object(__object_t __object); void __write(FILE* __f); void __collect_warnings(__warning_vector_t& __warnings); private: __gnu_cxx::__mutex __object_table_lock; __gnu_cxx::__mutex __stack_table_lock; typedef _GLIBCXX_IMPL_UNORDERED_MAP<__object_t, __object_info> __object_table_t; typedef _GLIBCXX_IMPL_UNORDERED_MAP<__stack_t, __stack_info, __stack_hash, __stack_hash> __stack_table_t; __object_table_t __object_table; __stack_table_t __stack_table; std::size_t __stack_table_byte_size; protected: const char* __id; }; template void __trace_base<__object_info, __stack_info>:: __collect_warnings(__warning_vector_t& __warnings) { for (typename __stack_table_t::iterator __it = __stack_table.begin(); __it != __stack_table.end(); ++__it) __warnings.push_back(__warning_data((*__it).second.__magnitude(), (*__it).first, __id, (*__it).second.__advice())); } template void __trace_base<__object_info, __stack_info>:: __add_object(__object_t __object, __object_info __info) { if (__max_mem() == 0 || __object_table.size() * sizeof(__object_info) <= __max_mem()) { this->__object_table_lock.lock(); __object_table.insert(typename __object_table_t:: value_type(__object, __info)); this->__object_table_lock.unlock(); } } template __object_info* __trace_base<__object_info, __stack_info>:: __get_object_info(__object_t __object) { // XXX: Revisit this to see if we can decrease mutex spans. // Without this mutex, the object table could be rehashed during an // insertion on another thread, which could result in a segfault. this->__object_table_lock.lock(); typename __object_table_t::iterator __object_it = __object_table.find(__object); if (__object_it == __object_table.end()) { this->__object_table_lock.unlock(); return 0; } else { this->__object_table_lock.unlock(); return &__object_it->second; } } template void __trace_base<__object_info, __stack_info>:: __retire_object(__object_t __object) { this->__object_table_lock.lock(); this->__stack_table_lock.lock(); typename __object_table_t::iterator __object_it = __object_table.find(__object); if (__object_it != __object_table.end()) { const __object_info& __info = __object_it->second; const __stack_t& __stack = __info.__stack(); typename __stack_table_t::iterator __stack_it = __stack_table.find(__stack); if (__stack_it == __stack_table.end()) { // First occurence of this call context. if (__max_mem() == 0 || __stack_table_byte_size < __max_mem()) { __stack_table_byte_size += (sizeof(__instruction_address_t) * __size(__stack) + sizeof(__stack) + sizeof(__stack_info)); __stack_table.insert(make_pair(__stack, __stack_info(__info))); } } else { // Merge object info into info summary for this call context. __stack_it->second.__merge(__info); delete __stack; } __object_table.erase(__object); } this->__object_table_lock.unlock(); this->__stack_table_lock.unlock(); } template void __trace_base<__object_info, __stack_info>:: __write(FILE* __f) { for (typename __stack_table_t::iterator __it = __stack_table.begin(); __it != __stack_table.end(); ++__it) if (__it->second.__is_valid()) { std::fprintf(__f, __id); std::fprintf(__f, "|"); __gnu_profile::__write(__f, __it->first); std::fprintf(__f, "|"); __it->second.__write(__f); } } inline std::size_t __env_to_size_t(const char* __env_var, std::size_t __default_value) { char* __env_value = std::getenv(__env_var); if (__env_value) { errno = 0; long __converted_value = std::strtol(__env_value, 0, 10); if (errno || __converted_value < 0) { std::fprintf(stderr, "Bad value for environment variable '%s'.\n", __env_var); std::abort(); } else return static_cast(__converted_value); } else return __default_value; } inline void __set_max_stack_trace_depth() { _GLIBCXX_PROFILE_DATA(_S_max_stack_depth) = __env_to_size_t(_GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR, _GLIBCXX_PROFILE_DATA(_S_max_stack_depth)); } inline void __set_max_mem() { _GLIBCXX_PROFILE_DATA(_S_max_mem) = __env_to_size_t(_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR, _GLIBCXX_PROFILE_DATA(_S_max_mem)); } inline int __log_magnitude(float __f) { const float __log_base = 10.0; int __result = 0; int __sign = 1; if (__f < 0) { __f = -__f; __sign = -1; } while (__f > __log_base) { ++__result; __f /= 10.0; } return __sign * __result; } inline FILE* __open_output_file(const char* __extension) { // The path is made of _S_trace_file_name + "." + extension. std::size_t __root_len = __builtin_strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name)); std::size_t __ext_len = __builtin_strlen(__extension); char* __file_name = new char[__root_len + 1 + __ext_len + 1]; __builtin_memcpy(__file_name, _GLIBCXX_PROFILE_DATA(_S_trace_file_name), __root_len); *(__file_name + __root_len) = '.'; __builtin_memcpy(__file_name + __root_len + 1, __extension, __ext_len + 1); FILE* __out_file = std::fopen(__file_name, "w"); if (!__out_file) { std::fprintf(stderr, "Could not open trace file '%s'.\n", __file_name); std::abort(); } delete[] __file_name; return __out_file; } struct __warn { FILE* __file; __warn(FILE* __f) { __file = __f; } void operator()(const __warning_data& __info) { std::fprintf(__file, __info.__warning_id); std::fprintf(__file, ": improvement = %d", __log_magnitude(__info.__magnitude)); std::fprintf(__file, ": call stack = "); __gnu_profile::__write(__file, __info.__context); std::fprintf(__file, ": advice = %s\n", __info.__warning_message.c_str()); } }; /** @brief Final report method, registered with @b atexit. * * This can also be called directly by user code, including signal handlers. * It is protected against deadlocks by the reentrance guard in profiler.h. * However, when called from a signal handler that triggers while within * __gnu_profile (under the guarded zone), no output will be produced. */ inline void __report(void) { _GLIBCXX_PROFILE_DATA(__global_lock).lock(); __warning_vector_t __warnings, __top_warnings; FILE* __raw_file = __open_output_file("raw"); __trace_vector_size_report(__raw_file, __warnings); __trace_hashtable_size_report(__raw_file, __warnings); __trace_hash_func_report(__raw_file, __warnings); __trace_vector_to_list_report(__raw_file, __warnings); __trace_list_to_slist_report(__raw_file, __warnings); __trace_list_to_vector_report(__raw_file, __warnings); __trace_map_to_unordered_map_report(__raw_file, __warnings); std::fclose(__raw_file); // Sort data by magnitude, keeping just top N. std::size_t __cutoff = std::min(_GLIBCXX_PROFILE_DATA(_S_max_warn_count), __warnings.size()); __top_n(__warnings, __top_warnings, __cutoff); FILE* __warn_file = __open_output_file("txt"); __for_each(__top_warnings.begin(), __top_warnings.end(), __warn(__warn_file)); std::fclose(__warn_file); _GLIBCXX_PROFILE_DATA(__global_lock).unlock(); } inline void __set_trace_path() { char* __env_trace_file_name = std::getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR); if (__env_trace_file_name) _GLIBCXX_PROFILE_DATA(_S_trace_file_name) = __env_trace_file_name; // Make sure early that we can create the trace file. std::fclose(__open_output_file("txt")); } inline void __set_max_warn_count() { char* __env_max_warn_count_str = std::getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR); if (__env_max_warn_count_str) _GLIBCXX_PROFILE_DATA(_S_max_warn_count) = static_cast(std::atoi(__env_max_warn_count_str)); } inline void __read_cost_factors() { std::string __conf_file_name(_GLIBCXX_PROFILE_DATA(_S_trace_file_name)); __conf_file_name += ".conf"; std::ifstream __conf_file(__conf_file_name.c_str()); if (__conf_file.is_open()) { std::string __line; while (std::getline(__conf_file, __line)) { std::string::size_type __i = __line.find_first_not_of(" \t\n\v"); if (__line.length() <= 0 || __line[__i] == '#') // Skip empty lines or comments. continue; } // Trim. __line.erase(__remove(__line.begin(), __line.end(), ' '), __line.end()); std::string::size_type __pos = __line.find("="); std::string __factor_name = __line.substr(0, __pos); std::string::size_type __end = __line.find_first_of(";\n"); std::string __factor_value = __line.substr(__pos + 1, __end - __pos); _GLIBCXX_PROFILE_DATA(__env)[__factor_name] = __factor_value; } } struct __cost_factor_writer { FILE* __file; __cost_factor_writer(FILE* __f) : __file(__f) { } void operator() (const __cost_factor* __factor) { std::fprintf(__file, "%s = %f\n", __factor->__env_var, __factor->__value); } }; inline void __write_cost_factors() { FILE* __file = __open_output_file("conf.out"); __for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(), _GLIBCXX_PROFILE_DATA(__cost_factors)->end(), __cost_factor_writer(__file)); std::fclose(__file); } struct __cost_factor_setter { void operator()(__cost_factor* __factor) { // Look it up in the process environment first. const char* __env_value = std::getenv(__factor->__env_var); if (!__env_value) { // Look it up in the config file. __env_t::iterator __it = _GLIBCXX_PROFILE_DATA(__env).find(__factor->__env_var); if (__it != _GLIBCXX_PROFILE_DATA(__env).end()) __env_value = (*__it).second.c_str(); } if (__env_value) __factor->__value = std::atof(__env_value); } }; inline void __set_cost_factors() { _GLIBCXX_PROFILE_DATA(__cost_factors) = new __cost_factor_vector; _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__list_shift_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__list_resize_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__map_find_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__umap_find_cost_factor)); _GLIBCXX_PROFILE_DATA(__cost_factors)-> push_back(&_GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor)); __for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(), _GLIBCXX_PROFILE_DATA(__cost_factors)->end(), __cost_factor_setter()); } inline void __profcxx_init_unconditional() { _GLIBCXX_PROFILE_DATA(__global_lock).lock(); if (__is_invalid()) { __set_max_warn_count(); if (_GLIBCXX_PROFILE_DATA(_S_max_warn_count) == 0) __turn_off(); else { __set_max_stack_trace_depth(); __set_max_mem(); __set_trace_path(); __read_cost_factors(); __set_cost_factors(); __write_cost_factors(); __trace_vector_size_init(); __trace_hashtable_size_init(); __trace_hash_func_init(); __trace_vector_to_list_init(); __trace_list_to_slist_init(); __trace_list_to_vector_init(); __trace_map_to_unordered_map_init(); std::atexit(__report); __turn_on(); } } _GLIBCXX_PROFILE_DATA(__global_lock).unlock(); } /** @brief This function must be called by each instrumentation point. * * The common path is inlined fully. */ inline bool __profcxx_init() { if (__is_invalid()) __profcxx_init_unconditional(); return __is_on(); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_TRACE_H */ 4.8.2/profile/impl/profiler_hash_func.h000064400000011542147547540550013652 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_hash_func.h * @brief Data structures to represent profiling traces. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H #define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { /** @brief A hash performance instrumentation line in the object table. */ class __hashfunc_info : public __object_info_base { public: __hashfunc_info() : _M_longest_chain(0), _M_accesses(0), _M_hops(0) { } __hashfunc_info(const __hashfunc_info& __o) : __object_info_base(__o), _M_longest_chain(__o._M_longest_chain), _M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { } __hashfunc_info(__stack_t __stack) : __object_info_base(__stack), _M_longest_chain(0), _M_accesses(0), _M_hops(0) { } virtual ~__hashfunc_info() { } void __merge(const __hashfunc_info& __o) { _M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain); _M_accesses += __o._M_accesses; _M_hops += __o._M_hops; } void __destruct(std::size_t __chain, std::size_t __accesses, std::size_t __hops) { _M_longest_chain = std::max(_M_longest_chain, __chain); _M_accesses += __accesses; _M_hops += __hops; } void __write(FILE* __f) const { std::fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); } float __magnitude() const { return static_cast(_M_hops); } std::string __advice() const { return "change hash function"; } private: std::size_t _M_longest_chain; std::size_t _M_accesses; std::size_t _M_hops; }; /** @brief A hash performance instrumentation line in the stack table. */ class __hashfunc_stack_info : public __hashfunc_info { public: __hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) { } }; /** @brief Hash performance instrumentation producer. */ class __trace_hash_func : public __trace_base<__hashfunc_info, __hashfunc_stack_info> { public: __trace_hash_func() : __trace_base<__hashfunc_info, __hashfunc_stack_info>() { __id = "hash-distr"; } ~__trace_hash_func() {} // Insert a new node at construct with object, callstack and initial size. void __insert(__object_t __obj, __stack_t __stack) { __add_object(__obj, __hashfunc_info(__stack)); } // Call at destruction/clean to set container final size. void __destruct(const void* __obj, std::size_t __chain, std::size_t __accesses, std::size_t __hops) { if (!__is_on()) return; // First find the item from the live objects and update the informations. __hashfunc_info* __objs = __get_object_info(__obj); if (!__objs) return; __objs->__destruct(__chain, __accesses, __hops); __retire_object(__obj); } }; inline void __trace_hash_func_init() { _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); } inline void __trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_hash_func)) { _GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f); } } inline void __trace_hash_func_construct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack()); } inline void __trace_hash_func_destruct(const void* __obj, std::size_t __chain, std::size_t __accesses, std::size_t __hops) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses, __hops); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */ 4.8.2/profile/impl/profiler_container_size.h000064400000014441147547540550014731 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_container_size.h * @brief Diagnostics for container sizes. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H #define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1 #include #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { /** @brief A container size instrumentation line in the object table. */ class __container_size_info : public __object_info_base { public: __container_size_info() : _M_init(0), _M_max(0), _M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0), _M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0) { } __container_size_info(const __container_size_info& __o) : __object_info_base(__o), _M_init(__o._M_init), _M_max(__o._M_max), _M_min(__o._M_min), _M_total(__o._M_total), _M_item_min(__o._M_item_min), _M_item_max(__o._M_item_max), _M_item_total(__o._M_item_total), _M_count(__o._M_count), _M_resize(__o._M_resize), _M_cost(__o._M_cost) { } __container_size_info(__stack_t __stack, std::size_t __num) : __object_info_base(__stack), _M_init(__num), _M_max(__num), _M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0), _M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0) { } virtual ~__container_size_info() { } void __write(FILE* __f) const { std::fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n", _M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max, _M_total, _M_item_min, _M_item_max, _M_item_total); } float __magnitude() const { return static_cast(_M_cost); } std::string __advice() const { std::stringstream __message; if (_M_init < _M_item_max) __message << "change initial container size from " << _M_init << " to " << _M_item_max; return __message.str(); } void __merge(const __container_size_info& __o) { _M_init = std::max(_M_init, __o._M_init); _M_max = std::max(_M_max, __o._M_max); _M_item_max = std::max(_M_item_max, __o._M_item_max); _M_min = std::min(_M_min, __o._M_min); _M_item_min = std::min(_M_item_min, __o._M_item_min); _M_total += __o._M_total; _M_item_total += __o._M_item_total; _M_count += __o._M_count; _M_cost += __o._M_cost; _M_resize += __o._M_resize; } // Call if a container is destructed or cleaned. void __destruct(std::size_t __num, std::size_t __inum) { _M_max = std::max(_M_max, __num); _M_item_max = std::max(_M_item_max, __inum); if (_M_min == 0) { _M_min = __num; _M_item_min = __inum; } else { _M_min = std::min(_M_min, __num); _M_item_min = std::min(_M_item_min, __inum); } _M_total += __num; _M_item_total += __inum; _M_count += 1; } // Estimate the cost of resize/rehash. float __resize_cost(std::size_t __from, std::size_t) { return __from; } // Call if container is resized. void __resize(std::size_t __from, std::size_t __to) { _M_cost += this->__resize_cost(__from, __to); _M_resize += 1; _M_max = std::max(_M_max, __to); } private: std::size_t _M_init; std::size_t _M_max; // range of # buckets std::size_t _M_min; std::size_t _M_total; std::size_t _M_item_min; // range of # items std::size_t _M_item_max; std::size_t _M_item_total; std::size_t _M_count; std::size_t _M_resize; std::size_t _M_cost; }; /** @brief A container size instrumentation line in the stack table. */ class __container_size_stack_info : public __container_size_info { public: __container_size_stack_info(const __container_size_info& __o) : __container_size_info(__o) { } }; /** @brief Container size instrumentation trace producer. */ class __trace_container_size : public __trace_base<__container_size_info, __container_size_stack_info> { public: ~__trace_container_size() { } __trace_container_size() : __trace_base<__container_size_info, __container_size_stack_info>() { }; // Insert a new node at construct with object, callstack and initial size. void __insert(const __object_t __obj, __stack_t __stack, std::size_t __num) { __add_object(__obj, __container_size_info(__stack, __num)); } // XXX Undefined? void __construct(const void* __obj, std::size_t __inum); // Call at destruction/clean to set container final size. void __destruct(const void* __obj, std::size_t __num, std::size_t __inum) { if (!__is_on()) return; __object_t __obj_handle = static_cast<__object_t>(__obj); __container_size_info* __object_info = __get_object_info(__obj_handle); if (!__object_info) return; __object_info->__destruct(__num, __inum); __retire_object(__obj_handle); } // Call at resize to set resize/cost information. void __resize(const void* __obj, int __from, int __to) { if (!__is_on()) return; __container_size_info* __object_info = __get_object_info(__obj); if (!__object_info) return; __object_info->__resize(__from, __to); } }; } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H */ 4.8.2/profile/impl/profiler_vector_size.h000064400000005457147547540550014260 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_vector_size.h * @brief Collection of vector size traces. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H #define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_state.h" #include "profile/impl/profiler_container_size.h" namespace __gnu_profile { /** @brief Hashtable size instrumentation trace producer. */ class __trace_vector_size : public __trace_container_size { public: __trace_vector_size() : __trace_container_size() { __id = "vector-size"; } }; inline void __trace_vector_size_init() { _GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); } inline void __trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_vector_size)) { _GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f); } } inline void __trace_vector_size_construct(const void* __obj, std::size_t __num) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(), __num); } inline void __trace_vector_size_destruct(const void* __obj, std::size_t __num, std::size_t __inum) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum); } inline void __trace_vector_size_resize(const void* __obj, std::size_t __from, std::size_t __to) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H */ 4.8.2/profile/impl/profiler_list_to_slist.h000064400000012262147547540550014607 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_list_to_slist.h * @brief Diagnostics for list to slist. */ // Written by Changhee Jung. #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { class __list2slist_info : public __object_info_base { public: __list2slist_info() : _M_rewind(false), _M_operations(0) { } __list2slist_info(__stack_t __stack) : __object_info_base(__stack), _M_rewind(false), _M_operations(0) { } virtual ~__list2slist_info() { } __list2slist_info(const __list2slist_info& __o) : __object_info_base(__o), _M_rewind(__o._M_rewind), _M_operations(__o._M_operations) { } // XXX: the magnitude should be multiplied with a constant factor F, // where F is 1 when the malloc size class of list nodes is different // from the malloc size class of slist nodes. When they fall into the same // class, the only slist benefit is from having to set fewer links, so // the factor F should be much smaller, closer to 0 than to 1. // This could be implemented by passing the size classes in the config // file. For now, we always assume F to be 1. float __magnitude() const { if (!_M_rewind) return _M_operations; else return 0; } void __merge(const __list2slist_info&) { } void __write(FILE* __f) const { std::fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); } std::string __advice() const { return "change std::list to std::forward_list"; } void __opr_rewind() { _M_rewind = true; _M_valid = false; } void __record_operation() { ++_M_operations; } bool __has_rewind() { return _M_rewind; } private: bool _M_rewind; std::size_t _M_operations; }; class __list2slist_stack_info : public __list2slist_info { public: __list2slist_stack_info(const __list2slist_info& __o) : __list2slist_info(__o) { } }; class __trace_list_to_slist : public __trace_base<__list2slist_info, __list2slist_stack_info> { public: ~__trace_list_to_slist() { } __trace_list_to_slist() : __trace_base<__list2slist_info, __list2slist_stack_info>() { __id = "list-to-slist"; } void __opr_rewind(const void* __obj) { __list2slist_info* __res = __get_object_info(__obj); if (__res) __res->__opr_rewind(); } void __record_operation(const void* __obj) { __list2slist_info* __res = __get_object_info(__obj); if (__res) __res->__record_operation(); } void __insert(const __object_t __obj, __stack_t __stack) { __add_object(__obj, __list2slist_info(__stack)); } void __destruct(const void* __obj) { if (!__is_on()) return; __list2slist_info* __res = __get_object_info(__obj); if (!__res) return; __retire_object(__obj); } }; inline void __trace_list_to_slist_init() { _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); } inline void __trace_list_to_slist_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist)) { _GLIBCXX_PROFILE_DATA(_S_list_to_slist)-> __collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f); } } inline void __trace_list_to_slist_rewind(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj); } inline void __trace_list_to_slist_operation(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj); } inline void __trace_list_to_slist_construct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack()); } inline void __trace_list_to_slist_destruct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H */ 4.8.2/profile/impl/profiler_vector_to_list.h000064400000021604147547540550014753 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_vector_to_list.h * @brief diagnostics for vector to list. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H #define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" namespace __gnu_profile { /** @brief A vector-to-list instrumentation line in the object table. */ class __vector2list_info : public __object_info_base { public: __vector2list_info() : _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true) { } __vector2list_info(__stack_t __stack) : __object_info_base(__stack), _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true) { } virtual ~__vector2list_info() { } __vector2list_info(const __vector2list_info& __o) : __object_info_base(__o), _M_shift_count(__o._M_shift_count), _M_iterate(__o._M_iterate), _M_resize(__o._M_resize), _M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost), _M_valid(__o._M_valid) { } void __merge(const __vector2list_info& __o) { _M_shift_count += __o._M_shift_count; _M_iterate += __o._M_iterate; _M_vector_cost += __o._M_vector_cost; _M_list_cost += __o._M_list_cost; _M_valid &= __o._M_valid; _M_resize += __o._M_resize; } void __write(FILE* __f) const { std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize, _M_iterate, _M_vector_cost, _M_list_cost); } float __magnitude() const { return _M_vector_cost - _M_list_cost; } std::string __advice() const { return "change std::vector to std::list"; } std::size_t __shift_count() { return _M_shift_count; } std::size_t __iterate() { return _M_iterate; } float __list_cost() { return _M_list_cost; } std::size_t __resize() { return _M_resize; } void __set_list_cost(float __lc) { _M_list_cost = __lc; } void __set_vector_cost(float __vc) { _M_vector_cost = __vc; } bool __is_valid() { return _M_valid; } void __set_invalid() { _M_valid = false; } void __opr_insert(std::size_t __pos, std::size_t __num) { _M_shift_count += __num - __pos; } void __opr_iterate(std::size_t __num) { _M_iterate += __num; } void __resize(std::size_t __from, std::size_t) { _M_resize += __from; } void __opr_find(std::size_t __size) { // Use average case complexity. _M_iterate += 3.0 / 4.0 * __size; } private: std::size_t _M_shift_count; std::size_t _M_iterate; std::size_t _M_resize; float _M_list_cost; float _M_vector_cost; bool _M_valid; }; /** @brief A vector-to-list instrumentation line in the stack table. */ class __vector2list_stack_info : public __vector2list_info { public: __vector2list_stack_info(const __vector2list_info& __o) : __vector2list_info(__o) { } }; /** @brief Vector-to-list instrumentation producer. */ class __trace_vector_to_list : public __trace_base<__vector2list_info, __vector2list_stack_info> { public: __trace_vector_to_list() : __trace_base<__vector2list_info, __vector2list_stack_info>() { __id = "vector-to-list"; } ~__trace_vector_to_list() { } // Insert a new node at construct with object, callstack and initial size. void __insert(__object_t __obj, __stack_t __stack) { __add_object(__obj, __vector2list_info(__stack)); } // Call at destruction/clean to set container final size. void __destruct(const void* __obj) { if (!__is_on()) return; __vector2list_info* __res = __get_object_info(__obj); if (!__res) return; float __vc = __vector_cost(__res->__shift_count(), __res->__iterate(), __res->__resize()); float __lc = __list_cost(__res->__shift_count(), __res->__iterate(), __res->__resize()); __res->__set_vector_cost(__vc); __res->__set_list_cost(__lc); __retire_object(__obj); } // Find the node in the live map. // XXX Undefined?!? __vector2list_info* __find(const void* __obj); // Collect cost of operations. void __opr_insert(const void* __obj, std::size_t __pos, std::size_t __num) { __vector2list_info* __res = __get_object_info(__obj); if (__res) __res->__opr_insert(__pos, __num); } void __opr_iterate(const void* __obj, std::size_t __num) { __vector2list_info* __res = __get_object_info(__obj); if (__res) __res->__opr_iterate(__num); } void __invalid_operator(const void* __obj) { __vector2list_info* __res = __get_object_info(__obj); if (__res) __res->__set_invalid(); } void __resize(const void* __obj, std::size_t __from, std::size_t __to) { __vector2list_info* __res = __get_object_info(__obj); if (__res) __res->__resize(__from, __to); } float __vector_cost(std::size_t __shift, std::size_t __iterate, std::size_t __resize) { return (__shift * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value + __iterate * _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value + __resize * _GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor).__value); } float __list_cost(std::size_t __shift, std::size_t __iterate, std::size_t __resize) { return (__shift * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value + __iterate * _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value + __resize * _GLIBCXX_PROFILE_DATA(__list_resize_cost_factor).__value); } void __opr_find(const void* __obj, std::size_t __size) { __vector2list_info* __res = __get_object_info(__obj); if (__res) __res->__opr_find(__size); } }; inline void __trace_vector_to_list_init() { _GLIBCXX_PROFILE_DATA(_S_vector_to_list) = new __trace_vector_to_list(); } inline void __trace_vector_to_list_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_vector_to_list)) { _GLIBCXX_PROFILE_DATA(_S_vector_to_list)-> __collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__write(__f); } } inline void __trace_vector_to_list_construct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__insert(__obj, __get_stack()); } inline void __trace_vector_to_list_destruct(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__destruct(__obj); } inline void __trace_vector_to_list_insert(const void* __obj, std::size_t __pos, std::size_t __num) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_insert(__obj, __pos, __num); } inline void __trace_vector_to_list_iterate(const void* __obj, std::size_t __num = 1) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_iterate(__obj, __num); } inline void __trace_vector_to_list_invalid_operator(const void* __obj) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__invalid_operator(__obj); } inline void __trace_vector_to_list_resize(const void* __obj, std::size_t __from, std::size_t __to) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__resize(__obj, __from, __to); } inline void __trace_vector_to_list_find(const void* __obj, std::size_t __size) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_find(__obj, __size); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H */ 4.8.2/profile/impl/profiler_state.h000064400000003724147547540550013037 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_state.h * @brief Global profiler state. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H #define _GLIBCXX_PROFILE_PROFILER_STATE_H 1 namespace __gnu_profile { enum __state_type { __ON, __OFF, __INVALID }; _GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID); inline bool __turn(__state_type __s) { __state_type inv(__INVALID); return __atomic_compare_exchange_n(&_GLIBCXX_PROFILE_DATA(__state), &inv, __s, false, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); } inline bool __turn_on() { return __turn(__ON); } inline bool __turn_off() { return __turn(__OFF); } inline bool __is_on() { return _GLIBCXX_PROFILE_DATA(__state) == __ON; } inline bool __is_off() { return _GLIBCXX_PROFILE_DATA(__state) == __OFF; } inline bool __is_invalid() { return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; } } // end namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */ 4.8.2/profile/impl/profiler_hashtable_size.h000064400000005561147547540550014705 0ustar00// -*- C++ -*- // // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_hashtable_size.h * @brief Collection of hashtable size traces. */ // Written by Lixia Liu and Silvius Rus. #ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H #define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1 #include "profile/impl/profiler.h" #include "profile/impl/profiler_node.h" #include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_state.h" #include "profile/impl/profiler_container_size.h" namespace __gnu_profile { /** @brief Hashtable size instrumentation trace producer. */ class __trace_hashtable_size : public __trace_container_size { public: __trace_hashtable_size() : __trace_container_size() { __id = "hashtable-size"; } }; inline void __trace_hashtable_size_init() { _GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); } inline void __trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings) { if (_GLIBCXX_PROFILE_DATA(_S_hashtable_size)) { _GLIBCXX_PROFILE_DATA(_S_hashtable_size)-> __collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f); } } inline void __trace_hashtable_size_construct(const void* __obj, std::size_t __num) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(), __num); } inline void __trace_hashtable_size_destruct(const void* __obj, std::size_t __num, std::size_t __inum) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__destruct(__obj, __num, __inum); } inline void __trace_hashtable_size_resize(const void* __obj, std::size_t __from, std::size_t __to) { if (!__profcxx_init()) return; _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to); } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H */ 4.8.2/profile/impl/profiler_algos.h000064400000006545147547540550013030 0ustar00// -*- C++ -*- // // Copyright (C) 2010-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/impl/profiler_algos.h * @brief Algorithms used by the profile extension. * * This file is needed to avoid including \ or \. * Including those files would result in recursive includes. * These implementations are oversimplified. In general, efficiency may be * sacrificed to minimize maintenance overhead. */ #ifndef _GLIBCXX_PROFILE_PROFILER_ALGOS_H #define _GLIBCXX_PROFILE_PROFILER_ALGOS_H 1 namespace __gnu_profile { /* Helper for __top_n. Insert in sorted vector, but not beyond Nth elem. */ template void __insert_top_n(_Container& __output, const typename _Container::value_type& __value, typename _Container::size_type __n) { typename _Container::iterator __it = __output.begin(); typename _Container::size_type __count = 0; // Skip up to N - 1 elements larger than VALUE. // XXX: Could do binary search for random iterators. while (true) { if (__count >= __n) // VALUE is not in top N. return; if (__it == __output.end()) break; if (*__it < __value) break; ++__it; ++__count; } __output.insert(__it, __value); } /* Copy the top N elements in INPUT, sorted in reverse order, to OUTPUT. */ template void __top_n(const _Container& __input, _Container& __output, typename _Container::size_type __n) { __output.clear(); typename _Container::const_iterator __it; for (__it = __input.begin(); __it != __input.end(); ++__it) __insert_top_n(__output, *__it, __n); } /* Simplified clone of std::for_each. */ template _Function __for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); return __f; } /* Simplified clone of std::remove. */ template _ForwardIterator __remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { if(__first == __last) return __first; _ForwardIterator __result = __first; ++__first; for(; __first != __last; ++__first) if(!(*__first == __value)) { *__result = *__first; ++__result; } return __result; } } // namespace __gnu_profile #endif /* _GLIBCXX_PROFILE_PROFILER_ALGOS_H */ 4.8.2/profile/multiset.h000064400000026561147547540550010726 0ustar00// Profiling multiset implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/multiset.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_MULTISET_H #define _GLIBCXX_PROFILE_MULTISET_H 1 #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::multiset wrapper with performance instrumentation. template, typename _Allocator = std::allocator<_Key> > class multiset : public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> { typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base; public: // types: typedef _Key key_type; typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef typename _Base::reverse_iterator reverse_iterator; typedef typename _Base::const_reverse_iterator const_reverse_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; // 23.3.3.1 construct/copy/destroy: explicit multiset(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } #if __cplusplus >= 201103L template> #else template #endif multiset(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__first, __last, __comp, __a) { } multiset(const multiset& __x) : _Base(__x) { } multiset(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L multiset(multiset&& __x) noexcept(is_nothrow_copy_constructible<_Compare>::value) : _Base(std::move(__x)) { } multiset(initializer_list __l, const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _Base(__l, __comp, __a) { } #endif ~multiset() _GLIBCXX_NOEXCEPT { } multiset& operator=(const multiset& __x) { *static_cast<_Base*>(this) = __x; return *this; } #if __cplusplus >= 201103L multiset& operator=(multiset&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } multiset& operator=(initializer_list __l) { this->clear(); this->insert(__l); return *this; } #endif using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin()); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin()); } iterator end() _GLIBCXX_NOEXCEPT { return iterator(_Base::end()); } const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::end()); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin()); } const_iterator cend() const noexcept { return const_iterator(_Base::end()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // capacity: using _Base::empty; using _Base::size; using _Base::max_size; // modifiers: #if __cplusplus >= 201103L template iterator emplace(_Args&&... __args) { return iterator(_Base::emplace(std::forward<_Args>(__args)...)); } template iterator emplace_hint(const_iterator __pos, _Args&&... __args) { return iterator(_Base::emplace_hint(__pos, std::forward<_Args>(__args)...)); } #endif iterator insert(const value_type& __x) { return iterator(_Base::insert(__x)); } #if __cplusplus >= 201103L iterator insert(value_type&& __x) { return iterator(_Base::insert(std::move(__x))); } #endif iterator insert(const_iterator __position, const value_type& __x) { return iterator(_Base::insert(__position, __x)); } #if __cplusplus >= 201103L iterator insert(const_iterator __position, value_type&& __x) { return iterator(_Base::insert(__position, std::move(__x))); } #endif #if __cplusplus >= 201103L template> #else template #endif void insert(_InputIterator __first, _InputIterator __last) { _Base::insert(__first, __last); } #if __cplusplus >= 201103L void insert(initializer_list __l) { _Base::insert(__l); } #endif #if __cplusplus >= 201103L iterator erase(const_iterator __position) { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) { _Base::erase(__position); } #endif size_type erase(const key_type& __x) { std::pair __victims = this->equal_range(__x); size_type __count = 0; while (__victims.first != __victims.second) { iterator __victim = __victims.first++; _Base::erase(__victim); ++__count; } return __count; } #if __cplusplus >= 201103L iterator erase(const_iterator __first, const_iterator __last) { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) { _Base::erase(__first, __last); } #endif void swap(multiset& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // multiset operations: iterator find(const key_type& __x) { return iterator(_Base::find(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x)); } using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x)); } iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x)); } std::pair equal_range(const key_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(iterator(__res.first), iterator(__res.second)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload std::pair equal_range(const key_type& __x) const { typedef typename _Base::const_iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first), const_iterator(__res.second)); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template inline bool operator==(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template void swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) { return __x.swap(__y); } } // namespace __profile } // namespace std #endif 4.8.2/profile/set.h000064400000027003147547540550007643 0ustar00// Profiling set implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/set.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_SET_H #define _GLIBCXX_PROFILE_SET_H 1 #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::set wrapper with performance instrumentation. template, typename _Allocator = std::allocator<_Key> > class set : public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator> { typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base; public: // types: typedef _Key key_type; typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef typename _Base::reverse_iterator reverse_iterator; typedef typename _Base::const_reverse_iterator const_reverse_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; // 23.3.3.1 construct/copy/destroy: explicit set(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } #if __cplusplus >= 201103L template> #else template #endif set(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__first, __last, __comp, __a) { } set(const set& __x) : _Base(__x) { } set(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L set(set&& __x) noexcept(is_nothrow_copy_constructible<_Compare>::value) : _Base(std::move(__x)) { } set(initializer_list __l, const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _Base(__l, __comp, __a) { } #endif ~set() _GLIBCXX_NOEXCEPT { } set& operator=(const set& __x) { *static_cast<_Base*>(this) = __x; return *this; } #if __cplusplus >= 201103L set& operator=(set&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } set& operator=(initializer_list __l) { this->clear(); this->insert(__l); return *this; } #endif using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin()); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin()); } iterator end() _GLIBCXX_NOEXCEPT { return iterator(_Base::end()); } const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::end()); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin()); } const_iterator cend() const noexcept { return const_iterator(_Base::end()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // capacity: using _Base::empty; using _Base::size; using _Base::max_size; // modifiers: #if __cplusplus >= 201103L template std::pair emplace(_Args&&... __args) { auto __res = _Base::emplace(std::forward<_Args>(__args)...); return std::pair(iterator(__res.first), __res.second); } template iterator emplace_hint(const_iterator __pos, _Args&&... __args) { return iterator(_Base::emplace_hint(__pos, std::forward<_Args>(__args)...)); } #endif std::pair insert(const value_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(__x); return std::pair(iterator(__res.first), __res.second); } #if __cplusplus >= 201103L std::pair insert(value_type&& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(std::move(__x)); return std::pair(iterator(__res.first), __res.second); } #endif iterator insert(const_iterator __position, const value_type& __x) { return iterator(_Base::insert(__position, __x)); } #if __cplusplus >= 201103L iterator insert(const_iterator __position, value_type&& __x) { return iterator(_Base::insert(__position, std::move(__x))); } #endif #if __cplusplus >= 201103L template> #else template #endif void insert(_InputIterator __first, _InputIterator __last) { _Base::insert(__first, __last); } #if __cplusplus >= 201103L void insert(initializer_list __l) { _Base::insert(__l); } #endif #if __cplusplus >= 201103L iterator erase(const_iterator __position) { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) { _Base::erase(__position); } #endif size_type erase(const key_type& __x) { iterator __victim = find(__x); if (__victim == end()) return 0; else { _Base::erase(__victim); return 1; } } #if __cplusplus >= 201103L iterator erase(const_iterator __first, const_iterator __last) { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) { _Base::erase(__first, __last); } #endif void swap(set& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // set operations: iterator find(const key_type& __x) { return iterator(_Base::find(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x)); } using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x)); } iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x)); } std::pair equal_range(const key_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(iterator(__res.first), iterator(__res.second)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload std::pair equal_range(const key_type& __x) const { typedef typename _Base::const_iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first), const_iterator(__res.second)); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template inline bool operator==(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) { return __x.swap(__y); } } // namespace __profile } // namespace std #endif 4.8.2/profile/multimap.h000064400000027564147547540550010714 0ustar00// Profiling multimap implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/multimap.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_MULTIMAP_H #define _GLIBCXX_PROFILE_MULTIMAP_H 1 #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::multimap wrapper with performance instrumentation. template, typename _Allocator = std::allocator > > class multimap : public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> { typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base; public: // types: typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef typename _Base::reverse_iterator reverse_iterator; typedef typename _Base::const_reverse_iterator const_reverse_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; // 23.3.1.1 construct/copy/destroy: explicit multimap(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } #if __cplusplus >= 201103L template> #else template #endif multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__first, __last, __comp, __a) { } multimap(const multimap& __x) : _Base(__x) { } multimap(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L multimap(multimap&& __x) noexcept(is_nothrow_copy_constructible<_Compare>::value) : _Base(std::move(__x)) { } multimap(initializer_list __l, const _Compare& __c = _Compare(), const allocator_type& __a = allocator_type()) : _Base(__l, __c, __a) { } #endif ~multimap() _GLIBCXX_NOEXCEPT { } multimap& operator=(const multimap& __x) { *static_cast<_Base*>(this) = __x; return *this; } #if __cplusplus >= 201103L multimap& operator=(multimap&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } multimap& operator=(initializer_list __l) { this->clear(); this->insert(__l); return *this; } #endif using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin()); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin()); } iterator end() _GLIBCXX_NOEXCEPT { return iterator(_Base::end()); } const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::end()); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin()); } const_iterator cend() const noexcept { return const_iterator(_Base::end()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // capacity: using _Base::empty; using _Base::size; using _Base::max_size; // modifiers: #if __cplusplus >= 201103L template iterator emplace(_Args&&... __args) { return iterator(_Base::emplace(std::forward<_Args>(__args)...)); } template iterator emplace_hint(const_iterator __pos, _Args&&... __args) { return iterator(_Base::emplace_hint(__pos, std::forward<_Args>(__args)...)); } #endif iterator insert(const value_type& __x) { return iterator(_Base::insert(__x)); } #if __cplusplus >= 201103L template::value>::type> iterator insert(_Pair&& __x) { return iterator(_Base::insert(std::forward<_Pair>(__x))); } #endif #if __cplusplus >= 201103L void insert(std::initializer_list __list) { _Base::insert(__list); } #endif iterator #if __cplusplus >= 201103L insert(const_iterator __position, const value_type& __x) #else insert(iterator __position, const value_type& __x) #endif { return iterator(_Base::insert(__position, __x)); } #if __cplusplus >= 201103L template::value>::type> iterator insert(const_iterator __position, _Pair&& __x) { return iterator(_Base::insert(__position, std::forward<_Pair>(__x))); } #endif #if __cplusplus >= 201103L template> #else template #endif void insert(_InputIterator __first, _InputIterator __last) { _Base::insert(__first, __last); } #if __cplusplus >= 201103L iterator erase(const_iterator __position) { return iterator(_Base::erase(__position)); } iterator erase(iterator __position) { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) { _Base::erase(__position); } #endif size_type erase(const key_type& __x) { std::pair __victims = this->equal_range(__x); size_type __count = 0; while (__victims.first != __victims.second) { iterator __victim = __victims.first++; _Base::erase(__victim); ++__count; } return __count; } #if __cplusplus >= 201103L iterator erase(const_iterator __first, const_iterator __last) { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) { _Base::erase(__first, __last); } #endif void swap(multimap& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // 23.3.1.3 multimap operations: iterator find(const key_type& __x) { return iterator(_Base::find(__x)); } const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x)); } using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x)); } const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x)); } iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x)); } const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x)); } std::pair equal_range(const key_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(iterator(__res.first), iterator(__res.second)); } std::pair equal_range(const key_type& __x) const { typedef typename _Base::const_iterator _Base_const_iterator; std::pair<_Base_const_iterator, _Base_const_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first), const_iterator(__res.second)); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template inline bool operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) { __lhs.swap(__rhs); } } // namespace __profile } // namespace std #endif 4.8.2/profile/bitset000064400000024222147547540550010114 0ustar00// Profiling bitset implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/bitset * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_BITSET #define _GLIBCXX_PROFILE_BITSET #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::bitset wrapper with performance instrumentation. template class bitset : public _GLIBCXX_STD_C::bitset<_Nb> { typedef _GLIBCXX_STD_C::bitset<_Nb> _Base; public: // bit reference: class reference : private _Base::reference { typedef typename _Base::reference _Base_ref; friend class bitset; reference(); reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT : _Base_ref(__base) { } public: reference(const reference& __x) _GLIBCXX_NOEXCEPT : _Base_ref(__x) { } reference& operator=(bool __x) _GLIBCXX_NOEXCEPT { *static_cast<_Base_ref*>(this) = __x; return *this; } reference& operator=(const reference& __x) _GLIBCXX_NOEXCEPT { *static_cast<_Base_ref*>(this) = __x; return *this; } bool operator~() const _GLIBCXX_NOEXCEPT { return ~(*static_cast(this)); } operator bool() const _GLIBCXX_NOEXCEPT { return *static_cast(this); } reference& flip() _GLIBCXX_NOEXCEPT { _Base_ref::flip(); return *this; } }; // 23.3.5.1 constructors: _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT : _Base() { } #if __cplusplus >= 201103L constexpr bitset(unsigned long long __val) noexcept #else bitset(unsigned long __val) #endif : _Base(__val) { } template explicit bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type __pos = 0, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type __n = (std::basic_string<_CharT, _Traits, _Alloc>::npos)) : _Base(__str, __pos, __n) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type __pos, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type __n, _CharT __zero, _CharT __one = _CharT('1')) : _Base(__str, __pos, __n, __zero, __one) { } bitset(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L template explicit bitset(const _CharT* __str, typename std::basic_string<_CharT>::size_type __n = std::basic_string<_CharT>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) : _Base(__str, __n, __zero, __one) { } #endif // 23.3.5.2 bitset operations: bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { _M_base() &= __rhs; return *this; } bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { _M_base() |= __rhs; return *this; } bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { _M_base() ^= __rhs; return *this; } bitset<_Nb>& operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT { _M_base() <<= __pos; return *this; } bitset<_Nb>& operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT { _M_base() >>= __pos; return *this; } bitset<_Nb>& set() _GLIBCXX_NOEXCEPT { _Base::set(); return *this; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 186. bitset::set() second parameter should be bool bitset<_Nb>& set(size_t __pos, bool __val = true) { _Base::set(__pos, __val); return *this; } bitset<_Nb>& reset() _GLIBCXX_NOEXCEPT { _Base::reset(); return *this; } bitset<_Nb>& reset(size_t __pos) { _Base::reset(__pos); return *this; } bitset<_Nb> operator~() const _GLIBCXX_NOEXCEPT { return bitset(~_M_base()); } bitset<_Nb>& flip() _GLIBCXX_NOEXCEPT { _Base::flip(); return *this; } bitset<_Nb>& flip(size_t __pos) { _Base::flip(__pos); return *this; } // element access: // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems reference operator[](size_t __pos) { return reference(_M_base()[__pos], this); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems _GLIBCXX_CONSTEXPR bool operator[](size_t __pos) const { return _Base::operator[](__pos); } using _Base::to_ulong; #if __cplusplus >= 201103L using _Base::to_ullong; #endif template std::basic_string<_CharT, _Traits, _Alloc> to_string() const { return _M_base().template to_string<_CharT, _Traits, _Alloc>(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template std::basic_string<_CharT, _Traits, _Alloc> to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return _M_base().template to_string<_CharT, _Traits, _Alloc>(__zero, __one); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 434. bitset::to_string() hard to use. template std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string() const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 853. to_string needs updating with zero and one. template std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(__zero, __one); } template std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string() const { return to_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> >(); } template std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> >(__zero, __one); } std::basic_string, std::allocator > to_string() const { return to_string,std::allocator >(); } std::basic_string, std::allocator > to_string(char __zero, char __one = '1') const { return to_string, std::allocator >(__zero, __one); } using _Base::count; using _Base::size; bool operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return _M_base() == __rhs; } bool operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return _M_base() != __rhs; } using _Base::test; using _Base::all; using _Base::any; using _Base::none; bitset<_Nb> operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(_M_base() << __pos); } bitset<_Nb> operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(_M_base() >> __pos); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) &= __y; } template bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) |= __y; } template bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) ^= __y; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) { return __is >> __x._M_base(); } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { return __os << __x._M_base(); } } // namespace __profile #if __cplusplus >= 201103L // DR 1182. /// std::hash specialization for bitset. template struct hash<__profile::bitset<_Nb>> : public __hash_base> { size_t operator()(const __profile::bitset<_Nb>& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); } }; #endif } // namespace std #endif 4.8.2/profile/vector000064400000036146147547540550010134 0ustar00// Profiling vector implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/vector * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_VECTOR #define _GLIBCXX_PROFILE_VECTOR 1 #include #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { template > class vector : public _GLIBCXX_STD_C::vector<_Tp, _Allocator> { typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base; #if __cplusplus >= 201103L typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits; #endif public: typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef __iterator_tracker iterator; typedef __iterator_tracker const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } // 23.2.4.1 construct/copy/destroy: explicit vector(const _Allocator& __a = _Allocator()) : _Base(__a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } #if __cplusplus >= 201103L explicit vector(size_type __n, const _Allocator& __a = _Allocator()) : _Base(__n, __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } vector(size_type __n, const _Tp& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } #else explicit vector(size_type __n, const _Tp& __value = _Tp(), const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } #endif #if __cplusplus >= 201103L template> #else template #endif vector(_InputIterator __first, _InputIterator __last, const _Allocator& __a = _Allocator()) : _Base(__first, __last, __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } vector(const vector& __x) : _Base(__x) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } /// Construction from a release-mode vector vector(const _Base& __x) : _Base(__x) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } #if __cplusplus >= 201103L vector(vector&& __x) noexcept : _Base(std::move(__x)) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } vector(const _Base& __x, const _Allocator& __a) : _Base(__x, __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } vector(vector&& __x, const _Allocator& __a) noexcept : _Base(std::move(__x), __a) { __profcxx_vector_construct(this, this->capacity()); __profcxx_vector_construct2(this); } vector(initializer_list __l, const allocator_type& __a = allocator_type()) : _Base(__l, __a) { } #endif ~vector() _GLIBCXX_NOEXCEPT { __profcxx_vector_destruct(this, this->capacity(), this->size()); __profcxx_vector_destruct2(this); } vector& operator=(const vector& __x) { static_cast<_Base&>(*this) = __x; return *this; } #if __cplusplus >= 201103L vector& operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) { __profcxx_vector_destruct(this, this->capacity(), this->size()); __profcxx_vector_destruct2(this); static_cast<_Base&>(*this) = std::move(__x); return *this; } vector& operator=(initializer_list __l) { static_cast<_Base&>(*this) = __l; return *this; } #endif using _Base::assign; using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin(), this); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin(), this); } iterator end() _GLIBCXX_NOEXCEPT { return iterator(_Base::end(), this); } const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::end(), this); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin(), this); } const_iterator cend() const noexcept { return const_iterator(_Base::end(), this); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // 23.2.4.2 capacity: using _Base::size; using _Base::max_size; #if __cplusplus >= 201103L void resize(size_type __sz) { __profcxx_vector_invalid_operator(this); _M_profile_resize(this, this->capacity(), __sz); _Base::resize(__sz); } void resize(size_type __sz, const _Tp& __c) { __profcxx_vector_invalid_operator(this); _M_profile_resize(this, this->capacity(), __sz); _Base::resize(__sz, __c); } #else void resize(size_type __sz, _Tp __c = _Tp()) { __profcxx_vector_invalid_operator(this); _M_profile_resize(this, this->capacity(), __sz); _Base::resize(__sz, __c); } #endif #if __cplusplus >= 201103L using _Base::shrink_to_fit; #endif using _Base::empty; // element access: reference operator[](size_type __n) { __profcxx_vector_invalid_operator(this); return _M_base()[__n]; } const_reference operator[](size_type __n) const { __profcxx_vector_invalid_operator(this); return _M_base()[__n]; } using _Base::at; reference front() { return _Base::front(); } const_reference front() const { return _Base::front(); } reference back() { return _Base::back(); } const_reference back() const { return _Base::back(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 464. Suggestion for new member functions in standard containers. using _Base::data; // 23.2.4.3 modifiers: void push_back(const _Tp& __x) { size_type __old_size = this->capacity(); _Base::push_back(__x); _M_profile_resize(this, __old_size, this->capacity()); } #if __cplusplus >= 201103L void push_back(_Tp&& __x) { size_type __old_size = this->capacity(); _Base::push_back(std::move(__x)); _M_profile_resize(this, __old_size, this->capacity()); } #endif iterator insert(iterator __position, const _Tp& __x) { __profcxx_vector_insert(this, __position.base() - _Base::begin(), this->size()); size_type __old_size = this->capacity(); typename _Base::iterator __res = _Base::insert(__position.base(), __x); _M_profile_resize(this, __old_size, this->capacity()); return iterator(__res, this); } #if __cplusplus >= 201103L iterator insert(iterator __position, _Tp&& __x) { __profcxx_vector_insert(this, __position.base() - _Base::begin(), this->size()); size_type __old_size = this->capacity(); typename _Base::iterator __res = _Base::insert(__position.base(), __x); _M_profile_resize(this, __old_size, this->capacity()); return iterator(__res, this); } template iterator emplace(iterator __position, _Args&&... __args) { typename _Base::iterator __res = _Base::emplace(__position.base(), std::forward<_Args>(__args)...); return iterator(__res, this); } void insert(iterator __position, initializer_list __l) { this->insert(__position, __l.begin(), __l.end()); } #endif #if __cplusplus >= 201103L void swap(vector&& __x) { _Base::swap(__x); } #endif void swap(vector& __x) #if __cplusplus >= 201103L noexcept(_Alloc_traits::_S_nothrow_swap()) #endif { _Base::swap(__x); } void insert(iterator __position, size_type __n, const _Tp& __x) { __profcxx_vector_insert(this, __position.base() - _Base::begin(), this->size()); size_type __old_size = this->capacity(); _Base::insert(__position, __n, __x); _M_profile_resize(this, __old_size, this->capacity()); } #if __cplusplus >= 201103L template> #else template #endif void insert(iterator __position, _InputIterator __first, _InputIterator __last) { __profcxx_vector_insert(this, __position.base()-_Base::begin(), this->size()); size_type __old_size = this->capacity(); _Base::insert(__position, __first, __last); _M_profile_resize(this, __old_size, this->capacity()); } iterator erase(iterator __position) { typename _Base::iterator __res = _Base::erase(__position.base()); return iterator(__res, this); } iterator erase(iterator __first, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container typename _Base::iterator __res = _Base::erase(__first.base(), __last.base()); return iterator(__res, this); } void clear() _GLIBCXX_NOEXCEPT { __profcxx_vector_destruct(this, this->capacity(), this->size()); __profcxx_vector_destruct2(this); _Base::clear(); } inline void _M_profile_find() const { __profcxx_vector_find(this, size()); } inline void _M_profile_iterate(int __rewind = 0) const { __profcxx_vector_iterate(this); } private: void _M_profile_resize(void* obj, size_type __old_size, size_type __new_size) { if (__old_size < __new_size) { __profcxx_vector_resize(this, this->size(), __new_size); __profcxx_vector_resize2(this, this->size(), __new_size); } } }; template inline bool operator==(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const vector<_Tp, _Alloc>& __lhs, const vector<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } #if __cplusplus >= 201103L template inline void swap(vector<_Tp, _Alloc>&& __lhs, vector<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } template inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>&& __rhs) { __lhs.swap(__rhs); } #endif } // namespace __profile #if __cplusplus >= 201103L // DR 1182. /// std::hash specialization for vector. template struct hash<__profile::vector> : public __hash_base> { size_t operator()(const __profile::vector& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::vector>() (__b._M_base()); } }; #endif } // namespace std #endif 4.8.2/profile/array000064400000017617147547540550007752 0ustar00// Profile array implementation -*- C++ -*- // Copyright (C) 2012-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/array * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_PROFILE_ARRAY #define _GLIBCXX_PROFILE_ARRAY 1 #pragma GCC system_header namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { template struct array { typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef value_type* iterator; typedef const value_type* const_iterator; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // Support for zero-sized arrays mandatory. typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type; typename _AT_Type::_Type _M_elems; // No explicit construct/copy/destroy for aggregate type. // DR 776. void fill(const value_type& __u) { std::fill_n(begin(), size(), __u); } void swap(array& __other) noexcept(noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))) { std::swap_ranges(begin(), end(), __other.begin()); } // Iterators. iterator begin() noexcept { return iterator(data()); } const_iterator begin() const noexcept { return const_iterator(data()); } iterator end() noexcept { return iterator(data() + _Nm); } const_iterator end() const noexcept { return const_iterator(data() + _Nm); } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_iterator cbegin() const noexcept { return const_iterator(data()); } const_iterator cend() const noexcept { return const_iterator(data() + _Nm); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } // Capacity. constexpr size_type size() const noexcept { return _Nm; } constexpr size_type max_size() const noexcept { return _Nm; } constexpr bool empty() const noexcept { return size() == 0; } // Element access. reference operator[](size_type __n) { return _AT_Type::_S_ref(_M_elems, __n); } constexpr const_reference operator[](size_type __n) const noexcept { return _AT_Type::_S_ref(_M_elems, __n); } reference at(size_type __n) { if (__n >= _Nm) std::__throw_out_of_range(__N("array::at")); return _AT_Type::_S_ref(_M_elems, __n); } constexpr const_reference at(size_type __n) const { // Result of conditional expression must be an lvalue so use // boolean ? lvalue : (throw-expr, lvalue) return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n) : (std::__throw_out_of_range(__N("array::at")), _AT_Type::_S_ref(_M_elems, 0)); } reference front() { return *begin(); } constexpr const_reference front() const { return _AT_Type::_S_ref(_M_elems, 0); } reference back() { return _Nm ? *(end() - 1) : *end(); } constexpr const_reference back() const { return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) : _AT_Type::_S_ref(_M_elems, 0); } pointer data() noexcept { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } const_pointer data() const noexcept { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } }; // Array comparisons. template inline bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } template inline bool operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one == __two); } template inline bool operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) { return std::lexicographical_compare(__a.begin(), __a.end(), __b.begin(), __b.end()); } template inline bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return __two < __one; } template inline bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one > __two); } template inline bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one < __two); } // Specialized algorithms. template inline void swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) noexcept(noexcept(__one.swap(__two))) { __one.swap(__two); } template constexpr _Tp& get(array<_Tp, _Nm>& __arr) noexcept { static_assert(_Int < _Nm, "index is out of bounds"); return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>:: _S_ref(__arr._M_elems, _Int); } template constexpr _Tp&& get(array<_Tp, _Nm>&& __arr) noexcept { static_assert(_Int < _Nm, "index is out of bounds"); return std::move(get<_Int>(__arr)); } template constexpr const _Tp& get(const array<_Tp, _Nm>& __arr) noexcept { static_assert(_Int < _Nm, "index is out of bounds"); return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>:: _S_ref(__arr._M_elems, _Int); } } // namespace __profile // Tuple interface to class template array. /// tuple_size template struct tuple_size<__profile::array<_Tp, _Nm>> : public integral_constant { }; /// tuple_element template struct tuple_element<_Int, __profile::array<_Tp, _Nm>> { static_assert(_Int < _Nm, "index is out of bounds"); typedef _Tp type; }; } // namespace std #endif // _GLIBCXX_PROFILE_ARRAY 4.8.2/profile/unordered_base.h000064400000017547147547540550012045 0ustar00// Profiling unordered containers implementation details -*- C++ -*- // Copyright (C) 2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/unordered_base.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_UNORDERED #define _GLIBCXX_PROFILE_UNORDERED 1 namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { template struct _Bucket_index_helper; template struct _Bucket_index_helper<_UnorderedCont, _Value, true> { static std::size_t bucket(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, true>* __node) { return __node->_M_hash_code % __uc.bucket_count(); } }; template struct _Bucket_index_helper<_UnorderedCont, _Value, false> { static std::size_t bucket(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, false>* __node) { return __uc.bucket(__node->_M_v); } }; template struct _Bucket_index_helper<_UnorderedCont, std::pair, false> { typedef std::pair _Value; static std::size_t bucket(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, false>* __node) { return __uc.bucket(__node->_M_v.first); } }; template std::size_t __get_bucket_index(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, _Cache_hash_code>* __node) { using __bucket_index_helper = _Bucket_index_helper<_UnorderedCont, _Value, _Cache_hash_code>; return __bucket_index_helper::bucket(__uc, __node); } template struct _Equal_helper; template struct _Equal_helper<_UnorderedCont, _Value, true> { static std::size_t are_equal(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, true>* __lhs, const __detail::_Hash_node<_Value, true>* __rhs) { return __lhs->_M_hash_code == __rhs->_M_hash_code && __uc.key_eq()(__lhs->_M_v, __rhs->_M_v); } }; template struct _Equal_helper<_UnorderedCont, _Value, false> { static std::size_t are_equal(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, false>* __lhs, const __detail::_Hash_node<_Value, false>* __rhs) { return __uc.key_eq()(__lhs->_M_v, __rhs->_M_v); } }; template struct _Equal_helper<_UnorderedCont, std::pair, true> { typedef std::pair _Value; static std::size_t are_equal(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, true>* __lhs, const __detail::_Hash_node<_Value, true>* __rhs) { return __lhs->_M_hash_code == __rhs->_M_hash_code && __uc.key_eq()(__lhs->_M_v.first, __rhs->_M_v.first); } }; template struct _Equal_helper<_UnorderedCont, std::pair, false> { typedef std::pair _Value; static std::size_t are_equal(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, false>* __lhs, const __detail::_Hash_node<_Value, false>* __rhs) { return __uc.key_eq()(__lhs->_M_v.first, __rhs->_M_v.first); } }; template bool __are_equal(const _UnorderedCont& __uc, const __detail::_Hash_node<_Value, _Cache_hash_code>* __lhs, const __detail::_Hash_node<_Value, _Cache_hash_code>* __rhs) { using __equal_helper = _Equal_helper<_UnorderedCont, _Value, _Cache_hash_code>; return __equal_helper::are_equal(__uc, __lhs, __rhs); } template class _Unordered_profile { _UnorderedCont& _M_conjure() { return *(static_cast<_UnorderedCont*>(this)); } using __unique_keys = std::integral_constant; protected: _Unordered_profile() { auto& __uc = _M_conjure(); __profcxx_hashtable_construct(&__uc, __uc.bucket_count()); __profcxx_hashtable_construct2(&__uc); } _Unordered_profile(const _Unordered_profile&) : _Unordered_profile() { } _Unordered_profile(_Unordered_profile&&) : _Unordered_profile() { } ~_Unordered_profile() noexcept { auto& __uc = _M_conjure(); __profcxx_hashtable_destruct(&__uc, __uc.bucket_count(), __uc.size()); _M_profile_destruct(); } _Unordered_profile& operator=(const _Unordered_profile&) = default; _Unordered_profile& operator=(_Unordered_profile&&) = default; void _M_profile_destruct() { if (!__profcxx_inefficient_hash_is_on()) return; _M_profile_destruct(__unique_keys()); } private: void _M_profile_destruct(std::true_type); void _M_profile_destruct(std::false_type); }; template void _Unordered_profile<_UnorderedCont, _Unique_keys>:: _M_profile_destruct(std::true_type) { auto& __uc = _M_conjure(); std::size_t __hops = 0, __lc = 0, __chain = 0; auto __it = __uc.begin(); while (__it != __uc.end()) { auto __bkt = __get_bucket_index(__uc, __it._M_cur); auto __lit = __uc.begin(__bkt); auto __lend = __uc.end(__bkt); for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit) ++__chain; if (__chain) { ++__chain; __lc = __lc > __chain ? __lc : __chain; __hops += __chain * (__chain - 1) / 2; __chain = 0; } } __profcxx_hashtable_destruct2(&__uc, __lc, __uc.size(), __hops); } template void _Unordered_profile<_UnorderedCont, _Unique_keys>:: _M_profile_destruct(std::false_type) { auto& __uc = _M_conjure(); std::size_t __hops = 0, __lc = 0, __chain = 0, __unique_size = 0; auto __it = __uc.begin(); while (__it != __uc.end()) { auto __bkt = __get_bucket_index(__uc, __it._M_cur); auto __lit = __uc.begin(__bkt); auto __lend = __uc.end(__bkt); auto __pit = __it; ++__unique_size; for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit) { if (!__are_equal(__uc, __pit._M_cur, __it._M_cur)) { ++__chain; ++__unique_size; __pit = __it; } } if (__chain) { ++__chain; __lc = __lc > __chain ? __lc : __chain; __hops += __chain * (__chain - 1) / 2; __chain = 0; } } __profcxx_hashtable_destruct2(&__uc, __lc, __unique_size, __hops); } } // namespace __profile } // namespace std #endif 4.8.2/profile/base.h000064400000003306147547540550007762 0ustar00// -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/base.h * @brief Sequential helper functions. * This file is a GNU profile extension to the Standard C++ Library. */ // Written by Lixia Liu #ifndef _GLIBCXX_PROFILE_BASE_H #define _GLIBCXX_PROFILE_BASE_H 1 #include #include // Profiling mode namespaces. /** * @namespace std::__profile * @brief GNU profile code, replaces standard behavior with profile behavior. */ namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { } } /** * @namespace __gnu_profile * @brief GNU profile code for public use. */ namespace __gnu_profile { // Import all the profile versions of components in namespace std. using namespace std::__profile; } #endif /* _GLIBCXX_PROFILE_BASE_H */ 4.8.2/profile/map.h000064400000037554147547540550007641 0ustar00// Profiling map implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/map.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_MAP_H #define _GLIBCXX_PROFILE_MAP_H 1 #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::map wrapper with performance instrumentation. template, typename _Allocator = std::allocator > > class map : public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> { typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base; public: // types: typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // 23.3.1.1 construct/copy/destroy: explicit map(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { __profcxx_map_to_unordered_map_construct(this); } #if __cplusplus >= 201103L template> #else template #endif map(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__first, __last, __comp, __a) { __profcxx_map_to_unordered_map_construct(this); } map(const map& __x) : _Base(__x) { __profcxx_map_to_unordered_map_construct(this); } map(const _Base& __x) : _Base(__x) { __profcxx_map_to_unordered_map_construct(this); } #if __cplusplus >= 201103L map(map&& __x) noexcept(is_nothrow_copy_constructible<_Compare>::value) : _Base(std::move(__x)) { } map(initializer_list __l, const _Compare& __c = _Compare(), const allocator_type& __a = allocator_type()) : _Base(__l, __c, __a) { } #endif ~map() _GLIBCXX_NOEXCEPT { __profcxx_map_to_unordered_map_destruct(this); } map& operator=(const map& __x) { *static_cast<_Base*>(this) = __x; return *this; } #if __cplusplus >= 201103L map& operator=(map&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } map& operator=(initializer_list __l) { this->clear(); this->insert(__l); return *this; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // 133. map missing get_allocator() using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return _Base::begin(); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return _Base::begin(); } iterator end() _GLIBCXX_NOEXCEPT { return _Base::end(); } const_iterator end() const _GLIBCXX_NOEXCEPT { return _Base::end(); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { __profcxx_map_to_unordered_map_invalidate(this); return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { __profcxx_map_to_unordered_map_invalidate(this); return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { __profcxx_map_to_unordered_map_invalidate(this); return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { __profcxx_map_to_unordered_map_invalidate(this); return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin()); } const_iterator cend() const noexcept { return const_iterator(_Base::end()); } const_reverse_iterator crbegin() const noexcept { __profcxx_map_to_unordered_map_invalidate(this); return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { __profcxx_map_to_unordered_map_invalidate(this); return const_reverse_iterator(begin()); } #endif // capacity: using _Base::empty; using _Base::size; using _Base::max_size; // 23.3.1.2 element access: mapped_type& operator[](const key_type& __k) { __profcxx_map_to_unordered_map_find(this, size()); return _Base::operator[](__k); } #if __cplusplus >= 201103L mapped_type& operator[](key_type&& __k) { __profcxx_map_to_unordered_map_find(this, size()); return _Base::operator[](std::move(__k)); } #endif mapped_type& at(const key_type& __k) { __profcxx_map_to_unordered_map_find(this, size()); return _Base::at(__k); } const mapped_type& at(const key_type& __k) const { __profcxx_map_to_unordered_map_find(this, size()); return _Base::at(__k); } // modifiers: #if __cplusplus >= 201103L template std::pair emplace(_Args&&... __args) { __profcxx_map_to_unordered_map_insert(this, size(), 1); auto __res = _Base::emplace(std::forward<_Args>(__args)...); return std::pair(iterator(__res.first), __res.second); } template iterator emplace_hint(const_iterator __pos, _Args&&... __args) { size_type size_before = size(); auto __res = _Base::emplace_hint(__pos, std::forward<_Args>(__args)...); __profcxx_map_to_unordered_map_insert(this, size_before, size() - size_before); return __res; } #endif std::pair insert(const value_type& __x) { __profcxx_map_to_unordered_map_insert(this, size(), 1); typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(__x); return std::pair(iterator(__res.first), __res.second); } #if __cplusplus >= 201103L template::value>::type> std::pair insert(_Pair&& __x) { __profcxx_map_to_unordered_map_insert(this, size(), 1); typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(std::forward<_Pair>(__x)); return std::pair(iterator(__res.first), __res.second); } #endif #if __cplusplus >= 201103L void insert(std::initializer_list __list) { size_type size_before = size(); _Base::insert(__list); __profcxx_map_to_unordered_map_insert(this, size_before, size() - size_before); } #endif iterator #if __cplusplus >= 201103L insert(const_iterator __position, const value_type& __x) #else insert(iterator __position, const value_type& __x) #endif { size_type size_before = size(); iterator __i = iterator(_Base::insert(__position, __x)); __profcxx_map_to_unordered_map_insert(this, size_before, size() - size_before); return __i; } #if __cplusplus >= 201103L template::value>::type> iterator insert(const_iterator __position, _Pair&& __x) { size_type size_before = size(); iterator __i = iterator(_Base::insert(__position, std::forward<_Pair>(__x))); __profcxx_map_to_unordered_map_insert(this, size_before, size() - size_before); return __i; } #endif #if __cplusplus >= 201103L template> #else template #endif void insert(_InputIterator __first, _InputIterator __last) { size_type size_before = size(); _Base::insert(__first, __last); __profcxx_map_to_unordered_map_insert(this, size_before, size() - size_before); } #if __cplusplus >= 201103L iterator erase(const_iterator __position) { iterator __i = _Base::erase(__position); __profcxx_map_to_unordered_map_erase(this, size(), 1); return __i; } iterator erase(iterator __position) { return erase(const_iterator(__position)); } #else void erase(iterator __position) { _Base::erase(__position); __profcxx_map_to_unordered_map_erase(this, size(), 1); } #endif size_type erase(const key_type& __x) { iterator __victim = find(__x); if (__victim == end()) return 0; else { _Base::erase(__victim); return 1; } } #if __cplusplus >= 201103L iterator erase(const_iterator __first, const_iterator __last) { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) { _Base::erase(__first, __last); } #endif void swap(map& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // 23.3.1.3 map operations: iterator find(const key_type& __x) { __profcxx_map_to_unordered_map_find(this, size()); return iterator(_Base::find(__x)); } const_iterator find(const key_type& __x) const { __profcxx_map_to_unordered_map_find(this, size()); return const_iterator(_Base::find(__x)); } size_type count(const key_type& __x) const { __profcxx_map_to_unordered_map_find(this, size()); return _Base::count(__x); } iterator lower_bound(const key_type& __x) { __profcxx_map_to_unordered_map_invalidate(this); return iterator(_Base::lower_bound(__x)); } const_iterator lower_bound(const key_type& __x) const { __profcxx_map_to_unordered_map_invalidate(this); return const_iterator(_Base::lower_bound(__x)); } iterator upper_bound(const key_type& __x) { __profcxx_map_to_unordered_map_invalidate(this); return iterator(_Base::upper_bound(__x)); } const_iterator upper_bound(const key_type& __x) const { __profcxx_map_to_unordered_map_invalidate(this); return const_iterator(_Base::upper_bound(__x)); } std::pair equal_range(const key_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(iterator(__res.first), iterator(__res.second)); } std::pair equal_range(const key_type& __x) const { __profcxx_map_to_unordered_map_find(this, size()); typedef typename _Base::const_iterator _Base_const_iterator; std::pair<_Base_const_iterator, _Base_const_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first), const_iterator(__res.second)); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template inline bool operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __profcxx_map_to_unordered_map_invalidate(&__lhs); __profcxx_map_to_unordered_map_invalidate(&__rhs); return __lhs._M_base() > __rhs._M_base(); } template inline void swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __lhs.swap(__rhs); } } // namespace __profile } // namespace std #endif 4.8.2/profile/forward_list000064400000012435147547540550011324 0ustar00// -*- C++ -*- // Copyright (C) 2010-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/forward_list * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_FORWARD_LIST #define _GLIBCXX_PROFILE_FORWARD_LIST 1 #if __cplusplus < 201103L # include #else #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::forward_list wrapper with performance instrumentation. template > class forward_list : public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> { typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base; typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_GLIBCXX_STD_C::_Fwd_list_node<_Tp>>::other _Node_alloc_type; typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; public: typedef typename _Base::size_type size_type; // 23.2.3.1 construct/copy/destroy: explicit forward_list(const _Alloc& __al = _Alloc()) : _Base(__al) { } forward_list(const forward_list& __list, const _Alloc& __al) : _Base(__list, __al) { } forward_list(forward_list&& __list, const _Alloc& __al) : _Base(std::move(__list), __al) { } explicit forward_list(size_type __n, const _Alloc& __al = _Alloc()) : _Base(__n, __al) { } forward_list(size_type __n, const _Tp& __value, const _Alloc& __al = _Alloc()) : _Base(__n, __value, __al) { } template> forward_list(_InputIterator __first, _InputIterator __last, const _Alloc& __al = _Alloc()) : _Base(__first, __last, __al) { } forward_list(const forward_list& __list) : _Base(__list) { } forward_list(forward_list&& __list) noexcept : _Base(std::move(__list)) { } forward_list(std::initializer_list<_Tp> __il, const _Alloc& __al = _Alloc()) : _Base(__il, __al) { } ~forward_list() noexcept { } forward_list& operator=(const forward_list& __list) { static_cast<_Base&>(*this) = __list; return *this; } forward_list& operator=(forward_list&& __list) noexcept(_Node_alloc_traits::_S_nothrow_move()) { static_cast<_Base&>(*this) = std::move(__list); return *this; } forward_list& operator=(std::initializer_list<_Tp> __il) { static_cast<_Base&>(*this) = __il; return *this; } _Base& _M_base() noexcept { return *this; } const _Base& _M_base() const noexcept { return *this; } }; template inline bool operator==(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return __lx._M_base() == __ly._M_base(); } template inline bool operator<(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return __lx._M_base() < __ly._M_base(); } template inline bool operator!=(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return !(__lx == __ly); } /// Based on operator< template inline bool operator>(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return (__ly < __lx); } /// Based on operator< template inline bool operator>=(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return !(__lx < __ly); } /// Based on operator< template inline bool operator<=(const forward_list<_Tp, _Alloc>& __lx, const forward_list<_Tp, _Alloc>& __ly) { return !(__ly < __lx); } /// See std::forward_list::swap(). template inline void swap(forward_list<_Tp, _Alloc>& __lx, forward_list<_Tp, _Alloc>& __ly) { __lx.swap(__ly); } } // namespace __profile } // namespace std #endif // C++11 #endif 4.8.2/profile/map000064400000002336147547540550007401 0ustar00// Profiling map/multimap implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/map * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_MAP #define _GLIBCXX_PROFILE_MAP 1 #include #include #include #endif 4.8.2/profile/set000064400000002336147547540550007417 0ustar00// Profiling set/multiset implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . /** @file profile/set * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_SET #define _GLIBCXX_PROFILE_SET 1 #include #include #include #endif 4.8.2/profile/deque000064400000025520147547540550007727 0ustar00// Profiling deque implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/deque * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_DEQUE #define _GLIBCXX_PROFILE_DEQUE 1 #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { /// Class std::deque wrapper with performance instrumentation. template > class deque : public _GLIBCXX_STD_C::deque<_Tp, _Allocator> { typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base; public: typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef typename _Base::reverse_iterator reverse_iterator; typedef typename _Base::const_reverse_iterator const_reverse_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; // 23.2.1.1 construct/copy/destroy: explicit deque(const _Allocator& __a = _Allocator()) : _Base(__a) { } #if __cplusplus >= 201103L explicit deque(size_type __n) : _Base(__n) { } deque(size_type __n, const _Tp& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } #else explicit deque(size_type __n, const _Tp& __value = _Tp(), const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } #endif #if __cplusplus >= 201103L template> #else template #endif deque(_InputIterator __first, _InputIterator __last, const _Allocator& __a = _Allocator()) : _Base(__first, __last, __a) { } deque(const deque& __x) : _Base(__x) { } deque(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L deque(deque&& __x) : _Base(std::move(__x)) { } deque(initializer_list __l, const allocator_type& __a = allocator_type()) : _Base(__l, __a) { } #endif ~deque() _GLIBCXX_NOEXCEPT { } deque& operator=(const deque& __x) { *static_cast<_Base*>(this) = __x; return *this; } #if __cplusplus >= 201103L deque& operator=(deque&& __x) { // NB: DR 1204. // NB: DR 675. this->clear(); this->swap(__x); return *this; } deque& operator=(initializer_list __l) { *static_cast<_Base*>(this) = __l; return *this; } #endif #if __cplusplus >= 201103L template> #else template #endif void assign(_InputIterator __first, _InputIterator __last) { _Base::assign(__first, __last); } void assign(size_type __n, const _Tp& __t) { _Base::assign(__n, __t); } #if __cplusplus >= 201103L void assign(initializer_list __l) { _Base::assign(__l); } #endif using _Base::get_allocator; // iterators: iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_Base::begin()); } const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::begin()); } iterator end() _GLIBCXX_NOEXCEPT { return iterator(_Base::end()); } const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_Base::end()); } reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L const_iterator cbegin() const noexcept { return const_iterator(_Base::begin()); } const_iterator cend() const noexcept { return const_iterator(_Base::end()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif // 23.2.1.2 capacity: using _Base::size; using _Base::max_size; #if __cplusplus >= 201103L void resize(size_type __sz) { _Base::resize(__sz); } void resize(size_type __sz, const _Tp& __c) { _Base::resize(__sz, __c); } #else void resize(size_type __sz, _Tp __c = _Tp()) { _Base::resize(__sz, __c); } #endif #if __cplusplus >= 201103L using _Base::shrink_to_fit; #endif using _Base::empty; // element access: reference operator[](size_type __n) { return _M_base()[__n]; } const_reference operator[](size_type __n) const { return _M_base()[__n]; } using _Base::at; reference front() { return _Base::front(); } const_reference front() const { return _Base::front(); } reference back() { return _Base::back(); } const_reference back() const { return _Base::back(); } // 23.2.1.3 modifiers: void push_front(const _Tp& __x) { _Base::push_front(__x); } void push_back(const _Tp& __x) { _Base::push_back(__x); } #if __cplusplus >= 201103L void push_front(_Tp&& __x) { emplace_front(std::move(__x)); } void push_back(_Tp&& __x) { emplace_back(std::move(__x)); } template void emplace_front(_Args&&... __args) { _Base::emplace_front(std::forward<_Args>(__args)...); } template void emplace_back(_Args&&... __args) { _Base::emplace_back(std::forward<_Args>(__args)...); } template iterator emplace(iterator __position, _Args&&... __args) { typename _Base::iterator __res = _Base::emplace(__position, std::forward<_Args>(__args)...); return iterator(__res); } #endif iterator insert(iterator __position, const _Tp& __x) { typename _Base::iterator __res = _Base::insert(__position, __x); return iterator(__res); } #if __cplusplus >= 201103L iterator insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } void insert(iterator __p, initializer_list __l) { _Base::insert(__p, __l); } #endif void insert(iterator __position, size_type __n, const _Tp& __x) { _Base::insert(__position, __n, __x); } #if __cplusplus >= 201103L template> #else template #endif void insert(iterator __position, _InputIterator __first, _InputIterator __last) { _Base::insert(__position, __first, __last); } void pop_front() { _Base::pop_front(); } void pop_back() { _Base::pop_back(); } iterator erase(iterator __position) { if (__position == begin() || __position == end()-1) { return iterator(_Base::erase(__position)); } else { typename _Base::iterator __res = _Base::erase(__position); return iterator(__res); } } iterator erase(iterator __first, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container return iterator(_Base::erase(__first, __last)); } void swap(deque& __x) { _Base::swap(__x); } void clear() _GLIBCXX_NOEXCEPT { _Base::clear(); } _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template inline bool operator==(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } } // namespace __profile } // namespace std #endif 4.8.2/profile/iterator_tracker.h000064400000021440147547540550012413 0ustar00// Profiling iterator implementation -*- C++ -*- // Copyright (C) 2009-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file profile/iterator_tracker.h * This file is a GNU profile extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PROFILE_ITERATOR_TRACKER #define _GLIBCXX_PROFILE_ITERATOR_TRACKER 1 #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __profile { template class __iterator_tracker { typedef __iterator_tracker _Self; // The underlying iterator _Iterator _M_current; // The underlying data structure const _Sequence* _M_ds; typedef std::iterator_traits<_Iterator> _Traits; public: typedef _Iterator _Base_iterator; typedef typename _Traits::iterator_category iterator_category; typedef typename _Traits::value_type value_type; typedef typename _Traits::difference_type difference_type; typedef typename _Traits::reference reference; typedef typename _Traits::pointer pointer; __iterator_tracker() : _M_current(), _M_ds(0) { } __iterator_tracker(const _Iterator& __i, const _Sequence* __seq) : _M_current(__i), _M_ds(__seq) { } __iterator_tracker(const __iterator_tracker& __x) : _M_current(__x._M_current), _M_ds(__x._M_ds) { } template __iterator_tracker(const __iterator_tracker<_MutableIterator, typename __gnu_cxx::__enable_if <(std::__are_same<_MutableIterator, typename _Sequence::iterator::_Base_iterator>::__value), _Sequence>::__type>& __x) : _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { } _Iterator base() const { return _M_current; } /** * @brief Conversion to underlying non-debug iterator to allow * better interaction with non-profile containers. */ operator _Iterator() const { return _M_current; } pointer operator->() const { return &*_M_current; } __iterator_tracker& operator++() { _M_ds->_M_profile_iterate(); ++_M_current; return *this; } __iterator_tracker operator++(int) { _M_ds->_M_profile_iterate(); __iterator_tracker __tmp(*this); ++_M_current; return __tmp; } __iterator_tracker& operator--() { _M_ds->_M_profile_iterate(1); --_M_current; return *this; } __iterator_tracker operator--(int) { _M_ds->_M_profile_iterate(1); __iterator_tracker __tmp(*this); --_M_current; return __tmp; } __iterator_tracker& operator=(const __iterator_tracker& __x) { _M_current = __x._M_current; return *this; } reference operator*() const { return *_M_current; } // ------ Random access iterator requirements ------ reference operator[](const difference_type& __n) const { return _M_current[__n]; } __iterator_tracker& operator+=(const difference_type& __n) { _M_current += __n; return *this; } __iterator_tracker operator+(const difference_type& __n) const { __iterator_tracker __tmp(*this); __tmp += __n; return __tmp; } __iterator_tracker& operator-=(const difference_type& __n) { _M_current += -__n; return *this; } __iterator_tracker operator-(const difference_type& __n) const { __iterator_tracker __tmp(*this); __tmp -= __n; return __tmp; } void _M_find() { _M_ds->_M_profile_find(); } const _Sequence* _M_get_sequence() const { return static_cast(_M_ds); } }; template inline bool operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() == __rhs.base(); } template inline bool operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() == __rhs.base(); } template inline bool operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() != __rhs.base(); } template inline bool operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() != __rhs.base(); } template inline bool operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() < __rhs.base(); } template inline bool operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() < __rhs.base(); } template inline bool operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() <= __rhs.base(); } template inline bool operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() <= __rhs.base(); } template inline bool operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() > __rhs.base(); } template inline bool operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() > __rhs.base(); } template inline bool operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() >= __rhs.base(); } template inline bool operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() >= __rhs.base(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // According to the resolution of DR179 not only the various comparison // operators but also operator- must accept mixed iterator/const_iterator // parameters. template inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, const __iterator_tracker<_IteratorR, _Sequence>& __rhs) { return __lhs.base() - __rhs.base(); } template inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs, const __iterator_tracker<_Iterator, _Sequence>& __rhs) { return __lhs.base() - __rhs.base(); } template inline __iterator_tracker<_Iterator, _Sequence> operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type __n, const __iterator_tracker<_Iterator, _Sequence>& __i) { return __i + __n; } } // namespace __profile } // namespace std #endif 4.8.2/unordered_set000064400000003500147547540550010020 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/unordered_set * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_UNORDERED_SET #define _GLIBCXX_UNORDERED_SET 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include #include #include #include #include #include // equal_to, _Identity, _Select1st #include #include #include #include #ifdef _GLIBCXX_DEBUG # include #endif #ifdef _GLIBCXX_PROFILE # include #endif #endif // C++11 #endif // _GLIBCXX_UNORDERED_SET 4.8.2/system_error000064400000024154147547540550007723 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/system_error * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_SYSTEM_ERROR #define _GLIBCXX_SYSTEM_ERROR 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION class error_code; class error_condition; class error_category; class system_error; /// is_error_code_enum template struct is_error_code_enum : public false_type { }; /// is_error_condition_enum template struct is_error_condition_enum : public false_type { }; template<> struct is_error_condition_enum : public true_type { }; /// error_category class error_category { protected: error_category() noexcept; public: virtual ~error_category() noexcept; error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; virtual const char* name() const noexcept = 0; virtual string message(int) const = 0; virtual error_condition default_error_condition(int __i) const noexcept; virtual bool equivalent(int __i, const error_condition& __cond) const noexcept; virtual bool equivalent(const error_code& __code, int __i) const noexcept; bool operator<(const error_category& __other) const noexcept { return less()(this, &__other); } bool operator==(const error_category& __other) const noexcept { return this == &__other; } bool operator!=(const error_category& __other) const noexcept { return this != &__other; } }; // DR 890. _GLIBCXX_CONST const error_category& system_category() noexcept; _GLIBCXX_CONST const error_category& generic_category() noexcept; error_code make_error_code(errc) noexcept; template struct hash; /// error_code // Implementation-specific error identification struct error_code { error_code() noexcept : _M_value(0), _M_cat(&system_category()) { } error_code(int __v, const error_category& __cat) noexcept : _M_value(__v), _M_cat(&__cat) { } template::value>::type> error_code(_ErrorCodeEnum __e) noexcept { *this = make_error_code(__e); } void assign(int __v, const error_category& __cat) noexcept { _M_value = __v; _M_cat = &__cat; } void clear() noexcept { assign(0, system_category()); } // DR 804. template typename enable_if::value, error_code&>::type operator=(_ErrorCodeEnum __e) noexcept { return *this = make_error_code(__e); } int value() const noexcept { return _M_value; } const error_category& category() const noexcept { return *_M_cat; } error_condition default_error_condition() const noexcept; string message() const { return category().message(value()); } explicit operator bool() const noexcept { return _M_value != 0 ? true : false; } // DR 804. private: friend class hash; int _M_value; const error_category* _M_cat; }; // 19.4.2.6 non-member functions inline error_code make_error_code(errc __e) noexcept { return error_code(static_cast(__e), generic_category()); } inline bool operator<(const error_code& __lhs, const error_code& __rhs) noexcept { return (__lhs.category() < __rhs.category() || (__lhs.category() == __rhs.category() && __lhs.value() < __rhs.value())); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) { return (__os << __e.category().name() << ':' << __e.value()); } error_condition make_error_condition(errc) noexcept; /// error_condition // Portable error identification struct error_condition { error_condition() noexcept : _M_value(0), _M_cat(&generic_category()) { } error_condition(int __v, const error_category& __cat) noexcept : _M_value(__v), _M_cat(&__cat) { } template::value>::type> error_condition(_ErrorConditionEnum __e) noexcept { *this = make_error_condition(__e); } void assign(int __v, const error_category& __cat) noexcept { _M_value = __v; _M_cat = &__cat; } // DR 804. template typename enable_if::value, error_condition&>::type operator=(_ErrorConditionEnum __e) noexcept { return *this = make_error_condition(__e); } void clear() noexcept { assign(0, generic_category()); } // 19.4.3.4 observers int value() const noexcept { return _M_value; } const error_category& category() const noexcept { return *_M_cat; } string message() const { return category().message(value()); } explicit operator bool() const noexcept { return _M_value != 0 ? true : false; } // DR 804. private: int _M_value; const error_category* _M_cat; }; // 19.4.3.6 non-member functions inline error_condition make_error_condition(errc __e) noexcept { return error_condition(static_cast(__e), generic_category()); } inline bool operator<(const error_condition& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category() < __rhs.category() || (__lhs.category() == __rhs.category() && __lhs.value() < __rhs.value())); } // 19.4.4 Comparison operators inline bool operator==(const error_code& __lhs, const error_code& __rhs) noexcept { return (__lhs.category() == __rhs.category() && __lhs.value() == __rhs.value()); } inline bool operator==(const error_code& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category().equivalent(__lhs.value(), __rhs) || __rhs.category().equivalent(__lhs, __rhs.value())); } inline bool operator==(const error_condition& __lhs, const error_code& __rhs) noexcept { return (__rhs.category().equivalent(__rhs.value(), __lhs) || __lhs.category().equivalent(__rhs, __lhs.value())); } inline bool operator==(const error_condition& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category() == __rhs.category() && __lhs.value() == __rhs.value()); } inline bool operator!=(const error_code& __lhs, const error_code& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_condition& __lhs, const error_condition& __rhs) noexcept { return !(__lhs == __rhs); } /** * @brief Thrown to indicate error code of underlying system. * * @ingroup exceptions */ class system_error : public std::runtime_error { private: error_code _M_code; public: system_error(error_code __ec = error_code()) : runtime_error(__ec.message()), _M_code(__ec) { } system_error(error_code __ec, const string& __what) : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { } /* * TODO: Add const char* ctors to all exceptions. * * system_error(error_code __ec, const char* __what) * : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { } * * system_error(int __v, const error_category& __ecat, const char* __what) * : runtime_error(__what + (": " + __ec.message())), * _M_code(error_code(__v, __ecat)) { } */ system_error(int __v, const error_category& __ecat) : runtime_error(error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } system_error(int __v, const error_category& __ecat, const string& __what) : runtime_error(__what + ": " + error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } virtual ~system_error() noexcept; const error_code& code() const noexcept { return _M_code; } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #ifndef _GLIBCXX_COMPATIBILITY_CXX0X #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // DR 1182. /// std::hash specialization for error_code. template<> struct hash : public __hash_base { size_t operator()(const error_code& __e) const noexcept { const size_t __tmp = std::_Hash_impl::hash(__e._M_value); return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp); } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _GLIBCXX_COMPATIBILITY_CXX0X #endif // C++11 #endif // _GLIBCXX_SYSTEM_ERROR 4.8.2/list000064400000005042147547540550006134 0ustar00// -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/list * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_LIST #define _GLIBCXX_LIST 1 #pragma GCC system_header #include #include #include #include #include #ifdef _GLIBCXX_DEBUG # include #endif #ifdef _GLIBCXX_PROFILE # include #endif #endif /* _GLIBCXX_LIST */ 4.8.2/stack000064400000004527147547540550006275 0ustar00// -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/stack * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_STACK #define _GLIBCXX_STACK 1 #pragma GCC system_header #include #include #endif /* _GLIBCXX_STACK */ 4.8.2/tgmath.h000064400000002520147547540550006671 0ustar00// -*- C++ -*- compatibility header. // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file tgmath.h * This is a Standard C++ Library header. */ #include #if __cplusplus >= 201103L # include #else # if _GLIBCXX_HAVE_TGMATH_H # include_next # endif #endif #ifndef _GLIBCXX_TGMATH_H #define _GLIBCXX_TGMATH_H 1 #endif 4.8.2/scoped_allocator000064400000037227147547540550010510 0ustar00// -*- C++ -*- // Copyright (C) 2011-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/scoped_allocator * This is a Standard C++ Library header. */ #ifndef _SCOPED_ALLOCATOR #define _SCOPED_ALLOCATOR 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template class _Pred, typename... _Allocs> struct __any_of; template class _Pred, typename _Alloc, typename... _Allocs> struct __any_of<_Pred, _Alloc, _Allocs...> : __or_<_Pred<_Alloc>, __any_of<_Pred, _Allocs...>> { }; template class _Pred, typename _Alloc> struct __any_of<_Pred, _Alloc> : _Pred<_Alloc> { }; /** * @addtogroup allocators * @{ */ template struct __propagate_on_copy : allocator_traits<_Alloc>::propagate_on_container_copy_assignment { }; template struct __propagate_on_move : allocator_traits<_Alloc>::propagate_on_container_move_assignment { }; template struct __propagate_on_swap : allocator_traits<_Alloc>::propagate_on_container_swap { }; template inline auto __do_outermost(_Alloc& __a, _Alloc*) -> decltype(__a.outer_allocator()) { return __a.outer_allocator(); } template inline _Alloc& __do_outermost(_Alloc& __a, ...) { return __a; } // TODO: make recursive (see note in 20.12.4/1) template inline auto __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, &__a)) { return __do_outermost(__a, &__a); } template class scoped_allocator_adaptor; template struct __inner_type_impl; template struct __inner_type_impl<_Outer> { typedef scoped_allocator_adaptor<_Outer> __type; __inner_type_impl() = default; __inner_type_impl(const __inner_type_impl&) = default; __inner_type_impl(__inner_type_impl&&) = default; __inner_type_impl& operator=(const __inner_type_impl&) = default; __inner_type_impl& operator=(__inner_type_impl&&) = default; template __inner_type_impl(const __inner_type_impl<_Alloc>& __other) { } template __inner_type_impl(__inner_type_impl<_Alloc>&& __other) { } __type& _M_get(__type* __p) noexcept { return *__p; } const __type& _M_get(const __type* __p) const noexcept { return *__p; } tuple<> _M_tie() const noexcept { return tuple<>(); } bool operator==(const __inner_type_impl&) const noexcept { return true; } }; template struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...> { typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type; __inner_type_impl() = default; __inner_type_impl(const __inner_type_impl&) = default; __inner_type_impl(__inner_type_impl&&) = default; __inner_type_impl& operator=(const __inner_type_impl&) = default; __inner_type_impl& operator=(__inner_type_impl&&) = default; template __inner_type_impl(const __inner_type_impl<_Allocs...>& __other) : _M_inner(__other._M_inner) { } template __inner_type_impl(__inner_type_impl<_Allocs...>&& __other) : _M_inner(std::move(__other._M_inner)) { } template explicit __inner_type_impl(_Args&&... __args) : _M_inner(std::forward<_Args>(__args)...) { } __type& _M_get(void*) noexcept { return _M_inner; } const __type& _M_get(const void*) const noexcept { return _M_inner; } tuple _M_tie() const noexcept { return _M_inner._M_tie(); } bool operator==(const __inner_type_impl& __other) const noexcept { return _M_inner == __other._M_inner; } private: template friend class __inner_type_impl; template friend class scoped_allocator_adaptor; __type _M_inner; }; /// Primary class template. template class scoped_allocator_adaptor : public _OuterAlloc { typedef allocator_traits<_OuterAlloc> __traits; typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type; __inner_type _M_inner; template friend class scoped_allocator_adaptor; template friend class __inner_type_impl; tuple _M_tie() const noexcept { return std::tuple_cat(std::tie(outer_allocator()), _M_inner._M_tie()); } template using __outermost_type = typename std::decay()))>::type; template using __outermost_alloc_traits = allocator_traits<__outermost_type<_Alloc>>; template void _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits _O_traits; _O_traits::construct(__outermost(*this), __p, std::forward<_Args>(__args)...); } typedef __uses_alloc1 __uses_alloc1_; typedef __uses_alloc2 __uses_alloc2_; template void _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits _O_traits; _O_traits::construct(__outermost(*this), __p, allocator_arg, inner_allocator(), std::forward<_Args>(__args)...); } template void _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits _O_traits; _O_traits::construct(__outermost(*this), __p, std::forward<_Args>(__args)..., inner_allocator()); } template static _Alloc _S_select_on_copy(const _Alloc& __a) { typedef allocator_traits<_Alloc> __a_traits; return __a_traits::select_on_container_copy_construction(__a); } template scoped_allocator_adaptor(tuple __refs, _Index_tuple<_Indices...>) : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))), _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...) { } public: typedef _OuterAlloc outer_allocator_type; typedef typename __inner_type::__type inner_allocator_type; typedef typename __traits::value_type value_type; typedef typename __traits::size_type size_type; typedef typename __traits::difference_type difference_type; typedef typename __traits::pointer pointer; typedef typename __traits::const_pointer const_pointer; typedef typename __traits::void_pointer void_pointer; typedef typename __traits::const_void_pointer const_void_pointer; typedef typename conditional< __any_of<__propagate_on_copy, _OuterAlloc, _InnerAllocs...>::value, true_type, false_type>::type propagate_on_container_copy_assignment; typedef typename conditional< __any_of<__propagate_on_move, _OuterAlloc, _InnerAllocs...>::value, true_type, false_type>::type propagate_on_container_move_assignment; typedef typename conditional< __any_of<__propagate_on_swap, _OuterAlloc, _InnerAllocs...>::value, true_type, false_type>::type propagate_on_container_swap; template struct rebind { typedef scoped_allocator_adaptor< typename __traits::template rebind_alloc<_Tp>, _InnerAllocs...> other; }; scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { } template scoped_allocator_adaptor(_Outer2&& __outer, const _InnerAllocs&... __inner) : _OuterAlloc(std::forward<_Outer2>(__outer)), _M_inner(__inner...) { } scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) : _OuterAlloc(__other.outer_allocator()), _M_inner(__other._M_inner) { } scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) : _OuterAlloc(std::move(__other.outer_allocator())), _M_inner(std::move(__other._M_inner)) { } template scoped_allocator_adaptor( const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other) : _OuterAlloc(__other.outer_allocator()), _M_inner(__other._M_inner) { } template scoped_allocator_adaptor( scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) : _OuterAlloc(std::move(__other.outer_allocator())), _M_inner(std::move(__other._M_inner)) { } scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; inner_allocator_type& inner_allocator() noexcept { return _M_inner._M_get(this); } const inner_allocator_type& inner_allocator() const noexcept { return _M_inner._M_get(this); } outer_allocator_type& outer_allocator() noexcept { return static_cast<_OuterAlloc&>(*this); } const outer_allocator_type& outer_allocator() const noexcept { return static_cast(*this); } pointer allocate(size_type __n) { return __traits::allocate(outer_allocator(), __n); } pointer allocate(size_type __n, const_void_pointer __hint) { return __traits::allocate(outer_allocator(), __n, __hint); } void deallocate(pointer __p, size_type __n) { return __traits::deallocate(outer_allocator(), __p, __n); } size_type max_size() const { return __traits::max_size(outer_allocator()); } template void construct(_Tp* __p, _Args&&... __args) { auto& __inner = inner_allocator(); auto __use_tag = __use_alloc<_Tp, inner_allocator_type, _Args...>(__inner); _M_construct(__use_tag, __p, std::forward<_Args>(__args)...); } template void construct(pair<_T1, _T2>* __p, piecewise_construct_t, tuple<_Args1...> __x, tuple<_Args2...> __y) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2203. wrong argument types for piecewise construction auto& __inner = inner_allocator(); auto __x_use_tag = __use_alloc<_T1, inner_allocator_type, _Args1...>(__inner); auto __y_use_tag = __use_alloc<_T2, inner_allocator_type, _Args2...>(__inner); typedef __outermost_alloc_traits _O_traits; _O_traits::construct(__outermost(*this), __p, piecewise_construct, _M_construct_p(__x_use_tag, __x), _M_construct_p(__y_use_tag, __y)); } template void construct(pair<_T1, _T2>* __p) { construct(__p, piecewise_construct, tuple<>(), tuple<>()); } template void construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v) { construct(__p, piecewise_construct, std::forward_as_tuple(std::forward<_Up>(__u)), std::forward_as_tuple(std::forward<_Vp>(__v))); } template void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) { construct(__p, piecewise_construct, std::forward_as_tuple(__x.first), std::forward_as_tuple(__x.second)); } template void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) { construct(__p, piecewise_construct, std::forward_as_tuple(std::forward<_Up>(__x.first)), std::forward_as_tuple(std::forward<_Vp>(__x.second))); } template void destroy(_Tp* __p) { typedef __outermost_alloc_traits _O_traits; _O_traits::destroy(__outermost(*this), __p); } scoped_allocator_adaptor select_on_container_copy_construction() const { typedef typename _Build_index_tuple::__type _Indices; return scoped_allocator_adaptor(_M_tie(), _Indices()); } template friend bool operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept; private: template _Tuple&& _M_construct_p(__uses_alloc0, _Tuple& __t) { return std::move(__t); } template std::tuple _M_construct_p(__uses_alloc1_, std::tuple<_Args...>& __t) { typedef std::tuple _Tuple; return std::tuple_cat(_Tuple(allocator_arg, inner_allocator()), std::move(__t)); } template std::tuple<_Args..., inner_allocator_type&> _M_construct_p(__uses_alloc2_, std::tuple<_Args...>& __t) { typedef std::tuple _Tuple; return std::tuple_cat(std::move(__t), _Tuple(inner_allocator())); } }; template inline bool operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept { return __a.outer_allocator() == __b.outer_allocator() && __a._M_inner == __b._M_inner; } template inline bool operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept { return !(__a == __b); } /// @} _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++11 #endif // _SCOPED_ALLOCATOR 4.8.2/parallel/tags.h000064400000013536147547540550010150 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** * @file parallel/tags.h * @brief Tags for compile-time selection. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_TAGS_H #define _GLIBCXX_PARALLEL_TAGS_H 1 #include #include namespace __gnu_parallel { /** @brief Forces sequential execution at compile time. */ struct sequential_tag { }; /** @brief Recommends parallel execution at compile time, * optionally using a user-specified number of threads. */ struct parallel_tag { private: _ThreadIndex _M_num_threads; public: /** @brief Default constructor. Use default number of threads. */ parallel_tag() { _M_num_threads = 0; } /** @brief Default constructor. Recommend number of threads to use. * @param __num_threads Desired number of threads. */ parallel_tag(_ThreadIndex __num_threads) { _M_num_threads = __num_threads; } /** @brief Find out desired number of threads. * @return Desired number of threads. */ _ThreadIndex __get_num_threads() { if(_M_num_threads == 0) return omp_get_max_threads(); else return _M_num_threads; } /** @brief Set the desired number of threads. * @param __num_threads Desired number of threads. */ void set_num_threads(_ThreadIndex __num_threads) { _M_num_threads = __num_threads; } }; /** @brief Recommends parallel execution using the default parallel algorithm. */ struct default_parallel_tag : public parallel_tag { default_parallel_tag() { } default_parallel_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Recommends parallel execution using dynamic load-balancing at compile time. */ struct balanced_tag : public parallel_tag { }; /** @brief Recommends parallel execution using static load-balancing at compile time. */ struct unbalanced_tag : public parallel_tag { }; /** @brief Recommends parallel execution using OpenMP dynamic load-balancing at compile time. */ struct omp_loop_tag : public parallel_tag { }; /** @brief Recommends parallel execution using OpenMP static load-balancing at compile time. */ struct omp_loop_static_tag : public parallel_tag { }; /** @brief Base class for for std::find() variants. */ struct find_tag { }; /** @brief Forces parallel merging * with exact splitting, at compile time. */ struct exact_tag : public parallel_tag { exact_tag() { } exact_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel merging * with exact splitting, at compile time. */ struct sampling_tag : public parallel_tag { sampling_tag() { } sampling_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel sorting using multiway mergesort * at compile time. */ struct multiway_mergesort_tag : public parallel_tag { multiway_mergesort_tag() { } multiway_mergesort_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel sorting using multiway mergesort * with exact splitting at compile time. */ struct multiway_mergesort_exact_tag : public parallel_tag { multiway_mergesort_exact_tag() { } multiway_mergesort_exact_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel sorting using multiway mergesort * with splitting by sampling at compile time. */ struct multiway_mergesort_sampling_tag : public parallel_tag { multiway_mergesort_sampling_tag() { } multiway_mergesort_sampling_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel sorting using unbalanced quicksort * at compile time. */ struct quicksort_tag : public parallel_tag { quicksort_tag() { } quicksort_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Forces parallel sorting using balanced quicksort * at compile time. */ struct balanced_quicksort_tag : public parallel_tag { balanced_quicksort_tag() { } balanced_quicksort_tag(_ThreadIndex __num_threads) : parallel_tag(__num_threads) { } }; /** @brief Selects the growing block size variant for std::find(). @see _GLIBCXX_FIND_GROWING_BLOCKS */ struct growing_blocks_tag : public find_tag { }; /** @brief Selects the constant block size variant for std::find(). @see _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS */ struct constant_size_blocks_tag : public find_tag { }; /** @brief Selects the equal splitting variant for std::find(). @see _GLIBCXX_FIND_EQUAL_SPLIT */ struct equal_split_tag : public find_tag { }; } #endif /* _GLIBCXX_PARALLEL_TAGS_H */ 4.8.2/parallel/multiway_merge.h000064400000211433147547540550012240 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/multiway_merge.h * @brief Implementation of sequential and parallel multiway merge. * * Explanations on the high-speed merging routines in the appendix of * * P. Sanders. * Fast priority queues for cached memory. * ACM Journal of Experimental Algorithmics, 5, 2000. * * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Manuel Holtgrewe. #ifndef _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H #define _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H #include #include #include #include #include #include #if _GLIBCXX_ASSERTIONS #include #endif /** @brief Length of a sequence described by a pair of iterators. */ #define _GLIBCXX_PARALLEL_LENGTH(__s) ((__s).second - (__s).first) namespace __gnu_parallel { template _OutputIterator __merge_advance(_RAIter1&, _RAIter1, _RAIter2&, _RAIter2, _OutputIterator, _DifferenceTp, _Compare); /** @brief _Iterator wrapper supporting an implicit supremum at the end * of the sequence, dominating all comparisons. * * The implicit supremum comes with a performance cost. * * Deriving from _RAIter is not possible since * _RAIter need not be a class. */ template class _GuardedIterator { private: /** @brief Current iterator __position. */ _RAIter _M_current; /** @brief End iterator of the sequence. */ _RAIter _M_end; /** @brief _Compare. */ _Compare& __comp; public: /** @brief Constructor. Sets iterator to beginning of sequence. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __comp Comparator provided for associated overloaded * compare operators. */ _GuardedIterator(_RAIter __begin, _RAIter __end, _Compare& __comp) : _M_current(__begin), _M_end(__end), __comp(__comp) { } /** @brief Pre-increment operator. * @return This. */ _GuardedIterator<_RAIter, _Compare>& operator++() { ++_M_current; return *this; } /** @brief Dereference operator. * @return Referenced element. */ typename std::iterator_traits<_RAIter>::value_type& operator*() { return *_M_current; } /** @brief Convert to wrapped iterator. * @return Wrapped iterator. */ operator _RAIter() { return _M_current; } /** @brief Compare two elements referenced by guarded iterators. * @param __bi1 First iterator. * @param __bi2 Second iterator. * @return @c true if less. */ friend bool operator<(_GuardedIterator<_RAIter, _Compare>& __bi1, _GuardedIterator<_RAIter, _Compare>& __bi2) { if (__bi1._M_current == __bi1._M_end) // __bi1 is sup return __bi2._M_current == __bi2._M_end; // __bi2 is not sup if (__bi2._M_current == __bi2._M_end) // __bi2 is sup return true; return (__bi1.__comp)(*__bi1, *__bi2); // normal compare } /** @brief Compare two elements referenced by guarded iterators. * @param __bi1 First iterator. * @param __bi2 Second iterator. * @return @c True if less equal. */ friend bool operator<=(_GuardedIterator<_RAIter, _Compare>& __bi1, _GuardedIterator<_RAIter, _Compare>& __bi2) { if (__bi2._M_current == __bi2._M_end) // __bi1 is sup return __bi1._M_current != __bi1._M_end; // __bi2 is not sup if (__bi1._M_current == __bi1._M_end) // __bi2 is sup return false; return !(__bi1.__comp)(*__bi2, *__bi1); // normal compare } }; template class _UnguardedIterator { private: /** @brief Current iterator __position. */ _RAIter _M_current; /** @brief _Compare. */ _Compare& __comp; public: /** @brief Constructor. Sets iterator to beginning of sequence. * @param __begin Begin iterator of sequence. * @param __end Unused, only for compatibility. * @param __comp Unused, only for compatibility. */ _UnguardedIterator(_RAIter __begin, _RAIter /* __end */, _Compare& __comp) : _M_current(__begin), __comp(__comp) { } /** @brief Pre-increment operator. * @return This. */ _UnguardedIterator<_RAIter, _Compare>& operator++() { ++_M_current; return *this; } /** @brief Dereference operator. * @return Referenced element. */ typename std::iterator_traits<_RAIter>::value_type& operator*() { return *_M_current; } /** @brief Convert to wrapped iterator. * @return Wrapped iterator. */ operator _RAIter() { return _M_current; } /** @brief Compare two elements referenced by unguarded iterators. * @param __bi1 First iterator. * @param __bi2 Second iterator. * @return @c true if less. */ friend bool operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1, _UnguardedIterator<_RAIter, _Compare>& __bi2) { // Normal compare. return (__bi1.__comp)(*__bi1, *__bi2); } /** @brief Compare two elements referenced by unguarded iterators. * @param __bi1 First iterator. * @param __bi2 Second iterator. * @return @c True if less equal. */ friend bool operator<=(_UnguardedIterator<_RAIter, _Compare>& __bi1, _UnguardedIterator<_RAIter, _Compare>& __bi2) { // Normal compare. return !(__bi1.__comp)(*__bi2, *__bi1); } }; /** @brief Highly efficient 3-way merging procedure. * * Merging is done with the algorithm implementation described by Peter * Sanders. Basically, the idea is to minimize the number of necessary * comparison after merging an element. The implementation trick * that makes this fast is that the order of the sequences is stored * in the instruction pointer (translated into labels in C++). * * This works well for merging up to 4 sequences. * * Note that making the merging stable does @a not come at a * performance hit. * * Whether the merging is done guarded or unguarded is selected by the * used iterator class. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, less equal than the * total number of elements available. * * @return End iterator of output sequence. */ template class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare> _RAIter3 multiway_merge_3_variant(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length); typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; if (__length == 0) return __target; #if _GLIBCXX_ASSERTIONS _DifferenceTp __orig_length = __length; #endif iterator<_RAIter1, _Compare> __seq0(__seqs_begin[0].first, __seqs_begin[0].second, __comp), __seq1(__seqs_begin[1].first, __seqs_begin[1].second, __comp), __seq2(__seqs_begin[2].first, __seqs_begin[2].second, __comp); if (__seq0 <= __seq1) { if (__seq1 <= __seq2) goto __s012; else if (__seq2 < __seq0) goto __s201; else goto __s021; } else { if (__seq1 <= __seq2) { if (__seq0 <= __seq2) goto __s102; else goto __s120; } else goto __s210; } #define _GLIBCXX_PARALLEL_MERGE_3_CASE(__a, __b, __c, __c0, __c1) \ __s ## __a ## __b ## __c : \ *__target = *__seq ## __a; \ ++__target; \ --__length; \ ++__seq ## __a; \ if (__length == 0) goto __finish; \ if (__seq ## __a __c0 __seq ## __b) goto __s ## __a ## __b ## __c; \ if (__seq ## __a __c1 __seq ## __c) goto __s ## __b ## __a ## __c; \ goto __s ## __b ## __c ## __a; _GLIBCXX_PARALLEL_MERGE_3_CASE(0, 1, 2, <=, <=); _GLIBCXX_PARALLEL_MERGE_3_CASE(1, 2, 0, <=, < ); _GLIBCXX_PARALLEL_MERGE_3_CASE(2, 0, 1, < , < ); _GLIBCXX_PARALLEL_MERGE_3_CASE(1, 0, 2, < , <=); _GLIBCXX_PARALLEL_MERGE_3_CASE(0, 2, 1, <=, <=); _GLIBCXX_PARALLEL_MERGE_3_CASE(2, 1, 0, < , < ); #undef _GLIBCXX_PARALLEL_MERGE_3_CASE __finish: ; #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT( ((_RAIter1)__seq0 - __seqs_begin[0].first) + ((_RAIter1)__seq1 - __seqs_begin[1].first) + ((_RAIter1)__seq2 - __seqs_begin[2].first) == __orig_length); #endif __seqs_begin[0].first = __seq0; __seqs_begin[1].first = __seq1; __seqs_begin[2].first = __seq2; return __target; } /** * @brief Highly efficient 4-way merging procedure. * * Merging is done with the algorithm implementation described by Peter * Sanders. Basically, the idea is to minimize the number of necessary * comparison after merging an element. The implementation trick * that makes this fast is that the order of the sequences is stored * in the instruction pointer (translated into goto labels in C++). * * This works well for merging up to 4 sequences. * * Note that making the merging stable does @a not come at a * performance hit. * * Whether the merging is done guarded or unguarded is selected by the * used iterator class. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, less equal than the * total number of elements available. * * @return End iterator of output sequence. */ template class iterator, typename _RAIterIterator, typename _RAIter3, typename _DifferenceTp, typename _Compare> _RAIter3 multiway_merge_4_variant(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length); typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; iterator<_RAIter1, _Compare> __seq0(__seqs_begin[0].first, __seqs_begin[0].second, __comp), __seq1(__seqs_begin[1].first, __seqs_begin[1].second, __comp), __seq2(__seqs_begin[2].first, __seqs_begin[2].second, __comp), __seq3(__seqs_begin[3].first, __seqs_begin[3].second, __comp); #define _GLIBCXX_PARALLEL_DECISION(__a, __b, __c, __d) { \ if (__seq ## __d < __seq ## __a) \ goto __s ## __d ## __a ## __b ## __c; \ if (__seq ## __d < __seq ## __b) \ goto __s ## __a ## __d ## __b ## __c; \ if (__seq ## __d < __seq ## __c) \ goto __s ## __a ## __b ## __d ## __c; \ goto __s ## __a ## __b ## __c ## __d; } if (__seq0 <= __seq1) { if (__seq1 <= __seq2) _GLIBCXX_PARALLEL_DECISION(0,1,2,3) else if (__seq2 < __seq0) _GLIBCXX_PARALLEL_DECISION(2,0,1,3) else _GLIBCXX_PARALLEL_DECISION(0,2,1,3) } else { if (__seq1 <= __seq2) { if (__seq0 <= __seq2) _GLIBCXX_PARALLEL_DECISION(1,0,2,3) else _GLIBCXX_PARALLEL_DECISION(1,2,0,3) } else _GLIBCXX_PARALLEL_DECISION(2,1,0,3) } #define _GLIBCXX_PARALLEL_MERGE_4_CASE(__a, __b, __c, __d, \ __c0, __c1, __c2) \ __s ## __a ## __b ## __c ## __d: \ if (__length == 0) goto __finish; \ *__target = *__seq ## __a; \ ++__target; \ --__length; \ ++__seq ## __a; \ if (__seq ## __a __c0 __seq ## __b) \ goto __s ## __a ## __b ## __c ## __d; \ if (__seq ## __a __c1 __seq ## __c) \ goto __s ## __b ## __a ## __c ## __d; \ if (__seq ## __a __c2 __seq ## __d) \ goto __s ## __b ## __c ## __a ## __d; \ goto __s ## __b ## __c ## __d ## __a; _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 1, 2, 3, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 1, 3, 2, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 2, 1, 3, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 2, 3, 1, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 3, 1, 2, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(0, 3, 2, 1, <=, <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 0, 2, 3, < , <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 0, 3, 2, < , <=, <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 2, 0, 3, <=, < , <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 2, 3, 0, <=, <=, < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 3, 0, 2, <=, < , <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(1, 3, 2, 0, <=, <=, < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 0, 1, 3, < , < , <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 0, 3, 1, < , <=, < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 1, 0, 3, < , < , <=); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 1, 3, 0, < , <=, < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 3, 0, 1, <=, < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(2, 3, 1, 0, <=, < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 0, 1, 2, < , < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 0, 2, 1, < , < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 1, 0, 2, < , < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 1, 2, 0, < , < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 2, 0, 1, < , < , < ); _GLIBCXX_PARALLEL_MERGE_4_CASE(3, 2, 1, 0, < , < , < ); #undef _GLIBCXX_PARALLEL_MERGE_4_CASE #undef _GLIBCXX_PARALLEL_DECISION __finish: ; __seqs_begin[0].first = __seq0; __seqs_begin[1].first = __seq1; __seqs_begin[2].first = __seq2; __seqs_begin[3].first = __seq3; return __target; } /** @brief Multi-way merging procedure for a high branching factor, * guarded case. * * This merging variant uses a LoserTree class as selected by _LT. * * Stability is selected through the used LoserTree class _LT. * * At least one non-empty sequence is required. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, less equal than the * total number of elements available. * * @return End iterator of output sequence. */ template _RAIter3 multiway_merge_loser_tree(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length) typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; _SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin); _LT __lt(__k, __comp); // Default value for potentially non-default-constructible types. _ValueType* __arbitrary_element = 0; for (_SeqNumber __t = 0; __t < __k; ++__t) { if(!__arbitrary_element && _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__t]) > 0) __arbitrary_element = &(*__seqs_begin[__t].first); } for (_SeqNumber __t = 0; __t < __k; ++__t) { if (__seqs_begin[__t].first == __seqs_begin[__t].second) __lt.__insert_start(*__arbitrary_element, __t, true); else __lt.__insert_start(*__seqs_begin[__t].first, __t, false); } __lt.__init(); _SeqNumber __source; for (_DifferenceType __i = 0; __i < __length; ++__i) { //take out __source = __lt.__get_min_source(); *(__target++) = *(__seqs_begin[__source].first++); // Feed. if (__seqs_begin[__source].first == __seqs_begin[__source].second) __lt.__delete_min_insert(*__arbitrary_element, true); else // Replace from same __source. __lt.__delete_min_insert(*__seqs_begin[__source].first, false); } return __target; } /** @brief Multi-way merging procedure for a high branching factor, * unguarded case. * * Merging is done using the LoserTree class _LT. * * Stability is selected by the used LoserTrees. * * @pre No input will run out of elements during the merge. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, less equal than the * total number of elements available. * * @return End iterator of output sequence. */ template _RAIter3 multiway_merge_loser_tree_unguarded(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits::value_type::first_type>::value_type& __sentinel, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length) typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; _SeqNumber __k = __seqs_end - __seqs_begin; _LT __lt(__k, __sentinel, __comp); for (_SeqNumber __t = 0; __t < __k; ++__t) { #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__seqs_begin[__t].first != __seqs_begin[__t].second); #endif __lt.__insert_start(*__seqs_begin[__t].first, __t, false); } __lt.__init(); _SeqNumber __source; #if _GLIBCXX_ASSERTIONS _DifferenceType __i = 0; #endif _RAIter3 __target_end = __target + __length; while (__target < __target_end) { // Take out. __source = __lt.__get_min_source(); #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(0 <= __source && __source < __k); _GLIBCXX_PARALLEL_ASSERT(__i == 0 || !__comp(*(__seqs_begin[__source].first), *(__target - 1))); #endif // Feed. *(__target++) = *(__seqs_begin[__source].first++); #if _GLIBCXX_ASSERTIONS ++__i; #endif // Replace from same __source. __lt.__delete_min_insert(*__seqs_begin[__source].first, false); } return __target; } /** @brief Multi-way merging procedure for a high branching factor, * requiring sentinels to exist. * * @tparam UnguardedLoserTree _Loser Tree variant to use for the unguarded * merging. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, less equal than the * total number of elements available. * * @return End iterator of output sequence. */ template _RAIter3 multiway_merge_loser_tree_sentinel(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits::value_type::first_type>::value_type& __sentinel, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length) typedef _DifferenceTp _DifferenceType; typedef std::iterator_traits<_RAIterIterator> _TraitsType; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; _RAIter3 __target_end; for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s) // Move the sequence ends to the sentinel. This has the // effect that the sentinel appears to be within the sequence. Then, // we can use the unguarded variant if we merge out as many // non-sentinel elements as we have. ++((*__s).second); __target_end = multiway_merge_loser_tree_unguarded (__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp); #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__target_end == __target + __length); _GLIBCXX_PARALLEL_ASSERT(__is_sorted(__target, __target_end, __comp)); #endif // Restore the sequence ends so the sentinels are not contained in the // sequence any more (see comment in loop above). for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s) --((*__s).second); return __target_end; } /** * @brief Traits for determining whether the loser tree should * use pointers or copies. * * The field "_M_use_pointer" is used to determine whether to use pointers * in he loser trees or whether to copy the values into the loser tree. * * The default behavior is to use pointers if the data type is 4 times as * big as the pointer to it. * * Specialize for your data type to customize the behavior. * * Example: * * template<> * struct _LoserTreeTraits * { static const bool _M_use_pointer = false; }; * * template<> * struct _LoserTreeTraits * { static const bool _M_use_pointer = true; }; * * @param _Tp type to give the loser tree traits for. */ template struct _LoserTreeTraits { /** * @brief True iff to use pointers instead of values in loser trees. * * The default behavior is to use pointers if the data type is four * times as big as the pointer to it. */ static const bool _M_use_pointer = (sizeof(_Tp) > 4 * sizeof(_Tp*)); }; /** * @brief Switch for 3-way merging with __sentinels turned off. * * Note that 3-way merging is always stable! */ template struct __multiway_merge_3_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { return multiway_merge_3_variant<_GuardedIterator> (__seqs_begin, __seqs_end, __target, __length, __comp); } }; /** * @brief Switch for 3-way merging with __sentinels turned on. * * Note that 3-way merging is always stable! */ template struct __multiway_merge_3_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { return multiway_merge_3_variant<_UnguardedIterator> (__seqs_begin, __seqs_end, __target, __length, __comp); } }; /** * @brief Switch for 4-way merging with __sentinels turned off. * * Note that 4-way merging is always stable! */ template struct __multiway_merge_4_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { return multiway_merge_4_variant<_GuardedIterator> (__seqs_begin, __seqs_end, __target, __length, __comp); } }; /** * @brief Switch for 4-way merging with __sentinels turned on. * * Note that 4-way merging is always stable! */ template struct __multiway_merge_4_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) { return multiway_merge_4_variant<_UnguardedIterator> (__seqs_begin, __seqs_end, __target, __length, __comp); } }; /** * @brief Switch for k-way merging with __sentinels turned on. */ template struct __multiway_merge_k_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits::value_type::first_type>::value_type& __sentinel, _DifferenceTp __length, _Compare __comp) { typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; return multiway_merge_loser_tree_sentinel< typename __gnu_cxx::__conditional_type< _LoserTreeTraits<_ValueType>::_M_use_pointer, _LoserTreePointerUnguarded<__stable, _ValueType, _Compare>, _LoserTreeUnguarded<__stable, _ValueType, _Compare> >::__type> (__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp); } }; /** * @brief Switch for k-way merging with __sentinels turned off. */ template struct __multiway_merge_k_variant_sentinel_switch { _RAIter3 operator()(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits::value_type::first_type>::value_type& __sentinel, _DifferenceTp __length, _Compare __comp) { typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; return multiway_merge_loser_tree< typename __gnu_cxx::__conditional_type< _LoserTreeTraits<_ValueType>::_M_use_pointer, _LoserTreePointer<__stable, _ValueType, _Compare>, _LoserTree<__stable, _ValueType, _Compare> >::__type >(__seqs_begin, __seqs_end, __target, __length, __comp); } }; /** @brief Sequential multi-way merging switch. * * The _GLIBCXX_PARALLEL_DECISION is based on the branching factor and * runtime settings. * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, possibly larger than the * number of elements available. * @param __sentinel The sequences have __a __sentinel element. * @return End iterator of output sequence. */ template _RAIter3 __sequential_multiway_merge(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits::value_type::first_type>::value_type& __sentinel, _DifferenceTp __length, _Compare __comp) { _GLIBCXX_CALL(__length) typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; #if _GLIBCXX_ASSERTIONS for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s) { _GLIBCXX_PARALLEL_ASSERT(__is_sorted((*__s).first, (*__s).second, __comp)); } #endif _DifferenceTp __total_length = 0; for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s) __total_length += _GLIBCXX_PARALLEL_LENGTH(*__s); __length = std::min<_DifferenceTp>(__length, __total_length); if(__length == 0) return __target; _RAIter3 __return_target = __target; _SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin); switch (__k) { case 0: break; case 1: __return_target = std::copy(__seqs_begin[0].first, __seqs_begin[0].first + __length, __target); __seqs_begin[0].first += __length; break; case 2: __return_target = __merge_advance(__seqs_begin[0].first, __seqs_begin[0].second, __seqs_begin[1].first, __seqs_begin[1].second, __target, __length, __comp); break; case 3: __return_target = __multiway_merge_3_variant_sentinel_switch <__sentinels, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>() (__seqs_begin, __seqs_end, __target, __length, __comp); break; case 4: __return_target = __multiway_merge_4_variant_sentinel_switch <__sentinels, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>() (__seqs_begin, __seqs_end, __target, __length, __comp); break; default: __return_target = __multiway_merge_k_variant_sentinel_switch <__sentinels, __stable, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>() (__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp); break; } #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT( __is_sorted(__target, __target + __length, __comp)); #endif return __return_target; } /** * @brief Stable sorting functor. * * Used to reduce code instanciation in multiway_merge_sampling_splitting. */ template struct _SamplingSorter { void operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp) { __gnu_sequential::stable_sort(__first, __last, __comp); } }; /** * @brief Non-__stable sorting functor. * * Used to reduce code instantiation in multiway_merge_sampling_splitting. */ template struct _SamplingSorter { void operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp) { __gnu_sequential::sort(__first, __last, __comp); } }; /** * @brief Sampling based splitting for parallel multiway-merge routine. */ template void multiway_merge_sampling_splitting(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector > *__pieces) { typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; // __k sequences. const _SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin); const _ThreadIndex __num_threads = omp_get_num_threads(); const _DifferenceType __num_samples = __gnu_parallel::_Settings::get().merge_oversampling * __num_threads; _ValueType* __samples = static_cast<_ValueType*> (::operator new(sizeof(_ValueType) * __k * __num_samples)); // Sample. for (_SeqNumber __s = 0; __s < __k; ++__s) for (_DifferenceType __i = 0; __i < __num_samples; ++__i) { _DifferenceType sample_index = static_cast<_DifferenceType> (_GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__s]) * (double(__i + 1) / (__num_samples + 1)) * (double(__length) / __total_length)); new(&(__samples[__s * __num_samples + __i])) _ValueType(__seqs_begin[__s].first[sample_index]); } // Sort stable or non-stable, depending on value of template parameter // "__stable". _SamplingSorter<__stable, _ValueType*, _Compare>() (__samples, __samples + (__num_samples * __k), __comp); for (_ThreadIndex __slab = 0; __slab < __num_threads; ++__slab) // For each slab / processor. for (_SeqNumber __seq = 0; __seq < __k; ++__seq) { // For each sequence. if (__slab > 0) __pieces[__slab][__seq].first = std::upper_bound (__seqs_begin[__seq].first, __seqs_begin[__seq].second, __samples[__num_samples * __k * __slab / __num_threads], __comp) - __seqs_begin[__seq].first; else // Absolute beginning. __pieces[__slab][__seq].first = 0; if ((__slab + 1) < __num_threads) __pieces[__slab][__seq].second = std::upper_bound (__seqs_begin[__seq].first, __seqs_begin[__seq].second, __samples[__num_samples * __k * (__slab + 1) / __num_threads], __comp) - __seqs_begin[__seq].first; else // Absolute end. __pieces[__slab][__seq].second = _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__seq]); } for (_SeqNumber __s = 0; __s < __k; ++__s) for (_DifferenceType __i = 0; __i < __num_samples; ++__i) __samples[__s * __num_samples + __i].~_ValueType(); ::operator delete(__samples); } /** * @brief Exact splitting for parallel multiway-merge routine. * * None of the passed sequences may be empty. */ template void multiway_merge_exact_splitting(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector > *__pieces) { typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; const bool __tight = (__total_length == __length); // __k sequences. const _SeqNumber __k = __seqs_end - __seqs_begin; const _ThreadIndex __num_threads = omp_get_num_threads(); // (Settings::multiway_merge_splitting // == __gnu_parallel::_Settings::EXACT). std::vector<_RAIter1>* __offsets = new std::vector<_RAIter1>[__num_threads]; std::vector > __se(__k); copy(__seqs_begin, __seqs_end, __se.begin()); _DifferenceType* __borders = new _DifferenceType[__num_threads + 1]; __equally_split(__length, __num_threads, __borders); for (_ThreadIndex __s = 0; __s < (__num_threads - 1); ++__s) { __offsets[__s].resize(__k); multiseq_partition(__se.begin(), __se.end(), __borders[__s + 1], __offsets[__s].begin(), __comp); // Last one also needed and available. if (!__tight) { __offsets[__num_threads - 1].resize(__k); multiseq_partition(__se.begin(), __se.end(), _DifferenceType(__length), __offsets[__num_threads - 1].begin(), __comp); } } delete[] __borders; for (_ThreadIndex __slab = 0; __slab < __num_threads; ++__slab) { // For each slab / processor. for (_SeqNumber __seq = 0; __seq < __k; ++__seq) { // For each sequence. if (__slab == 0) { // Absolute beginning. __pieces[__slab][__seq].first = 0; } else __pieces[__slab][__seq].first = __pieces[__slab - 1][__seq].second; if (!__tight || __slab < (__num_threads - 1)) __pieces[__slab][__seq].second = __offsets[__slab][__seq] - __seqs_begin[__seq].first; else { // __slab == __num_threads - 1 __pieces[__slab][__seq].second = _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__seq]); } } } delete[] __offsets; } /** @brief Parallel multi-way merge routine. * * The _GLIBCXX_PARALLEL_DECISION is based on the branching factor * and runtime settings. * * Must not be called if the number of sequences is 1. * * @tparam _Splitter functor to split input (either __exact or sampling based) * @tparam __stable Stable merging incurs a performance penalty. * @tparam __sentinel Ignored. * * @param __seqs_begin Begin iterator of iterator pair input sequence. * @param __seqs_end End iterator of iterator pair input sequence. * @param __target Begin iterator of output sequence. * @param __comp Comparator. * @param __length Maximum length to merge, possibly larger than the * number of elements available. * @return End iterator of output sequence. */ template _RAIter3 parallel_multiway_merge(_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _Splitter __splitter, _DifferenceTp __length, _Compare __comp, _ThreadIndex __num_threads) { #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__seqs_end - __seqs_begin > 1); #endif _GLIBCXX_CALL(__length) typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIterIterator> ::difference_type _SeqNumber; typedef typename std::iterator_traits<_RAIterIterator> ::value_type::first_type _RAIter1; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; // Leave only non-empty sequences. typedef std::pair<_RAIter1, _RAIter1> seq_type; seq_type* __ne_seqs = new seq_type[__seqs_end - __seqs_begin]; _SeqNumber __k = 0; _DifferenceType __total_length = 0; for (_RAIterIterator __raii = __seqs_begin; __raii != __seqs_end; ++__raii) { _DifferenceTp __seq_length = _GLIBCXX_PARALLEL_LENGTH(*__raii); if(__seq_length > 0) { __total_length += __seq_length; __ne_seqs[__k++] = *__raii; } } _GLIBCXX_CALL(__total_length) __length = std::min<_DifferenceTp>(__length, __total_length); if (__total_length == 0 || __k == 0) { delete[] __ne_seqs; return __target; } std::vector >* __pieces; __num_threads = static_cast<_ThreadIndex> (std::min<_DifferenceType>(__num_threads, __total_length)); # pragma omp parallel num_threads (__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); // Thread __t will have to merge pieces[__iam][0..__k - 1] __pieces = new std::vector< std::pair<_DifferenceType, _DifferenceType> >[__num_threads]; for (_ThreadIndex __s = 0; __s < __num_threads; ++__s) __pieces[__s].resize(__k); _DifferenceType __num_samples = __gnu_parallel::_Settings::get().merge_oversampling * __num_threads; __splitter(__ne_seqs, __ne_seqs + __k, __length, __total_length, __comp, __pieces); } //single _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __target_position = 0; for (_SeqNumber __c = 0; __c < __k; ++__c) __target_position += __pieces[__iam][__c].first; seq_type* __chunks = new seq_type[__k]; for (_SeqNumber __s = 0; __s < __k; ++__s) __chunks[__s] = std::make_pair(__ne_seqs[__s].first + __pieces[__iam][__s].first, __ne_seqs[__s].first + __pieces[__iam][__s].second); if(__length > __target_position) __sequential_multiway_merge<__stable, __sentinels> (__chunks, __chunks + __k, __target + __target_position, *(__seqs_begin->second), __length - __target_position, __comp); delete[] __chunks; } // parallel #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT( __is_sorted(__target, __target + __length, __comp)); #endif __k = 0; // Update ends of sequences. for (_RAIterIterator __raii = __seqs_begin; __raii != __seqs_end; ++__raii) { _DifferenceTp __length = _GLIBCXX_PARALLEL_LENGTH(*__raii); if(__length > 0) (*__raii).first += __pieces[__num_threads - 1][__k++].second; } delete[] __pieces; delete[] __ne_seqs; return __target + __length; } /** * @brief Multiway Merge Frontend. * * Merge the sequences specified by seqs_begin and __seqs_end into * __target. __seqs_begin and __seqs_end must point to a sequence of * pairs. These pairs must contain an iterator to the beginning * of a sequence in their first entry and an iterator the _M_end of * the same sequence in their second entry. * * Ties are broken arbitrarily. See stable_multiway_merge for a variant * that breaks ties by sequence number but is slower. * * The first entries of the pairs (i.e. the begin iterators) will be moved * forward. * * The output sequence has to provide enough space for all elements * that are written to it. * * This function will merge the input sequences: * * - not stable * - parallel, depending on the input size and Settings * - using sampling for splitting * - not using sentinels * * Example: * *
   *   int sequences[10][10];
   *   for (int __i = 0; __i < 10; ++__i)
   *     for (int __j = 0; __i < 10; ++__j)
   *       sequences[__i][__j] = __j;
   *
   *   int __out[33];
   *   std::vector > seqs;
   *   for (int __i = 0; __i < 10; ++__i)
   *     { seqs.push(std::make_pair(sequences[__i],
   *                                      sequences[__i] + 10)) }
   *
   *   multiway_merge(seqs.begin(), seqs.end(), __target, std::less(), 33);
   * 
* * @see stable_multiway_merge * * @pre All input sequences must be sorted. * @pre Target must provide enough space to merge out length elements or * the number of elements in all sequences, whichever is smaller. * * @post [__target, return __value) contains merged __elements from the * input sequences. * @post return __value - __target = min(__length, number of elements in all * sequences). * * @tparam _RAIterPairIterator iterator over sequence * of pairs of iterators * @tparam _RAIterOut iterator over target sequence * @tparam _DifferenceTp difference type for the sequence * @tparam _Compare strict weak ordering type to compare elements * in sequences * * @param __seqs_begin __begin of sequence __sequence * @param __seqs_end _M_end of sequence __sequence * @param __target target sequence to merge to. * @param __comp strict weak ordering to use for element comparison. * @param __length Maximum length to merge, possibly larger than the * number of elements available. * * @return _M_end iterator of output sequence */ // multiway_merge // public interface template _RAIterOut multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute multiway merge *sequentially*. return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_exact_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sampling_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_exact_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag = parallel_tag(0)) { return multiway_merge(__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // public interface template _RAIterOut multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) { return multiway_merge(__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // stable_multiway_merge // public interface template _RAIterOut stable_multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute multiway merge *sequentially*. return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_exact_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_sampling_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag = parallel_tag(0)) { return stable_multiway_merge (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // public interface template _RAIterOut stable_multiway_merge(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) { return stable_multiway_merge (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } /** * @brief Multiway Merge Frontend. * * Merge the sequences specified by seqs_begin and __seqs_end into * __target. __seqs_begin and __seqs_end must point to a sequence of * pairs. These pairs must contain an iterator to the beginning * of a sequence in their first entry and an iterator the _M_end of * the same sequence in their second entry. * * Ties are broken arbitrarily. See stable_multiway_merge for a variant * that breaks ties by sequence number but is slower. * * The first entries of the pairs (i.e. the begin iterators) will be moved * forward accordingly. * * The output sequence has to provide enough space for all elements * that are written to it. * * This function will merge the input sequences: * * - not stable * - parallel, depending on the input size and Settings * - using sampling for splitting * - using sentinels * * You have to take care that the element the _M_end iterator points to is * readable and contains a value that is greater than any other non-sentinel * value in all sequences. * * Example: * *
   *   int sequences[10][11];
   *   for (int __i = 0; __i < 10; ++__i)
   *     for (int __j = 0; __i < 11; ++__j)
   *       sequences[__i][__j] = __j; // __last one is sentinel!
   *
   *   int __out[33];
   *   std::vector > seqs;
   *   for (int __i = 0; __i < 10; ++__i)
   *     { seqs.push(std::make_pair(sequences[__i],
   *                                      sequences[__i] + 10)) }
   *
   *   multiway_merge(seqs.begin(), seqs.end(), __target, std::less(), 33);
   * 
* * @pre All input sequences must be sorted. * @pre Target must provide enough space to merge out length elements or * the number of elements in all sequences, whichever is smaller. * @pre For each @c __i, @c __seqs_begin[__i].second must be the end * marker of the sequence, but also reference the one more __sentinel * element. * * @post [__target, return __value) contains merged __elements from the * input sequences. * @post return __value - __target = min(__length, number of elements in all * sequences). * * @see stable_multiway_merge_sentinels * * @tparam _RAIterPairIterator iterator over sequence * of pairs of iterators * @tparam _RAIterOut iterator over target sequence * @tparam _DifferenceTp difference type for the sequence * @tparam _Compare strict weak ordering type to compare elements * in sequences * * @param __seqs_begin __begin of sequence __sequence * @param __seqs_end _M_end of sequence __sequence * @param __target target sequence to merge to. * @param __comp strict weak ordering to use for element comparison. * @param __length Maximum length to merge, possibly larger than the * number of elements available. * * @return _M_end iterator of output sequence */ // multiway_merge_sentinels // public interface template _RAIterOut multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute multiway merge *sequentially*. return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_exact_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_sampling_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge ( __seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag = parallel_tag(0)) { return multiway_merge_sentinels (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // public interface template _RAIterOut multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) { return multiway_merge_sentinels (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // stable_multiway_merge_sentinels // public interface template _RAIterOut stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute multiway merge *sequentially*. return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_exact_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) { typedef _DifferenceTp _DifferenceType; _GLIBCXX_CALL(__seqs_end - __seqs_begin) // catch special case: no sequences if (__seqs_begin == __seqs_end) return __target; // Execute merge; maybe parallel, depending on the number of merged // elements and the number of sequences and global thresholds in // Settings. if ((__seqs_end - __seqs_begin > 1) && _GLIBCXX_PARALLEL_CONDITION( ((__seqs_end - __seqs_begin) >= __gnu_parallel::_Settings::get().multiway_merge_minimal_k) && ((_SequenceIndex)__length >= __gnu_parallel::_Settings::get().multiway_merge_minimal_n))) return parallel_multiway_merge (__seqs_begin, __seqs_end, __target, multiway_merge_sampling_splitting ::value_type*, _Compare, _DifferenceTp>, static_cast<_DifferenceType>(__length), __comp, __tag.__get_num_threads()); else return __sequential_multiway_merge (__seqs_begin, __seqs_end, __target, *(__seqs_begin->second), __length, __comp); } // public interface template _RAIterOut stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag = parallel_tag(0)) { return stable_multiway_merge_sentinels (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } // public interface template _RAIterOut stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) { return stable_multiway_merge_sentinels (__seqs_begin, __seqs_end, __target, __length, __comp, exact_tag(__tag.__get_num_threads())); } }; // namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H */ 4.8.2/parallel/compiletime_settings.h000064400000005417147547540550013440 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/compiletime_settings.h * @brief Defines on options concerning debugging and performance, at * compile-time. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #include /** @brief Determine verbosity level of the parallel mode. * Level 1 prints a message each time a parallel-mode function is entered. */ #define _GLIBCXX_VERBOSE_LEVEL 0 /** @def _GLIBCXX_CALL * @brief Macro to produce log message when entering a function. * @param __n Input size. * @see _GLIBCXX_VERBOSE_LEVEL */ #if (_GLIBCXX_VERBOSE_LEVEL == 0) #define _GLIBCXX_CALL(__n) #endif #if (_GLIBCXX_VERBOSE_LEVEL == 1) #define _GLIBCXX_CALL(__n) \ printf(" %__s:\niam = %d, __n = %ld, __num_threads = %d\n", \ __PRETTY_FUNCTION__, omp_get_thread_num(), (__n), __get_max_threads()); #endif #ifndef _GLIBCXX_SCALE_DOWN_FPU /** @brief Use floating-point scaling instead of modulo for mapping * random numbers to a range. This can be faster on certain CPUs. */ #define _GLIBCXX_SCALE_DOWN_FPU 0 #endif #ifndef _GLIBCXX_ASSERTIONS /** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code. * Should be switched on only locally. */ #define _GLIBCXX_ASSERTIONS 0 #endif #ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 /** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code. * Consider the size of the L1 cache for * gnu_parallel::__parallel_random_shuffle(). */ #define _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 0 #endif #ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB /** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code. * Consider the size of the TLB for * gnu_parallel::__parallel_random_shuffle(). */ #define _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB 0 #endif 4.8.2/parallel/list_partition.h000064400000014612147547540550012252 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute __it and/or modify __it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that __it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/list_partition.h * @brief _Functionality to split __sequence referenced by only input * iterators. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Leonor Frias Moya and Johannes Singler. #ifndef _GLIBCXX_PARALLEL_LIST_PARTITION_H #define _GLIBCXX_PARALLEL_LIST_PARTITION_H 1 #include #include namespace __gnu_parallel { /** @brief Shrinks and doubles the ranges. * @param __os_starts Start positions worked on (oversampled). * @param __count_to_two Counts up to 2. * @param __range_length Current length of a chunk. * @param __make_twice Whether the @c __os_starts is allowed to be * grown or not */ template void __shrink_and_double(std::vector<_IIter>& __os_starts, size_t& __count_to_two, size_t& __range_length, const bool __make_twice) { ++__count_to_two; if (!__make_twice || __count_to_two < 2) __shrink(__os_starts, __count_to_two, __range_length); else { __os_starts.resize((__os_starts.size() - 1) * 2 + 1); __count_to_two = 0; } } /** @brief Combines two ranges into one and thus halves the number of ranges. * @param __os_starts Start positions worked on (oversampled). * @param __count_to_two Counts up to 2. * @param __range_length Current length of a chunk. */ template void __shrink(std::vector<_IIter>& __os_starts, size_t& __count_to_two, size_t& __range_length) { for (typename std::vector<_IIter>::size_type __i = 0; __i <= (__os_starts.size() / 2); ++__i) __os_starts[__i] = __os_starts[__i * 2]; __range_length *= 2; } /** @brief Splits a sequence given by input iterators into parts of * almost equal size * * The function needs only one pass over the sequence. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __starts Start iterators for the resulting parts, dimension * @c __num_parts+1. For convenience, @c __starts @c [__num_parts] * contains the end iterator of the sequence. * @param __lengths Length of the resulting parts. * @param __num_parts Number of parts to split the sequence into. * @param __f Functor to be applied to each element by traversing __it * @param __oversampling Oversampling factor. If 0, then the * partitions will differ in at most * \sqrt{\mathrm{__end} - \mathrm{__begin}} * __elements. Otherwise, the ratio between the * longest and the shortest part is bounded by * 1/(\mathrm{__oversampling} \cdot \mathrm{num\_parts}) * @return Length of the whole sequence. */ template size_t list_partition(const _IIter __begin, const _IIter __end, _IIter* __starts, size_t* __lengths, const int __num_parts, _FunctorType& __f, int __oversampling = 0) { bool __make_twice = false; // The resizing algorithm is chosen according to the oversampling factor. if (__oversampling == 0) { __make_twice = true; __oversampling = 1; } std::vector<_IIter> __os_starts(2 * __oversampling * __num_parts + 1); __os_starts[0] = __begin; _IIter __prev = __begin, __it = __begin; size_t __dist_limit = 0, __dist = 0; size_t __cur = 1, __next = 1; size_t __range_length = 1; size_t __count_to_two = 0; while (__it != __end) { __cur = __next; for (; __cur < __os_starts.size() and __it != __end; ++__cur) { for (__dist_limit += __range_length; __dist < __dist_limit and __it != __end; ++__dist) { __f(__it); ++__it; } __os_starts[__cur] = __it; } // Must compare for end and not __cur < __os_starts.size() , because // __cur could be == __os_starts.size() as well if (__it == __end) break; __shrink_and_double(__os_starts, __count_to_two, __range_length, __make_twice); __next = __os_starts.size() / 2 + 1; } // Calculation of the parts (one must be extracted from __current // because the partition beginning at end, consists only of // itself). size_t __size_part = (__cur - 1) / __num_parts; int __size_greater = static_cast((__cur - 1) % __num_parts); __starts[0] = __os_starts[0]; size_t __index = 0; // Smallest partitions. for (int __i = 1; __i < (__num_parts + 1 - __size_greater); ++__i) { __lengths[__i - 1] = __size_part * __range_length; __index += __size_part; __starts[__i] = __os_starts[__index]; } // Biggest partitions. for (int __i = __num_parts + 1 - __size_greater; __i <= __num_parts; ++__i) { __lengths[__i - 1] = (__size_part+1) * __range_length; __index += (__size_part+1); __starts[__i] = __os_starts[__index]; } // Correction of the end size (the end iteration has not finished). __lengths[__num_parts - 1] -= (__dist_limit - __dist); return __dist; } } #endif /* _GLIBCXX_PARALLEL_LIST_PARTITION_H */ 4.8.2/parallel/workstealing.h000064400000022614147547540550011720 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/workstealing.h * @brief Parallelization of embarrassingly parallel execution by * means of work-stealing. * * Work stealing is described in * * R. D. Blumofe and C. E. Leiserson. * Scheduling multithreaded computations by work stealing. * Journal of the ACM, 46(5):720–748, 1999. * * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_WORKSTEALING_H #define _GLIBCXX_PARALLEL_WORKSTEALING_H 1 #include #include #include namespace __gnu_parallel { #define _GLIBCXX_JOB_VOLATILE volatile /** @brief One __job for a certain thread. */ template struct _Job { typedef _DifferenceTp _DifferenceType; /** @brief First element. * * Changed by owning and stealing thread. By stealing thread, * always incremented. */ _GLIBCXX_JOB_VOLATILE _DifferenceType _M_first; /** @brief Last element. * * Changed by owning thread only. */ _GLIBCXX_JOB_VOLATILE _DifferenceType _M_last; /** @brief Number of elements, i.e. @c _M_last-_M_first+1. * * Changed by owning thread only. */ _GLIBCXX_JOB_VOLATILE _DifferenceType _M_load; }; /** @brief Work stealing algorithm for random access iterators. * * Uses O(1) additional memory. Synchronization at job lists is * done with atomic operations. * @param __begin Begin iterator of element sequence. * @param __end End iterator of element sequence. * @param __op User-supplied functor (comparator, predicate, adding * functor, ...). * @param __f Functor to @a process an element with __op (depends on * desired functionality, e. g. for std::for_each(), ...). * @param __r Functor to @a add a single __result to the already * processed elements (depends on functionality). * @param __base Base value for reduction. * @param __output Pointer to position where final result is written to * @param __bound Maximum number of elements processed (e. g. for * std::count_n()). * @return User-supplied functor (that may contain a part of the result). */ template _Op __for_each_template_random_access_workstealing(_RAIter __begin, _RAIter __end, _Op __op, _Fu& __f, _Red __r, _Result __base, _Result& __output, typename std::iterator_traits<_RAIter>::difference_type __bound) { _GLIBCXX_CALL(__end - __begin) typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; const _Settings& __s = _Settings::get(); _DifferenceType __chunk_size = static_cast<_DifferenceType>(__s.workstealing_chunk_size); // How many jobs? _DifferenceType __length = (__bound < 0) ? (__end - __begin) : __bound; // To avoid false sharing in a cache line. const int __stride = (__s.cache_line_size * 10 / sizeof(_Job<_DifferenceType>) + 1); // Total number of threads currently working. _ThreadIndex __busy = 0; _Job<_DifferenceType> *__job; omp_lock_t __output_lock; omp_init_lock(&__output_lock); // Write base value to output. __output = __base; // No more threads than jobs, at least one thread. _ThreadIndex __num_threads = __gnu_parallel::max<_ThreadIndex> (1, __gnu_parallel::min<_DifferenceType>(__length, __get_max_threads())); # pragma omp parallel shared(__busy) num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); // Create job description array. __job = new _Job<_DifferenceType>[__num_threads * __stride]; } // Initialization phase. // Flags for every thread if it is doing productive work. bool __iam_working = false; // Thread id. _ThreadIndex __iam = omp_get_thread_num(); // This job. _Job<_DifferenceType>& __my_job = __job[__iam * __stride]; // Random number (for work stealing). _ThreadIndex __victim; // Local value for reduction. _Result __result = _Result(); // Number of elements to steal in one attempt. _DifferenceType __steal; // Every thread has its own random number generator // (modulo __num_threads). _RandomNumber __rand_gen(__iam, __num_threads); // This thread is currently working. # pragma omp atomic ++__busy; __iam_working = true; // How many jobs per thread? last thread gets the rest. __my_job._M_first = static_cast<_DifferenceType> (__iam * (__length / __num_threads)); __my_job._M_last = (__iam == (__num_threads - 1) ? (__length - 1) : ((__iam + 1) * (__length / __num_threads) - 1)); __my_job._M_load = __my_job._M_last - __my_job._M_first + 1; // Init result with _M_first value (to have a base value for reduction) if (__my_job._M_first <= __my_job._M_last) { // Cannot use volatile variable directly. _DifferenceType __my_first = __my_job._M_first; __result = __f(__op, __begin + __my_first); ++__my_job._M_first; --__my_job._M_load; } _RAIter __current; # pragma omp barrier // Actual work phase // Work on own or stolen current start while (__busy > 0) { // Work until no productive thread left. # pragma omp flush(__busy) // Thread has own work to do while (__my_job._M_first <= __my_job._M_last) { // fetch-and-add call // Reserve current job block (size __chunk_size) in my queue. _DifferenceType __current_job = __fetch_and_add<_DifferenceType>(&(__my_job._M_first), __chunk_size); // Update _M_load, to make the three values consistent, // _M_first might have been changed in the meantime __my_job._M_load = __my_job._M_last - __my_job._M_first + 1; for (_DifferenceType __job_counter = 0; __job_counter < __chunk_size && __current_job <= __my_job._M_last; ++__job_counter) { // Yes: process it! __current = __begin + __current_job; ++__current_job; // Do actual work. __result = __r(__result, __f(__op, __current)); } # pragma omp flush(__busy) } // After reaching this point, a thread's __job list is empty. if (__iam_working) { // This thread no longer has work. # pragma omp atomic --__busy; __iam_working = false; } _DifferenceType __supposed_first, __supposed_last, __supposed_load; do { // Find random nonempty deque (not own), do consistency check. __yield(); # pragma omp flush(__busy) __victim = __rand_gen(); __supposed_first = __job[__victim * __stride]._M_first; __supposed_last = __job[__victim * __stride]._M_last; __supposed_load = __job[__victim * __stride]._M_load; } while (__busy > 0 && ((__supposed_load <= 0) || ((__supposed_first + __supposed_load - 1) != __supposed_last))); if (__busy == 0) break; if (__supposed_load > 0) { // Has work and work to do. // Number of elements to steal (at least one). __steal = (__supposed_load < 2) ? 1 : __supposed_load / 2; // Push __victim's current start forward. _DifferenceType __stolen_first = __fetch_and_add<_DifferenceType> (&(__job[__victim * __stride]._M_first), __steal); _DifferenceType __stolen_try = (__stolen_first + __steal - _DifferenceType(1)); __my_job._M_first = __stolen_first; __my_job._M_last = __gnu_parallel::min(__stolen_try, __supposed_last); __my_job._M_load = __my_job._M_last - __my_job._M_first + 1; // Has potential work again. # pragma omp atomic ++__busy; __iam_working = true; # pragma omp flush(__busy) } # pragma omp flush(__busy) } // end while __busy > 0 // Add accumulated result to output. omp_set_lock(&__output_lock); __output = __r(__output, __result); omp_unset_lock(&__output_lock); } delete[] __job; // Points to last element processed (needed as return value for // some algorithms like transform) __f._M_finish_iterator = __begin + __length; omp_destroy_lock(&__output_lock); return __op; } } // end namespace #endif /* _GLIBCXX_PARALLEL_WORKSTEALING_H */ 4.8.2/parallel/quicksort.h000064400000013756147547540550011242 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/quicksort.h * @brief Implementation of a unbalanced parallel quicksort (in-place). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_QUICKSORT_H #define _GLIBCXX_PARALLEL_QUICKSORT_H 1 #include #include namespace __gnu_parallel { /** @brief Unbalanced quicksort divide step. * @param __begin Begin iterator of subsequence. * @param __end End iterator of subsequence. * @param __comp Comparator. * @param __pivot_rank Desired __rank of the pivot. * @param __num_samples Choose pivot from that many samples. * @param __num_threads Number of threads that are allowed to work on * this part. */ template typename std::iterator_traits<_RAIter>::difference_type __parallel_sort_qs_divide(_RAIter __begin, _RAIter __end, _Compare __comp, typename std::iterator_traits <_RAIter>::difference_type __pivot_rank, typename std::iterator_traits <_RAIter>::difference_type __num_samples, _ThreadIndex __num_threads) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; __num_samples = std::min(__num_samples, __n); // Allocate uninitialized, to avoid default constructor. _ValueType* __samples = static_cast<_ValueType*> (::operator new(__num_samples * sizeof(_ValueType))); for (_DifferenceType __s = 0; __s < __num_samples; ++__s) { const unsigned long long __index = static_cast (__s) * __n / __num_samples; ::new(&(__samples[__s])) _ValueType(__begin[__index]); } __gnu_sequential::sort(__samples, __samples + __num_samples, __comp); _ValueType& __pivot = __samples[__pivot_rank * __num_samples / __n]; __gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool> __pred(__comp, __pivot); _DifferenceType __split = __parallel_partition(__begin, __end, __pred, __num_threads); for (_DifferenceType __s = 0; __s < __num_samples; ++__s) __samples[__s].~_ValueType(); ::operator delete(__samples); return __split; } /** @brief Unbalanced quicksort conquer step. * @param __begin Begin iterator of subsequence. * @param __end End iterator of subsequence. * @param __comp Comparator. * @param __num_threads Number of threads that are allowed to work on * this part. */ template void __parallel_sort_qs_conquer(_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; if (__num_threads <= 1) { __gnu_sequential::sort(__begin, __end, __comp); return; } _DifferenceType __n = __end - __begin, __pivot_rank; if (__n <= 1) return; _ThreadIndex __num_threads_left; if ((__num_threads % 2) == 1) __num_threads_left = __num_threads / 2 + 1; else __num_threads_left = __num_threads / 2; __pivot_rank = __n * __num_threads_left / __num_threads; _DifferenceType __split = __parallel_sort_qs_divide (__begin, __end, __comp, __pivot_rank, _Settings::get().sort_qs_num_samples_preset, __num_threads); #pragma omp parallel sections num_threads(2) { #pragma omp section __parallel_sort_qs_conquer(__begin, __begin + __split, __comp, __num_threads_left); #pragma omp section __parallel_sort_qs_conquer(__begin + __split, __end, __comp, __num_threads - __num_threads_left); } } /** @brief Unbalanced quicksort main call. * @param __begin Begin iterator of input sequence. * @param __end End iterator input sequence, ignored. * @param __comp Comparator. * @param __num_threads Number of threads that are allowed to work on * this part. */ template void __parallel_sort_qs(_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads) { _GLIBCXX_CALL(__n) typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; // At least one element per processor. if (__num_threads > __n) __num_threads = static_cast<_ThreadIndex>(__n); __parallel_sort_qs_conquer( __begin, __begin + __n, __comp, __num_threads); } } //namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_QUICKSORT_H */ 4.8.2/parallel/basic_iterator.h000064400000003062147547540550012175 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/basic_iterator.h * @brief Includes the original header files concerned with iterators * except for stream iterators. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_BASIC_ITERATOR_H #define _GLIBCXX_PARALLEL_BASIC_ITERATOR_H 1 #include #include #include #include #endif /* _GLIBCXX_PARALLEL_BASIC_ITERATOR_H */ 4.8.2/parallel/types.h000064400000007204147547540550010351 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/types.h * @brief Basic types and typedefs. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_TYPES_H #define _GLIBCXX_PARALLEL_TYPES_H 1 #include #include #include namespace __gnu_parallel { // Enumerated types. /// Run-time equivalents for the compile-time tags. enum _Parallelism { /// Not parallel. sequential, /// Parallel unbalanced (equal-sized chunks). parallel_unbalanced, /// Parallel balanced (work-stealing). parallel_balanced, /// Parallel with OpenMP dynamic load-balancing. parallel_omp_loop, /// Parallel with OpenMP static load-balancing. parallel_omp_loop_static, /// Parallel with OpenMP taskqueue construct. parallel_taskqueue }; /// Strategies for run-time algorithm selection: // force_sequential, force_parallel, heuristic. enum _AlgorithmStrategy { heuristic, force_sequential, force_parallel }; /// Sorting algorithms: // multi-way mergesort, quicksort, load-balanced quicksort. enum _SortAlgorithm { MWMS, QS, QS_BALANCED }; /// Merging algorithms: // bubblesort-alike, loser-tree variants, enum __sentinel. enum _MultiwayMergeAlgorithm { LOSER_TREE }; /// Partial sum algorithms: recursive, linear. enum _PartialSumAlgorithm { RECURSIVE, LINEAR }; /// Sorting/merging algorithms: sampling, __exact. enum _SplittingAlgorithm { SAMPLING, EXACT }; /// Find algorithms: // growing blocks, equal-sized blocks, equal splitting. enum _FindAlgorithm { GROWING_BLOCKS, CONSTANT_SIZE_BLOCKS, EQUAL_SPLIT }; /** * @brief Unsigned integer to index __elements. * The total number of elements for each algorithm must fit into this type. */ typedef uint64_t _SequenceIndex; /** * @brief Unsigned integer to index a thread number. * The maximum thread number (for each processor) must fit into this type. */ typedef uint16_t _ThreadIndex; // XXX atomics interface? /// Longest compare-and-swappable integer type on this platform. typedef int64_t _CASable; /// Number of bits of _CASable. static const int _CASable_bits = std::numeric_limits<_CASable>::digits; /// ::_CASable with the right half of bits set to 1. static const _CASable _CASable_mask = ((_CASable(1) << (_CASable_bits / 2)) - 1); } #endif /* _GLIBCXX_PARALLEL_TYPES_H */ 4.8.2/parallel/for_each_selectors.h000064400000024505147547540550013041 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/for_each_selectors.h * @brief Functors representing different tasks to be plugged into the * generic parallelization methods for embarrassingly parallel functions. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H #define _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H 1 #include namespace __gnu_parallel { /** @brief Generic __selector for embarrassingly parallel functions. */ template struct __generic_for_each_selector { /** @brief _Iterator on last element processed; needed for some * algorithms (e. g. std::transform()). */ _It _M_finish_iterator; }; /** @brief std::for_each() selector. */ template struct __for_each_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. */ template bool operator()(_Op& __o, _It __i) { __o(*__i); return true; } }; /** @brief std::generate() selector. */ template struct __generate_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. */ template bool operator()(_Op& __o, _It __i) { *__i = __o(); return true; } }; /** @brief std::fill() selector. */ template struct __fill_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __v Current value. * @param __i iterator referencing object. */ template bool operator()(_ValueType& __v, _It __i) { *__i = __v; return true; } }; /** @brief std::transform() __selector, one input sequence variant. */ template struct __transform1_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. */ template bool operator()(_Op& __o, _It __i) { *__i.second = __o(*__i.first); return true; } }; /** @brief std::transform() __selector, two input sequences variant. */ template struct __transform2_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. */ template bool operator()(_Op& __o, _It __i) { *__i._M_third = __o(*__i._M_first, *__i._M_second); return true; } }; /** @brief std::replace() selector. */ template struct __replace_selector : public __generic_for_each_selector<_It> { /** @brief Value to replace with. */ const _Tp& __new_val; /** @brief Constructor * @param __new_val Value to replace with. */ explicit __replace_selector(const _Tp &__new_val) : __new_val(__new_val) {} /** @brief Functor execution. * @param __v Current value. * @param __i iterator referencing object. */ bool operator()(_Tp& __v, _It __i) { if (*__i == __v) *__i = __new_val; return true; } }; /** @brief std::replace() selector. */ template struct __replace_if_selector : public __generic_for_each_selector<_It> { /** @brief Value to replace with. */ const _Tp& __new_val; /** @brief Constructor. * @param __new_val Value to replace with. */ explicit __replace_if_selector(const _Tp &__new_val) : __new_val(__new_val) { } /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. */ bool operator()(_Op& __o, _It __i) { if (__o(*__i)) *__i = __new_val; return true; } }; /** @brief std::count() selector. */ template struct __count_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __v Current value. * @param __i iterator referencing object. * @return 1 if count, 0 if does not count. */ template _Diff operator()(_ValueType& __v, _It __i) { return (__v == *__i) ? 1 : 0; } }; /** @brief std::count_if () selector. */ template struct __count_if_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator. * @param __i iterator referencing object. * @return 1 if count, 0 if does not count. */ template _Diff operator()(_Op& __o, _It __i) { return (__o(*__i)) ? 1 : 0; } }; /** @brief std::accumulate() selector. */ template struct __accumulate_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator (unused). * @param __i iterator referencing object. * @return The current value. */ template typename std::iterator_traits<_It>::value_type operator()(_Op __o, _It __i) { return *__i; } }; /** @brief std::inner_product() selector. */ template struct __inner_product_selector : public __generic_for_each_selector<_It> { /** @brief Begin iterator of first sequence. */ _It __begin1_iterator; /** @brief Begin iterator of second sequence. */ _It2 __begin2_iterator; /** @brief Constructor. * @param __b1 Begin iterator of first sequence. * @param __b2 Begin iterator of second sequence. */ explicit __inner_product_selector(_It __b1, _It2 __b2) : __begin1_iterator(__b1), __begin2_iterator(__b2) { } /** @brief Functor execution. * @param __mult Multiplication functor. * @param __current iterator referencing object. * @return Inner product elemental __result. */ template _Tp operator()(_Op __mult, _It __current) { typename std::iterator_traits<_It>::difference_type __position = __current - __begin1_iterator; return __mult(*__current, *(__begin2_iterator + __position)); } }; /** @brief Selector that just returns the passed iterator. */ template struct __identity_selector : public __generic_for_each_selector<_It> { /** @brief Functor execution. * @param __o Operator (unused). * @param __i iterator referencing object. * @return Passed iterator. */ template _It operator()(_Op __o, _It __i) { return __i; } }; /** @brief Selector that returns the difference between two adjacent * __elements. */ template struct __adjacent_difference_selector : public __generic_for_each_selector<_It> { template bool operator()(_Op& __o, _It __i) { typename _It::first_type __go_back_one = __i.first; --__go_back_one; *__i.second = __o(*__i.first, *__go_back_one); return true; } }; /** @brief Functor doing nothing * * For some __reduction tasks (this is not a function object, but is * passed as __selector __dummy parameter. */ struct _Nothing { /** @brief Functor execution. * @param __i iterator referencing object. */ template void operator()(_It __i) { } }; /** @brief Reduction function doing nothing. */ struct _DummyReduct { bool operator()(bool, bool) const { return true; } }; /** @brief Reduction for finding the maximum element, using a comparator. */ template struct __min_element_reduct { _Compare& __comp; explicit __min_element_reduct(_Compare &__c) : __comp(__c) { } _It operator()(_It __x, _It __y) { return (__comp(*__x, *__y)) ? __x : __y; } }; /** @brief Reduction for finding the maximum element, using a comparator. */ template struct __max_element_reduct { _Compare& __comp; explicit __max_element_reduct(_Compare& __c) : __comp(__c) { } _It operator()(_It __x, _It __y) { return (__comp(*__x, *__y)) ? __y : __x; } }; /** @brief General reduction, using a binary operator. */ template struct __accumulate_binop_reduct { _BinOp& __binop; explicit __accumulate_binop_reduct(_BinOp& __b) : __binop(__b) { } template _Result operator()(const _Result& __x, const _Addend& __y) { return __binop(__x, __y); } }; } #endif /* _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H */ 4.8.2/parallel/random_shuffle.h000064400000044363147547540550012210 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/random_shuffle.h * @brief Parallel implementation of std::random_shuffle(). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H #define _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H 1 #include #include #include #include namespace __gnu_parallel { /** @brief Type to hold the index of a bin. * * Since many variables of this type are allocated, it should be * chosen as small as possible. */ typedef unsigned short _BinIndex; /** @brief Data known to every thread participating in __gnu_parallel::__parallel_random_shuffle(). */ template struct _DRandomShufflingGlobalData { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; /** @brief Begin iterator of the __source. */ _RAIter& _M_source; /** @brief Temporary arrays for each thread. */ _ValueType** _M_temporaries; /** @brief Two-dimensional array to hold the thread-bin distribution. * * Dimensions (_M_num_threads + 1) __x (_M_num_bins + 1). */ _DifferenceType** _M_dist; /** @brief Start indexes of the threads' __chunks. */ _DifferenceType* _M_starts; /** @brief Number of the thread that will further process the corresponding bin. */ _ThreadIndex* _M_bin_proc; /** @brief Number of bins to distribute to. */ int _M_num_bins; /** @brief Number of bits needed to address the bins. */ int _M_num_bits; /** @brief Constructor. */ _DRandomShufflingGlobalData(_RAIter& __source) : _M_source(__source) { } }; /** @brief Local data for a thread participating in __gnu_parallel::__parallel_random_shuffle(). */ template struct _DRSSorterPU { /** @brief Number of threads participating in total. */ int _M_num_threads; /** @brief Begin index for bins taken care of by this thread. */ _BinIndex _M_bins_begin; /** @brief End index for bins taken care of by this thread. */ _BinIndex __bins_end; /** @brief Random _M_seed for this thread. */ uint32_t _M_seed; /** @brief Pointer to global data. */ _DRandomShufflingGlobalData<_RAIter>* _M_sd; }; /** @brief Generate a random number in @c [0,2^__logp). * @param __logp Logarithm (basis 2) of the upper range __bound. * @param __rng Random number generator to use. */ template inline int __random_number_pow2(int __logp, _RandomNumberGenerator& __rng) { return __rng.__genrand_bits(__logp); } /** @brief Random shuffle code executed by each thread. * @param __pus Array of thread-local data records. */ template void __parallel_random_shuffle_drs_pu(_DRSSorterPU<_RAIter, _RandomNumberGenerator>* __pus) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _ThreadIndex __iam = omp_get_thread_num(); _DRSSorterPU<_RAIter, _RandomNumberGenerator>* __d = &__pus[__iam]; _DRandomShufflingGlobalData<_RAIter>* __sd = __d->_M_sd; // Indexing: _M_dist[bin][processor] _DifferenceType __length = (__sd->_M_starts[__iam + 1] - __sd->_M_starts[__iam]); _BinIndex* __oracles = new _BinIndex[__length]; _DifferenceType* __dist = new _DifferenceType[__sd->_M_num_bins + 1]; _BinIndex* __bin_proc = new _BinIndex[__sd->_M_num_bins]; _ValueType** __temporaries = new _ValueType*[__d->_M_num_threads]; // Compute oracles and count appearances. for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b) __dist[__b] = 0; int __num_bits = __sd->_M_num_bits; _RandomNumber __rng(__d->_M_seed); // First main loop. for (_DifferenceType __i = 0; __i < __length; ++__i) { _BinIndex __oracle = __random_number_pow2(__num_bits, __rng); __oracles[__i] = __oracle; // To allow prefix (partial) sum. ++(__dist[__oracle + 1]); } for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b) __sd->_M_dist[__b][__iam + 1] = __dist[__b]; # pragma omp barrier # pragma omp single { // Sum up bins, __sd->_M_dist[__s + 1][__d->_M_num_threads] now // contains the total number of items in bin __s for (_BinIndex __s = 0; __s < __sd->_M_num_bins; ++__s) __gnu_sequential::partial_sum(__sd->_M_dist[__s + 1], __sd->_M_dist[__s + 1] + __d->_M_num_threads + 1, __sd->_M_dist[__s + 1]); } # pragma omp barrier _SequenceIndex __offset = 0, __global_offset = 0; for (_BinIndex __s = 0; __s < __d->_M_bins_begin; ++__s) __global_offset += __sd->_M_dist[__s + 1][__d->_M_num_threads]; # pragma omp barrier for (_BinIndex __s = __d->_M_bins_begin; __s < __d->__bins_end; ++__s) { for (int __t = 0; __t < __d->_M_num_threads + 1; ++__t) __sd->_M_dist[__s + 1][__t] += __offset; __offset = __sd->_M_dist[__s + 1][__d->_M_num_threads]; } __sd->_M_temporaries[__iam] = static_cast<_ValueType*> (::operator new(sizeof(_ValueType) * __offset)); # pragma omp barrier // Draw local copies to avoid false sharing. for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b) __dist[__b] = __sd->_M_dist[__b][__iam]; for (_BinIndex __b = 0; __b < __sd->_M_num_bins; ++__b) __bin_proc[__b] = __sd->_M_bin_proc[__b]; for (_ThreadIndex __t = 0; __t < __d->_M_num_threads; ++__t) __temporaries[__t] = __sd->_M_temporaries[__t]; _RAIter __source = __sd->_M_source; _DifferenceType __start = __sd->_M_starts[__iam]; // Distribute according to oracles, second main loop. for (_DifferenceType __i = 0; __i < __length; ++__i) { _BinIndex __target_bin = __oracles[__i]; _ThreadIndex __target_p = __bin_proc[__target_bin]; // Last column [__d->_M_num_threads] stays unchanged. ::new(&(__temporaries[__target_p][__dist[__target_bin + 1]++])) _ValueType(*(__source + __i + __start)); } delete[] __oracles; delete[] __dist; delete[] __bin_proc; delete[] __temporaries; # pragma omp barrier // Shuffle bins internally. for (_BinIndex __b = __d->_M_bins_begin; __b < __d->__bins_end; ++__b) { _ValueType* __begin = (__sd->_M_temporaries[__iam] + (__b == __d->_M_bins_begin ? 0 : __sd->_M_dist[__b][__d->_M_num_threads])), *__end = (__sd->_M_temporaries[__iam] + __sd->_M_dist[__b + 1][__d->_M_num_threads]); __sequential_random_shuffle(__begin, __end, __rng); std::copy(__begin, __end, __sd->_M_source + __global_offset + (__b == __d->_M_bins_begin ? 0 : __sd->_M_dist[__b][__d->_M_num_threads])); } for (_SequenceIndex __i = 0; __i < __offset; ++__i) __sd->_M_temporaries[__iam][__i].~_ValueType(); ::operator delete(__sd->_M_temporaries[__iam]); } /** @brief Round up to the next greater power of 2. * @param __x _Integer to round up */ template _Tp __round_up_to_pow2(_Tp __x) { if (__x <= 1) return 1; else return (_Tp)1 << (__rd_log2(__x - 1) + 1); } /** @brief Main parallel random shuffle step. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __n Length of sequence. * @param __num_threads Number of threads to use. * @param __rng Random number generator to use. */ template void __parallel_random_shuffle_drs(_RAIter __begin, _RAIter __end, typename std::iterator_traits <_RAIter>::difference_type __n, _ThreadIndex __num_threads, _RandomNumberGenerator& __rng) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _GLIBCXX_CALL(__n) const _Settings& __s = _Settings::get(); if (__num_threads > __n) __num_threads = static_cast<_ThreadIndex>(__n); _BinIndex __num_bins, __num_bins_cache; #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 // Try the L1 cache first. // Must fit into L1. __num_bins_cache = std::max<_DifferenceType>(1, __n / (__s.L1_cache_size_lb / sizeof(_ValueType))); __num_bins_cache = __round_up_to_pow2(__num_bins_cache); // No more buckets than TLB entries, power of 2 // Power of 2 and at least one element per bin, at most the TLB size. __num_bins = std::min<_DifferenceType>(__n, __num_bins_cache); #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB // 2 TLB entries needed per bin. __num_bins = std::min<_DifferenceType>(__s.TLB_size / 2, __num_bins); #endif __num_bins = __round_up_to_pow2(__num_bins); if (__num_bins < __num_bins_cache) { #endif // Now try the L2 cache // Must fit into L2 __num_bins_cache = static_cast<_BinIndex> (std::max<_DifferenceType>(1, __n / (__s.L2_cache_size / sizeof(_ValueType)))); __num_bins_cache = __round_up_to_pow2(__num_bins_cache); // No more buckets than TLB entries, power of 2. __num_bins = static_cast<_BinIndex> (std::min(__n, static_cast<_DifferenceType>(__num_bins_cache))); // Power of 2 and at least one element per bin, at most the TLB size. #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB // 2 TLB entries needed per bin. __num_bins = std::min(static_cast<_DifferenceType>(__s.TLB_size / 2), __num_bins); #endif __num_bins = __round_up_to_pow2(__num_bins); #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 } #endif __num_bins = __round_up_to_pow2( std::max<_BinIndex>(__num_threads, __num_bins)); if (__num_threads <= 1) { _RandomNumber __derived_rng( __rng(std::numeric_limits::max())); __sequential_random_shuffle(__begin, __end, __derived_rng); return; } _DRandomShufflingGlobalData<_RAIter> __sd(__begin); _DRSSorterPU<_RAIter, _RandomNumber >* __pus; _DifferenceType* __starts; # pragma omp parallel num_threads(__num_threads) { _ThreadIndex __num_threads = omp_get_num_threads(); # pragma omp single { __pus = new _DRSSorterPU<_RAIter, _RandomNumber>[__num_threads]; __sd._M_temporaries = new _ValueType*[__num_threads]; __sd._M_dist = new _DifferenceType*[__num_bins + 1]; __sd._M_bin_proc = new _ThreadIndex[__num_bins]; for (_BinIndex __b = 0; __b < __num_bins + 1; ++__b) __sd._M_dist[__b] = new _DifferenceType[__num_threads + 1]; for (_BinIndex __b = 0; __b < (__num_bins + 1); ++__b) { __sd._M_dist[0][0] = 0; __sd._M_dist[__b][0] = 0; } __starts = __sd._M_starts = new _DifferenceType[__num_threads + 1]; int __bin_cursor = 0; __sd._M_num_bins = __num_bins; __sd._M_num_bits = __rd_log2(__num_bins); _DifferenceType __chunk_length = __n / __num_threads, __split = __n % __num_threads, __start = 0; _DifferenceType __bin_chunk_length = __num_bins / __num_threads, __bin_split = __num_bins % __num_threads; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) { __starts[__i] = __start; __start += (__i < __split ? (__chunk_length + 1) : __chunk_length); int __j = __pus[__i]._M_bins_begin = __bin_cursor; // Range of bins for this processor. __bin_cursor += (__i < __bin_split ? (__bin_chunk_length + 1) : __bin_chunk_length); __pus[__i].__bins_end = __bin_cursor; for (; __j < __bin_cursor; ++__j) __sd._M_bin_proc[__j] = __i; __pus[__i]._M_num_threads = __num_threads; __pus[__i]._M_seed = __rng(std::numeric_limits::max()); __pus[__i]._M_sd = &__sd; } __starts[__num_threads] = __start; } //single // Now shuffle in parallel. __parallel_random_shuffle_drs_pu(__pus); } // parallel delete[] __starts; delete[] __sd._M_bin_proc; for (int __s = 0; __s < (__num_bins + 1); ++__s) delete[] __sd._M_dist[__s]; delete[] __sd._M_dist; delete[] __sd._M_temporaries; delete[] __pus; } /** @brief Sequential cache-efficient random shuffle. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __rng Random number generator to use. */ template void __sequential_random_shuffle(_RAIter __begin, _RAIter __end, _RandomNumberGenerator& __rng) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; const _Settings& __s = _Settings::get(); _BinIndex __num_bins, __num_bins_cache; #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 // Try the L1 cache first, must fit into L1. __num_bins_cache = std::max<_DifferenceType> (1, __n / (__s.L1_cache_size_lb / sizeof(_ValueType))); __num_bins_cache = __round_up_to_pow2(__num_bins_cache); // No more buckets than TLB entries, power of 2 // Power of 2 and at least one element per bin, at most the TLB size __num_bins = std::min(__n, (_DifferenceType)__num_bins_cache); #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB // 2 TLB entries needed per bin __num_bins = std::min((_DifferenceType)__s.TLB_size / 2, __num_bins); #endif __num_bins = __round_up_to_pow2(__num_bins); if (__num_bins < __num_bins_cache) { #endif // Now try the L2 cache, must fit into L2. __num_bins_cache = static_cast<_BinIndex> (std::max<_DifferenceType>(1, __n / (__s.L2_cache_size / sizeof(_ValueType)))); __num_bins_cache = __round_up_to_pow2(__num_bins_cache); // No more buckets than TLB entries, power of 2 // Power of 2 and at least one element per bin, at most the TLB size. __num_bins = static_cast<_BinIndex> (std::min(__n, static_cast<_DifferenceType>(__num_bins_cache))); #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB // 2 TLB entries needed per bin __num_bins = std::min<_DifferenceType>(__s.TLB_size / 2, __num_bins); #endif __num_bins = __round_up_to_pow2(__num_bins); #if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 } #endif int __num_bits = __rd_log2(__num_bins); if (__num_bins > 1) { _ValueType* __target = static_cast<_ValueType*>(::operator new(sizeof(_ValueType) * __n)); _BinIndex* __oracles = new _BinIndex[__n]; _DifferenceType* __dist0 = new _DifferenceType[__num_bins + 1], * __dist1 = new _DifferenceType[__num_bins + 1]; for (int __b = 0; __b < __num_bins + 1; ++__b) __dist0[__b] = 0; _RandomNumber __bitrng(__rng(0xFFFFFFFF)); for (_DifferenceType __i = 0; __i < __n; ++__i) { _BinIndex __oracle = __random_number_pow2(__num_bits, __bitrng); __oracles[__i] = __oracle; // To allow prefix (partial) sum. ++(__dist0[__oracle + 1]); } // Sum up bins. __gnu_sequential::partial_sum(__dist0, __dist0 + __num_bins + 1, __dist0); for (int __b = 0; __b < __num_bins + 1; ++__b) __dist1[__b] = __dist0[__b]; // Distribute according to oracles. for (_DifferenceType __i = 0; __i < __n; ++__i) ::new(&(__target[(__dist0[__oracles[__i]])++])) _ValueType(*(__begin + __i)); for (int __b = 0; __b < __num_bins; ++__b) __sequential_random_shuffle(__target + __dist1[__b], __target + __dist1[__b + 1], __rng); // Copy elements back. std::copy(__target, __target + __n, __begin); delete[] __dist0; delete[] __dist1; delete[] __oracles; for (_DifferenceType __i = 0; __i < __n; ++__i) __target[__i].~_ValueType(); ::operator delete(__target); } else __gnu_sequential::random_shuffle(__begin, __end, __rng); } /** @brief Parallel random public call. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __rng Random number generator to use. */ template inline void __parallel_random_shuffle(_RAIter __begin, _RAIter __end, _RandomNumberGenerator __rng = _RandomNumber()) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; __parallel_random_shuffle_drs(__begin, __end, __n, __get_max_threads(), __rng); } } #endif /* _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H */ 4.8.2/parallel/iterator.h000064400000013056147547540550011040 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/iterator.h * @brief Helper iterator classes for the std::transform() functions. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_ITERATOR_H #define _GLIBCXX_PARALLEL_ITERATOR_H 1 #include #include namespace __gnu_parallel { /** @brief A pair of iterators. The usual iterator operations are * applied to both child iterators. */ template class _IteratorPair : public std::pair<_Iterator1, _Iterator2> { private: typedef std::pair<_Iterator1, _Iterator2> _Base; public: typedef _IteratorCategory iterator_category; typedef void value_type; typedef std::iterator_traits<_Iterator1> _TraitsType; typedef typename _TraitsType::difference_type difference_type; typedef _IteratorPair* pointer; typedef _IteratorPair& reference; _IteratorPair() { } _IteratorPair(const _Iterator1& __first, const _Iterator2& __second) : _Base(__first, __second) { } // Pre-increment operator. _IteratorPair& operator++() { ++_Base::first; ++_Base::second; return *this; } // Post-increment operator. const _IteratorPair operator++(int) { return _IteratorPair(_Base::first++, _Base::second++); } // Pre-decrement operator. _IteratorPair& operator--() { --_Base::first; --_Base::second; return *this; } // Post-decrement operator. const _IteratorPair operator--(int) { return _IteratorPair(_Base::first--, _Base::second--); } // Type conversion. operator _Iterator2() const { return _Base::second; } _IteratorPair& operator=(const _IteratorPair& __other) { _Base::first = __other.first; _Base::second = __other.second; return *this; } _IteratorPair operator+(difference_type __delta) const { return _IteratorPair(_Base::first + __delta, _Base::second + __delta); } difference_type operator-(const _IteratorPair& __other) const { return _Base::first - __other.first; } }; /** @brief A triple of iterators. The usual iterator operations are applied to all three child iterators. */ template class _IteratorTriple { public: typedef _IteratorCategory iterator_category; typedef void value_type; typedef typename std::iterator_traits<_Iterator1>::difference_type difference_type; typedef _IteratorTriple* pointer; typedef _IteratorTriple& reference; _Iterator1 _M_first; _Iterator2 _M_second; _Iterator3 _M_third; _IteratorTriple() { } _IteratorTriple(const _Iterator1& __first, const _Iterator2& __second, const _Iterator3& __third) { _M_first = __first; _M_second = __second; _M_third = __third; } // Pre-increment operator. _IteratorTriple& operator++() { ++_M_first; ++_M_second; ++_M_third; return *this; } // Post-increment operator. const _IteratorTriple operator++(int) { return _IteratorTriple(_M_first++, _M_second++, _M_third++); } // Pre-decrement operator. _IteratorTriple& operator--() { --_M_first; --_M_second; --_M_third; return *this; } // Post-decrement operator. const _IteratorTriple operator--(int) { return _IteratorTriple(_M_first--, _M_second--, _M_third--); } // Type conversion. operator _Iterator3() const { return _M_third; } _IteratorTriple& operator=(const _IteratorTriple& __other) { _M_first = __other._M_first; _M_second = __other._M_second; _M_third = __other._M_third; return *this; } _IteratorTriple operator+(difference_type __delta) const { return _IteratorTriple(_M_first + __delta, _M_second + __delta, _M_third + __delta); } difference_type operator-(const _IteratorTriple& __other) const { return _M_first - __other._M_first; } }; } #endif /* _GLIBCXX_PARALLEL_ITERATOR_H */ 4.8.2/parallel/omp_loop_static.h000064400000010010147547540550012365 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/omp_loop_static.h * @brief Parallelization of embarrassingly parallel execution by * means of an OpenMP for loop with static scheduling. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H #define _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H 1 #include #include #include namespace __gnu_parallel { /** @brief Embarrassingly parallel algorithm for random access * iterators, using an OpenMP for loop with static scheduling. * * @param __begin Begin iterator of element sequence. * @param __end End iterator of element sequence. * @param __o User-supplied functor (comparator, predicate, adding * functor, ...). * @param __f Functor to @a process an element with __op (depends on * desired functionality, e. g. for std::for_each(), ...). * @param __r Functor to @a add a single __result to the already processed * __elements (depends on functionality). * @param __base Base value for reduction. * @param __output Pointer to position where final result is written to * @param __bound Maximum number of elements processed (e. g. for * std::count_n()). * @return User-supplied functor (that may contain a part of the result). */ template _Op __for_each_template_random_access_omp_loop_static(_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _Result __base, _Result& __output, typename std::iterator_traits<_RAIter>::difference_type __bound) { typedef typename std::iterator_traits<_RAIter>::difference_type _DifferenceType; _DifferenceType __length = __end - __begin; _ThreadIndex __num_threads = std::min<_DifferenceType> (__get_max_threads(), __length); _Result *__thread_results; # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __thread_results = new _Result[__num_threads]; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __thread_results[__i] = _Result(); } _ThreadIndex __iam = omp_get_thread_num(); #pragma omp for schedule(static, _Settings::get().workstealing_chunk_size) for (_DifferenceType __pos = 0; __pos < __length; ++__pos) __thread_results[__iam] = __r(__thread_results[__iam], __f(__o, __begin+__pos)); } //parallel for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __output = __r(__output, __thread_results[__i]); delete [] __thread_results; // Points to last element processed (needed as return value for // some algorithms like transform). __f.finish_iterator = __begin + __length; return __o; } } // end namespace #endif /* _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H */ 4.8.2/parallel/par_loop.h000064400000010710147547540550011014 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/par_loop.h * @brief Parallelization of embarrassingly parallel execution by * means of equal splitting. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_PAR_LOOP_H #define _GLIBCXX_PARALLEL_PAR_LOOP_H 1 #include #include #include #include namespace __gnu_parallel { /** @brief Embarrassingly parallel algorithm for random access * iterators, using hand-crafted parallelization by equal splitting * the work. * * @param __begin Begin iterator of element sequence. * @param __end End iterator of element sequence. * @param __o User-supplied functor (comparator, predicate, adding * functor, ...) * @param __f Functor to "process" an element with __op (depends on * desired functionality, e. g. for std::for_each(), ...). * @param __r Functor to "add" a single __result to the already * processed elements (depends on functionality). * @param __base Base value for reduction. * @param __output Pointer to position where final result is written to * @param __bound Maximum number of elements processed (e. g. for * std::count_n()). * @return User-supplied functor (that may contain a part of the result). */ template _Op __for_each_template_random_access_ed(_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _Result __base, _Result& __output, typename std::iterator_traits<_RAIter>::difference_type __bound) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; const _DifferenceType __length = __end - __begin; _Result *__thread_results; bool* __constructed; _ThreadIndex __num_threads = __gnu_parallel::min<_DifferenceType> (__get_max_threads(), __length); # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __thread_results = static_cast<_Result*> (::operator new(__num_threads * sizeof(_Result))); __constructed = new bool[__num_threads]; } _ThreadIndex __iam = omp_get_thread_num(); // Neutral element. _Result* __reduct; _DifferenceType __start = __equally_split_point(__length, __num_threads, __iam), __stop = __equally_split_point(__length, __num_threads, __iam + 1); if (__start < __stop) { __reduct = new _Result(__f(__o, __begin + __start)); ++__start; __constructed[__iam] = true; } else __constructed[__iam] = false; for (; __start < __stop; ++__start) *__reduct = __r(*__reduct, __f(__o, __begin + __start)); if (__constructed[__iam]) { ::new(&__thread_results[__iam]) _Result(*__reduct); delete __reduct; } } //parallel for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) if (__constructed[__i]) { __output = __r(__output, __thread_results[__i]); __thread_results[__i].~_Result(); } // Points to last element processed (needed as return value for // some algorithms like transform). __f._M_finish_iterator = __begin + __length; ::operator delete(__thread_results); delete[] __constructed; return __o; } } // end namespace #endif /* _GLIBCXX_PARALLEL_PAR_LOOP_H */ 4.8.2/parallel/equally_split.h000064400000006434147547540550012100 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/equally_split.h * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H #define _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H 1 namespace __gnu_parallel { /** @brief function to split a sequence into parts of almost equal size. * * The resulting sequence __s of length __num_threads+1 contains the * splitting positions when splitting the range [0,__n) into parts of * almost equal size (plus minus 1). The first entry is 0, the last * one n. There may result empty parts. * @param __n Number of elements * @param __num_threads Number of parts * @param __s Splitters * @returns End of __splitter sequence, i.e. @c __s+__num_threads+1 */ template _OutputIterator __equally_split(_DifferenceType __n, _ThreadIndex __num_threads, _OutputIterator __s) { _DifferenceType __chunk_length = __n / __num_threads; _DifferenceType __num_longer_chunks = __n % __num_threads; _DifferenceType __pos = 0; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) { *__s++ = __pos; __pos += ((__i < __num_longer_chunks) ? (__chunk_length + 1) : __chunk_length); } *__s++ = __n; return __s; } /** @brief function to split a sequence into parts of almost equal size. * * Returns the position of the splitting point between * thread number __thread_no (included) and * thread number __thread_no+1 (excluded). * @param __n Number of elements * @param __num_threads Number of parts * @param __thread_no Number of threads * @returns splitting point */ template _DifferenceType __equally_split_point(_DifferenceType __n, _ThreadIndex __num_threads, _ThreadIndex __thread_no) { _DifferenceType __chunk_length = __n / __num_threads; _DifferenceType __num_longer_chunks = __n % __num_threads; if (__thread_no < __num_longer_chunks) return __thread_no * (__chunk_length + 1); else return __num_longer_chunks * (__chunk_length + 1) + (__thread_no - __num_longer_chunks) * __chunk_length; } } #endif /* _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H */ 4.8.2/parallel/find.h000064400000032427147547540550010132 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/find.h * @brief Parallel implementation base for std::find(), std::equal() * and related functions. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze and Johannes Singler. #ifndef _GLIBCXX_PARALLEL_FIND_H #define _GLIBCXX_PARALLEL_FIND_H 1 #include #include #include #include #include namespace __gnu_parallel { /** * @brief Parallel std::find, switch for different algorithms. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. Must have same * length as first sequence. * @param __pred Find predicate. * @param __selector _Functionality (e. g. std::find_if(), std::equal(),...) * @return Place of finding in both sequences. */ template inline std::pair<_RAIter1, _RAIter2> __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector) { switch (_Settings::get().find_algorithm) { case GROWING_BLOCKS: return __find_template(__begin1, __end1, __begin2, __pred, __selector, growing_blocks_tag()); case CONSTANT_SIZE_BLOCKS: return __find_template(__begin1, __end1, __begin2, __pred, __selector, constant_size_blocks_tag()); case EQUAL_SPLIT: return __find_template(__begin1, __end1, __begin2, __pred, __selector, equal_split_tag()); default: _GLIBCXX_PARALLEL_ASSERT(false); return std::make_pair(__begin1, __begin2); } } #if _GLIBCXX_FIND_EQUAL_SPLIT /** * @brief Parallel std::find, equal splitting variant. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. Second __sequence * must have same length as first sequence. * @param __pred Find predicate. * @param __selector _Functionality (e. g. std::find_if(), std::equal(),...) * @return Place of finding in both sequences. */ template std::pair<_RAIter1, _RAIter2> __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, equal_split_tag) { _GLIBCXX_CALL(__end1 - __begin1) typedef std::iterator_traits<_RAIter1> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::value_type _ValueType; _DifferenceType __length = __end1 - __begin1; _DifferenceType __result = __length; _DifferenceType* __borders; omp_lock_t __result_lock; omp_init_lock(&__result_lock); _ThreadIndex __num_threads = __get_max_threads(); # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __borders = new _DifferenceType[__num_threads + 1]; __equally_split(__length, __num_threads, __borders); } //single _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __start = __borders[__iam], __stop = __borders[__iam + 1]; _RAIter1 __i1 = __begin1 + __start; _RAIter2 __i2 = __begin2 + __start; for (_DifferenceType __pos = __start; __pos < __stop; ++__pos) { # pragma omp flush(__result) // Result has been set to something lower. if (__result < __pos) break; if (__selector(__i1, __i2, __pred)) { omp_set_lock(&__result_lock); if (__pos < __result) __result = __pos; omp_unset_lock(&__result_lock); break; } ++__i1; ++__i2; } } //parallel omp_destroy_lock(&__result_lock); delete[] __borders; return std::pair<_RAIter1, _RAIter2>(__begin1 + __result, __begin2 + __result); } #endif #if _GLIBCXX_FIND_GROWING_BLOCKS /** * @brief Parallel std::find, growing block size variant. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. Second __sequence * must have same length as first sequence. * @param __pred Find predicate. * @param __selector _Functionality (e. g. std::find_if(), std::equal(),...) * @return Place of finding in both sequences. * @see __gnu_parallel::_Settings::find_sequential_search_size * @see __gnu_parallel::_Settings::find_scale_factor * * There are two main differences between the growing blocks and * the constant-size blocks variants. * 1. For GB, the block size grows; for CSB, the block size is fixed. * 2. For GB, the blocks are allocated dynamically; * for CSB, the blocks are allocated in a predetermined manner, * namely spacial round-robin. */ template std::pair<_RAIter1, _RAIter2> __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, growing_blocks_tag) { _GLIBCXX_CALL(__end1 - __begin1) typedef std::iterator_traits<_RAIter1> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::value_type _ValueType; const _Settings& __s = _Settings::get(); _DifferenceType __length = __end1 - __begin1; _DifferenceType __sequential_search_size = std::min<_DifferenceType> (__length, __s.find_sequential_search_size); // Try it sequentially first. std::pair<_RAIter1, _RAIter2> __find_seq_result = __selector._M_sequential_algorithm (__begin1, __begin1 + __sequential_search_size, __begin2, __pred); if (__find_seq_result.first != (__begin1 + __sequential_search_size)) return __find_seq_result; // Index of beginning of next free block (after sequential find). _DifferenceType __next_block_start = __sequential_search_size; _DifferenceType __result = __length; omp_lock_t __result_lock; omp_init_lock(&__result_lock); const float __scale_factor = __s.find_scale_factor; _ThreadIndex __num_threads = __get_max_threads(); # pragma omp parallel shared(__result) num_threads(__num_threads) { # pragma omp single __num_threads = omp_get_num_threads(); // Not within first __k elements -> start parallel. _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __block_size = std::max<_DifferenceType>(1, __scale_factor * __next_block_start); _DifferenceType __start = __fetch_and_add<_DifferenceType> (&__next_block_start, __block_size); // Get new block, update pointer to next block. _DifferenceType __stop = std::min<_DifferenceType>(__length, __start + __block_size); std::pair<_RAIter1, _RAIter2> __local_result; while (__start < __length) { # pragma omp flush(__result) // Get new value of result. if (__result < __start) { // No chance to find first element. break; } __local_result = __selector._M_sequential_algorithm (__begin1 + __start, __begin1 + __stop, __begin2 + __start, __pred); if (__local_result.first != (__begin1 + __stop)) { omp_set_lock(&__result_lock); if ((__local_result.first - __begin1) < __result) { __result = __local_result.first - __begin1; // Result cannot be in future blocks, stop algorithm. __fetch_and_add<_DifferenceType>(&__next_block_start, __length); } omp_unset_lock(&__result_lock); } _DifferenceType __block_size = std::max<_DifferenceType>(1, __scale_factor * __next_block_start); // Get new block, update pointer to next block. __start = __fetch_and_add<_DifferenceType>(&__next_block_start, __block_size); __stop = std::min<_DifferenceType>(__length, __start + __block_size); } } //parallel omp_destroy_lock(&__result_lock); // Return iterator on found element. return std::pair<_RAIter1, _RAIter2>(__begin1 + __result, __begin2 + __result); } #endif #if _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS /** * @brief Parallel std::find, constant block size variant. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. Second __sequence * must have same length as first sequence. * @param __pred Find predicate. * @param __selector _Functionality (e. g. std::find_if(), std::equal(),...) * @return Place of finding in both sequences. * @see __gnu_parallel::_Settings::find_sequential_search_size * @see __gnu_parallel::_Settings::find_block_size * There are two main differences between the growing blocks and the * constant-size blocks variants. * 1. For GB, the block size grows; for CSB, the block size is fixed. * 2. For GB, the blocks are allocated dynamically; for CSB, the * blocks are allocated in a predetermined manner, namely spacial * round-robin. */ template std::pair<_RAIter1, _RAIter2> __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector, constant_size_blocks_tag) { _GLIBCXX_CALL(__end1 - __begin1) typedef std::iterator_traits<_RAIter1> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::value_type _ValueType; const _Settings& __s = _Settings::get(); _DifferenceType __length = __end1 - __begin1; _DifferenceType __sequential_search_size = std::min<_DifferenceType> (__length, __s.find_sequential_search_size); // Try it sequentially first. std::pair<_RAIter1, _RAIter2> __find_seq_result = __selector._M_sequential_algorithm (__begin1, __begin1 + __sequential_search_size, __begin2, __pred); if (__find_seq_result.first != (__begin1 + __sequential_search_size)) return __find_seq_result; _DifferenceType __result = __length; omp_lock_t __result_lock; omp_init_lock(&__result_lock); // Not within first __sequential_search_size elements -> start parallel. _ThreadIndex __num_threads = __get_max_threads(); # pragma omp parallel shared(__result) num_threads(__num_threads) { # pragma omp single __num_threads = omp_get_num_threads(); _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __block_size = __s.find_initial_block_size; // First element of thread's current iteration. _DifferenceType __iteration_start = __sequential_search_size; // Where to work (initialization). _DifferenceType __start = __iteration_start + __iam * __block_size; _DifferenceType __stop = std::min<_DifferenceType>(__length, __start + __block_size); std::pair<_RAIter1, _RAIter2> __local_result; while (__start < __length) { // Get new value of result. # pragma omp flush(__result) // No chance to find first element. if (__result < __start) break; __local_result = __selector._M_sequential_algorithm (__begin1 + __start, __begin1 + __stop, __begin2 + __start, __pred); if (__local_result.first != (__begin1 + __stop)) { omp_set_lock(&__result_lock); if ((__local_result.first - __begin1) < __result) __result = __local_result.first - __begin1; omp_unset_lock(&__result_lock); // Will not find better value in its interval. break; } __iteration_start += __num_threads * __block_size; // Where to work. __start = __iteration_start + __iam * __block_size; __stop = std::min<_DifferenceType>(__length, __start + __block_size); } } //parallel omp_destroy_lock(&__result_lock); // Return iterator on found element. return std::pair<_RAIter1, _RAIter2>(__begin1 + __result, __begin2 + __result); } #endif } // end namespace #endif /* _GLIBCXX_PARALLEL_FIND_H */ 4.8.2/parallel/search.h000064400000012417147547540550010454 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/search.h * @brief Parallel implementation base for std::search() and * std::search_n(). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_SEARCH_H #define _GLIBCXX_PARALLEL_SEARCH_H 1 #include #include #include namespace __gnu_parallel { /** * @brief Precalculate __advances for Knuth-Morris-Pratt algorithm. * @param __elements Begin iterator of sequence to search for. * @param __length Length of sequence to search for. * @param __off Returned __offsets. */ template void __calc_borders(_RAIter __elements, _DifferenceTp __length, _DifferenceTp* __off) { typedef _DifferenceTp _DifferenceType; __off[0] = -1; if (__length > 1) __off[1] = 0; _DifferenceType __k = 0; for (_DifferenceType __j = 2; __j <= __length; __j++) { while ((__k >= 0) && !(__elements[__k] == __elements[__j-1])) __k = __off[__k]; __off[__j] = ++__k; } } // Generic parallel find algorithm (requires random access iterator). /** @brief Parallel std::search. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __pred Find predicate. * @return Place of finding in first sequences. */ template __RAIter1 __search_template(__RAIter1 __begin1, __RAIter1 __end1, __RAIter2 __begin2, __RAIter2 __end2, _Pred __pred) { typedef std::iterator_traits<__RAIter1> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; _GLIBCXX_CALL((__end1 - __begin1) + (__end2 - __begin2)); _DifferenceType __pattern_length = __end2 - __begin2; // Pattern too short. if(__pattern_length <= 0) return __end1; // Last point to start search. _DifferenceType __input_length = (__end1 - __begin1) - __pattern_length; // Where is first occurrence of pattern? defaults to end. _DifferenceType __result = (__end1 - __begin1); _DifferenceType *__splitters; // Pattern too long. if (__input_length < 0) return __end1; omp_lock_t __result_lock; omp_init_lock(&__result_lock); _ThreadIndex __num_threads = std::max<_DifferenceType> (1, std::min<_DifferenceType>(__input_length, __get_max_threads())); _DifferenceType __advances[__pattern_length]; __calc_borders(__begin2, __pattern_length, __advances); # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __splitters = new _DifferenceType[__num_threads + 1]; __equally_split(__input_length, __num_threads, __splitters); } _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __start = __splitters[__iam], __stop = __splitters[__iam + 1]; _DifferenceType __pos_in_pattern = 0; bool __found_pattern = false; while (__start <= __stop && !__found_pattern) { // Get new value of result. #pragma omp flush(__result) // No chance for this thread to find first occurrence. if (__result < __start) break; while (__pred(__begin1[__start + __pos_in_pattern], __begin2[__pos_in_pattern])) { ++__pos_in_pattern; if (__pos_in_pattern == __pattern_length) { // Found new candidate for result. omp_set_lock(&__result_lock); __result = std::min(__result, __start); omp_unset_lock(&__result_lock); __found_pattern = true; break; } } // Make safe jump. __start += (__pos_in_pattern - __advances[__pos_in_pattern]); __pos_in_pattern = (__advances[__pos_in_pattern] < 0 ? 0 : __advances[__pos_in_pattern]); } } //parallel omp_destroy_lock(&__result_lock); delete[] __splitters; // Return iterator on found element. return (__begin1 + __result); } } // end namespace #endif /* _GLIBCXX_PARALLEL_SEARCH_H */ 4.8.2/parallel/merge.h000064400000022541147547540550010305 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/merge.h * @brief Parallel implementation of std::merge(). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_MERGE_H #define _GLIBCXX_PARALLEL_MERGE_H 1 #include #include namespace __gnu_parallel { /** @brief Merge routine being able to merge only the @c __max_length * smallest elements. * * The @c __begin iterators are advanced accordingly, they might not * reach @c __end, in contrast to the usual variant. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __target Target begin iterator. * @param __max_length Maximum number of elements to merge. * @param __comp Comparator. * @return Output end iterator. */ template _OutputIterator __merge_advance_usual(_RAIter1& __begin1, _RAIter1 __end1, _RAIter2& __begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp __max_length, _Compare __comp) { typedef _DifferenceTp _DifferenceType; while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0) { // array1[__i1] < array0[i0] if (__comp(*__begin2, *__begin1)) *__target++ = *__begin2++; else *__target++ = *__begin1++; --__max_length; } if (__begin1 != __end1) { __target = std::copy(__begin1, __begin1 + __max_length, __target); __begin1 += __max_length; } else { __target = std::copy(__begin2, __begin2 + __max_length, __target); __begin2 += __max_length; } return __target; } /** @brief Merge routine being able to merge only the @c __max_length * smallest elements. * * The @c __begin iterators are advanced accordingly, they might not * reach @c __end, in contrast to the usual variant. * Specially designed code should allow the compiler to generate * conditional moves instead of branches. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __target Target begin iterator. * @param __max_length Maximum number of elements to merge. * @param __comp Comparator. * @return Output end iterator. */ template _OutputIterator __merge_advance_movc(_RAIter1& __begin1, _RAIter1 __end1, _RAIter2& __begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp __max_length, _Compare __comp) { typedef _DifferenceTp _DifferenceType; typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType1; typedef typename std::iterator_traits<_RAIter2>::value_type _ValueType2; #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__max_length >= 0); #endif while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0) { _RAIter1 __next1 = __begin1 + 1; _RAIter2 __next2 = __begin2 + 1; _ValueType1 __element1 = *__begin1; _ValueType2 __element2 = *__begin2; if (__comp(__element2, __element1)) { __element1 = __element2; __begin2 = __next2; } else __begin1 = __next1; *__target = __element1; ++__target; --__max_length; } if (__begin1 != __end1) { __target = std::copy(__begin1, __begin1 + __max_length, __target); __begin1 += __max_length; } else { __target = std::copy(__begin2, __begin2 + __max_length, __target); __begin2 += __max_length; } return __target; } /** @brief Merge routine being able to merge only the @c __max_length * smallest elements. * * The @c __begin iterators are advanced accordingly, they might not * reach @c __end, in contrast to the usual variant. * Static switch on whether to use the conditional-move variant. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __target Target begin iterator. * @param __max_length Maximum number of elements to merge. * @param __comp Comparator. * @return Output end iterator. */ template inline _OutputIterator __merge_advance(_RAIter1& __begin1, _RAIter1 __end1, _RAIter2& __begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp __max_length, _Compare __comp) { _GLIBCXX_CALL(__max_length) return __merge_advance_movc(__begin1, __end1, __begin2, __end2, __target, __max_length, __comp); } /** @brief Merge routine fallback to sequential in case the iterators of the two input sequences are of different type. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __target Target begin iterator. * @param __max_length Maximum number of elements to merge. * @param __comp Comparator. * @return Output end iterator. */ template inline _RAIter3 __parallel_merge_advance(_RAIter1& __begin1, _RAIter1 __end1, _RAIter2& __begin2, // different iterators, parallel implementation // not available _RAIter2 __end2, _RAIter3 __target, typename std::iterator_traits<_RAIter1>:: difference_type __max_length, _Compare __comp) { return __merge_advance(__begin1, __end1, __begin2, __end2, __target, __max_length, __comp); } /** @brief Parallel merge routine being able to merge only the @c * __max_length smallest elements. * * The @c __begin iterators are advanced accordingly, they might not * reach @c __end, in contrast to the usual variant. * The functionality is projected onto parallel_multiway_merge. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __end2 End iterator of second sequence. * @param __target Target begin iterator. * @param __max_length Maximum number of elements to merge. * @param __comp Comparator. * @return Output end iterator. */ template inline _RAIter3 __parallel_merge_advance(_RAIter1& __begin1, _RAIter1 __end1, _RAIter1& __begin2, _RAIter1 __end2, _RAIter3 __target, typename std::iterator_traits<_RAIter1>:: difference_type __max_length, _Compare __comp) { typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType; typedef typename std::iterator_traits<_RAIter1>:: difference_type _DifferenceType1 /* == difference_type2 */; typedef typename std::iterator_traits<_RAIter3>:: difference_type _DifferenceType3; typedef typename std::pair<_RAIter1, _RAIter1> _IteratorPair; _IteratorPair __seqs[2] = { std::make_pair(__begin1, __end1), std::make_pair(__begin2, __end2) }; _RAIter3 __target_end = parallel_multiway_merge < /* __stable = */ true, /* __sentinels = */ false> (__seqs, __seqs + 2, __target, multiway_merge_exact_splitting < /* __stable = */ true, _IteratorPair*, _Compare, _DifferenceType1>, __max_length, __comp, omp_get_max_threads()); return __target_end; } } //namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_MERGE_H */ 4.8.2/parallel/numeric000064400000050600147547540550010417 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** * @file parallel/numeric * * @brief Parallel STL function calls corresponding to stl_numeric.h. * The functions defined here mainly do case switches and * call the actual parallelized versions in other files. * Inlining policy: Functions that basically only contain one function call, * are declared inline. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_NUMERIC_H #define _GLIBCXX_PARALLEL_NUMERIC_H 1 #include #include #include #include #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { // Sequential fallback. template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::accumulate(__begin, __end, __init); } template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init, _BinaryOperation __binary_op, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::accumulate(__begin, __end, __init, __binary_op); } // Sequential fallback for input iterator case. template inline _Tp __accumulate_switch(_IIter __begin, _IIter __end, _Tp __init, _IteratorTag) { return accumulate(__begin, __end, __init, __gnu_parallel::sequential_tag()); } template inline _Tp __accumulate_switch(_IIter __begin, _IIter __end, _Tp __init, _BinaryOperation __binary_op, _IteratorTag) { return accumulate(__begin, __end, __init, __binary_op, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template _Tp __accumulate_switch(__RAIter __begin, __RAIter __end, _Tp __init, _BinaryOperation __binary_op, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_unbalanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().accumulate_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { _Tp __res = __init; __gnu_parallel::__accumulate_selector<__RAIter> __my_selector; __gnu_parallel:: __for_each_template_random_access_ed(__begin, __end, __gnu_parallel::_Nothing(), __my_selector, __gnu_parallel:: __accumulate_binop_reduct <_BinaryOperation>(__binary_op), __res, __res, -1); return __res; } else return accumulate(__begin, __end, __init, __binary_op, __gnu_parallel::sequential_tag()); } // Public interface. template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::value_type _ValueType; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __accumulate_switch(__begin, __end, __init, __gnu_parallel::_Plus<_Tp, _ValueType>(), _IteratorCategory(), __parallelism_tag); } template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init) { typedef std::iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::value_type _ValueType; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __accumulate_switch(__begin, __end, __init, __gnu_parallel::_Plus<_Tp, _ValueType>(), _IteratorCategory()); } template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init, _BinaryOperation __binary_op, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __accumulate_switch(__begin, __end, __init, __binary_op, _IteratorCategory(), __parallelism_tag); } template inline _Tp accumulate(_IIter __begin, _IIter __end, _Tp __init, _BinaryOperation __binary_op) { typedef iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __accumulate_switch(__begin, __end, __init, __binary_op, _IteratorCategory()); } // Sequential fallback. template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::inner_product( __first1, __last1, __first2, __init); } template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1, _BinaryFunction2 __binary_op2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::inner_product(__first1, __last1, __first2, __init, __binary_op1, __binary_op2); } // Parallel algorithm for random access iterators. template _Tp __inner_product_switch(_RAIter1 __first1, _RAIter1 __last1, _RAIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1, _BinaryFunction2 __binary_op2, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_unbalanced) { if (_GLIBCXX_PARALLEL_CONDITION((__last1 - __first1) >= __gnu_parallel::_Settings::get(). accumulate_minimal_n && __gnu_parallel:: __is_parallel(__parallelism_tag))) { _Tp __res = __init; __gnu_parallel:: __inner_product_selector<_RAIter1, _RAIter2, _Tp> __my_selector(__first1, __first2); __gnu_parallel:: __for_each_template_random_access_ed( __first1, __last1, __binary_op2, __my_selector, __binary_op1, __res, __res, -1); return __res; } else return inner_product(__first1, __last1, __first2, __init, __gnu_parallel::sequential_tag()); } // No parallelism for input iterators. template inline _Tp __inner_product_switch(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1, _BinaryFunction2 __binary_op2, _IteratorTag1, _IteratorTag2) { return inner_product(__first1, __last1, __first2, __init, __binary_op1, __binary_op2, __gnu_parallel::sequential_tag()); } template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1, _BinaryFunction2 __binary_op2, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::iterator_category _IteratorCategory1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::iterator_category _IteratorCategory2; return __inner_product_switch(__first1, __last1, __first2, __init, __binary_op1, __binary_op2, _IteratorCategory1(), _IteratorCategory2(), __parallelism_tag); } template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1, _BinaryFunction2 __binary_op2) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::iterator_category _IteratorCategory1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::iterator_category _IteratorCategory2; return __inner_product_switch(__first1, __last1, __first2, __init, __binary_op1, __binary_op2, _IteratorCategory1(), _IteratorCategory2()); } template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::value_type _ValueType1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::value_type _ValueType2; typedef typename __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type _MultipliesResultType; return __gnu_parallel::inner_product(__first1, __last1, __first2, __init, __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(), __gnu_parallel:: _Multiplies<_ValueType1, _ValueType2>(), __parallelism_tag); } template inline _Tp inner_product(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _Tp __init) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::value_type _ValueType1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::value_type _ValueType2; typedef typename __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type _MultipliesResultType; return __gnu_parallel::inner_product(__first1, __last1, __first2, __init, __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(), __gnu_parallel:: _Multiplies<_ValueType1, _ValueType2>()); } // Sequential fallback. template inline _OutputIterator partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result); } // Sequential fallback. template inline _OutputIterator partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result, __bin_op); } // Sequential fallback for input iterator case. template inline _OutputIterator __partial_sum_switch(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, _IteratorTag1, _IteratorTag2) { return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result, __bin_op); } // Parallel algorithm for random access iterators. template _OutputIterator __partial_sum_switch(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().partial_sum_minimal_n)) return __gnu_parallel::__parallel_partial_sum(__begin, __end, __result, __bin_op); else return partial_sum(__begin, __end, __result, __bin_op, __gnu_parallel::sequential_tag()); } // Public interface. template inline _OutputIterator partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result) { typedef typename iterator_traits<_IIter>::value_type _ValueType; return __gnu_parallel::partial_sum(__begin, __end, __result, std::plus<_ValueType>()); } // Public interface template inline _OutputIterator partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __binary_op) { typedef iterator_traits<_IIter> _ITraitsType; typedef typename _ITraitsType::iterator_category _IIteratorCategory; typedef iterator_traits<_OutputIterator> _OTraitsType; typedef typename _OTraitsType::iterator_category _OIterCategory; return __partial_sum_switch(__begin, __end, __result, __binary_op, _IIteratorCategory(), _OIterCategory()); } // Sequential fallback. template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::adjacent_difference(__begin, __end, __result); } // Sequential fallback. template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::adjacent_difference(__begin, __end, __result, __bin_op); } // Sequential fallback for input iterator case. template inline _OutputIterator __adjacent_difference_switch(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, _IteratorTag1, _IteratorTag2) { return adjacent_difference(__begin, __end, __result, __bin_op, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template _OutputIterator __adjacent_difference_switch(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().adjacent_difference_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy = true; typedef __gnu_parallel::_IteratorPair<_IIter, _OutputIterator, random_access_iterator_tag> _ItTrip; *__result = *__begin; _ItTrip __begin_pair(__begin + 1, __result + 1), __end_pair(__end, __result + (__end - __begin)); __gnu_parallel::__adjacent_difference_selector<_ItTrip> __functionality; __gnu_parallel:: __for_each_template_random_access_ed( __begin_pair, __end_pair, __bin_op, __functionality, __gnu_parallel::_DummyReduct(), __dummy, __dummy, -1); return __functionality._M_finish_iterator; } else return adjacent_difference(__begin, __end, __result, __bin_op, __gnu_parallel::sequential_tag()); } // Public interface. template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; return adjacent_difference(__begin, __end, __result, std::minus<_ValueType>(), __parallelism_tag); } template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; return adjacent_difference(__begin, __end, __result, std::minus<_ValueType>()); } template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __binary_op, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter> _ITraitsType; typedef typename _ITraitsType::iterator_category _IIteratorCategory; typedef iterator_traits<_OutputIterator> _OTraitsType; typedef typename _OTraitsType::iterator_category _OIterCategory; return __adjacent_difference_switch(__begin, __end, __result, __binary_op, _IIteratorCategory(), _OIterCategory(), __parallelism_tag); } template inline _OutputIterator adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __binary_op) { typedef iterator_traits<_IIter> _ITraitsType; typedef typename _ITraitsType::iterator_category _IIteratorCategory; typedef iterator_traits<_OutputIterator> _OTraitsType; typedef typename _OTraitsType::iterator_category _OIterCategory; return __adjacent_difference_switch(__begin, __end, __result, __binary_op, _IIteratorCategory(), _OIterCategory()); } } // end namespace } // end namespace #endif /* _GLIBCXX_NUMERIC_H */ 4.8.2/parallel/random_number.h000064400000010203147547540550012026 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/random_number.h * @brief Random number generator based on the Mersenne twister. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_RANDOM_NUMBER_H #define _GLIBCXX_PARALLEL_RANDOM_NUMBER_H 1 #include #include #include namespace __gnu_parallel { /** @brief Random number generator, based on the Mersenne twister. */ class _RandomNumber { private: std::tr1::mt19937 _M_mt; uint64_t _M_supremum; uint64_t _M_rand_sup; double _M_supremum_reciprocal; double _M_rand_sup_reciprocal; // Assumed to be twice as long as the usual random number. uint64_t __cache; // Bit results. int __bits_left; static uint32_t __scale_down(uint64_t __x, #if _GLIBCXX_SCALE_DOWN_FPU uint64_t /*_M_supremum*/, double _M_supremum_reciprocal) #else uint64_t _M_supremum, double /*_M_supremum_reciprocal*/) #endif { #if _GLIBCXX_SCALE_DOWN_FPU return uint32_t(__x * _M_supremum_reciprocal); #else return static_cast(__x % _M_supremum); #endif } public: /** @brief Default constructor. Seed with 0. */ _RandomNumber() : _M_mt(0), _M_supremum(0x100000000ULL), _M_rand_sup(1ULL << std::numeric_limits::digits), _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)), _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)), __cache(0), __bits_left(0) { } /** @brief Constructor. * @param __seed Random __seed. * @param _M_supremum Generate integer random numbers in the * interval @c [0,_M_supremum). */ _RandomNumber(uint32_t __seed, uint64_t _M_supremum = 0x100000000ULL) : _M_mt(__seed), _M_supremum(_M_supremum), _M_rand_sup(1ULL << std::numeric_limits::digits), _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)), _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)), __cache(0), __bits_left(0) { } /** @brief Generate unsigned random 32-bit integer. */ uint32_t operator()() { return __scale_down(_M_mt(), _M_supremum, _M_supremum_reciprocal); } /** @brief Generate unsigned random 32-bit integer in the interval @c [0,local_supremum). */ uint32_t operator()(uint64_t local_supremum) { return __scale_down(_M_mt(), local_supremum, double(local_supremum * _M_rand_sup_reciprocal)); } /** @brief Generate a number of random bits, run-time parameter. * @param __bits Number of bits to generate. */ unsigned long __genrand_bits(int __bits) { unsigned long __res = __cache & ((1 << __bits) - 1); __cache = __cache >> __bits; __bits_left -= __bits; if (__bits_left < 32) { __cache |= ((uint64_t(_M_mt())) << __bits_left); __bits_left += 32; } return __res; } }; } // namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_RANDOM_NUMBER_H */ 4.8.2/parallel/queue.h000064400000012635147547540550010335 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/queue.h * @brief Lock-free double-ended queue. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_QUEUE_H #define _GLIBCXX_PARALLEL_QUEUE_H 1 #include #include #include /** @brief Decide whether to declare certain variable volatile in this file. */ #define _GLIBCXX_VOLATILE volatile namespace __gnu_parallel { /**@brief Double-ended queue of bounded size, allowing lock-free * atomic access. push_front() and pop_front() must not be called * concurrently to each other, while pop_back() can be called * concurrently at all times. * @c empty(), @c size(), and @c top() are intentionally not provided. * Calling them would not make sense in a concurrent setting. * @param _Tp Contained element type. */ template class _RestrictedBoundedConcurrentQueue { private: /** @brief Array of elements, seen as cyclic buffer. */ _Tp* _M_base; /** @brief Maximal number of elements contained at the same time. */ _SequenceIndex _M_max_size; /** @brief Cyclic __begin and __end pointers contained in one atomically changeable value. */ _GLIBCXX_VOLATILE _CASable _M_borders; public: /** @brief Constructor. Not to be called concurrent, of course. * @param __max_size Maximal number of elements to be contained. */ _RestrictedBoundedConcurrentQueue(_SequenceIndex __max_size) { _M_max_size = __max_size; _M_base = new _Tp[__max_size]; _M_borders = __encode2(0, 0); #pragma omp flush } /** @brief Destructor. Not to be called concurrent, of course. */ ~_RestrictedBoundedConcurrentQueue() { delete[] _M_base; } /** @brief Pushes one element into the queue at the front end. * Must not be called concurrently with pop_front(). */ void push_front(const _Tp& __t) { _CASable __former_borders = _M_borders; int __former_front, __former_back; __decode2(__former_borders, __former_front, __former_back); *(_M_base + __former_front % _M_max_size) = __t; #if _GLIBCXX_ASSERTIONS // Otherwise: front - back > _M_max_size eventually. _GLIBCXX_PARALLEL_ASSERT(((__former_front + 1) - __former_back) <= _M_max_size); #endif __fetch_and_add(&_M_borders, __encode2(1, 0)); } /** @brief Pops one element from the queue at the front end. * Must not be called concurrently with pop_front(). */ bool pop_front(_Tp& __t) { int __former_front, __former_back; #pragma omp flush __decode2(_M_borders, __former_front, __former_back); while (__former_front > __former_back) { // Chance. _CASable __former_borders = __encode2(__former_front, __former_back); _CASable __new_borders = __encode2(__former_front - 1, __former_back); if (__compare_and_swap(&_M_borders, __former_borders, __new_borders)) { __t = *(_M_base + (__former_front - 1) % _M_max_size); return true; } #pragma omp flush __decode2(_M_borders, __former_front, __former_back); } return false; } /** @brief Pops one element from the queue at the front end. * Must not be called concurrently with pop_front(). */ bool pop_back(_Tp& __t) //queue behavior { int __former_front, __former_back; #pragma omp flush __decode2(_M_borders, __former_front, __former_back); while (__former_front > __former_back) { // Chance. _CASable __former_borders = __encode2(__former_front, __former_back); _CASable __new_borders = __encode2(__former_front, __former_back + 1); if (__compare_and_swap(&_M_borders, __former_borders, __new_borders)) { __t = *(_M_base + __former_back % _M_max_size); return true; } #pragma omp flush __decode2(_M_borders, __former_front, __former_back); } return false; } }; } //namespace __gnu_parallel #undef _GLIBCXX_VOLATILE #endif /* _GLIBCXX_PARALLEL_QUEUE_H */ 4.8.2/parallel/parallel.h000064400000003050147547540550010774 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/parallel.h * @brief End-user include file. Provides advanced settings and * tuning options. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze and Johannes Singler. #ifndef _GLIBCXX_PARALLEL_PARALLEL_H #define _GLIBCXX_PARALLEL_PARALLEL_H 1 #include #include #include #include #include #endif /* _GLIBCXX_PARALLEL_PARALLEL_H */ 4.8.2/parallel/algorithmfwd.h000064400000076716147547540550011712 0ustar00// Forward declarations -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/algorithmfwd.h * This file is a GNU parallel extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PARALLEL_ALGORITHMFWD_H #define _GLIBCXX_PARALLEL_ALGORITHMFWD_H 1 #pragma GCC system_header #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { template _FIter adjacent_find(_FIter, _FIter); template _FIter adjacent_find(_FIter, _FIter, __gnu_parallel::sequential_tag); template _FIter __adjacent_find_switch(_FIter, _FIter, _IterTag); template _RAIter __adjacent_find_switch(_RAIter, _RAIter, random_access_iterator_tag); template _FIter adjacent_find(_FIter, _FIter, _BiPredicate); template _FIter adjacent_find(_FIter, _FIter, _BiPredicate, __gnu_parallel::sequential_tag); template _FIter __adjacent_find_switch(_FIter, _FIter, _BiPredicate, _IterTag); template _RAIter __adjacent_find_switch(_RAIter, _RAIter, _BiPredicate, random_access_iterator_tag); template typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&); template typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&, __gnu_parallel::sequential_tag); template typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&, __gnu_parallel::_Parallelism); template typename iterator_traits<_IIter>::difference_type __count_switch(_IIter, _IIter, const _Tp&, _IterTag); template typename iterator_traits<_RAIter>::difference_type __count_switch(_RAIter, _RAIter, const _Tp&, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_unbalanced); template typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate); template typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate, __gnu_parallel::sequential_tag); template typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate, __gnu_parallel::_Parallelism); template typename iterator_traits<_IIter>::difference_type __count_if_switch(_IIter, _IIter, _Predicate, _IterTag); template typename iterator_traits<_RAIter>::difference_type __count_if_switch(_RAIter, _RAIter, _Predicate, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_unbalanced); // algobase.h template bool equal(_IIter1, _IIter1, _IIter2, __gnu_parallel::sequential_tag); template bool equal(_IIter1, _IIter1, _IIter2, _Predicate, __gnu_parallel::sequential_tag); template bool equal(_IIter1, _IIter1, _IIter2); template bool equal(_IIter1, _IIter1, _IIter2, _Predicate); template _IIter find(_IIter, _IIter, const _Tp&, __gnu_parallel::sequential_tag); template _IIter find(_IIter, _IIter, const _Tp& __val); template _IIter __find_switch(_IIter, _IIter, const _Tp&, _IterTag); template _RAIter __find_switch(_RAIter, _RAIter, const _Tp&, random_access_iterator_tag); template _IIter find_if(_IIter, _IIter, _Predicate, __gnu_parallel::sequential_tag); template _IIter find_if(_IIter, _IIter, _Predicate); template _IIter __find_if_switch(_IIter, _IIter, _Predicate, _IterTag); template _RAIter __find_if_switch(_RAIter, _RAIter, _Predicate, random_access_iterator_tag); template _IIter find_first_of(_IIter, _IIter, _FIter, _FIter, __gnu_parallel::sequential_tag); template _IIter find_first_of(_IIter, _IIter, _FIter, _FIter, _BiPredicate, __gnu_parallel::sequential_tag); template _IIter find_first_of(_IIter, _IIter, _FIter, _FIter, _BiPredicate); template _IIter find_first_of(_IIter, _IIter, _FIter, _FIter); template _IIter __find_first_of_switch( _IIter, _IIter, _FIter, _FIter, _IterTag1, _IterTag2); template _RAIter __find_first_of_switch(_RAIter, _RAIter, _FIter, _FIter, _BiPredicate, random_access_iterator_tag, _IterTag); template _IIter __find_first_of_switch(_IIter, _IIter, _FIter, _FIter, _BiPredicate, _IterTag1, _IterTag2); template _Function for_each(_IIter, _IIter, _Function); template _Function for_each(_IIter, _IIter, _Function, __gnu_parallel::sequential_tag); template _Function for_each(_Iterator, _Iterator, _Function, __gnu_parallel::_Parallelism); template _Function __for_each_switch(_IIter, _IIter, _Function, _IterTag); template _Function __for_each_switch(_RAIter, _RAIter, _Function, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template void generate(_FIter, _FIter, _Generator); template void generate(_FIter, _FIter, _Generator, __gnu_parallel::sequential_tag); template void generate(_FIter, _FIter, _Generator, __gnu_parallel::_Parallelism); template void __generate_switch(_FIter, _FIter, _Generator, _IterTag); template void __generate_switch(_RAIter, _RAIter, _Generator, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template _OIter generate_n(_OIter, _Size, _Generator); template _OIter generate_n(_OIter, _Size, _Generator, __gnu_parallel::sequential_tag); template _OIter generate_n(_OIter, _Size, _Generator, __gnu_parallel::_Parallelism); template _OIter __generate_n_switch(_OIter, _Size, _Generator, _IterTag); template _RAIter __generate_n_switch(_RAIter, _Size, _Generator, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, __gnu_parallel::sequential_tag); template bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Predicate, __gnu_parallel::sequential_tag); template bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); template bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Predicate); template bool __lexicographical_compare_switch(_IIter1, _IIter1, _IIter2, _IIter2, _Predicate, _IterTag1, _IterTag2); template bool __lexicographical_compare_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Predicate, random_access_iterator_tag, random_access_iterator_tag); // algo.h template pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, __gnu_parallel::sequential_tag); template pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, _Predicate, __gnu_parallel::sequential_tag); template pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2); template pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, _Predicate); template pair<_IIter1, _IIter2> __mismatch_switch(_IIter1, _IIter1, _IIter2, _Predicate, _IterTag1, _IterTag2); template pair<_RAIter1, _RAIter2> __mismatch_switch(_RAIter1, _RAIter1, _RAIter2, _Predicate, random_access_iterator_tag, random_access_iterator_tag); template _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, __gnu_parallel::sequential_tag); template _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2); template _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate, __gnu_parallel::sequential_tag); template _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate); template _RAIter1 __search_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, random_access_iterator_tag, random_access_iterator_tag); template _FIter1 __search_switch(_FIter1, _FIter1, _FIter2, _FIter2, _IterTag1, _IterTag2); template _RAIter1 __search_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _BiPredicate, random_access_iterator_tag, random_access_iterator_tag); template _FIter1 __search_switch(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate, _IterTag1, _IterTag2); template _FIter search_n(_FIter, _FIter, _Integer, const _Tp&, __gnu_parallel::sequential_tag); template _FIter search_n(_FIter, _FIter, _Integer, const _Tp&, _BiPredicate, __gnu_parallel::sequential_tag); template _FIter search_n(_FIter, _FIter, _Integer, const _Tp&); template _FIter search_n(_FIter, _FIter, _Integer, const _Tp&, _BiPredicate); template _RAIter __search_n_switch(_RAIter, _RAIter, _Integer, const _Tp&, _BiPredicate, random_access_iterator_tag); template _FIter __search_n_switch(_FIter, _FIter, _Integer, const _Tp&, _BiPredicate, _IterTag); template _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation); template _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation, __gnu_parallel::sequential_tag); template _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation, __gnu_parallel::_Parallelism); template _OIter __transform1_switch(_IIter, _IIter, _OIter, _UnaryOperation, _IterTag1, _IterTag2); template _RAOIter __transform1_switch(_RAIIter, _RAIIter, _RAOIter, _UnaryOperation, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation); template _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation, __gnu_parallel::sequential_tag); template _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation, __gnu_parallel::_Parallelism); template _RAIter3 __transform2_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter3, _BiOperation, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template _OIter __transform2_switch(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation, _Tag1, _Tag2, _Tag3); template void replace(_FIter, _FIter, const _Tp&, const _Tp&); template void replace(_FIter, _FIter, const _Tp&, const _Tp&, __gnu_parallel::sequential_tag); template void replace(_FIter, _FIter, const _Tp&, const _Tp&, __gnu_parallel::_Parallelism); template void __replace_switch(_FIter, _FIter, const _Tp&, const _Tp&, _IterTag); template void __replace_switch(_RAIter, _RAIter, const _Tp&, const _Tp&, random_access_iterator_tag, __gnu_parallel::_Parallelism); template void replace_if(_FIter, _FIter, _Predicate, const _Tp&); template void replace_if(_FIter, _FIter, _Predicate, const _Tp&, __gnu_parallel::sequential_tag); template void replace_if(_FIter, _FIter, _Predicate, const _Tp&, __gnu_parallel::_Parallelism); template void __replace_if_switch(_FIter, _FIter, _Predicate, const _Tp&, _IterTag); template void __replace_if_switch(_RAIter, _RAIter, _Predicate, const _Tp&, random_access_iterator_tag, __gnu_parallel::_Parallelism); template _FIter max_element(_FIter, _FIter); template _FIter max_element(_FIter, _FIter, __gnu_parallel::sequential_tag); template _FIter max_element(_FIter, _FIter, __gnu_parallel::_Parallelism); template _FIter max_element(_FIter, _FIter, _Compare); template _FIter max_element(_FIter, _FIter, _Compare, __gnu_parallel::sequential_tag); template _FIter max_element(_FIter, _FIter, _Compare, __gnu_parallel::_Parallelism); template _FIter __max_element_switch(_FIter, _FIter, _Compare, _IterTag); template _RAIter __max_element_switch( _RAIter, _RAIter, _Compare, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, __gnu_parallel::sequential_tag); template _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare, __gnu_parallel::sequential_tag); template _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template _OIter __merge_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare, _IterTag1, _IterTag2, _IterTag3); template _OIter __merge_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag); template _FIter min_element(_FIter, _FIter); template _FIter min_element(_FIter, _FIter, __gnu_parallel::sequential_tag); template _FIter min_element(_FIter, _FIter, __gnu_parallel::_Parallelism __parallelism_tag); template _FIter min_element(_FIter, _FIter, _Compare); template _FIter min_element(_FIter, _FIter, _Compare, __gnu_parallel::sequential_tag); template _FIter min_element(_FIter, _FIter, _Compare, __gnu_parallel::_Parallelism); template _FIter __min_element_switch(_FIter, _FIter, _Compare, _IterTag); template _RAIter __min_element_switch( _RAIter, _RAIter, _Compare, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_balanced); template void nth_element(_RAIter, _RAIter, _RAIter, __gnu_parallel::sequential_tag); template void nth_element(_RAIter, _RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag); template void nth_element(_RAIter, _RAIter, _RAIter, _Compare); template void nth_element(_RAIter, _RAIter, _RAIter); template void partial_sort(_RAIter, _RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag); template void partial_sort(_RAIter, _RAIter, _RAIter, __gnu_parallel::sequential_tag); template void partial_sort(_RAIter, _RAIter, _RAIter, _Compare); template void partial_sort(_RAIter, _RAIter, _RAIter); template _FIter partition(_FIter, _FIter, _Predicate, __gnu_parallel::sequential_tag); template _FIter partition(_FIter, _FIter, _Predicate); template _FIter __partition_switch(_FIter, _FIter, _Predicate, _IterTag); template _RAIter __partition_switch( _RAIter, _RAIter, _Predicate, random_access_iterator_tag); template void random_shuffle(_RAIter, _RAIter, __gnu_parallel::sequential_tag); template void random_shuffle(_RAIter, _RAIter, _RandomNumberGenerator&, __gnu_parallel::sequential_tag); template void random_shuffle(_RAIter, _RAIter); template void random_shuffle(_RAIter, _RAIter, #if __cplusplus >= 201103L _RandomNumberGenerator&&); #else _RandomNumberGenerator&); #endif template _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, __gnu_parallel::sequential_tag); template _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, __gnu_parallel::sequential_tag); template _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate); template _OIter __set_union_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, _IterTag1, _IterTag2, _IterTag3); template _Output_RAIter __set_union_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Output_RAIter, _Predicate, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag); template _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, __gnu_parallel::sequential_tag); template _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, __gnu_parallel::sequential_tag); template _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate); template _OIter __set_intersection_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, _IterTag1, _IterTag2, _IterTag3); template _Output_RAIter __set_intersection_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Output_RAIter, _Predicate, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag); template _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, __gnu_parallel::sequential_tag); template _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, __gnu_parallel::sequential_tag); template _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate); template _OIter __set_symmetric_difference_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, _IterTag1, _IterTag2, _IterTag3); template _Output_RAIter __set_symmetric_difference_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Output_RAIter, _Predicate, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag); template _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, __gnu_parallel::sequential_tag); template _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, __gnu_parallel::sequential_tag); template _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate); template _OIter __set_difference_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate, _IterTag1, _IterTag2, _IterTag3); template _Output_RAIter __set_difference_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Output_RAIter, _Predicate, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag); template void sort(_RAIter, _RAIter, __gnu_parallel::sequential_tag); template void sort(_RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag); template void sort(_RAIter, _RAIter); template void sort(_RAIter, _RAIter, _Compare); template void stable_sort(_RAIter, _RAIter, __gnu_parallel::sequential_tag); template void stable_sort(_RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag); template void stable_sort(_RAIter, _RAIter); template void stable_sort(_RAIter, _RAIter, _Compare); template _OIter unique_copy(_IIter, _IIter, _OIter, __gnu_parallel::sequential_tag); template _OIter unique_copy(_IIter, _IIter, _OIter, _Predicate, __gnu_parallel::sequential_tag); template _OIter unique_copy(_IIter, _IIter, _OIter); template _OIter unique_copy(_IIter, _IIter, _OIter, _Predicate); template _OIter __unique_copy_switch(_IIter, _IIter, _OIter, _Predicate, _IterTag1, _IterTag2); template _RandomAccess_OIter __unique_copy_switch(_RAIter, _RAIter, _RandomAccess_OIter, _Predicate, random_access_iterator_tag, random_access_iterator_tag); } // end namespace __parallel } // end namespace std #endif /* _GLIBCXX_PARALLEL_ALGORITHMFWD_H */ 4.8.2/parallel/sort.h000064400000017024147547540550010175 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/sort.h * @brief Parallel sorting algorithm switch. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_SORT_H #define _GLIBCXX_PARALLEL_SORT_H 1 #include #include #include #if _GLIBCXX_ASSERTIONS #include #endif #if _GLIBCXX_MERGESORT #include #endif #if _GLIBCXX_QUICKSORT #include #endif #if _GLIBCXX_BAL_QUICKSORT #include #endif namespace __gnu_parallel { //prototype template void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, _Parallelism __parallelism); /** * @brief Choose multiway mergesort, splitting variant at run-time, * for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, multiway_mergesort_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) if(_Settings::get().sort_splitting == EXACT) parallel_sort_mwms<__stable, true> (__begin, __end, __comp, __parallelism.__get_num_threads()); else parallel_sort_mwms<__stable, false> (__begin, __end, __comp, __parallelism.__get_num_threads()); } /** * @brief Choose multiway mergesort with exact splitting, * for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, multiway_mergesort_exact_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) parallel_sort_mwms<__stable, true> (__begin, __end, __comp, __parallelism.__get_num_threads()); } /** * @brief Choose multiway mergesort with splitting by sampling, * for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, multiway_mergesort_sampling_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) parallel_sort_mwms<__stable, false> (__begin, __end, __comp, __parallelism.__get_num_threads()); } /** * @brief Choose quicksort for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, quicksort_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) _GLIBCXX_PARALLEL_ASSERT(__stable == false); __parallel_sort_qs(__begin, __end, __comp, __parallelism.__get_num_threads()); } /** * @brief Choose balanced quicksort for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, balanced_quicksort_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) _GLIBCXX_PARALLEL_ASSERT(__stable == false); __parallel_sort_qsb(__begin, __end, __comp, __parallelism.__get_num_threads()); } /** * @brief Choose multiway mergesort with exact splitting, * for parallel sorting. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, default_parallel_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) __parallel_sort<__stable> (__begin, __end, __comp, multiway_mergesort_exact_tag(__parallelism.__get_num_threads())); } /** * @brief Choose a parallel sorting algorithm. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __comp Comparator. * @tparam __stable Sort stable. * @callgraph */ template inline void __parallel_sort(_RAIter __begin, _RAIter __end, _Compare __comp, parallel_tag __parallelism) { _GLIBCXX_CALL(__end - __begin) typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; if (false) ; #if _GLIBCXX_MERGESORT else if (__stable || _Settings::get().sort_algorithm == MWMS) { if(_Settings::get().sort_splitting == EXACT) parallel_sort_mwms<__stable, true> (__begin, __end, __comp, __parallelism.__get_num_threads()); else parallel_sort_mwms (__begin, __end, __comp, __parallelism.__get_num_threads()); } #endif #if _GLIBCXX_QUICKSORT else if (_Settings::get().sort_algorithm == QS) __parallel_sort_qs(__begin, __end, __comp, __parallelism.__get_num_threads()); #endif #if _GLIBCXX_BAL_QUICKSORT else if (_Settings::get().sort_algorithm == QS_BALANCED) __parallel_sort_qsb(__begin, __end, __comp, __parallelism.__get_num_threads()); #endif else __gnu_sequential::sort(__begin, __end, __comp); } } // end namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_SORT_H */ 4.8.2/parallel/algobase.h000064400000026663147547540550010774 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/algobase.h * @brief Parallel STL function calls corresponding to the * stl_algobase.h header. The functions defined here mainly do case * switches and call the actual parallelized versions in other files. * Inlining policy: Functions that basically only contain one * function call, are declared inline. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_ALGOBASE_H #define _GLIBCXX_PARALLEL_ALGOBASE_H 1 #include #include #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { // NB: equal and lexicographical_compare require mismatch. // Sequential fallback template inline pair<_IIter1, _IIter2> mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2); } // Sequential fallback template inline pair<_IIter1, _IIter2> mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); } // Sequential fallback for input iterator case template inline pair<_IIter1, _IIter2> __mismatch_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred, _IteratorTag1, _IteratorTag2) { return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); } // Parallel mismatch for random access iterators template pair<_RAIter1, _RAIter2> __mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION(true)) { _RAIter1 __res = __gnu_parallel::__find_template(__begin1, __end1, __begin2, __pred, __gnu_parallel:: __mismatch_selector()).first; return make_pair(__res , __begin2 + (__res - __begin1)); } else return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); } // Public interface template inline pair<_IIter1, _IIter2> mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2) { typedef std::iterator_traits<_IIter1> _Iterator1Traits; typedef std::iterator_traits<_IIter2> _Iterator2Traits; typedef typename _Iterator1Traits::value_type _ValueType1; typedef typename _Iterator2Traits::value_type _ValueType2; typedef typename _Iterator1Traits::iterator_category _IteratorCategory1; typedef typename _Iterator2Traits::iterator_category _IteratorCategory2; typedef __gnu_parallel::_EqualTo<_ValueType1, _ValueType2> _EqualTo; return __mismatch_switch(__begin1, __end1, __begin2, _EqualTo(), _IteratorCategory1(), _IteratorCategory2()); } // Public interface template inline pair<_IIter1, _IIter2> mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred) { typedef std::iterator_traits<_IIter1> _Iterator1Traits; typedef std::iterator_traits<_IIter2> _Iterator2Traits; typedef typename _Iterator1Traits::iterator_category _IteratorCategory1; typedef typename _Iterator2Traits::iterator_category _IteratorCategory2; return __mismatch_switch(__begin1, __end1, __begin2, __pred, _IteratorCategory1(), _IteratorCategory2()); } // Sequential fallback template inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2); } // Sequential fallback template inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred); } // Public interface template inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2) { return __gnu_parallel::mismatch(__begin1, __end1, __begin2).first == __end1; } // Public interface template inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred) { return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __pred).first == __end1; } // Sequential fallback template inline bool lexicographical_compare(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1, __begin2, __end2); } // Sequential fallback template inline bool lexicographical_compare(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::lexicographical_compare( __begin1, __end1, __begin2, __end2, __pred); } // Sequential fallback for input iterator case template inline bool __lexicographical_compare_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _Predicate __pred, _IteratorTag1, _IteratorTag2) { return _GLIBCXX_STD_A::lexicographical_compare( __begin1, __end1, __begin2, __end2, __pred); } // Parallel lexicographical_compare for random access iterators // Limitation: Both valuetypes must be the same template bool __lexicographical_compare_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION(true)) { typedef iterator_traits<_RAIter1> _TraitsType1; typedef typename _TraitsType1::value_type _ValueType1; typedef iterator_traits<_RAIter2> _TraitsType2; typedef typename _TraitsType2::value_type _ValueType2; typedef __gnu_parallel:: _EqualFromLess<_ValueType1, _ValueType2, _Predicate> _EqualFromLessCompare; // Longer sequence in first place. if ((__end1 - __begin1) < (__end2 - __begin2)) { typedef pair<_RAIter1, _RAIter2> _SpotType; _SpotType __mm = __mismatch_switch(__begin1, __end1, __begin2, _EqualFromLessCompare(__pred), random_access_iterator_tag(), random_access_iterator_tag()); return (__mm.first == __end1) || bool(__pred(*__mm.first, *__mm.second)); } else { typedef pair<_RAIter2, _RAIter1> _SpotType; _SpotType __mm = __mismatch_switch(__begin2, __end2, __begin1, _EqualFromLessCompare(__pred), random_access_iterator_tag(), random_access_iterator_tag()); return (__mm.first != __end2) && bool(__pred(*__mm.second, *__mm.first)); } } else return _GLIBCXX_STD_A::lexicographical_compare( __begin1, __end1, __begin2, __end2, __pred); } // Public interface template inline bool lexicographical_compare(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::value_type _ValueType1; typedef typename _TraitsType1::iterator_category _IteratorCategory1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::value_type _ValueType2; typedef typename _TraitsType2::iterator_category _IteratorCategory2; typedef __gnu_parallel::_Less<_ValueType1, _ValueType2> _LessType; return __lexicographical_compare_switch( __begin1, __end1, __begin2, __end2, _LessType(), _IteratorCategory1(), _IteratorCategory2()); } // Public interface template inline bool lexicographical_compare(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _Predicate __pred) { typedef iterator_traits<_IIter1> _TraitsType1; typedef typename _TraitsType1::iterator_category _IteratorCategory1; typedef iterator_traits<_IIter2> _TraitsType2; typedef typename _TraitsType2::iterator_category _IteratorCategory2; return __lexicographical_compare_switch( __begin1, __end1, __begin2, __end2, __pred, _IteratorCategory1(), _IteratorCategory2()); } } // end namespace } // end namespace #endif /* _GLIBCXX_PARALLEL_ALGOBASE_H */ 4.8.2/parallel/algorithm000064400000002545147547540550010750 0ustar00// Algorithm extensions -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/algorithm * This file is a GNU extension to the Standard C++ Library. */ #ifndef _PARALLEL_ALGORITHM #define _PARALLEL_ALGORITHM 1 #pragma GCC system_header #include #include #include #include #endif 4.8.2/parallel/features.h000064400000006727147547540550011034 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/features.h * @brief Defines on whether to include algorithm variants. * * Less variants reduce executable size and compile time. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_FEATURES_H #define _GLIBCXX_PARALLEL_FEATURES_H 1 #ifndef _GLIBCXX_MERGESORT /** @def _GLIBCXX_MERGESORT * @brief Include parallel multi-way mergesort. * @see __gnu_parallel::_Settings::sort_algorithm */ #define _GLIBCXX_MERGESORT 1 #endif #ifndef _GLIBCXX_QUICKSORT /** @def _GLIBCXX_QUICKSORT * @brief Include parallel unbalanced quicksort. * @see __gnu_parallel::_Settings::sort_algorithm */ #define _GLIBCXX_QUICKSORT 1 #endif #ifndef _GLIBCXX_BAL_QUICKSORT /** @def _GLIBCXX_BAL_QUICKSORT * @brief Include parallel dynamically load-balanced quicksort. * @see __gnu_parallel::_Settings::sort_algorithm */ #define _GLIBCXX_BAL_QUICKSORT 1 #endif #ifndef _GLIBCXX_FIND_GROWING_BLOCKS /** @brief Include the growing blocks variant for std::find. * @see __gnu_parallel::_Settings::find_algorithm */ #define _GLIBCXX_FIND_GROWING_BLOCKS 1 #endif #ifndef _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS /** @brief Include the equal-sized blocks variant for std::find. * @see __gnu_parallel::_Settings::find_algorithm */ #define _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS 1 #endif #ifndef _GLIBCXX_FIND_EQUAL_SPLIT /** @def _GLIBCXX_FIND_EQUAL_SPLIT * @brief Include the equal splitting variant for std::find. * @see __gnu_parallel::_Settings::find_algorithm */ #define _GLIBCXX_FIND_EQUAL_SPLIT 1 #endif #ifndef _GLIBCXX_TREE_INITIAL_SPLITTING /** @def _GLIBCXX_TREE_INITIAL_SPLITTING * @brief Include the initial splitting variant for * _Rb_tree::insert_unique(_IIter beg, _IIter __end). * @see __gnu_parallel::_Rb_tree */ #define _GLIBCXX_TREE_INITIAL_SPLITTING 1 #endif #ifndef _GLIBCXX_TREE_DYNAMIC_BALANCING /** @def _GLIBCXX_TREE_DYNAMIC_BALANCING * @brief Include the dynamic balancing variant for * _Rb_tree::insert_unique(_IIter beg, _IIter __end). * @see __gnu_parallel::_Rb_tree */ #define _GLIBCXX_TREE_DYNAMIC_BALANCING 1 #endif #ifndef _GLIBCXX_TREE_FULL_COPY /** @def _GLIBCXX_TREE_FULL_COPY * @brief In order to sort the input sequence of * _Rb_tree::insert_unique(_IIter beg, _IIter __end) a * full copy of the input elements is done. * @see __gnu_parallel::_Rb_tree */ #define _GLIBCXX_TREE_FULL_COPY 1 #endif #endif /* _GLIBCXX_PARALLEL_FEATURES_H */ 4.8.2/parallel/algo.h000064400000277242147547540550010142 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/algo.h * @brief Parallel STL function calls corresponding to the stl_algo.h header. * * The functions defined here mainly do case switches and * call the actual parallelized versions in other files. * Inlining policy: Functions that basically only contain one function call, * are declared inline. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_ALGO_H #define _GLIBCXX_PARALLEL_ALGO_H 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { // Sequential fallback template inline _Function for_each(_IIter __begin, _IIter __end, _Function __f, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::for_each(__begin, __end, __f); } // Sequential fallback for input iterator case template inline _Function __for_each_switch(_IIter __begin, _IIter __end, _Function __f, _IteratorTag) { return for_each(__begin, __end, __f, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators template _Function __for_each_switch(_RAIter __begin, _RAIter __end, _Function __f, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().for_each_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy; __gnu_parallel::__for_each_selector<_RAIter> __functionality; return __gnu_parallel:: __for_each_template_random_access( __begin, __end, __f, __functionality, __gnu_parallel::_DummyReduct(), true, __dummy, -1, __parallelism_tag); } else return for_each(__begin, __end, __f, __gnu_parallel::sequential_tag()); } // Public interface template inline _Function for_each(_Iterator __begin, _Iterator __end, _Function __f, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_Iterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __for_each_switch(__begin, __end, __f, _IteratorCategory(), __parallelism_tag); } template inline _Function for_each(_Iterator __begin, _Iterator __end, _Function __f) { typedef std::iterator_traits<_Iterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __for_each_switch(__begin, __end, __f, _IteratorCategory()); } // Sequential fallback template inline _IIter find(_IIter __begin, _IIter __end, const _Tp& __val, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::find(__begin, __end, __val); } // Sequential fallback for input iterator case template inline _IIter __find_switch(_IIter __begin, _IIter __end, const _Tp& __val, _IteratorTag) { return _GLIBCXX_STD_A::find(__begin, __end, __val); } // Parallel find for random access iterators template _RAIter __find_switch(_RAIter __begin, _RAIter __end, const _Tp& __val, random_access_iterator_tag) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; if (_GLIBCXX_PARALLEL_CONDITION(true)) { std::binder2nd<__gnu_parallel::_EqualTo<_ValueType, const _Tp&> > __comp(__gnu_parallel::_EqualTo<_ValueType, const _Tp&>(), __val); return __gnu_parallel::__find_template( __begin, __end, __begin, __comp, __gnu_parallel::__find_if_selector()).first; } else return _GLIBCXX_STD_A::find(__begin, __end, __val); } // Public interface template inline _IIter find(_IIter __begin, _IIter __end, const _Tp& __val) { typedef std::iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __find_switch(__begin, __end, __val, _IteratorCategory()); } // Sequential fallback template inline _IIter find_if(_IIter __begin, _IIter __end, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::find_if(__begin, __end, __pred); } // Sequential fallback for input iterator case template inline _IIter __find_if_switch(_IIter __begin, _IIter __end, _Predicate __pred, _IteratorTag) { return _GLIBCXX_STD_A::find_if(__begin, __end, __pred); } // Parallel find_if for random access iterators template _RAIter __find_if_switch(_RAIter __begin, _RAIter __end, _Predicate __pred, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION(true)) return __gnu_parallel::__find_template(__begin, __end, __begin, __pred, __gnu_parallel:: __find_if_selector()).first; else return _GLIBCXX_STD_A::find_if(__begin, __end, __pred); } // Public interface template inline _IIter find_if(_IIter __begin, _IIter __end, _Predicate __pred) { typedef std::iterator_traits<_IIter> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __find_if_switch(__begin, __end, __pred, _IteratorCategory()); } // Sequential fallback template inline _IIter find_first_of(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::find_first_of(__begin1, __end1, __begin2, __end2); } // Sequential fallback template inline _IIter find_first_of(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2, _BinaryPredicate __comp, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::find_first_of( __begin1, __end1, __begin2, __end2, __comp); } // Sequential fallback for input iterator type template inline _IIter __find_first_of_switch(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2, _IteratorTag1, _IteratorTag2) { return find_first_of(__begin1, __end1, __begin2, __end2, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators template inline _RAIter __find_first_of_switch(_RAIter __begin1, _RAIter __end1, _FIterator __begin2, _FIterator __end2, _BinaryPredicate __comp, random_access_iterator_tag, _IteratorTag) { return __gnu_parallel:: __find_template(__begin1, __end1, __begin1, __comp, __gnu_parallel::__find_first_of_selector <_FIterator>(__begin2, __end2)).first; } // Sequential fallback for input iterator type template inline _IIter __find_first_of_switch(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2, _BinaryPredicate __comp, _IteratorTag1, _IteratorTag2) { return find_first_of(__begin1, __end1, __begin2, __end2, __comp, __gnu_parallel::sequential_tag()); } // Public interface template inline _IIter find_first_of(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2, _BinaryPredicate __comp) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_FIterator> _FIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; typedef typename _FIterTraits::iterator_category _FIteratorCategory; return __find_first_of_switch(__begin1, __end1, __begin2, __end2, __comp, _IIteratorCategory(), _FIteratorCategory()); } // Public interface, insert default comparator template inline _IIter find_first_of(_IIter __begin1, _IIter __end1, _FIterator __begin2, _FIterator __end2) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_FIterator> _FIterTraits; typedef typename _IIterTraits::value_type _IValueType; typedef typename _FIterTraits::value_type _FValueType; return __gnu_parallel::find_first_of(__begin1, __end1, __begin2, __end2, __gnu_parallel::_EqualTo<_IValueType, _FValueType>()); } // Sequential fallback template inline _OutputIterator unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::unique_copy(__begin1, __end1, __out); } // Sequential fallback template inline _OutputIterator unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::unique_copy(__begin1, __end1, __out, __pred); } // Sequential fallback for input iterator case template inline _OutputIterator __unique_copy_switch(_IIter __begin, _IIter __last, _OutputIterator __out, _Predicate __pred, _IteratorTag1, _IteratorTag2) { return _GLIBCXX_STD_A::unique_copy(__begin, __last, __out, __pred); } // Parallel unique_copy for random access iterators template RandomAccessOutputIterator __unique_copy_switch(_RAIter __begin, _RAIter __last, RandomAccessOutputIterator __out, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__last - __begin) > __gnu_parallel::_Settings::get().unique_copy_minimal_n)) return __gnu_parallel::__parallel_unique_copy( __begin, __last, __out, __pred); else return _GLIBCXX_STD_A::unique_copy(__begin, __last, __out, __pred); } // Public interface template inline _OutputIterator unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; typedef typename _IIterTraits::value_type _ValueType; typedef typename _OIterTraits::iterator_category _OIterCategory; return __unique_copy_switch( __begin1, __end1, __out, equal_to<_ValueType>(), _IIteratorCategory(), _OIterCategory()); } // Public interface template inline _OutputIterator unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out, _Predicate __pred) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; typedef typename _OIterTraits::iterator_category _OIterCategory; return __unique_copy_switch( __begin1, __end1, __out, __pred, _IIteratorCategory(), _OIterCategory()); } // Sequential fallback template inline _OutputIterator set_union(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_union( __begin1, __end1, __begin2, __end2, __out); } // Sequential fallback template inline _OutputIterator set_union(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_union(__begin1, __end1, __begin2, __end2, __out, __pred); } // Sequential fallback for input iterator case template inline _OutputIterator __set_union_switch( _IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Predicate __pred, _IteratorTag1, _IteratorTag2, _IteratorTag3) { return _GLIBCXX_STD_A::set_union(__begin1, __end1, __begin2, __end2, __result, __pred); } // Parallel set_union for random access iterators template _Output_RAIter __set_union_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _Output_RAIter __result, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().set_union_minimal_n || static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2) >= __gnu_parallel::_Settings::get().set_union_minimal_n)) return __gnu_parallel::__parallel_set_union( __begin1, __end1, __begin2, __end2, __result, __pred); else return _GLIBCXX_STD_A::set_union(__begin1, __end1, __begin2, __end2, __result, __pred); } // Public interface template inline _OutputIterator set_union(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; typedef typename _IIterTraits1::value_type _ValueType1; typedef typename _IIterTraits2::value_type _ValueType2; return __set_union_switch( __begin1, __end1, __begin2, __end2, __out, __gnu_parallel::_Less<_ValueType1, _ValueType2>(), _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Public interface template inline _OutputIterator set_union(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; return __set_union_switch( __begin1, __end1, __begin2, __end2, __out, __pred, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Sequential fallback. template inline _OutputIterator set_intersection(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_intersection(__begin1, __end1, __begin2, __end2, __out); } // Sequential fallback. template inline _OutputIterator set_intersection(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_intersection( __begin1, __end1, __begin2, __end2, __out, __pred); } // Sequential fallback for input iterator case template inline _OutputIterator __set_intersection_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Predicate __pred, _IteratorTag1, _IteratorTag2, _IteratorTag3) { return _GLIBCXX_STD_A::set_intersection(__begin1, __end1, __begin2, __end2, __result, __pred); } // Parallel set_intersection for random access iterators template _Output_RAIter __set_intersection_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _Output_RAIter __result, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().set_union_minimal_n || static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2) >= __gnu_parallel::_Settings::get().set_union_minimal_n)) return __gnu_parallel::__parallel_set_intersection( __begin1, __end1, __begin2, __end2, __result, __pred); else return _GLIBCXX_STD_A::set_intersection( __begin1, __end1, __begin2, __end2, __result, __pred); } // Public interface template inline _OutputIterator set_intersection(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; typedef typename _IIterTraits1::value_type _ValueType1; typedef typename _IIterTraits2::value_type _ValueType2; return __set_intersection_switch( __begin1, __end1, __begin2, __end2, __out, __gnu_parallel::_Less<_ValueType1, _ValueType2>(), _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } template inline _OutputIterator set_intersection(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; return __set_intersection_switch( __begin1, __end1, __begin2, __end2, __out, __pred, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Sequential fallback template inline _OutputIterator set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_symmetric_difference( __begin1, __end1, __begin2, __end2, __out); } // Sequential fallback template inline _OutputIterator set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_symmetric_difference( __begin1, __end1, __begin2, __end2, __out, __pred); } // Sequential fallback for input iterator case template inline _OutputIterator __set_symmetric_difference_switch( _IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Predicate __pred, _IteratorTag1, _IteratorTag2, _IteratorTag3) { return _GLIBCXX_STD_A::set_symmetric_difference( __begin1, __end1, __begin2, __end2, __result, __pred); } // Parallel set_symmetric_difference for random access iterators template _Output_RAIter __set_symmetric_difference_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _Output_RAIter __result, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().set_symmetric_difference_minimal_n || static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2) >= __gnu_parallel::_Settings::get().set_symmetric_difference_minimal_n)) return __gnu_parallel::__parallel_set_symmetric_difference( __begin1, __end1, __begin2, __end2, __result, __pred); else return _GLIBCXX_STD_A::set_symmetric_difference( __begin1, __end1, __begin2, __end2, __result, __pred); } // Public interface. template inline _OutputIterator set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; typedef typename _IIterTraits1::value_type _ValueType1; typedef typename _IIterTraits2::value_type _ValueType2; return __set_symmetric_difference_switch( __begin1, __end1, __begin2, __end2, __out, __gnu_parallel::_Less<_ValueType1, _ValueType2>(), _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Public interface. template inline _OutputIterator set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; return __set_symmetric_difference_switch( __begin1, __end1, __begin2, __end2, __out, __pred, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Sequential fallback. template inline _OutputIterator set_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_difference( __begin1,__end1, __begin2, __end2, __out); } // Sequential fallback. template inline _OutputIterator set_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::set_difference(__begin1, __end1, __begin2, __end2, __out, __pred); } // Sequential fallback for input iterator case. template inline _OutputIterator __set_difference_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Predicate __pred, _IteratorTag1, _IteratorTag2, _IteratorTag3) { return _GLIBCXX_STD_A::set_difference( __begin1, __end1, __begin2, __end2, __result, __pred); } // Parallel set_difference for random access iterators template _Output_RAIter __set_difference_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _Output_RAIter __result, _Predicate __pred, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().set_difference_minimal_n || static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2) >= __gnu_parallel::_Settings::get().set_difference_minimal_n)) return __gnu_parallel::__parallel_set_difference( __begin1, __end1, __begin2, __end2, __result, __pred); else return _GLIBCXX_STD_A::set_difference( __begin1, __end1, __begin2, __end2, __result, __pred); } // Public interface template inline _OutputIterator set_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; typedef typename _IIterTraits1::value_type _ValueType1; typedef typename _IIterTraits2::value_type _ValueType2; return __set_difference_switch( __begin1, __end1, __begin2, __end2, __out, __gnu_parallel::_Less<_ValueType1, _ValueType2>(), _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Public interface template inline _OutputIterator set_difference(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __out, _Predicate __pred) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; return __set_difference_switch( __begin1, __end1, __begin2, __end2, __out, __pred, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Sequential fallback template inline _FIterator adjacent_find(_FIterator __begin, _FIterator __end, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::adjacent_find(__begin, __end); } // Sequential fallback template inline _FIterator adjacent_find(_FIterator __begin, _FIterator __end, _BinaryPredicate __binary_pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::adjacent_find(__begin, __end, __binary_pred); } // Parallel algorithm for random access iterators template _RAIter __adjacent_find_switch(_RAIter __begin, _RAIter __end, random_access_iterator_tag) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; if (_GLIBCXX_PARALLEL_CONDITION(true)) { _RAIter __spot = __gnu_parallel:: __find_template( __begin, __end - 1, __begin, equal_to<_ValueType>(), __gnu_parallel::__adjacent_find_selector()) .first; if (__spot == (__end - 1)) return __end; else return __spot; } else return adjacent_find(__begin, __end, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case template inline _FIterator __adjacent_find_switch(_FIterator __begin, _FIterator __end, _IteratorTag) { return adjacent_find(__begin, __end, __gnu_parallel::sequential_tag()); } // Public interface template inline _FIterator adjacent_find(_FIterator __begin, _FIterator __end) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __adjacent_find_switch(__begin, __end, _IteratorCategory()); } // Sequential fallback for input iterator case template inline _FIterator __adjacent_find_switch(_FIterator __begin, _FIterator __end, _BinaryPredicate __pred, _IteratorTag) { return adjacent_find(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators template _RAIter __adjacent_find_switch(_RAIter __begin, _RAIter __end, _BinaryPredicate __pred, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION(true)) return __gnu_parallel::__find_template(__begin, __end, __begin, __pred, __gnu_parallel:: __adjacent_find_selector()).first; else return adjacent_find(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Public interface template inline _FIterator adjacent_find(_FIterator __begin, _FIterator __end, _BinaryPredicate __pred) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __adjacent_find_switch(__begin, __end, __pred, _IteratorCategory()); } // Sequential fallback template inline typename iterator_traits<_IIter>::difference_type count(_IIter __begin, _IIter __end, const _Tp& __value, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::count(__begin, __end, __value); } // Parallel code for random access iterators template typename iterator_traits<_RAIter>::difference_type __count_switch(_RAIter __begin, _RAIter __end, const _Tp& __value, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_unbalanced) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; typedef __gnu_parallel::_SequenceIndex _SequenceIndex; if (_GLIBCXX_PARALLEL_CONDITION( static_cast<_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().count_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { __gnu_parallel::__count_selector<_RAIter, _DifferenceType> __functionality; _DifferenceType __res = 0; __gnu_parallel:: __for_each_template_random_access( __begin, __end, __value, __functionality, std::plus<_SequenceIndex>(), __res, __res, -1, __parallelism_tag); return __res; } else return count(__begin, __end, __value, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case. template inline typename iterator_traits<_IIter>::difference_type __count_switch(_IIter __begin, _IIter __end, const _Tp& __value, _IteratorTag) { return count(__begin, __end, __value, __gnu_parallel::sequential_tag()); } // Public interface. template inline typename iterator_traits<_IIter>::difference_type count(_IIter __begin, _IIter __end, const _Tp& __value, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __count_switch(__begin, __end, __value, _IteratorCategory(), __parallelism_tag); } template inline typename iterator_traits<_IIter>::difference_type count(_IIter __begin, _IIter __end, const _Tp& __value) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __count_switch(__begin, __end, __value, _IteratorCategory()); } // Sequential fallback. template inline typename iterator_traits<_IIter>::difference_type count_if(_IIter __begin, _IIter __end, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::count_if(__begin, __end, __pred); } // Parallel count_if for random access iterators template typename iterator_traits<_RAIter>::difference_type __count_if_switch(_RAIter __begin, _RAIter __end, _Predicate __pred, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_unbalanced) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; typedef __gnu_parallel::_SequenceIndex _SequenceIndex; if (_GLIBCXX_PARALLEL_CONDITION( static_cast<_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().count_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { _DifferenceType __res = 0; __gnu_parallel:: __count_if_selector<_RAIter, _DifferenceType> __functionality; __gnu_parallel:: __for_each_template_random_access( __begin, __end, __pred, __functionality, std::plus<_SequenceIndex>(), __res, __res, -1, __parallelism_tag); return __res; } else return count_if(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case. template inline typename iterator_traits<_IIter>::difference_type __count_if_switch(_IIter __begin, _IIter __end, _Predicate __pred, _IteratorTag) { return count_if(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Public interface. template inline typename iterator_traits<_IIter>::difference_type count_if(_IIter __begin, _IIter __end, _Predicate __pred, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __count_if_switch(__begin, __end, __pred, _IteratorCategory(), __parallelism_tag); } template inline typename iterator_traits<_IIter>::difference_type count_if(_IIter __begin, _IIter __end, _Predicate __pred) { typedef iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __count_if_switch(__begin, __end, __pred, _IteratorCategory()); } // Sequential fallback. template inline _FIterator1 search(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::search(__begin1, __end1, __begin2, __end2); } // Parallel algorithm for random access iterator template _RAIter1 __search_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, random_access_iterator_tag, random_access_iterator_tag) { typedef std::iterator_traits<_RAIter1> _Iterator1Traits; typedef typename _Iterator1Traits::value_type _ValueType1; typedef std::iterator_traits<_RAIter2> _Iterator2Traits; typedef typename _Iterator2Traits::value_type _ValueType2; if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().search_minimal_n)) return __gnu_parallel:: __search_template( __begin1, __end1, __begin2, __end2, __gnu_parallel::_EqualTo<_ValueType1, _ValueType2>()); else return search(__begin1, __end1, __begin2, __end2, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case template inline _FIterator1 __search_switch(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2, _IteratorTag1, _IteratorTag2) { return search(__begin1, __end1, __begin2, __end2, __gnu_parallel::sequential_tag()); } // Public interface. template inline _FIterator1 search(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2) { typedef std::iterator_traits<_FIterator1> _Iterator1Traits; typedef typename _Iterator1Traits::iterator_category _IteratorCategory1; typedef std::iterator_traits<_FIterator2> _Iterator2Traits; typedef typename _Iterator2Traits::iterator_category _IteratorCategory2; return __search_switch(__begin1, __end1, __begin2, __end2, _IteratorCategory1(), _IteratorCategory2()); } // Public interface. template inline _FIterator1 search(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2, _BinaryPredicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::search( __begin1, __end1, __begin2, __end2, __pred); } // Parallel algorithm for random access iterator. template _RAIter1 __search_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter2 __end2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().search_minimal_n)) return __gnu_parallel::__search_template(__begin1, __end1, __begin2, __end2, __pred); else return search(__begin1, __end1, __begin2, __end2, __pred, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case template inline _FIterator1 __search_switch(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2, _BinaryPredicate __pred, _IteratorTag1, _IteratorTag2) { return search(__begin1, __end1, __begin2, __end2, __pred, __gnu_parallel::sequential_tag()); } // Public interface template inline _FIterator1 search(_FIterator1 __begin1, _FIterator1 __end1, _FIterator2 __begin2, _FIterator2 __end2, _BinaryPredicate __pred) { typedef std::iterator_traits<_FIterator1> _Iterator1Traits; typedef typename _Iterator1Traits::iterator_category _IteratorCategory1; typedef std::iterator_traits<_FIterator2> _Iterator2Traits; typedef typename _Iterator2Traits::iterator_category _IteratorCategory2; return __search_switch(__begin1, __end1, __begin2, __end2, __pred, _IteratorCategory1(), _IteratorCategory2()); } // Sequential fallback template inline _FIterator search_n(_FIterator __begin, _FIterator __end, _Integer __count, const _Tp& __val, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val); } // Sequential fallback template inline _FIterator search_n(_FIterator __begin, _FIterator __end, _Integer __count, const _Tp& __val, _BinaryPredicate __binary_pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::search_n( __begin, __end, __count, __val, __binary_pred); } // Public interface. template inline _FIterator search_n(_FIterator __begin, _FIterator __end, _Integer __count, const _Tp& __val) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; return __gnu_parallel::search_n(__begin, __end, __count, __val, __gnu_parallel::_EqualTo<_ValueType, _Tp>()); } // Parallel algorithm for random access iterators. template _RAIter __search_n_switch(_RAIter __begin, _RAIter __end, _Integer __count, const _Tp& __val, _BinaryPredicate __binary_pred, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().search_minimal_n)) { __gnu_parallel::_PseudoSequence<_Tp, _Integer> __ps(__val, __count); return __gnu_parallel::__search_template( __begin, __end, __ps.begin(), __ps.end(), __binary_pred); } else return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val, __binary_pred); } // Sequential fallback for input iterator case. template inline _FIterator __search_n_switch(_FIterator __begin, _FIterator __end, _Integer __count, const _Tp& __val, _BinaryPredicate __binary_pred, _IteratorTag) { return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val, __binary_pred); } // Public interface. template inline _FIterator search_n(_FIterator __begin, _FIterator __end, _Integer __count, const _Tp& __val, _BinaryPredicate __binary_pred) { return __search_n_switch(__begin, __end, __count, __val, __binary_pred, typename std::iterator_traits<_FIterator>:: iterator_category()); } // Sequential fallback. template inline _OutputIterator transform(_IIter __begin, _IIter __end, _OutputIterator __result, _UnaryOperation __unary_op, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::transform(__begin, __end, __result, __unary_op); } // Parallel unary transform for random access iterators. template _RAIter2 __transform1_switch(_RAIter1 __begin, _RAIter1 __end, _RAIter2 __result, _UnaryOperation __unary_op, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().transform_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy = true; typedef __gnu_parallel::_IteratorPair<_RAIter1, _RAIter2, random_access_iterator_tag> _ItTrip; _ItTrip __begin_pair(__begin, __result), __end_pair(__end, __result + (__end - __begin)); __gnu_parallel::__transform1_selector<_ItTrip> __functionality; __gnu_parallel:: __for_each_template_random_access( __begin_pair, __end_pair, __unary_op, __functionality, __gnu_parallel::_DummyReduct(), __dummy, __dummy, -1, __parallelism_tag); return __functionality._M_finish_iterator; } else return transform(__begin, __end, __result, __unary_op, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case. template inline _RAIter2 __transform1_switch(_RAIter1 __begin, _RAIter1 __end, _RAIter2 __result, _UnaryOperation __unary_op, _IteratorTag1, _IteratorTag2) { return transform(__begin, __end, __result, __unary_op, __gnu_parallel::sequential_tag()); } // Public interface. template inline _OutputIterator transform(_IIter __begin, _IIter __end, _OutputIterator __result, _UnaryOperation __unary_op, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; typedef typename _OIterTraits::iterator_category _OIterCategory; return __transform1_switch(__begin, __end, __result, __unary_op, _IIteratorCategory(), _OIterCategory(), __parallelism_tag); } template inline _OutputIterator transform(_IIter __begin, _IIter __end, _OutputIterator __result, _UnaryOperation __unary_op) { typedef std::iterator_traits<_IIter> _IIterTraits; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; typedef typename _OIterTraits::iterator_category _OIterCategory; return __transform1_switch(__begin, __end, __result, __unary_op, _IIteratorCategory(), _OIterCategory()); } // Sequential fallback template inline _OutputIterator transform(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _OutputIterator __result, _BinaryOperation __binary_op, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::transform(__begin1, __end1, __begin2, __result, __binary_op); } // Parallel binary transform for random access iterators. template _RAIter3 __transform2_switch(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _RAIter3 __result, _BinaryOperation __binary_op, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( (__end1 - __begin1) >= __gnu_parallel::_Settings::get().transform_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy = true; typedef __gnu_parallel::_IteratorTriple<_RAIter1, _RAIter2, _RAIter3, random_access_iterator_tag> _ItTrip; _ItTrip __begin_triple(__begin1, __begin2, __result), __end_triple(__end1, __begin2 + (__end1 - __begin1), __result + (__end1 - __begin1)); __gnu_parallel::__transform2_selector<_ItTrip> __functionality; __gnu_parallel:: __for_each_template_random_access(__begin_triple, __end_triple, __binary_op, __functionality, __gnu_parallel::_DummyReduct(), __dummy, __dummy, -1, __parallelism_tag); return __functionality._M_finish_iterator; } else return transform(__begin1, __end1, __begin2, __result, __binary_op, __gnu_parallel::sequential_tag()); } // Sequential fallback for input iterator case. template inline _OutputIterator __transform2_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _OutputIterator __result, _BinaryOperation __binary_op, _Tag1, _Tag2, _Tag3) { return transform(__begin1, __end1, __begin2, __result, __binary_op, __gnu_parallel::sequential_tag()); } // Public interface. template inline _OutputIterator transform(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _OutputIterator __result, _BinaryOperation __binary_op, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _OIterTraits::iterator_category _OIterCategory; return __transform2_switch( __begin1, __end1, __begin2, __result, __binary_op, _IIterCategory1(), _IIterCategory2(), _OIterCategory(), __parallelism_tag); } template inline _OutputIterator transform(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _OutputIterator __result, _BinaryOperation __binary_op) { typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _OIterTraits::iterator_category _OIterCategory; return __transform2_switch( __begin1, __end1, __begin2, __result, __binary_op, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Sequential fallback template inline void replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value, const _Tp& __new_value, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::replace(__begin, __end, __old_value, __new_value); } // Sequential fallback for input iterator case template inline void __replace_switch(_FIterator __begin, _FIterator __end, const _Tp& __old_value, const _Tp& __new_value, _IteratorTag) { replace(__begin, __end, __old_value, __new_value, __gnu_parallel::sequential_tag()); } // Parallel replace for random access iterators template inline void __replace_switch(_RAIter __begin, _RAIter __end, const _Tp& __old_value, const _Tp& __new_value, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { // XXX parallel version is where? replace(__begin, __end, __old_value, __new_value, __gnu_parallel::sequential_tag()); } // Public interface template inline void replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value, const _Tp& __new_value, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; __replace_switch(__begin, __end, __old_value, __new_value, _IteratorCategory(), __parallelism_tag); } template inline void replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value, const _Tp& __new_value) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; __replace_switch(__begin, __end, __old_value, __new_value, _IteratorCategory()); } // Sequential fallback template inline void replace_if(_FIterator __begin, _FIterator __end, _Predicate __pred, const _Tp& __new_value, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::replace_if(__begin, __end, __pred, __new_value); } // Sequential fallback for input iterator case template inline void __replace_if_switch(_FIterator __begin, _FIterator __end, _Predicate __pred, const _Tp& __new_value, _IteratorTag) { replace_if(__begin, __end, __pred, __new_value, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template void __replace_if_switch(_RAIter __begin, _RAIter __end, _Predicate __pred, const _Tp& __new_value, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().replace_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy; __gnu_parallel:: __replace_if_selector<_RAIter, _Predicate, _Tp> __functionality(__new_value); __gnu_parallel:: __for_each_template_random_access( __begin, __end, __pred, __functionality, __gnu_parallel::_DummyReduct(), true, __dummy, -1, __parallelism_tag); } else replace_if(__begin, __end, __pred, __new_value, __gnu_parallel::sequential_tag()); } // Public interface. template inline void replace_if(_FIterator __begin, _FIterator __end, _Predicate __pred, const _Tp& __new_value, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_FIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; __replace_if_switch(__begin, __end, __pred, __new_value, _IteratorCategory(), __parallelism_tag); } template inline void replace_if(_FIterator __begin, _FIterator __end, _Predicate __pred, const _Tp& __new_value) { typedef std::iterator_traits<_FIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; __replace_if_switch(__begin, __end, __pred, __new_value, _IteratorCategory()); } // Sequential fallback template inline void generate(_FIterator __begin, _FIterator __end, _Generator __gen, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::generate(__begin, __end, __gen); } // Sequential fallback for input iterator case. template inline void __generate_switch(_FIterator __begin, _FIterator __end, _Generator __gen, _IteratorTag) { generate(__begin, __end, __gen, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template void __generate_switch(_RAIter __begin, _RAIter __end, _Generator __gen, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().generate_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { bool __dummy; __gnu_parallel::__generate_selector<_RAIter> __functionality; __gnu_parallel:: __for_each_template_random_access( __begin, __end, __gen, __functionality, __gnu_parallel::_DummyReduct(), true, __dummy, -1, __parallelism_tag); } else generate(__begin, __end, __gen, __gnu_parallel::sequential_tag()); } // Public interface. template inline void generate(_FIterator __begin, _FIterator __end, _Generator __gen, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_FIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; __generate_switch(__begin, __end, __gen, _IteratorCategory(), __parallelism_tag); } template inline void generate(_FIterator __begin, _FIterator __end, _Generator __gen) { typedef std::iterator_traits<_FIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; __generate_switch(__begin, __end, __gen, _IteratorCategory()); } // Sequential fallback. template inline _OutputIterator generate_n(_OutputIterator __begin, _Size __n, _Generator __gen, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::generate_n(__begin, __n, __gen); } // Sequential fallback for input iterator case. template inline _OutputIterator __generate_n_switch(_OutputIterator __begin, _Size __n, _Generator __gen, _IteratorTag) { return generate_n(__begin, __n, __gen, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template inline _RAIter __generate_n_switch(_RAIter __begin, _Size __n, _Generator __gen, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { // XXX parallel version is where? return generate_n(__begin, __n, __gen, __gnu_parallel::sequential_tag()); } // Public interface. template inline _OutputIterator generate_n(_OutputIterator __begin, _Size __n, _Generator __gen, __gnu_parallel::_Parallelism __parallelism_tag) { typedef std::iterator_traits<_OutputIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __generate_n_switch(__begin, __n, __gen, _IteratorCategory(), __parallelism_tag); } template inline _OutputIterator generate_n(_OutputIterator __begin, _Size __n, _Generator __gen) { typedef std::iterator_traits<_OutputIterator> _IteratorTraits; typedef typename _IteratorTraits::iterator_category _IteratorCategory; return __generate_n_switch(__begin, __n, __gen, _IteratorCategory()); } // Sequential fallback. template inline void random_shuffle(_RAIter __begin, _RAIter __end, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::random_shuffle(__begin, __end); } // Sequential fallback. template inline void random_shuffle(_RAIter __begin, _RAIter __end, _RandomNumberGenerator& __rand, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::random_shuffle(__begin, __end, __rand); } /** @brief Functor wrapper for std::rand(). */ template struct _CRandNumber { int operator()(int __limit) { return rand() % __limit; } }; // Fill in random number generator. template inline void random_shuffle(_RAIter __begin, _RAIter __end) { _CRandNumber<> __r; // Parallelization still possible. __gnu_parallel::random_shuffle(__begin, __end, __r); } // Parallel algorithm for random access iterators. template void random_shuffle(_RAIter __begin, _RAIter __end, #if __cplusplus >= 201103L _RandomNumberGenerator&& __rand) #else _RandomNumberGenerator& __rand) #endif { if (__begin == __end) return; if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().random_shuffle_minimal_n)) __gnu_parallel::__parallel_random_shuffle(__begin, __end, __rand); else __gnu_parallel::__sequential_random_shuffle(__begin, __end, __rand); } // Sequential fallback. template inline _FIterator partition(_FIterator __begin, _FIterator __end, _Predicate __pred, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::partition(__begin, __end, __pred); } // Sequential fallback for input iterator case. template inline _FIterator __partition_switch(_FIterator __begin, _FIterator __end, _Predicate __pred, _IteratorTag) { return partition(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators. template _RAIter __partition_switch(_RAIter __begin, _RAIter __end, _Predicate __pred, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().partition_minimal_n)) { typedef typename std::iterator_traits<_RAIter>:: difference_type _DifferenceType; _DifferenceType __middle = __gnu_parallel:: __parallel_partition(__begin, __end, __pred, __gnu_parallel::__get_max_threads()); return __begin + __middle; } else return partition(__begin, __end, __pred, __gnu_parallel::sequential_tag()); } // Public interface. template inline _FIterator partition(_FIterator __begin, _FIterator __end, _Predicate __pred) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __partition_switch(__begin, __end, __pred, _IteratorCategory()); } // sort interface // Sequential fallback template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::sort(__begin, __end); } // Sequential fallback template inline void sort(_RAIter __begin, _RAIter __end, _Compare __comp, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::sort<_RAIter, _Compare>(__begin, __end, __comp); } // Public interface template void sort(_RAIter __begin, _RAIter __end, _Compare __comp, _Parallelism __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; if (__begin != __end) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().sort_minimal_n)) __gnu_parallel::__parallel_sort( __begin, __end, __comp, __parallelism); else sort(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __gnu_parallel::default_parallel_tag()); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::default_parallel_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::parallel_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::multiway_mergesort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::multiway_mergesort_sampling_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::multiway_mergesort_exact_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::quicksort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void sort(_RAIter __begin, _RAIter __end, __gnu_parallel::balanced_quicksort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface template void sort(_RAIter __begin, _RAIter __end, _Compare __comp) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; sort(__begin, __end, __comp, __gnu_parallel::default_parallel_tag()); } // stable_sort interface // Sequential fallback template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::stable_sort(__begin, __end); } // Sequential fallback template inline void stable_sort(_RAIter __begin, _RAIter __end, _Compare __comp, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::stable_sort<_RAIter, _Compare>( __begin, __end, __comp); } // Public interface template void stable_sort(_RAIter __begin, _RAIter __end, _Compare __comp, _Parallelism __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; if (__begin != __end) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().sort_minimal_n)) __gnu_parallel::__parallel_sort( __begin, __end, __comp, __parallelism); else stable_sort(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __gnu_parallel::default_parallel_tag()); } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::default_parallel_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::parallel_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::multiway_mergesort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::quicksort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface, insert default comparator template inline void stable_sort(_RAIter __begin, _RAIter __end, __gnu_parallel::balanced_quicksort_tag __parallelism) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism); } // Public interface template void stable_sort(_RAIter __begin, _RAIter __end, _Compare __comp) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; stable_sort( __begin, __end, __comp, __gnu_parallel::default_parallel_tag()); } // Sequential fallback template inline _OutputIterator merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::merge( __begin1, __end1, __begin2, __end2, __result); } // Sequential fallback template inline _OutputIterator merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Compare __comp, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::merge( __begin1, __end1, __begin2, __end2, __result, __comp); } // Sequential fallback for input iterator case template inline _OutputIterator __merge_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Compare __comp, _IteratorTag1, _IteratorTag2, _IteratorTag3) { return _GLIBCXX_STD_A::merge(__begin1, __end1, __begin2, __end2, __result, __comp); } // Parallel algorithm for random access iterators template _OutputIterator __merge_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Compare __comp, random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag) { if (_GLIBCXX_PARALLEL_CONDITION( (static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1) >= __gnu_parallel::_Settings::get().merge_minimal_n || static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2) >= __gnu_parallel::_Settings::get().merge_minimal_n))) return __gnu_parallel::__parallel_merge_advance( __begin1, __end1, __begin2, __end2, __result, (__end1 - __begin1) + (__end2 - __begin2), __comp); else return __gnu_parallel::__merge_advance( __begin1, __end1, __begin2, __end2, __result, (__end1 - __begin1) + (__end2 - __begin2), __comp); } // Public interface template inline _OutputIterator merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result, _Compare __comp) { typedef typename iterator_traits<_IIter1>::value_type _ValueType; typedef std::iterator_traits<_IIter1> _IIterTraits1; typedef std::iterator_traits<_IIter2> _IIterTraits2; typedef std::iterator_traits<_OutputIterator> _OIterTraits; typedef typename _IIterTraits1::iterator_category _IIterCategory1; typedef typename _IIterTraits2::iterator_category _IIterCategory2; typedef typename _OIterTraits::iterator_category _OIterCategory; return __merge_switch( __begin1, __end1, __begin2, __end2, __result, __comp, _IIterCategory1(), _IIterCategory2(), _OIterCategory()); } // Public interface, insert default comparator template inline _OutputIterator merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2, _OutputIterator __result) { typedef std::iterator_traits<_IIter1> _Iterator1Traits; typedef std::iterator_traits<_IIter2> _Iterator2Traits; typedef typename _Iterator1Traits::value_type _ValueType1; typedef typename _Iterator2Traits::value_type _ValueType2; return __gnu_parallel::merge(__begin1, __end1, __begin2, __end2, __result, __gnu_parallel::_Less<_ValueType1, _ValueType2>()); } // Sequential fallback template inline void nth_element(_RAIter __begin, _RAIter __nth, _RAIter __end, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::nth_element(__begin, __nth, __end); } // Sequential fallback template inline void nth_element(_RAIter __begin, _RAIter __nth, _RAIter __end, _Compare __comp, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::nth_element(__begin, __nth, __end, __comp); } // Public interface template inline void nth_element(_RAIter __begin, _RAIter __nth, _RAIter __end, _Compare __comp) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().nth_element_minimal_n)) __gnu_parallel::__parallel_nth_element(__begin, __nth, __end, __comp); else nth_element(__begin, __nth, __end, __comp, __gnu_parallel::sequential_tag()); } // Public interface, insert default comparator template inline void nth_element(_RAIter __begin, _RAIter __nth, _RAIter __end) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; __gnu_parallel::nth_element(__begin, __nth, __end, std::less<_ValueType>()); } // Sequential fallback template inline void partial_sort(_RAIter __begin, _RAIter __middle, _RAIter __end, _Compare __comp, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::partial_sort(__begin, __middle, __end, __comp); } // Sequential fallback template inline void partial_sort(_RAIter __begin, _RAIter __middle, _RAIter __end, __gnu_parallel::sequential_tag) { _GLIBCXX_STD_A::partial_sort(__begin, __middle, __end); } // Public interface, parallel algorithm for random access iterators template void partial_sort(_RAIter __begin, _RAIter __middle, _RAIter __end, _Compare __comp) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().partial_sort_minimal_n)) __gnu_parallel:: __parallel_partial_sort(__begin, __middle, __end, __comp); else partial_sort(__begin, __middle, __end, __comp, __gnu_parallel::sequential_tag()); } // Public interface, insert default comparator template inline void partial_sort(_RAIter __begin, _RAIter __middle, _RAIter __end) { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; __gnu_parallel::partial_sort(__begin, __middle, __end, std::less<_ValueType>()); } // Sequential fallback template inline _FIterator max_element(_FIterator __begin, _FIterator __end, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::max_element(__begin, __end); } // Sequential fallback template inline _FIterator max_element(_FIterator __begin, _FIterator __end, _Compare __comp, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::max_element(__begin, __end, __comp); } // Sequential fallback for input iterator case template inline _FIterator __max_element_switch(_FIterator __begin, _FIterator __end, _Compare __comp, _IteratorTag) { return max_element(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators template _RAIter __max_element_switch(_RAIter __begin, _RAIter __end, _Compare __comp, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().max_element_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { _RAIter __res(__begin); __gnu_parallel::__identity_selector<_RAIter> __functionality; __gnu_parallel:: __for_each_template_random_access( __begin, __end, __gnu_parallel::_Nothing(), __functionality, __gnu_parallel::__max_element_reduct<_Compare, _RAIter>(__comp), __res, __res, -1, __parallelism_tag); return __res; } else return max_element(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } // Public interface, insert default comparator template inline _FIterator max_element(_FIterator __begin, _FIterator __end, __gnu_parallel::_Parallelism __parallelism_tag) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; return max_element(__begin, __end, std::less<_ValueType>(), __parallelism_tag); } template inline _FIterator max_element(_FIterator __begin, _FIterator __end) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; return __gnu_parallel::max_element(__begin, __end, std::less<_ValueType>()); } // Public interface template inline _FIterator max_element(_FIterator __begin, _FIterator __end, _Compare __comp, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __max_element_switch(__begin, __end, __comp, _IteratorCategory(), __parallelism_tag); } template inline _FIterator max_element(_FIterator __begin, _FIterator __end, _Compare __comp) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __max_element_switch(__begin, __end, __comp, _IteratorCategory()); } // Sequential fallback template inline _FIterator min_element(_FIterator __begin, _FIterator __end, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::min_element(__begin, __end); } // Sequential fallback template inline _FIterator min_element(_FIterator __begin, _FIterator __end, _Compare __comp, __gnu_parallel::sequential_tag) { return _GLIBCXX_STD_A::min_element(__begin, __end, __comp); } // Sequential fallback for input iterator case template inline _FIterator __min_element_switch(_FIterator __begin, _FIterator __end, _Compare __comp, _IteratorTag) { return min_element(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } // Parallel algorithm for random access iterators template _RAIter __min_element_switch(_RAIter __begin, _RAIter __end, _Compare __comp, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism_tag = __gnu_parallel::parallel_balanced) { if (_GLIBCXX_PARALLEL_CONDITION( static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >= __gnu_parallel::_Settings::get().min_element_minimal_n && __gnu_parallel::__is_parallel(__parallelism_tag))) { _RAIter __res(__begin); __gnu_parallel::__identity_selector<_RAIter> __functionality; __gnu_parallel:: __for_each_template_random_access( __begin, __end, __gnu_parallel::_Nothing(), __functionality, __gnu_parallel::__min_element_reduct<_Compare, _RAIter>(__comp), __res, __res, -1, __parallelism_tag); return __res; } else return min_element(__begin, __end, __comp, __gnu_parallel::sequential_tag()); } // Public interface, insert default comparator template inline _FIterator min_element(_FIterator __begin, _FIterator __end, __gnu_parallel::_Parallelism __parallelism_tag) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; return min_element(__begin, __end, std::less<_ValueType>(), __parallelism_tag); } template inline _FIterator min_element(_FIterator __begin, _FIterator __end) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; return __gnu_parallel::min_element(__begin, __end, std::less<_ValueType>()); } // Public interface template inline _FIterator min_element(_FIterator __begin, _FIterator __end, _Compare __comp, __gnu_parallel::_Parallelism __parallelism_tag) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __min_element_switch(__begin, __end, __comp, _IteratorCategory(), __parallelism_tag); } template inline _FIterator min_element(_FIterator __begin, _FIterator __end, _Compare __comp) { typedef iterator_traits<_FIterator> _TraitsType; typedef typename _TraitsType::iterator_category _IteratorCategory; return __min_element_switch(__begin, __end, __comp, _IteratorCategory()); } } // end namespace } // end namespace #endif /* _GLIBCXX_PARALLEL_ALGO_H */ 4.8.2/parallel/compatibility.h000064400000007316147547540550012062 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/compatibility.h * @brief Compatibility layer, mostly concerned with atomic operations. * * This file is a GNU parallel extension to the Standard C++ Library * and contains implementation details for the library's internal use. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_COMPATIBILITY_H #define _GLIBCXX_PARALLEL_COMPATIBILITY_H 1 #include #include #if !defined(_WIN32) || defined (__CYGWIN__) #include #endif #ifdef __MINGW32__ // Including will drag in all the windows32 names. Since // that can cause user code portability problems, we just declare the // one needed function here. extern "C" __attribute((dllimport)) void __attribute__((stdcall)) Sleep (unsigned long); #endif namespace __gnu_parallel { template inline _Tp __add_omp(volatile _Tp* __ptr, _Tp __addend) { int64_t __res; #pragma omp critical { __res = *__ptr; *(__ptr) += __addend; } return __res; } /** @brief Add a value to a variable, atomically. * * @param __ptr Pointer to a signed integer. * @param __addend Value to add. */ template inline _Tp __fetch_and_add(volatile _Tp* __ptr, _Tp __addend) { if (__atomic_always_lock_free(sizeof(_Tp), __ptr)) return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL); return __add_omp(__ptr, __addend); } template inline bool __cas_omp(volatile _Tp* __ptr, _Tp __comparand, _Tp __replacement) { bool __res = false; #pragma omp critical { if (*__ptr == __comparand) { *__ptr = __replacement; __res = true; } } return __res; } /** @brief Compare-and-swap * * Compare @c *__ptr and @c __comparand. If equal, let @c * *__ptr=__replacement and return @c true, return @c false otherwise. * * @param __ptr Pointer to signed integer. * @param __comparand Compare value. * @param __replacement Replacement value. */ template inline bool __compare_and_swap(volatile _Tp* __ptr, _Tp __comparand, _Tp __replacement) { if (__atomic_always_lock_free(sizeof(_Tp), __ptr)) return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, false, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); return __cas_omp(__ptr, __comparand, __replacement); } /** @brief Yield control to another thread, without waiting for * the end of the time slice. */ inline void __yield() { #if defined (_WIN32) && !defined (__CYGWIN__) Sleep(0); #else sched_yield(); #endif } } // end namespace #endif /* _GLIBCXX_PARALLEL_COMPATIBILITY_H */ 4.8.2/parallel/numericfwd.h000064400000016514147547540550011354 0ustar00// Forward declarations -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/numericfwd.h * This file is a GNU parallel extension to the Standard C++ Library. */ #ifndef _GLIBCXX_PARALLEL_NUMERICFWD_H #define _GLIBCXX_PARALLEL_NUMERICFWD_H 1 #pragma GCC system_header #include #include namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { template _Tp accumulate(_IIter, _IIter, _Tp); template _Tp accumulate(_IIter, _IIter, _Tp, __gnu_parallel::sequential_tag); template _Tp accumulate(_IIter, _IIter, _Tp, __gnu_parallel::_Parallelism); template _Tp __accumulate_switch(_IIter, _IIter, _Tp, _Tag); template _Tp accumulate(_IIter, _IIter, _Tp, _BinaryOper); template _Tp accumulate(_IIter, _IIter, _Tp, _BinaryOper, __gnu_parallel::sequential_tag); template _Tp accumulate(_IIter, _IIter, _Tp, _BinaryOper, __gnu_parallel::_Parallelism); template _Tp __accumulate_switch(_IIter, _IIter, _Tp, _BinaryOper, _Tag); template _Tp __accumulate_switch(_RAIter, _RAIter, _Tp, _BinaryOper, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_unbalanced); template _OIter adjacent_difference(_IIter, _IIter, _OIter); template _OIter adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper); template _OIter adjacent_difference(_IIter, _IIter, _OIter, __gnu_parallel::sequential_tag); template _OIter adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper, __gnu_parallel::sequential_tag); template _OIter adjacent_difference(_IIter, _IIter, _OIter, __gnu_parallel::_Parallelism); template _OIter adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper, __gnu_parallel::_Parallelism); template _OIter __adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper, _Tag1, _Tag2); template _OIter __adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism __parallelism = __gnu_parallel::parallel_unbalanced); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp, __gnu_parallel::sequential_tag); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp, __gnu_parallel::_Parallelism); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp, _BinaryFunction1, _BinaryFunction2); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp, _BinaryFunction1, _BinaryFunction2, __gnu_parallel::sequential_tag); template _Tp inner_product(_IIter1, _IIter1, _IIter2, _Tp, BinaryFunction1, BinaryFunction2, __gnu_parallel::_Parallelism); template _Tp __inner_product_switch(_RAIter1, _RAIter1, _RAIter2, _Tp, BinaryFunction1, BinaryFunction2, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::_Parallelism = __gnu_parallel::parallel_unbalanced); template _Tp __inner_product_switch(_IIter1, _IIter1, _IIter2, _Tp, _BinaryFunction1, _BinaryFunction2, _Tag1, _Tag2); template _OIter partial_sum(_IIter, _IIter, _OIter, __gnu_parallel::sequential_tag); template _OIter partial_sum(_IIter, _IIter, _OIter, _BinaryOper, __gnu_parallel::sequential_tag); template _OIter partial_sum(_IIter, _IIter, _OIter __result); template _OIter partial_sum(_IIter, _IIter, _OIter, _BinaryOper); template _OIter __partial_sum_switch(_IIter, _IIter, _OIter, _BinaryOper, _Tag1, _Tag2); template _OIter __partial_sum_switch(_IIter, _IIter, _OIter, _BinaryOper, random_access_iterator_tag, random_access_iterator_tag); } // end namespace } // end namespace #endif /* _GLIBCXX_PARALLEL_NUMERICFWD_H */ 4.8.2/parallel/multiway_mergesort.h000064400000035647147547540550013163 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/multiway_mergesort.h * @brief Parallel multiway merge sort. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H #define _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H 1 #include #include #include #include #include namespace __gnu_parallel { /** @brief Subsequence description. */ template struct _Piece { typedef _DifferenceTp _DifferenceType; /** @brief Begin of subsequence. */ _DifferenceType _M_begin; /** @brief End of subsequence. */ _DifferenceType _M_end; }; /** @brief Data accessed by all threads. * * PMWMS = parallel multiway mergesort */ template struct _PMWMSSortingData { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; /** @brief Number of threads involved. */ _ThreadIndex _M_num_threads; /** @brief Input __begin. */ _RAIter _M_source; /** @brief Start indices, per thread. */ _DifferenceType* _M_starts; /** @brief Storage in which to sort. */ _ValueType** _M_temporary; /** @brief Samples. */ _ValueType* _M_samples; /** @brief Offsets to add to the found positions. */ _DifferenceType* _M_offsets; /** @brief Pieces of data to merge @c [thread][__sequence] */ std::vector<_Piece<_DifferenceType> >* _M_pieces; }; /** * @brief Select _M_samples from a sequence. * @param __sd Pointer to algorithm data. _Result will be placed in * @c __sd->_M_samples. * @param __num_samples Number of _M_samples to select. */ template void __determine_samples(_PMWMSSortingData<_RAIter>* __sd, _DifferenceTp __num_samples) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef _DifferenceTp _DifferenceType; _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType* __es = new _DifferenceType[__num_samples + 2]; __equally_split(__sd->_M_starts[__iam + 1] - __sd->_M_starts[__iam], __num_samples + 1, __es); for (_DifferenceType __i = 0; __i < __num_samples; ++__i) ::new(&(__sd->_M_samples[__iam * __num_samples + __i])) _ValueType(__sd->_M_source[__sd->_M_starts[__iam] + __es[__i + 1]]); delete[] __es; } /** @brief Split consistently. */ template struct _SplitConsistently { }; /** @brief Split by exact splitting. */ template struct _SplitConsistently { void operator()(const _ThreadIndex __iam, _PMWMSSortingData<_RAIter>* __sd, _Compare& __comp, const typename std::iterator_traits<_RAIter>::difference_type __num_samples) const { # pragma omp barrier std::vector > __seqs(__sd->_M_num_threads); for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++) __seqs[__s] = std::make_pair(__sd->_M_temporary[__s], __sd->_M_temporary[__s] + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s])); std::vector<_SortingPlacesIterator> __offsets(__sd->_M_num_threads); // if not last thread if (__iam < __sd->_M_num_threads - 1) multiseq_partition(__seqs.begin(), __seqs.end(), __sd->_M_starts[__iam + 1], __offsets.begin(), __comp); for (_ThreadIndex __seq = 0; __seq < __sd->_M_num_threads; __seq++) { // for each sequence if (__iam < (__sd->_M_num_threads - 1)) __sd->_M_pieces[__iam][__seq]._M_end = __offsets[__seq] - __seqs[__seq].first; else // very end of this sequence __sd->_M_pieces[__iam][__seq]._M_end = __sd->_M_starts[__seq + 1] - __sd->_M_starts[__seq]; } # pragma omp barrier for (_ThreadIndex __seq = 0; __seq < __sd->_M_num_threads; __seq++) { // For each sequence. if (__iam > 0) __sd->_M_pieces[__iam][__seq]._M_begin = __sd->_M_pieces[__iam - 1][__seq]._M_end; else // Absolute beginning. __sd->_M_pieces[__iam][__seq]._M_begin = 0; } } }; /** @brief Split by sampling. */ template struct _SplitConsistently { void operator()(const _ThreadIndex __iam, _PMWMSSortingData<_RAIter>* __sd, _Compare& __comp, const typename std::iterator_traits<_RAIter>::difference_type __num_samples) const { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; __determine_samples(__sd, __num_samples); # pragma omp barrier # pragma omp single __gnu_sequential::sort(__sd->_M_samples, __sd->_M_samples + (__num_samples * __sd->_M_num_threads), __comp); # pragma omp barrier for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; ++__s) { // For each sequence. if (__num_samples * __iam > 0) __sd->_M_pieces[__iam][__s]._M_begin = std::lower_bound(__sd->_M_temporary[__s], __sd->_M_temporary[__s] + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]), __sd->_M_samples[__num_samples * __iam], __comp) - __sd->_M_temporary[__s]; else // Absolute beginning. __sd->_M_pieces[__iam][__s]._M_begin = 0; if ((__num_samples * (__iam + 1)) < (__num_samples * __sd->_M_num_threads)) __sd->_M_pieces[__iam][__s]._M_end = std::lower_bound(__sd->_M_temporary[__s], __sd->_M_temporary[__s] + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]), __sd->_M_samples[__num_samples * (__iam + 1)], __comp) - __sd->_M_temporary[__s]; else // Absolute end. __sd->_M_pieces[__iam][__s]._M_end = (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]); } } }; template struct __possibly_stable_sort { }; template struct __possibly_stable_sort { void operator()(const _RAIter& __begin, const _RAIter& __end, _Compare& __comp) const { __gnu_sequential::stable_sort(__begin, __end, __comp); } }; template struct __possibly_stable_sort { void operator()(const _RAIter __begin, const _RAIter __end, _Compare& __comp) const { __gnu_sequential::sort(__begin, __end, __comp); } }; template struct __possibly_stable_multiway_merge { }; template struct __possibly_stable_multiway_merge { void operator()(const Seq_RAIter& __seqs_begin, const Seq_RAIter& __seqs_end, const _RAIter& __target, _Compare& __comp, _DiffType __length_am) const { stable_multiway_merge(__seqs_begin, __seqs_end, __target, __length_am, __comp, sequential_tag()); } }; template struct __possibly_stable_multiway_merge { void operator()(const Seq_RAIter& __seqs_begin, const Seq_RAIter& __seqs_end, const _RAIter& __target, _Compare& __comp, _DiffType __length_am) const { multiway_merge(__seqs_begin, __seqs_end, __target, __length_am, __comp, sequential_tag()); } }; /** @brief PMWMS code executed by each thread. * @param __sd Pointer to algorithm data. * @param __comp Comparator. */ template void parallel_sort_mwms_pu(_PMWMSSortingData<_RAIter>* __sd, _Compare& __comp) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _ThreadIndex __iam = omp_get_thread_num(); // Length of this thread's chunk, before merging. _DifferenceType __length_local = __sd->_M_starts[__iam + 1] - __sd->_M_starts[__iam]; // Sort in temporary storage, leave space for sentinel. typedef _ValueType* _SortingPlacesIterator; __sd->_M_temporary[__iam] = static_cast<_ValueType*>(::operator new(sizeof(_ValueType) * (__length_local + 1))); // Copy there. std::uninitialized_copy(__sd->_M_source + __sd->_M_starts[__iam], __sd->_M_source + __sd->_M_starts[__iam] + __length_local, __sd->_M_temporary[__iam]); __possibly_stable_sort<__stable, _SortingPlacesIterator, _Compare>() (__sd->_M_temporary[__iam], __sd->_M_temporary[__iam] + __length_local, __comp); // Invariant: locally sorted subsequence in sd->_M_temporary[__iam], // __sd->_M_temporary[__iam] + __length_local. // No barrier here: Synchronization is done by the splitting routine. _DifferenceType __num_samples = _Settings::get().sort_mwms_oversampling * __sd->_M_num_threads - 1; _SplitConsistently<__exact, _RAIter, _Compare, _SortingPlacesIterator>() (__iam, __sd, __comp, __num_samples); // Offset from __target __begin, __length after merging. _DifferenceType __offset = 0, __length_am = 0; for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++) { __length_am += (__sd->_M_pieces[__iam][__s]._M_end - __sd->_M_pieces[__iam][__s]._M_begin); __offset += __sd->_M_pieces[__iam][__s]._M_begin; } typedef std::vector< std::pair<_SortingPlacesIterator, _SortingPlacesIterator> > _SeqVector; _SeqVector __seqs(__sd->_M_num_threads); for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; ++__s) { __seqs[__s] = std::make_pair(__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_begin, __sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_end); } __possibly_stable_multiway_merge< __stable, typename _SeqVector::iterator, _RAIter, _Compare, _DifferenceType>()(__seqs.begin(), __seqs.end(), __sd->_M_source + __offset, __comp, __length_am); # pragma omp barrier for (_DifferenceType __i = 0; __i < __length_local; ++__i) __sd->_M_temporary[__iam][__i].~_ValueType(); ::operator delete(__sd->_M_temporary[__iam]); } /** @brief PMWMS main call. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __comp Comparator. * @param __num_threads Number of threads to use. */ template void parallel_sort_mwms(_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads) { _GLIBCXX_CALL(__end - __begin) typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; if (__n <= 1) return; // at least one element per thread if (__num_threads > __n) __num_threads = static_cast<_ThreadIndex>(__n); // shared variables _PMWMSSortingData<_RAIter> __sd; _DifferenceType* __starts; _DifferenceType __size; # pragma omp parallel num_threads(__num_threads) { __num_threads = omp_get_num_threads(); //no more threads than requested # pragma omp single { __sd._M_num_threads = __num_threads; __sd._M_source = __begin; __sd._M_temporary = new _ValueType*[__num_threads]; if (!__exact) { __size = (_Settings::get().sort_mwms_oversampling * __num_threads - 1) * __num_threads; __sd._M_samples = static_cast<_ValueType*> (::operator new(__size * sizeof(_ValueType))); } else __sd._M_samples = 0; __sd._M_offsets = new _DifferenceType[__num_threads - 1]; __sd._M_pieces = new std::vector<_Piece<_DifferenceType> >[__num_threads]; for (_ThreadIndex __s = 0; __s < __num_threads; ++__s) __sd._M_pieces[__s].resize(__num_threads); __starts = __sd._M_starts = new _DifferenceType[__num_threads + 1]; _DifferenceType __chunk_length = __n / __num_threads; _DifferenceType __split = __n % __num_threads; _DifferenceType __pos = 0; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) { __starts[__i] = __pos; __pos += ((__i < __split) ? (__chunk_length + 1) : __chunk_length); } __starts[__num_threads] = __pos; } //single // Now sort in parallel. parallel_sort_mwms_pu<__stable, __exact>(&__sd, __comp); } //parallel delete[] __starts; delete[] __sd._M_temporary; if (!__exact) { for (_DifferenceType __i = 0; __i < __size; ++__i) __sd._M_samples[__i].~_ValueType(); ::operator delete(__sd._M_samples); } delete[] __sd._M_offsets; delete[] __sd._M_pieces; } } //namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H */ 4.8.2/parallel/checkers.h000064400000004374147547540550011001 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/checkers.h * @brief Routines for checking the correctness of algorithm results. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_CHECKERS_H #define _GLIBCXX_PARALLEL_CHECKERS_H 1 #include #include #include namespace __gnu_parallel { /** * @brief Check whether @c [__begin, @c __end) is sorted according * to @c __comp. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __comp Comparator. * @return @c true if sorted, @c false otherwise. */ template bool __is_sorted(_IIter __begin, _IIter __end, _Compare __comp) { if (__begin == __end) return true; _IIter __current(__begin), __recent(__begin); unsigned long long __position = 1; for (__current++; __current != __end; __current++) { if (__comp(*__current, *__recent)) { return false; } __recent = __current; __position++; } return true; } } #endif /* _GLIBCXX_PARALLEL_CHECKERS_H */ 4.8.2/parallel/base.h000064400000027723147547540550010127 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/base.h * @brief Sequential helper functions. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_BASE_H #define _GLIBCXX_PARALLEL_BASE_H 1 #include #include #include #include #include #include // Parallel mode namespaces. /** * @namespace std::__parallel * @brief GNU parallel code, replaces standard behavior with parallel behavior. */ namespace std _GLIBCXX_VISIBILITY(default) { namespace __parallel { } } /** * @namespace __gnu_parallel * @brief GNU parallel code for public use. */ namespace __gnu_parallel { // Import all the parallel versions of components in namespace std. using namespace std::__parallel; } /** * @namespace __gnu_sequential * @brief GNU sequential classes for public use. */ namespace __gnu_sequential { // Import whatever is the serial version. #ifdef _GLIBCXX_PARALLEL using namespace std::_GLIBCXX_STD_A; #else using namespace std; #endif } namespace __gnu_parallel { // NB: Including this file cannot produce (unresolved) symbols from // the OpenMP runtime unless the parallel mode is actually invoked // and active, which imples that the OpenMP runtime is actually // going to be linked in. inline _ThreadIndex __get_max_threads() { _ThreadIndex __i = omp_get_max_threads(); return __i > 1 ? __i : 1; } inline bool __is_parallel(const _Parallelism __p) { return __p != sequential; } /** @brief Calculates the rounded-down logarithm of @c __n for base 2. * @param __n Argument. * @return Returns 0 for any argument <1. */ template inline _Size __rd_log2(_Size __n) { _Size __k; for (__k = 0; __n > 1; __n >>= 1) ++__k; return __k; } /** @brief Encode two integers into one gnu_parallel::_CASable. * @param __a First integer, to be encoded in the most-significant @c * _CASable_bits/2 bits. * @param __b Second integer, to be encoded in the least-significant * @c _CASable_bits/2 bits. * @return value encoding @c __a and @c __b. * @see __decode2 */ inline _CASable __encode2(int __a, int __b) //must all be non-negative, actually { return (((_CASable)__a) << (_CASable_bits / 2)) | (((_CASable)__b) << 0); } /** @brief Decode two integers from one gnu_parallel::_CASable. * @param __x __gnu_parallel::_CASable to decode integers from. * @param __a First integer, to be decoded from the most-significant * @c _CASable_bits/2 bits of @c __x. * @param __b Second integer, to be encoded in the least-significant * @c _CASable_bits/2 bits of @c __x. * @see __encode2 */ inline void __decode2(_CASable __x, int& __a, int& __b) { __a = (int)((__x >> (_CASable_bits / 2)) & _CASable_mask); __b = (int)((__x >> 0 ) & _CASable_mask); } //needed for parallel "numeric", even if "algorithm" not included /** @brief Equivalent to std::min. */ template inline const _Tp& min(const _Tp& __a, const _Tp& __b) { return (__a < __b) ? __a : __b; } /** @brief Equivalent to std::max. */ template inline const _Tp& max(const _Tp& __a, const _Tp& __b) { return (__a > __b) ? __a : __b; } /** @brief Constructs predicate for equality from strict weak * ordering predicate */ template class _EqualFromLess : public std::binary_function<_T1, _T2, bool> { private: _Compare& _M_comp; public: _EqualFromLess(_Compare& __comp) : _M_comp(__comp) { } bool operator()(const _T1& __a, const _T2& __b) { return !_M_comp(__a, __b) && !_M_comp(__b, __a); } }; /** @brief Similar to std::unary_negate, * but giving the argument types explicitly. */ template class __unary_negate : public std::unary_function { protected: _Predicate _M_pred; public: explicit __unary_negate(const _Predicate& __x) : _M_pred(__x) { } bool operator()(const argument_type& __x) { return !_M_pred(__x); } }; /** @brief Similar to std::binder1st, * but giving the argument types explicitly. */ template class __binder1st : public std::unary_function<_SecondArgumentType, _ResultType> { protected: _Operation _M_op; _FirstArgumentType _M_value; public: __binder1st(const _Operation& __x, const _FirstArgumentType& __y) : _M_op(__x), _M_value(__y) { } _ResultType operator()(const _SecondArgumentType& __x) { return _M_op(_M_value, __x); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 109. Missing binders for non-const sequence elements _ResultType operator()(_SecondArgumentType& __x) const { return _M_op(_M_value, __x); } }; /** * @brief Similar to std::binder2nd, but giving the argument types * explicitly. */ template class __binder2nd : public std::unary_function<_FirstArgumentType, _ResultType> { protected: _Operation _M_op; _SecondArgumentType _M_value; public: __binder2nd(const _Operation& __x, const _SecondArgumentType& __y) : _M_op(__x), _M_value(__y) { } _ResultType operator()(const _FirstArgumentType& __x) const { return _M_op(__x, _M_value); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 109. Missing binders for non-const sequence elements _ResultType operator()(_FirstArgumentType& __x) { return _M_op(__x, _M_value); } }; /** @brief Similar to std::equal_to, but allows two different types. */ template struct _EqualTo : std::binary_function<_T1, _T2, bool> { bool operator()(const _T1& __t1, const _T2& __t2) const { return __t1 == __t2; } }; /** @brief Similar to std::less, but allows two different types. */ template struct _Less : std::binary_function<_T1, _T2, bool> { bool operator()(const _T1& __t1, const _T2& __t2) const { return __t1 < __t2; } bool operator()(const _T2& __t2, const _T1& __t1) const { return __t2 < __t1; } }; // Partial specialization for one type. Same as std::less. template struct _Less<_Tp, _Tp> : public std::less<_Tp> { }; /** @brief Similar to std::plus, but allows two different types. */ template(0) + *static_cast<_Tp2*>(0))> struct _Plus : public std::binary_function<_Tp1, _Tp2, _Result> { _Result operator()(const _Tp1& __x, const _Tp2& __y) const { return __x + __y; } }; // Partial specialization for one type. Same as std::plus. template struct _Plus<_Tp, _Tp, _Tp> : public std::plus<_Tp> { }; /** @brief Similar to std::multiplies, but allows two different types. */ template(0) * *static_cast<_Tp2*>(0))> struct _Multiplies : public std::binary_function<_Tp1, _Tp2, _Result> { _Result operator()(const _Tp1& __x, const _Tp2& __y) const { return __x * __y; } }; // Partial specialization for one type. Same as std::multiplies. template struct _Multiplies<_Tp, _Tp, _Tp> : public std::multiplies<_Tp> { }; /** @brief _Iterator associated with __gnu_parallel::_PseudoSequence. * If features the usual random-access iterator functionality. * @param _Tp Sequence _M_value type. * @param _DifferenceTp Sequence difference type. */ template class _PseudoSequenceIterator { public: typedef _DifferenceTp _DifferenceType; _PseudoSequenceIterator(const _Tp& __val, _DifferenceType __pos) : _M_val(__val), _M_pos(__pos) { } // Pre-increment operator. _PseudoSequenceIterator& operator++() { ++_M_pos; return *this; } // Post-increment operator. _PseudoSequenceIterator operator++(int) { return _PseudoSequenceIterator(_M_pos++); } const _Tp& operator*() const { return _M_val; } const _Tp& operator[](_DifferenceType) const { return _M_val; } bool operator==(const _PseudoSequenceIterator& __i2) { return _M_pos == __i2._M_pos; } bool operator!=(const _PseudoSequenceIterator& __i2) { return _M_pos != __i2._M_pos; } _DifferenceType operator-(const _PseudoSequenceIterator& __i2) { return _M_pos - __i2._M_pos; } private: const _Tp& _M_val; _DifferenceType _M_pos; }; /** @brief Sequence that conceptually consists of multiple copies of the same element. * The copies are not stored explicitly, of course. * @param _Tp Sequence _M_value type. * @param _DifferenceTp Sequence difference type. */ template class _PseudoSequence { public: typedef _DifferenceTp _DifferenceType; // Better cast down to uint64_t, than up to _DifferenceTp. typedef _PseudoSequenceIterator<_Tp, uint64_t> iterator; /** @brief Constructor. * @param __val Element of the sequence. * @param __count Number of (virtual) copies. */ _PseudoSequence(const _Tp& __val, _DifferenceType __count) : _M_val(__val), _M_count(__count) { } /** @brief Begin iterator. */ iterator begin() const { return iterator(_M_val, 0); } /** @brief End iterator. */ iterator end() const { return iterator(_M_val, _M_count); } private: const _Tp& _M_val; _DifferenceType _M_count; }; /** @brief Compute the median of three referenced elements, according to @c __comp. * @param __a First iterator. * @param __b Second iterator. * @param __c Third iterator. * @param __comp Comparator. */ template _RAIter __median_of_three_iterators(_RAIter __a, _RAIter __b, _RAIter __c, _Compare __comp) { if (__comp(*__a, *__b)) if (__comp(*__b, *__c)) return __b; else if (__comp(*__a, *__c)) return __c; else return __a; else { // Just swap __a and __b. if (__comp(*__a, *__c)) return __a; else if (__comp(*__b, *__c)) return __c; else return __b; } } #define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert(_Condition) } //namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_BASE_H */ 4.8.2/parallel/settings.h000064400000030252147547540550011044 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/settings.h * @brief Runtime settings and tuning parameters, heuristics to decide * whether to use parallelized algorithms. * This file is a GNU parallel extension to the Standard C++ Library. * * @section parallelization_decision * The decision whether to run an algorithm in parallel. * * There are several ways the user can switch on and __off the parallel * execution of an algorithm, both at compile- and run-time. * * Only sequential execution can be forced at compile-time. This * reduces code size and protects code parts that have * non-thread-safe side effects. * * Ultimately, forcing parallel execution at compile-time makes * sense. Often, the sequential algorithm implementation is used as * a subroutine, so no reduction in code size can be achieved. Also, * the machine the program is run on might have only one processor * core, so to avoid overhead, the algorithm is executed * sequentially. * * To force sequential execution of an algorithm ultimately at * compile-time, the user must add the tag * gnu_parallel::sequential_tag() to the end of the parameter list, * e. g. * * \code * std::sort(__v.begin(), __v.end(), __gnu_parallel::sequential_tag()); * \endcode * * This is compatible with all overloaded algorithm variants. No * additional code will be instantiated, at all. The same holds for * most algorithm calls with iterators not providing random access. * * If the algorithm call is not forced to be executed sequentially * at compile-time, the decision is made at run-time. * The global variable __gnu_parallel::_Settings::algorithm_strategy * is checked. _It is a tristate variable corresponding to: * * a. force_sequential, meaning the sequential algorithm is executed. * b. force_parallel, meaning the parallel algorithm is executed. * c. heuristic * * For heuristic, the parallel algorithm implementation is called * only if the input size is sufficiently large. For most * algorithms, the input size is the (combined) length of the input * sequence(__s). The threshold can be set by the user, individually * for each algorithm. The according variables are called * gnu_parallel::_Settings::[algorithm]_minimal_n . * * For some of the algorithms, there are even more tuning options, * e. g. the ability to choose from multiple algorithm variants. See * below for details. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_SETTINGS_H #define _GLIBCXX_PARALLEL_SETTINGS_H 1 #include /** * @brief Determine at compile(?)-time if the parallel variant of an * algorithm should be called. * @param __c A condition that is convertible to bool that is overruled by * __gnu_parallel::_Settings::algorithm_strategy. Usually a decision * based on the input size. */ #define _GLIBCXX_PARALLEL_CONDITION(__c) \ (__gnu_parallel::_Settings::get().algorithm_strategy \ != __gnu_parallel::force_sequential \ && ((__gnu_parallel::__get_max_threads() > 1 && (__c)) \ || __gnu_parallel::_Settings::get().algorithm_strategy \ == __gnu_parallel::force_parallel)) /* inline bool parallel_condition(bool __c) { bool ret = false; const _Settings& __s = _Settings::get(); if (__s.algorithm_strategy != force_seqential) { if (__s.algorithm_strategy == force_parallel) ret = true; else ret = __get_max_threads() > 1 && __c; } return ret; } */ namespace __gnu_parallel { /// class _Settings /// Run-time settings for the parallel mode including all tunable parameters. struct _Settings { _AlgorithmStrategy algorithm_strategy; _SortAlgorithm sort_algorithm; _PartialSumAlgorithm partial_sum_algorithm; _MultiwayMergeAlgorithm multiway_merge_algorithm; _FindAlgorithm find_algorithm; _SplittingAlgorithm sort_splitting; _SplittingAlgorithm merge_splitting; _SplittingAlgorithm multiway_merge_splitting; // Per-algorithm settings. /// Minimal input size for accumulate. _SequenceIndex accumulate_minimal_n; /// Minimal input size for adjacent_difference. unsigned int adjacent_difference_minimal_n; /// Minimal input size for count and count_if. _SequenceIndex count_minimal_n; /// Minimal input size for fill. _SequenceIndex fill_minimal_n; /// Block size increase factor for find. double find_increasing_factor; /// Initial block size for find. _SequenceIndex find_initial_block_size; /// Maximal block size for find. _SequenceIndex find_maximum_block_size; /// Start with looking for this many elements sequentially, for find. _SequenceIndex find_sequential_search_size; /// Minimal input size for for_each. _SequenceIndex for_each_minimal_n; /// Minimal input size for generate. _SequenceIndex generate_minimal_n; /// Minimal input size for max_element. _SequenceIndex max_element_minimal_n; /// Minimal input size for merge. _SequenceIndex merge_minimal_n; /// Oversampling factor for merge. unsigned int merge_oversampling; /// Minimal input size for min_element. _SequenceIndex min_element_minimal_n; /// Minimal input size for multiway_merge. _SequenceIndex multiway_merge_minimal_n; /// Oversampling factor for multiway_merge. int multiway_merge_minimal_k; /// Oversampling factor for multiway_merge. unsigned int multiway_merge_oversampling; /// Minimal input size for nth_element. _SequenceIndex nth_element_minimal_n; /// Chunk size for partition. _SequenceIndex partition_chunk_size; /// Chunk size for partition, relative to input size. If > 0.0, /// this value overrides partition_chunk_size. double partition_chunk_share; /// Minimal input size for partition. _SequenceIndex partition_minimal_n; /// Minimal input size for partial_sort. _SequenceIndex partial_sort_minimal_n; /// Ratio for partial_sum. Assume "sum and write result" to be /// this factor slower than just "sum". float partial_sum_dilation; /// Minimal input size for partial_sum. unsigned int partial_sum_minimal_n; /// Minimal input size for random_shuffle. unsigned int random_shuffle_minimal_n; /// Minimal input size for replace and replace_if. _SequenceIndex replace_minimal_n; /// Minimal input size for set_difference. _SequenceIndex set_difference_minimal_n; /// Minimal input size for set_intersection. _SequenceIndex set_intersection_minimal_n; /// Minimal input size for set_symmetric_difference. _SequenceIndex set_symmetric_difference_minimal_n; /// Minimal input size for set_union. _SequenceIndex set_union_minimal_n; /// Minimal input size for parallel sorting. _SequenceIndex sort_minimal_n; /// Oversampling factor for parallel std::sort (MWMS). unsigned int sort_mwms_oversampling; /// Such many samples to take to find a good pivot (quicksort). unsigned int sort_qs_num_samples_preset; /// Maximal subsequence __length to switch to unbalanced __base case. /// Applies to std::sort with dynamically load-balanced quicksort. _SequenceIndex sort_qsb_base_case_maximal_n; /// Minimal input size for parallel std::transform. _SequenceIndex transform_minimal_n; /// Minimal input size for unique_copy. _SequenceIndex unique_copy_minimal_n; _SequenceIndex workstealing_chunk_size; // Hardware dependent tuning parameters. /// size of the L1 cache in bytes (underestimation). unsigned long long L1_cache_size; /// size of the L2 cache in bytes (underestimation). unsigned long long L2_cache_size; /// size of the Translation Lookaside Buffer (underestimation). unsigned int TLB_size; /// Overestimation of cache line size. Used to avoid false /// sharing, i.e. elements of different threads are at least this /// amount apart. unsigned int cache_line_size; // Statistics. /// The number of stolen ranges in load-balanced quicksort. _SequenceIndex qsb_steals; /// Minimal input size for search and search_n. _SequenceIndex search_minimal_n; /// Block size scale-down factor with respect to current position. float find_scale_factor; /// Get the global settings. _GLIBCXX_CONST static const _Settings& get() throw(); /// Set the global settings. static void set(_Settings&) throw(); explicit _Settings() : algorithm_strategy(heuristic), sort_algorithm(MWMS), partial_sum_algorithm(LINEAR), multiway_merge_algorithm(LOSER_TREE), find_algorithm(CONSTANT_SIZE_BLOCKS), sort_splitting(EXACT), merge_splitting(EXACT), multiway_merge_splitting(EXACT), accumulate_minimal_n(1000), adjacent_difference_minimal_n(1000), count_minimal_n(1000), fill_minimal_n(1000), find_increasing_factor(2.0), find_initial_block_size(256), find_maximum_block_size(8192), find_sequential_search_size(256), for_each_minimal_n(1000), generate_minimal_n(1000), max_element_minimal_n(1000), merge_minimal_n(1000), merge_oversampling(10), min_element_minimal_n(1000), multiway_merge_minimal_n(1000), multiway_merge_minimal_k(2), multiway_merge_oversampling(10), nth_element_minimal_n(1000), partition_chunk_size(1000), partition_chunk_share(0.0), partition_minimal_n(1000), partial_sort_minimal_n(1000), partial_sum_dilation(1.0f), partial_sum_minimal_n(1000), random_shuffle_minimal_n(1000), replace_minimal_n(1000), set_difference_minimal_n(1000), set_intersection_minimal_n(1000), set_symmetric_difference_minimal_n(1000), set_union_minimal_n(1000), sort_minimal_n(1000), sort_mwms_oversampling(10), sort_qs_num_samples_preset(100), sort_qsb_base_case_maximal_n(100), transform_minimal_n(1000), unique_copy_minimal_n(10000), workstealing_chunk_size(100), L1_cache_size(16 << 10), L2_cache_size(256 << 10), TLB_size(128), cache_line_size(64), qsb_steals(0), search_minimal_n(1000), find_scale_factor(0.01f) { } }; } #endif /* _GLIBCXX_PARALLEL_SETTINGS_H */ 4.8.2/parallel/multiseq_selection.h000064400000053073147547540550013122 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/multiseq_selection.h * @brief Functions to find elements of a certain global __rank in * multiple sorted sequences. Also serves for splitting such * sequence sets. * * The algorithm description can be found in * * P. J. Varman, S. D. Scheufler, B. R. Iyer, and G. R. Ricard. * Merging Multiple Lists on Hierarchical-Memory Multiprocessors. * Journal of Parallel and Distributed Computing, 12(2):171–177, 1991. * * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H #define _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H 1 #include #include #include namespace __gnu_parallel { /** @brief Compare __a pair of types lexicographically, ascending. */ template class _Lexicographic : public std::binary_function, std::pair<_T1, _T2>, bool> { private: _Compare& _M_comp; public: _Lexicographic(_Compare& __comp) : _M_comp(__comp) { } bool operator()(const std::pair<_T1, _T2>& __p1, const std::pair<_T1, _T2>& __p2) const { if (_M_comp(__p1.first, __p2.first)) return true; if (_M_comp(__p2.first, __p1.first)) return false; // Firsts are equal. return __p1.second < __p2.second; } }; /** @brief Compare __a pair of types lexicographically, descending. */ template class _LexicographicReverse : public std::binary_function<_T1, _T2, bool> { private: _Compare& _M_comp; public: _LexicographicReverse(_Compare& __comp) : _M_comp(__comp) { } bool operator()(const std::pair<_T1, _T2>& __p1, const std::pair<_T1, _T2>& __p2) const { if (_M_comp(__p2.first, __p1.first)) return true; if (_M_comp(__p1.first, __p2.first)) return false; // Firsts are equal. return __p2.second < __p1.second; } }; /** * @brief Splits several sorted sequences at a certain global __rank, * resulting in a splitting point for each sequence. * The sequences are passed via a sequence of random-access * iterator pairs, none of the sequences may be empty. If there * are several equal elements across the split, the ones on the * __left side will be chosen from sequences with smaller number. * @param __begin_seqs Begin of the sequence of iterator pairs. * @param __end_seqs End of the sequence of iterator pairs. * @param __rank The global rank to partition at. * @param __begin_offsets A random-access __sequence __begin where the * __result will be stored in. Each element of the sequence is an * iterator that points to the first element on the greater part of * the respective __sequence. * @param __comp The ordering functor, defaults to std::less<_Tp>. */ template void multiseq_partition(_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankIterator __begin_offsets, _Compare __comp = std::less< typename std::iterator_traits::value_type:: first_type>::value_type>()) // std::less<_Tp> { _GLIBCXX_CALL(__end_seqs - __begin_seqs) typedef typename std::iterator_traits<_RanSeqs>::value_type::first_type _It; typedef typename std::iterator_traits<_RanSeqs>::difference_type _SeqNumber; typedef typename std::iterator_traits<_It>::difference_type _DifferenceType; typedef typename std::iterator_traits<_It>::value_type _ValueType; _Lexicographic<_ValueType, _SeqNumber, _Compare> __lcomp(__comp); _LexicographicReverse<_ValueType, _SeqNumber, _Compare> __lrcomp(__comp); // Number of sequences, number of elements in total (possibly // including padding). _DifferenceType __m = std::distance(__begin_seqs, __end_seqs), __nn = 0, __nmax, __n, __r; for (_SeqNumber __i = 0; __i < __m; __i++) { __nn += std::distance(__begin_seqs[__i].first, __begin_seqs[__i].second); _GLIBCXX_PARALLEL_ASSERT( std::distance(__begin_seqs[__i].first, __begin_seqs[__i].second) > 0); } if (__rank == __nn) { for (_SeqNumber __i = 0; __i < __m; __i++) __begin_offsets[__i] = __begin_seqs[__i].second; // Very end. // Return __m - 1; return; } _GLIBCXX_PARALLEL_ASSERT(__m != 0); _GLIBCXX_PARALLEL_ASSERT(__nn != 0); _GLIBCXX_PARALLEL_ASSERT(__rank >= 0); _GLIBCXX_PARALLEL_ASSERT(__rank < __nn); _DifferenceType* __ns = new _DifferenceType[__m]; _DifferenceType* __a = new _DifferenceType[__m]; _DifferenceType* __b = new _DifferenceType[__m]; _DifferenceType __l; __ns[0] = std::distance(__begin_seqs[0].first, __begin_seqs[0].second); __nmax = __ns[0]; for (_SeqNumber __i = 0; __i < __m; __i++) { __ns[__i] = std::distance(__begin_seqs[__i].first, __begin_seqs[__i].second); __nmax = std::max(__nmax, __ns[__i]); } __r = __rd_log2(__nmax) + 1; // Pad all lists to this length, at least as long as any ns[__i], // equality iff __nmax = 2^__k - 1. __l = (1ULL << __r) - 1; for (_SeqNumber __i = 0; __i < __m; __i++) { __a[__i] = 0; __b[__i] = __l; } __n = __l / 2; // Invariants: // 0 <= __a[__i] <= __ns[__i], 0 <= __b[__i] <= __l #define __S(__i) (__begin_seqs[__i].first) // Initial partition. std::vector > __sample; for (_SeqNumber __i = 0; __i < __m; __i++) if (__n < __ns[__i]) //__sequence long enough __sample.push_back(std::make_pair(__S(__i)[__n], __i)); __gnu_sequential::sort(__sample.begin(), __sample.end(), __lcomp); for (_SeqNumber __i = 0; __i < __m; __i++) //conceptual infinity if (__n >= __ns[__i]) //__sequence too short, conceptual infinity __sample.push_back( std::make_pair(__S(__i)[0] /*__dummy element*/, __i)); _DifferenceType __localrank = __rank / __l; _SeqNumber __j; for (__j = 0; __j < __localrank && ((__n + 1) <= __ns[__sample[__j].second]); ++__j) __a[__sample[__j].second] += __n + 1; for (; __j < __m; __j++) __b[__sample[__j].second] -= __n + 1; // Further refinement. while (__n > 0) { __n /= 2; _SeqNumber __lmax_seq = -1; // to avoid warning const _ValueType* __lmax = 0; // impossible to avoid the warning? for (_SeqNumber __i = 0; __i < __m; __i++) { if (__a[__i] > 0) { if (!__lmax) { __lmax = &(__S(__i)[__a[__i] - 1]); __lmax_seq = __i; } else { // Max, favor rear sequences. if (!__comp(__S(__i)[__a[__i] - 1], *__lmax)) { __lmax = &(__S(__i)[__a[__i] - 1]); __lmax_seq = __i; } } } } _SeqNumber __i; for (__i = 0; __i < __m; __i++) { _DifferenceType __middle = (__b[__i] + __a[__i]) / 2; if (__lmax && __middle < __ns[__i] && __lcomp(std::make_pair(__S(__i)[__middle], __i), std::make_pair(*__lmax, __lmax_seq))) __a[__i] = std::min(__a[__i] + __n + 1, __ns[__i]); else __b[__i] -= __n + 1; } _DifferenceType __leftsize = 0; for (_SeqNumber __i = 0; __i < __m; __i++) __leftsize += __a[__i] / (__n + 1); _DifferenceType __skew = __rank / (__n + 1) - __leftsize; if (__skew > 0) { // Move to the left, find smallest. std::priority_queue, std::vector >, _LexicographicReverse<_ValueType, _SeqNumber, _Compare> > __pq(__lrcomp); for (_SeqNumber __i = 0; __i < __m; __i++) if (__b[__i] < __ns[__i]) __pq.push(std::make_pair(__S(__i)[__b[__i]], __i)); for (; __skew != 0 && !__pq.empty(); --__skew) { _SeqNumber __source = __pq.top().second; __pq.pop(); __a[__source] = std::min(__a[__source] + __n + 1, __ns[__source]); __b[__source] += __n + 1; if (__b[__source] < __ns[__source]) __pq.push( std::make_pair(__S(__source)[__b[__source]], __source)); } } else if (__skew < 0) { // Move to the right, find greatest. std::priority_queue, std::vector >, _Lexicographic<_ValueType, _SeqNumber, _Compare> > __pq(__lcomp); for (_SeqNumber __i = 0; __i < __m; __i++) if (__a[__i] > 0) __pq.push(std::make_pair(__S(__i)[__a[__i] - 1], __i)); for (; __skew != 0; ++__skew) { _SeqNumber __source = __pq.top().second; __pq.pop(); __a[__source] -= __n + 1; __b[__source] -= __n + 1; if (__a[__source] > 0) __pq.push(std::make_pair( __S(__source)[__a[__source] - 1], __source)); } } } // Postconditions: // __a[__i] == __b[__i] in most cases, except when __a[__i] has been // clamped because of having reached the boundary // Now return the result, calculate the offset. // Compare the keys on both edges of the border. // Maximum of left edge, minimum of right edge. _ValueType* __maxleft = 0; _ValueType* __minright = 0; for (_SeqNumber __i = 0; __i < __m; __i++) { if (__a[__i] > 0) { if (!__maxleft) __maxleft = &(__S(__i)[__a[__i] - 1]); else { // Max, favor rear sequences. if (!__comp(__S(__i)[__a[__i] - 1], *__maxleft)) __maxleft = &(__S(__i)[__a[__i] - 1]); } } if (__b[__i] < __ns[__i]) { if (!__minright) __minright = &(__S(__i)[__b[__i]]); else { // Min, favor fore sequences. if (__comp(__S(__i)[__b[__i]], *__minright)) __minright = &(__S(__i)[__b[__i]]); } } } _SeqNumber __seq = 0; for (_SeqNumber __i = 0; __i < __m; __i++) __begin_offsets[__i] = __S(__i) + __a[__i]; delete[] __ns; delete[] __a; delete[] __b; } /** * @brief Selects the element at a certain global __rank from several * sorted sequences. * * The sequences are passed via a sequence of random-access * iterator pairs, none of the sequences may be empty. * @param __begin_seqs Begin of the sequence of iterator pairs. * @param __end_seqs End of the sequence of iterator pairs. * @param __rank The global rank to partition at. * @param __offset The rank of the selected element in the global * subsequence of elements equal to the selected element. If the * selected element is unique, this number is 0. * @param __comp The ordering functor, defaults to std::less. */ template _Tp multiseq_selection(_RanSeqs __begin_seqs, _RanSeqs __end_seqs, _RankType __rank, _RankType& __offset, _Compare __comp = std::less<_Tp>()) { _GLIBCXX_CALL(__end_seqs - __begin_seqs) typedef typename std::iterator_traits<_RanSeqs>::value_type::first_type _It; typedef typename std::iterator_traits<_RanSeqs>::difference_type _SeqNumber; typedef typename std::iterator_traits<_It>::difference_type _DifferenceType; _Lexicographic<_Tp, _SeqNumber, _Compare> __lcomp(__comp); _LexicographicReverse<_Tp, _SeqNumber, _Compare> __lrcomp(__comp); // Number of sequences, number of elements in total (possibly // including padding). _DifferenceType __m = std::distance(__begin_seqs, __end_seqs); _DifferenceType __nn = 0; _DifferenceType __nmax, __n, __r; for (_SeqNumber __i = 0; __i < __m; __i++) __nn += std::distance(__begin_seqs[__i].first, __begin_seqs[__i].second); if (__m == 0 || __nn == 0 || __rank < 0 || __rank >= __nn) { // result undefined if there is no data or __rank is outside bounds throw std::exception(); } _DifferenceType* __ns = new _DifferenceType[__m]; _DifferenceType* __a = new _DifferenceType[__m]; _DifferenceType* __b = new _DifferenceType[__m]; _DifferenceType __l; __ns[0] = std::distance(__begin_seqs[0].first, __begin_seqs[0].second); __nmax = __ns[0]; for (_SeqNumber __i = 0; __i < __m; ++__i) { __ns[__i] = std::distance(__begin_seqs[__i].first, __begin_seqs[__i].second); __nmax = std::max(__nmax, __ns[__i]); } __r = __rd_log2(__nmax) + 1; // Pad all lists to this length, at least as long as any ns[__i], // equality iff __nmax = 2^__k - 1 __l = __round_up_to_pow2(__r) - 1; for (_SeqNumber __i = 0; __i < __m; ++__i) { __a[__i] = 0; __b[__i] = __l; } __n = __l / 2; // Invariants: // 0 <= __a[__i] <= __ns[__i], 0 <= __b[__i] <= __l #define __S(__i) (__begin_seqs[__i].first) // Initial partition. std::vector > __sample; for (_SeqNumber __i = 0; __i < __m; __i++) if (__n < __ns[__i]) __sample.push_back(std::make_pair(__S(__i)[__n], __i)); __gnu_sequential::sort(__sample.begin(), __sample.end(), __lcomp, sequential_tag()); // Conceptual infinity. for (_SeqNumber __i = 0; __i < __m; __i++) if (__n >= __ns[__i]) __sample.push_back( std::make_pair(__S(__i)[0] /*__dummy element*/, __i)); _DifferenceType __localrank = __rank / __l; _SeqNumber __j; for (__j = 0; __j < __localrank && ((__n + 1) <= __ns[__sample[__j].second]); ++__j) __a[__sample[__j].second] += __n + 1; for (; __j < __m; ++__j) __b[__sample[__j].second] -= __n + 1; // Further refinement. while (__n > 0) { __n /= 2; const _Tp* __lmax = 0; for (_SeqNumber __i = 0; __i < __m; ++__i) { if (__a[__i] > 0) { if (!__lmax) __lmax = &(__S(__i)[__a[__i] - 1]); else { if (__comp(*__lmax, __S(__i)[__a[__i] - 1])) //max __lmax = &(__S(__i)[__a[__i] - 1]); } } } _SeqNumber __i; for (__i = 0; __i < __m; __i++) { _DifferenceType __middle = (__b[__i] + __a[__i]) / 2; if (__lmax && __middle < __ns[__i] && __comp(__S(__i)[__middle], *__lmax)) __a[__i] = std::min(__a[__i] + __n + 1, __ns[__i]); else __b[__i] -= __n + 1; } _DifferenceType __leftsize = 0; for (_SeqNumber __i = 0; __i < __m; ++__i) __leftsize += __a[__i] / (__n + 1); _DifferenceType __skew = __rank / (__n + 1) - __leftsize; if (__skew > 0) { // Move to the left, find smallest. std::priority_queue, std::vector >, _LexicographicReverse<_Tp, _SeqNumber, _Compare> > __pq(__lrcomp); for (_SeqNumber __i = 0; __i < __m; ++__i) if (__b[__i] < __ns[__i]) __pq.push(std::make_pair(__S(__i)[__b[__i]], __i)); for (; __skew != 0 && !__pq.empty(); --__skew) { _SeqNumber __source = __pq.top().second; __pq.pop(); __a[__source] = std::min(__a[__source] + __n + 1, __ns[__source]); __b[__source] += __n + 1; if (__b[__source] < __ns[__source]) __pq.push( std::make_pair(__S(__source)[__b[__source]], __source)); } } else if (__skew < 0) { // Move to the right, find greatest. std::priority_queue, std::vector >, _Lexicographic<_Tp, _SeqNumber, _Compare> > __pq(__lcomp); for (_SeqNumber __i = 0; __i < __m; ++__i) if (__a[__i] > 0) __pq.push(std::make_pair(__S(__i)[__a[__i] - 1], __i)); for (; __skew != 0; ++__skew) { _SeqNumber __source = __pq.top().second; __pq.pop(); __a[__source] -= __n + 1; __b[__source] -= __n + 1; if (__a[__source] > 0) __pq.push(std::make_pair( __S(__source)[__a[__source] - 1], __source)); } } } // Postconditions: // __a[__i] == __b[__i] in most cases, except when __a[__i] has been // clamped because of having reached the boundary // Now return the result, calculate the offset. // Compare the keys on both edges of the border. // Maximum of left edge, minimum of right edge. bool __maxleftset = false, __minrightset = false; // Impossible to avoid the warning? _Tp __maxleft, __minright; for (_SeqNumber __i = 0; __i < __m; ++__i) { if (__a[__i] > 0) { if (!__maxleftset) { __maxleft = __S(__i)[__a[__i] - 1]; __maxleftset = true; } else { // Max. if (__comp(__maxleft, __S(__i)[__a[__i] - 1])) __maxleft = __S(__i)[__a[__i] - 1]; } } if (__b[__i] < __ns[__i]) { if (!__minrightset) { __minright = __S(__i)[__b[__i]]; __minrightset = true; } else { // Min. if (__comp(__S(__i)[__b[__i]], __minright)) __minright = __S(__i)[__b[__i]]; } } } // Minright is the __splitter, in any case. if (!__maxleftset || __comp(__minright, __maxleft)) { // Good luck, everything is split unambiguously. __offset = 0; } else { // We have to calculate an offset. __offset = 0; for (_SeqNumber __i = 0; __i < __m; ++__i) { _DifferenceType lb = std::lower_bound(__S(__i), __S(__i) + __ns[__i], __minright, __comp) - __S(__i); __offset += __a[__i] - lb; } } delete[] __ns; delete[] __a; delete[] __b; return __minright; } } #undef __S #endif /* _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H */ 4.8.2/parallel/partition.h000064400000035126147547540550011222 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/partition.h * @brief Parallel implementation of std::partition(), * std::nth_element(), and std::partial_sort(). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler and Felix Putze. #ifndef _GLIBCXX_PARALLEL_PARTITION_H #define _GLIBCXX_PARALLEL_PARTITION_H 1 #include #include #include #include #include /** @brief Decide whether to declare certain variables volatile. */ #define _GLIBCXX_VOLATILE volatile namespace __gnu_parallel { /** @brief Parallel implementation of std::partition. * @param __begin Begin iterator of input sequence to split. * @param __end End iterator of input sequence to split. * @param __pred Partition predicate, possibly including some kind * of pivot. * @param __num_threads Maximum number of threads to use for this task. * @return Number of elements not fulfilling the predicate. */ template typename std::iterator_traits<_RAIter>::difference_type __parallel_partition(_RAIter __begin, _RAIter __end, _Predicate __pred, _ThreadIndex __num_threads) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; _GLIBCXX_CALL(__n) const _Settings& __s = _Settings::get(); // shared _GLIBCXX_VOLATILE _DifferenceType __left = 0, __right = __n - 1, __dist = __n, __leftover_left, __leftover_right, __leftnew, __rightnew; // just 0 or 1, but int to allow atomic operations int* __reserved_left = 0, * __reserved_right = 0; _DifferenceType __chunk_size = __s.partition_chunk_size; //at least two chunks per thread if (__dist >= 2 * __num_threads * __chunk_size) # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __reserved_left = new int[__num_threads]; __reserved_right = new int[__num_threads]; if (__s.partition_chunk_share > 0.0) __chunk_size = std::max<_DifferenceType> (__s.partition_chunk_size, (double)__n * __s.partition_chunk_share / (double)__num_threads); else __chunk_size = __s.partition_chunk_size; } while (__dist >= 2 * __num_threads * __chunk_size) { # pragma omp single { _DifferenceType __num_chunks = __dist / __chunk_size; for (_ThreadIndex __r = 0; __r < __num_threads; ++__r) { __reserved_left [__r] = 0; // false __reserved_right[__r] = 0; // false } __leftover_left = 0; __leftover_right = 0; } //implicit barrier // Private. _DifferenceType __thread_left, __thread_left_border, __thread_right, __thread_right_border; __thread_left = __left + 1; // Just to satisfy the condition below. __thread_left_border = __thread_left - 1; __thread_right = __n - 1; // Just to satisfy the condition below. __thread_right_border = __thread_right + 1; bool __iam_finished = false; while (!__iam_finished) { if (__thread_left > __thread_left_border) { _DifferenceType __former_dist = __fetch_and_add(&__dist, -__chunk_size); if (__former_dist < __chunk_size) { __fetch_and_add(&__dist, __chunk_size); __iam_finished = true; break; } else { __thread_left = __fetch_and_add(&__left, __chunk_size); __thread_left_border = __thread_left + (__chunk_size - 1); } } if (__thread_right < __thread_right_border) { _DifferenceType __former_dist = __fetch_and_add(&__dist, -__chunk_size); if (__former_dist < __chunk_size) { __fetch_and_add(&__dist, __chunk_size); __iam_finished = true; break; } else { __thread_right = __fetch_and_add(&__right, -__chunk_size); __thread_right_border = __thread_right - (__chunk_size - 1); } } // Swap as usual. while (__thread_left < __thread_right) { while (__pred(__begin[__thread_left]) && __thread_left <= __thread_left_border) ++__thread_left; while (!__pred(__begin[__thread_right]) && __thread_right >= __thread_right_border) --__thread_right; if (__thread_left > __thread_left_border || __thread_right < __thread_right_border) // Fetch new chunk(__s). break; std::iter_swap(__begin + __thread_left, __begin + __thread_right); ++__thread_left; --__thread_right; } } // Now swap the leftover chunks to the right places. if (__thread_left <= __thread_left_border) # pragma omp atomic ++__leftover_left; if (__thread_right >= __thread_right_border) # pragma omp atomic ++__leftover_right; # pragma omp barrier _DifferenceType __leftold = __left, __leftnew = __left - __leftover_left * __chunk_size, __rightold = __right, __rightnew = __right + __leftover_right * __chunk_size; // <=> __thread_left_border + (__chunk_size - 1) >= __leftnew if (__thread_left <= __thread_left_border && __thread_left_border >= __leftnew) { // Chunk already in place, reserve spot. __reserved_left[(__left - (__thread_left_border + 1)) / __chunk_size] = 1; } // <=> __thread_right_border - (__chunk_size - 1) <= __rightnew if (__thread_right >= __thread_right_border && __thread_right_border <= __rightnew) { // Chunk already in place, reserve spot. __reserved_right[((__thread_right_border - 1) - __right) / __chunk_size] = 1; } # pragma omp barrier if (__thread_left <= __thread_left_border && __thread_left_border < __leftnew) { // Find spot and swap. _DifferenceType __swapstart = -1; for (int __r = 0; __r < __leftover_left; ++__r) if (__reserved_left[__r] == 0 && __compare_and_swap(&(__reserved_left[__r]), 0, 1)) { __swapstart = __leftold - (__r + 1) * __chunk_size; break; } #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__swapstart != -1); #endif std::swap_ranges(__begin + __thread_left_border - (__chunk_size - 1), __begin + __thread_left_border + 1, __begin + __swapstart); } if (__thread_right >= __thread_right_border && __thread_right_border > __rightnew) { // Find spot and swap _DifferenceType __swapstart = -1; for (int __r = 0; __r < __leftover_right; ++__r) if (__reserved_right[__r] == 0 && __compare_and_swap(&(__reserved_right[__r]), 0, 1)) { __swapstart = __rightold + __r * __chunk_size + 1; break; } #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__swapstart != -1); #endif std::swap_ranges(__begin + __thread_right_border, __begin + __thread_right_border + __chunk_size, __begin + __swapstart); } #if _GLIBCXX_ASSERTIONS # pragma omp barrier # pragma omp single { for (_DifferenceType __r = 0; __r < __leftover_left; ++__r) _GLIBCXX_PARALLEL_ASSERT(__reserved_left[__r] == 1); for (_DifferenceType __r = 0; __r < __leftover_right; ++__r) _GLIBCXX_PARALLEL_ASSERT(__reserved_right[__r] == 1); } #endif __left = __leftnew; __right = __rightnew; __dist = __right - __left + 1; } # pragma omp flush(__left, __right) } // end "recursion" //parallel _DifferenceType __final_left = __left, __final_right = __right; while (__final_left < __final_right) { // Go right until key is geq than pivot. while (__pred(__begin[__final_left]) && __final_left < __final_right) ++__final_left; // Go left until key is less than pivot. while (!__pred(__begin[__final_right]) && __final_left < __final_right) --__final_right; if (__final_left == __final_right) break; std::iter_swap(__begin + __final_left, __begin + __final_right); ++__final_left; --__final_right; } // All elements on the left side are < piv, all elements on the // right are >= piv delete[] __reserved_left; delete[] __reserved_right; // Element "between" __final_left and __final_right might not have // been regarded yet if (__final_left < __n && !__pred(__begin[__final_left])) // Really swapped. return __final_left; else return __final_left + 1; } /** * @brief Parallel implementation of std::nth_element(). * @param __begin Begin iterator of input sequence. * @param __nth _Iterator of element that must be in position afterwards. * @param __end End iterator of input sequence. * @param __comp Comparator. */ template void __parallel_nth_element(_RAIter __begin, _RAIter __nth, _RAIter __end, _Compare __comp) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _GLIBCXX_CALL(__end - __begin) _RAIter __split; _RandomNumber __rng; const _Settings& __s = _Settings::get(); _DifferenceType __minimum_length = std::max<_DifferenceType>(2, std::max(__s.nth_element_minimal_n, __s.partition_minimal_n)); // Break if input range to small. while (static_cast<_SequenceIndex>(__end - __begin) >= __minimum_length) { _DifferenceType __n = __end - __begin; _RAIter __pivot_pos = __begin + __rng(__n); // Swap __pivot_pos value to end. if (__pivot_pos != (__end - 1)) std::iter_swap(__pivot_pos, __end - 1); __pivot_pos = __end - 1; // _Compare must have first_value_type, second_value_type, // result_type // _Compare == // __gnu_parallel::_Lexicographic > // __pivot_pos == std::pair* __gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool> __pred(__comp, *__pivot_pos); // Divide, leave pivot unchanged in last place. _RAIter __split_pos1, __split_pos2; __split_pos1 = __begin + __parallel_partition(__begin, __end - 1, __pred, __get_max_threads()); // Left side: < __pivot_pos; __right side: >= __pivot_pos // Swap pivot back to middle. if (__split_pos1 != __pivot_pos) std::iter_swap(__split_pos1, __pivot_pos); __pivot_pos = __split_pos1; // In case all elements are equal, __split_pos1 == 0 if ((__split_pos1 + 1 - __begin) < (__n >> 7) || (__end - __split_pos1) < (__n >> 7)) { // Very unequal split, one part smaller than one 128th // elements not strictly larger than the pivot. __gnu_parallel::__unary_negate<__gnu_parallel:: __binder1st<_Compare, _ValueType, _ValueType, bool>, _ValueType> __pred(__gnu_parallel::__binder1st<_Compare, _ValueType, _ValueType, bool>(__comp, *__pivot_pos)); // Find other end of pivot-equal range. __split_pos2 = __gnu_sequential::partition(__split_pos1 + 1, __end, __pred); } else // Only skip the pivot. __split_pos2 = __split_pos1 + 1; // Compare iterators. if (__split_pos2 <= __nth) __begin = __split_pos2; else if (__nth < __split_pos1) __end = __split_pos1; else break; } // Only at most _Settings::partition_minimal_n __elements __left. __gnu_sequential::nth_element(__begin, __nth, __end, __comp); } /** @brief Parallel implementation of std::partial_sort(). * @param __begin Begin iterator of input sequence. * @param __middle Sort until this position. * @param __end End iterator of input sequence. * @param __comp Comparator. */ template void __parallel_partial_sort(_RAIter __begin, _RAIter __middle, _RAIter __end, _Compare __comp) { __parallel_nth_element(__begin, __middle, __end, __comp); std::sort(__begin, __middle, __comp); } } //namespace __gnu_parallel #undef _GLIBCXX_VOLATILE #endif /* _GLIBCXX_PARALLEL_PARTITION_H */ 4.8.2/parallel/partial_sum.h000064400000016462147547540550011533 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/partial_sum.h * @brief Parallel implementation of std::partial_sum(), i.e. prefix * sums. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_PARTIAL_SUM_H #define _GLIBCXX_PARALLEL_PARTIAL_SUM_H 1 #include #include #include #include #include namespace __gnu_parallel { // Problem: there is no 0-element given. /** @brief Base case prefix sum routine. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __result Begin iterator of output sequence. * @param __bin_op Associative binary function. * @param __value Start value. Must be passed since the neutral * element is unknown in general. * @return End iterator of output sequence. */ template _OutputIterator __parallel_partial_sum_basecase(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, typename std::iterator_traits <_IIter>::value_type __value) { if (__begin == __end) return __result; while (__begin != __end) { __value = __bin_op(__value, *__begin); *__result = __value; ++__result; ++__begin; } return __result; } /** @brief Parallel partial sum implementation, two-phase approach, no recursion. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __result Begin iterator of output sequence. * @param __bin_op Associative binary function. * @param __n Length of sequence. * @return End iterator of output sequence. */ template _OutputIterator __parallel_partial_sum_linear(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op, typename std::iterator_traits<_IIter>::difference_type __n) { typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; if (__begin == __end) return __result; _ThreadIndex __num_threads = std::min<_DifferenceType>(__get_max_threads(), __n - 1); if (__num_threads < 2) { *__result = *__begin; return __parallel_partial_sum_basecase(__begin + 1, __end, __result + 1, __bin_op, *__begin); } _DifferenceType* __borders; _ValueType* __sums; const _Settings& __s = _Settings::get(); # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __borders = new _DifferenceType[__num_threads + 2]; if (__s.partial_sum_dilation == 1.0f) __equally_split(__n, __num_threads + 1, __borders); else { _DifferenceType __first_part_length = std::max<_DifferenceType>(1, __n / (1.0f + __s.partial_sum_dilation * __num_threads)); _DifferenceType __chunk_length = (__n - __first_part_length) / __num_threads; _DifferenceType __borderstart = __n - __num_threads * __chunk_length; __borders[0] = 0; for (_ThreadIndex __i = 1; __i < (__num_threads + 1); ++__i) { __borders[__i] = __borderstart; __borderstart += __chunk_length; } __borders[__num_threads + 1] = __n; } __sums = static_cast<_ValueType*>(::operator new(sizeof(_ValueType) * __num_threads)); _OutputIterator __target_end; } //single _ThreadIndex __iam = omp_get_thread_num(); if (__iam == 0) { *__result = *__begin; __parallel_partial_sum_basecase(__begin + 1, __begin + __borders[1], __result + 1, __bin_op, *__begin); ::new(&(__sums[__iam])) _ValueType(*(__result + __borders[1] - 1)); } else { ::new(&(__sums[__iam])) _ValueType(__gnu_parallel::accumulate( __begin + __borders[__iam] + 1, __begin + __borders[__iam + 1], *(__begin + __borders[__iam]), __bin_op, __gnu_parallel::sequential_tag())); } # pragma omp barrier # pragma omp single __parallel_partial_sum_basecase(__sums + 1, __sums + __num_threads, __sums + 1, __bin_op, __sums[0]); # pragma omp barrier // Still same team. __parallel_partial_sum_basecase(__begin + __borders[__iam + 1], __begin + __borders[__iam + 2], __result + __borders[__iam + 1], __bin_op, __sums[__iam]); } //parallel for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __sums[__i].~_ValueType(); ::operator delete(__sums); delete[] __borders; return __result + __n; } /** @brief Parallel partial sum front-__end. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __result Begin iterator of output sequence. * @param __bin_op Associative binary function. * @return End iterator of output sequence. */ template _OutputIterator __parallel_partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result, _BinaryOperation __bin_op) { _GLIBCXX_CALL(__begin - __end) typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; switch (_Settings::get().partial_sum_algorithm) { case LINEAR: // Need an initial offset. return __parallel_partial_sum_linear(__begin, __end, __result, __bin_op, __n); default: // Partial_sum algorithm not implemented. _GLIBCXX_PARALLEL_ASSERT(0); return __result + __n; } } } #endif /* _GLIBCXX_PARALLEL_PARTIAL_SUM_H */ 4.8.2/parallel/for_each.h000064400000007553147547540550010762 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/for_each.h * @brief Main interface for embarrassingly parallel functions. * * The explicit implementation are in other header files, like * workstealing.h, par_loop.h, omp_loop.h, and omp_loop_static.h. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_FOR_EACH_H #define _GLIBCXX_PARALLEL_FOR_EACH_H 1 #include #include #include #include namespace __gnu_parallel { /** @brief Chose the desired algorithm by evaluating @c __parallelism_tag. * @param __begin Begin iterator of input sequence. * @param __end End iterator of input sequence. * @param __user_op A user-specified functor (comparator, predicate, * associative operator,...) * @param __functionality functor to @a process an element with * __user_op (depends on desired functionality, e. g. accumulate, * for_each,... * @param __reduction Reduction functor. * @param __reduction_start Initial value for reduction. * @param __output Output iterator. * @param __bound Maximum number of elements processed. * @param __parallelism_tag Parallelization method */ template _UserOp __for_each_template_random_access(_IIter __begin, _IIter __end, _UserOp __user_op, _Functionality& __functionality, _Red __reduction, _Result __reduction_start, _Result& __output, typename std::iterator_traits<_IIter>:: difference_type __bound, _Parallelism __parallelism_tag) { if (__parallelism_tag == parallel_unbalanced) return __for_each_template_random_access_ed (__begin, __end, __user_op, __functionality, __reduction, __reduction_start, __output, __bound); else if (__parallelism_tag == parallel_omp_loop) return __for_each_template_random_access_omp_loop (__begin, __end, __user_op, __functionality, __reduction, __reduction_start, __output, __bound); else if (__parallelism_tag == parallel_omp_loop_static) return __for_each_template_random_access_omp_loop (__begin, __end, __user_op, __functionality, __reduction, __reduction_start, __output, __bound); else //e. g. parallel_balanced return __for_each_template_random_access_workstealing (__begin, __end, __user_op, __functionality, __reduction, __reduction_start, __output, __bound); } } #endif /* _GLIBCXX_PARALLEL_FOR_EACH_H */ 4.8.2/parallel/set_operations.h000064400000034376147547540550012255 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** * @file parallel/set_operations.h * @brief Parallel implementations of set operations for random-access * iterators. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Marius Elvert and Felix Bondarenko. #ifndef _GLIBCXX_PARALLEL_SET_OPERATIONS_H #define _GLIBCXX_PARALLEL_SET_OPERATIONS_H 1 #include #include #include namespace __gnu_parallel { template _OutputIterator __copy_tail(std::pair<_IIter, _IIter> __b, std::pair<_IIter, _IIter> __e, _OutputIterator __r) { if (__b.first != __e.first) { do { *__r++ = *__b.first++; } while (__b.first != __e.first); } else { while (__b.second != __e.second) *__r++ = *__b.second++; } return __r; } template struct __symmetric_difference_func { typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename std::pair<_IIter, _IIter> _IteratorPair; __symmetric_difference_func(_Compare __comp) : _M_comp(__comp) {} _Compare _M_comp; _OutputIterator _M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d, _OutputIterator __r) const { while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { *__r = *__a; ++__a; ++__r; } else if (_M_comp(*__c, *__a)) { *__r = *__c; ++__c; ++__r; } else { ++__a; ++__c; } } return std::copy(__c, __d, std::copy(__a, __b, __r)); } _DifferenceType __count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const { _DifferenceType __counter = 0; while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { ++__a; ++__counter; } else if (_M_comp(*__c, *__a)) { ++__c; ++__counter; } else { ++__a; ++__c; } } return __counter + (__b - __a) + (__d - __c); } _OutputIterator __first_empty(_IIter __c, _IIter __d, _OutputIterator __out) const { return std::copy(__c, __d, __out); } _OutputIterator __second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const { return std::copy(__a, __b, __out); } }; template struct __difference_func { typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename std::pair<_IIter, _IIter> _IteratorPair; __difference_func(_Compare __comp) : _M_comp(__comp) {} _Compare _M_comp; _OutputIterator _M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d, _OutputIterator __r) const { while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { *__r = *__a; ++__a; ++__r; } else if (_M_comp(*__c, *__a)) { ++__c; } else { ++__a; ++__c; } } return std::copy(__a, __b, __r); } _DifferenceType __count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const { _DifferenceType __counter = 0; while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { ++__a; ++__counter; } else if (_M_comp(*__c, *__a)) { ++__c; } else { ++__a; ++__c; } } return __counter + (__b - __a); } _OutputIterator __first_empty(_IIter, _IIter, _OutputIterator __out) const { return __out; } _OutputIterator __second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const { return std::copy(__a, __b, __out); } }; template struct __intersection_func { typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename std::pair<_IIter, _IIter> _IteratorPair; __intersection_func(_Compare __comp) : _M_comp(__comp) {} _Compare _M_comp; _OutputIterator _M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d, _OutputIterator __r) const { while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { ++__a; } else if (_M_comp(*__c, *__a)) { ++__c; } else { *__r = *__a; ++__a; ++__c; ++__r; } } return __r; } _DifferenceType __count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const { _DifferenceType __counter = 0; while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { ++__a; } else if (_M_comp(*__c, *__a)) { ++__c; } else { ++__a; ++__c; ++__counter; } } return __counter; } _OutputIterator __first_empty(_IIter, _IIter, _OutputIterator __out) const { return __out; } _OutputIterator __second_empty(_IIter, _IIter, _OutputIterator __out) const { return __out; } }; template struct __union_func { typedef typename std::iterator_traits<_IIter>::difference_type _DifferenceType; __union_func(_Compare __comp) : _M_comp(__comp) {} _Compare _M_comp; _OutputIterator _M_invoke(_IIter __a, const _IIter __b, _IIter __c, const _IIter __d, _OutputIterator __r) const { while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { *__r = *__a; ++__a; } else if (_M_comp(*__c, *__a)) { *__r = *__c; ++__c; } else { *__r = *__a; ++__a; ++__c; } ++__r; } return std::copy(__c, __d, std::copy(__a, __b, __r)); } _DifferenceType __count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const { _DifferenceType __counter = 0; while (__a != __b && __c != __d) { if (_M_comp(*__a, *__c)) { ++__a; } else if (_M_comp(*__c, *__a)) { ++__c; } else { ++__a; ++__c; } ++__counter; } __counter += (__b - __a); __counter += (__d - __c); return __counter; } _OutputIterator __first_empty(_IIter __c, _IIter __d, _OutputIterator __out) const { return std::copy(__c, __d, __out); } _OutputIterator __second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const { return std::copy(__a, __b, __out); } }; template _OutputIterator __parallel_set_operation(_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Operation __op) { _GLIBCXX_CALL((__end1 - __begin1) + (__end2 - __begin2)) typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; typedef typename std::pair<_IIter, _IIter> _IteratorPair; if (__begin1 == __end1) return __op.__first_empty(__begin2, __end2, __result); if (__begin2 == __end2) return __op.__second_empty(__begin1, __end1, __result); const _DifferenceType __size = (__end1 - __begin1) + (__end2 - __begin2); const _IteratorPair __sequence[2] = { std::make_pair(__begin1, __end1), std::make_pair(__begin2, __end2) }; _OutputIterator __return_value = __result; _DifferenceType *__borders; _IteratorPair *__block_begins; _DifferenceType* __lengths; _ThreadIndex __num_threads = std::min<_DifferenceType>(__get_max_threads(), std::min(__end1 - __begin1, __end2 - __begin2)); # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __borders = new _DifferenceType[__num_threads + 2]; __equally_split(__size, __num_threads + 1, __borders); __block_begins = new _IteratorPair[__num_threads + 1]; // Very __start. __block_begins[0] = std::make_pair(__begin1, __begin2); __lengths = new _DifferenceType[__num_threads]; } //single _ThreadIndex __iam = omp_get_thread_num(); // _Result from multiseq_partition. _IIter __offset[2]; const _DifferenceType __rank = __borders[__iam + 1]; multiseq_partition(__sequence, __sequence + 2, __rank, __offset, __op._M_comp); // allowed to read? // together // *(__offset[ 0 ] - 1) == *__offset[ 1 ] if (__offset[ 0 ] != __begin1 && __offset[1] != __end2 && !__op._M_comp(*(__offset[0] - 1), *__offset[1]) && !__op._M_comp(*__offset[1], *(__offset[0] - 1))) { // Avoid split between globally equal elements: move one to // front in first sequence. --__offset[0]; } _IteratorPair __block_end = __block_begins[__iam + 1] = _IteratorPair(__offset[0], __offset[1]); // Make sure all threads have their block_begin result written out. # pragma omp barrier _IteratorPair __block_begin = __block_begins[__iam]; // Begin working for the first block, while the others except // the last start to count. if (__iam == 0) { // The first thread can copy already. __lengths[ __iam ] = __op._M_invoke(__block_begin.first, __block_end.first, __block_begin.second, __block_end.second, __result) - __result; } else { __lengths[ __iam ] = __op.__count(__block_begin.first, __block_end.first, __block_begin.second, __block_end.second); } // Make sure everyone wrote their lengths. # pragma omp barrier _OutputIterator __r = __result; if (__iam == 0) { // Do the last block. for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __r += __lengths[__i]; __block_begin = __block_begins[__num_threads]; // Return the result iterator of the last block. __return_value = __op._M_invoke(__block_begin.first, __end1, __block_begin.second, __end2, __r); } else { for (_ThreadIndex __i = 0; __i < __iam; ++__i) __r += __lengths[ __i ]; // Reset begins for copy pass. __op._M_invoke(__block_begin.first, __block_end.first, __block_begin.second, __block_end.second, __r); } } return __return_value; } template inline _OutputIterator __parallel_set_union(_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp) { return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, __union_func< _IIter, _OutputIterator, _Compare>(__comp)); } template inline _OutputIterator __parallel_set_intersection(_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp) { return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, __intersection_func<_IIter, _OutputIterator, _Compare>(__comp)); } template inline _OutputIterator __parallel_set_difference(_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp) { return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, __difference_func<_IIter, _OutputIterator, _Compare>(__comp)); } template inline _OutputIterator __parallel_set_symmetric_difference(_IIter __begin1, _IIter __end1, _IIter __begin2, _IIter __end2, _OutputIterator __result, _Compare __comp) { return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, __symmetric_difference_func<_IIter, _OutputIterator, _Compare>(__comp)); } } #endif /* _GLIBCXX_PARALLEL_SET_OPERATIONS_H */ 4.8.2/parallel/losertree.h000064400000067440147547540550011221 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/losertree.h * @brief Many generic loser tree variants. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_LOSERTREE_H #define _GLIBCXX_PARALLEL_LOSERTREE_H 1 #include #include #include #include namespace __gnu_parallel { /** * @brief Guarded loser/tournament tree. * * The smallest element is at the top. * * Guarding is done explicitly through one flag _M_sup per element, * inf is not needed due to a better initialization routine. This * is a well-performing variant. * * @param _Tp the element type * @param _Compare the comparator to use, defaults to std::less<_Tp> */ template class _LoserTreeBase { protected: /** @brief Internal representation of a _LoserTree element. */ struct _Loser { /** @brief flag, true iff this is a "maximum" __sentinel. */ bool _M_sup; /** @brief __index of the __source __sequence. */ int _M_source; /** @brief _M_key of the element in the _LoserTree. */ _Tp _M_key; }; unsigned int _M_ik, _M_k, _M_offset; /** log_2{_M_k} */ unsigned int _M_log_k; /** @brief _LoserTree __elements. */ _Loser* _M_losers; /** @brief _Compare to use. */ _Compare _M_comp; /** * @brief State flag that determines whether the _LoserTree is empty. * * Only used for building the _LoserTree. */ bool _M_first_insert; public: /** * @brief The constructor. * * @param __k The number of sequences to merge. * @param __comp The comparator to use. */ _LoserTreeBase(unsigned int __k, _Compare __comp) : _M_comp(__comp) { _M_ik = __k; // Compute log_2{_M_k} for the _Loser Tree _M_log_k = __rd_log2(_M_ik - 1) + 1; // Next greater power of 2. _M_k = 1 << _M_log_k; _M_offset = _M_k; // Avoid default-constructing _M_losers[]._M_key _M_losers = static_cast<_Loser*>(::operator new(2 * _M_k * sizeof(_Loser))); for (unsigned int __i = _M_ik - 1; __i < _M_k; ++__i) _M_losers[__i + _M_k]._M_sup = true; _M_first_insert = true; } /** * @brief The destructor. */ ~_LoserTreeBase() { for (unsigned int __i = 0; __i < (2 * _M_k); ++__i) _M_losers[__i].~_Loser(); ::operator delete(_M_losers); } /** * @brief Initializes the sequence "_M_source" with the element "__key". * * @param __key the element to insert * @param __source __index of the __source __sequence * @param __sup flag that determines whether the value to insert is an * explicit __supremum. */ void __insert_start(const _Tp& __key, int __source, bool __sup) { unsigned int __pos = _M_k + __source; if (_M_first_insert) { // Construct all keys, so we can easily destruct them. for (unsigned int __i = 0; __i < (2 * _M_k); ++__i) ::new(&(_M_losers[__i]._M_key)) _Tp(__key); _M_first_insert = false; } else _M_losers[__pos]._M_key = __key; _M_losers[__pos]._M_sup = __sup; _M_losers[__pos]._M_source = __source; } /** * @return the index of the sequence with the smallest element. */ int __get_min_source() { return _M_losers[0]._M_source; } }; /** * @brief Stable _LoserTree variant. * * Provides the stable implementations of insert_start, __init_winner, * __init and __delete_min_insert. * * Unstable variant is done using partial specialisation below. */ template class _LoserTree : public _LoserTreeBase<_Tp, _Compare> { typedef _LoserTreeBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; using _Base::_M_first_insert; public: _LoserTree(unsigned int __k, _Compare __comp) : _Base::_LoserTreeBase(__k, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (_M_losers[__right]._M_sup || (!_M_losers[__left]._M_sup && !_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key))) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; } /** * @brief Delete the smallest element and insert a new element from * the previously smallest element's sequence. * * This implementation is stable. */ // Do not pass a const reference since __key will be used as // local variable. void __delete_min_insert(_Tp __key, bool __sup) { using std::swap; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted, ties are broken by _M_source. if ((__sup && (!_M_losers[__pos]._M_sup || _M_losers[__pos]._M_source < __source)) || (!__sup && !_M_losers[__pos]._M_sup && ((_M_comp(_M_losers[__pos]._M_key, __key)) || (!_M_comp(__key, _M_losers[__pos]._M_key) && _M_losers[__pos]._M_source < __source)))) { // The other one is smaller. std::swap(_M_losers[__pos]._M_sup, __sup); std::swap(_M_losers[__pos]._M_source, __source); swap(_M_losers[__pos]._M_key, __key); } } _M_losers[0]._M_sup = __sup; _M_losers[0]._M_source = __source; _M_losers[0]._M_key = __key; } }; /** * @brief Unstable _LoserTree variant. * * Stability (non-stable here) is selected with partial specialization. */ template class _LoserTree : public _LoserTreeBase<_Tp, _Compare> { typedef _LoserTreeBase<_Tp, _Compare> _Base; using _Base::_M_log_k; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; using _Base::_M_first_insert; public: _LoserTree(unsigned int __k, _Compare __comp) : _Base::_LoserTreeBase(__k, __comp) { } /** * Computes the winner of the competition at position "__root". * * Called recursively (starting at 0) to build the initial tree. * * @param __root __index of the "game" to start. */ unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (_M_losers[__right]._M_sup || (!_M_losers[__left]._M_sup && !_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key))) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; } /** * Delete the _M_key smallest element and insert the element __key * instead. * * @param __key the _M_key to insert * @param __sup true iff __key is an explicitly marked supremum */ // Do not pass a const reference since __key will be used as local // variable. void __delete_min_insert(_Tp __key, bool __sup) { using std::swap; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted. if (__sup || (!_M_losers[__pos]._M_sup && _M_comp(_M_losers[__pos]._M_key, __key))) { // The other one is smaller. std::swap(_M_losers[__pos]._M_sup, __sup); std::swap(_M_losers[__pos]._M_source, __source); swap(_M_losers[__pos]._M_key, __key); } } _M_losers[0]._M_sup = __sup; _M_losers[0]._M_source = __source; _M_losers[0]._M_key = __key; } }; /** * @brief Base class of _Loser Tree implementation using pointers. */ template class _LoserTreePointerBase { protected: /** @brief Internal representation of _LoserTree __elements. */ struct _Loser { bool _M_sup; int _M_source; const _Tp* _M_keyp; }; unsigned int _M_ik, _M_k, _M_offset; _Loser* _M_losers; _Compare _M_comp; public: _LoserTreePointerBase(unsigned int __k, _Compare __comp = std::less<_Tp>()) : _M_comp(__comp) { _M_ik = __k; // Next greater power of 2. _M_k = 1 << (__rd_log2(_M_ik - 1) + 1); _M_offset = _M_k; _M_losers = new _Loser[_M_k * 2]; for (unsigned int __i = _M_ik - 1; __i < _M_k; __i++) _M_losers[__i + _M_k]._M_sup = true; } ~_LoserTreePointerBase() { delete[] _M_losers; } int __get_min_source() { return _M_losers[0]._M_source; } void __insert_start(const _Tp& __key, int __source, bool __sup) { unsigned int __pos = _M_k + __source; _M_losers[__pos]._M_sup = __sup; _M_losers[__pos]._M_source = __source; _M_losers[__pos]._M_keyp = &__key; } }; /** * @brief Stable _LoserTree implementation. * * The unstable variant is implemented using partial instantiation below. */ template class _LoserTreePointer : public _LoserTreePointerBase<_Tp, _Compare> { typedef _LoserTreePointerBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreePointerBase(__k, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (_M_losers[__right]._M_sup || (!_M_losers[__left]._M_sup && !_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp))) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; } void __delete_min_insert(const _Tp& __key, bool __sup) { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif const _Tp* __keyp = &__key; int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted, ties are broken by __source. if ((__sup && (!_M_losers[__pos]._M_sup || _M_losers[__pos]._M_source < __source)) || (!__sup && !_M_losers[__pos]._M_sup && ((_M_comp(*_M_losers[__pos]._M_keyp, *__keyp)) || (!_M_comp(*__keyp, *_M_losers[__pos]._M_keyp) && _M_losers[__pos]._M_source < __source)))) { // The other one is smaller. std::swap(_M_losers[__pos]._M_sup, __sup); std::swap(_M_losers[__pos]._M_source, __source); std::swap(_M_losers[__pos]._M_keyp, __keyp); } } _M_losers[0]._M_sup = __sup; _M_losers[0]._M_source = __source; _M_losers[0]._M_keyp = __keyp; } }; /** * @brief Unstable _LoserTree implementation. * * The stable variant is above. */ template class _LoserTreePointer : public _LoserTreePointerBase<_Tp, _Compare> { typedef _LoserTreePointerBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreePointerBase(__k, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (_M_losers[__right]._M_sup || (!_M_losers[__left]._M_sup && !_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp))) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; } void __delete_min_insert(const _Tp& __key, bool __sup) { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif const _Tp* __keyp = &__key; int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted. if (__sup || (!_M_losers[__pos]._M_sup && _M_comp(*_M_losers[__pos]._M_keyp, *__keyp))) { // The other one is smaller. std::swap(_M_losers[__pos]._M_sup, __sup); std::swap(_M_losers[__pos]._M_source, __source); std::swap(_M_losers[__pos]._M_keyp, __keyp); } } _M_losers[0]._M_sup = __sup; _M_losers[0]._M_source = __source; _M_losers[0]._M_keyp = __keyp; } }; /** @brief Base class for unguarded _LoserTree implementation. * * The whole element is copied into the tree structure. * * No guarding is done, therefore not a single input sequence must * run empty. Unused __sequence heads are marked with a sentinel which * is > all elements that are to be merged. * * This is a very fast variant. */ template class _LoserTreeUnguardedBase { protected: struct _Loser { int _M_source; _Tp _M_key; }; unsigned int _M_ik, _M_k, _M_offset; _Loser* _M_losers; _Compare _M_comp; public: _LoserTreeUnguardedBase(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _M_comp(__comp) { _M_ik = __k; // Next greater power of 2. _M_k = 1 << (__rd_log2(_M_ik - 1) + 1); _M_offset = _M_k; // Avoid default-constructing _M_losers[]._M_key _M_losers = static_cast<_Loser*>(::operator new(2 * _M_k * sizeof(_Loser))); for (unsigned int __i = 0; __i < _M_k; ++__i) { ::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel); _M_losers[__i]._M_source = -1; } for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i) { ::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel); _M_losers[__i]._M_source = -1; } } ~_LoserTreeUnguardedBase() { for (unsigned int __i = 0; __i < (2 * _M_k); ++__i) _M_losers[__i].~_Loser(); ::operator delete(_M_losers); } int __get_min_source() { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif return _M_losers[0]._M_source; } void __insert_start(const _Tp& __key, int __source, bool) { unsigned int __pos = _M_k + __source; ::new(&(_M_losers[__pos]._M_key)) _Tp(__key); _M_losers[__pos]._M_source = __source; } }; /** * @brief Stable implementation of unguarded _LoserTree. * * Unstable variant is selected below with partial specialization. */ template class _LoserTreeUnguarded : public _LoserTreeUnguardedBase<_Tp, _Compare> { typedef _LoserTreeUnguardedBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (!_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key)) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top at the beginning // (0 sequences!) _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif } // Do not pass a const reference since __key will be used as // local variable. void __delete_min_insert(_Tp __key, bool) { using std::swap; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted, ties are broken by _M_source. if (_M_comp(_M_losers[__pos]._M_key, __key) || (!_M_comp(__key, _M_losers[__pos]._M_key) && _M_losers[__pos]._M_source < __source)) { // The other one is smaller. std::swap(_M_losers[__pos]._M_source, __source); swap(_M_losers[__pos]._M_key, __key); } } _M_losers[0]._M_source = __source; _M_losers[0]._M_key = __key; } }; /** * @brief Non-Stable implementation of unguarded _LoserTree. * * Stable implementation is above. */ template class _LoserTreeUnguarded : public _LoserTreeUnguardedBase<_Tp, _Compare> { typedef _LoserTreeUnguardedBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); #if _GLIBCXX_ASSERTIONS // If __left one is sentinel then __right one must be, too. if (_M_losers[__left]._M_source == -1) _GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1); #endif if (!_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key)) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top at the beginning // (0 sequences!) _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif } // Do not pass a const reference since __key will be used as // local variable. void __delete_min_insert(_Tp __key, bool) { using std::swap; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted. if (_M_comp(_M_losers[__pos]._M_key, __key)) { // The other one is smaller. std::swap(_M_losers[__pos]._M_source, __source); swap(_M_losers[__pos]._M_key, __key); } } _M_losers[0]._M_source = __source; _M_losers[0]._M_key = __key; } }; /** @brief Unguarded loser tree, keeping only pointers to the * elements in the tree structure. * * No guarding is done, therefore not a single input sequence must * run empty. This is a very fast variant. */ template class _LoserTreePointerUnguardedBase { protected: struct _Loser { int _M_source; const _Tp* _M_keyp; }; unsigned int _M_ik, _M_k, _M_offset; _Loser* _M_losers; _Compare _M_comp; public: _LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _M_comp(__comp) { _M_ik = __k; // Next greater power of 2. _M_k = 1 << (__rd_log2(_M_ik - 1) + 1); _M_offset = _M_k; // Avoid default-constructing _M_losers[]._M_key _M_losers = new _Loser[2 * _M_k]; for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i) { _M_losers[__i]._M_keyp = &__sentinel; _M_losers[__i]._M_source = -1; } } ~_LoserTreePointerUnguardedBase() { delete[] _M_losers; } int __get_min_source() { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif return _M_losers[0]._M_source; } void __insert_start(const _Tp& __key, int __source, bool) { unsigned int __pos = _M_k + __source; _M_losers[__pos]._M_keyp = &__key; _M_losers[__pos]._M_source = __source; } }; /** * @brief Stable unguarded _LoserTree variant storing pointers. * * Unstable variant is implemented below using partial specialization. */ template class _LoserTreePointerUnguarded : public _LoserTreePointerUnguardedBase<_Tp, _Compare> { typedef _LoserTreePointerUnguardedBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreePointerUnguarded(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreePointerUnguardedBase(__k, __sentinel, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); if (!_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp)) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top at the beginning // (0 sequences!) _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif } void __delete_min_insert(const _Tp& __key, bool __sup) { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif const _Tp* __keyp = &__key; int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted, ties are broken by _M_source. if (_M_comp(*_M_losers[__pos]._M_keyp, *__keyp) || (!_M_comp(*__keyp, *_M_losers[__pos]._M_keyp) && _M_losers[__pos]._M_source < __source)) { // The other one is smaller. std::swap(_M_losers[__pos]._M_source, __source); std::swap(_M_losers[__pos]._M_keyp, __keyp); } } _M_losers[0]._M_source = __source; _M_losers[0]._M_keyp = __keyp; } }; /** * @brief Unstable unguarded _LoserTree variant storing pointers. * * Stable variant is above. */ template class _LoserTreePointerUnguarded : public _LoserTreePointerUnguardedBase<_Tp, _Compare> { typedef _LoserTreePointerUnguardedBase<_Tp, _Compare> _Base; using _Base::_M_k; using _Base::_M_comp; using _Base::_M_losers; public: _LoserTreePointerUnguarded(unsigned int __k, const _Tp& __sentinel, _Compare __comp = std::less<_Tp>()) : _Base::_LoserTreePointerUnguardedBase(__k, __sentinel, __comp) { } unsigned int __init_winner(unsigned int __root) { if (__root >= _M_k) return __root; else { unsigned int __left = __init_winner(2 * __root); unsigned int __right = __init_winner(2 * __root + 1); #if _GLIBCXX_ASSERTIONS // If __left one is sentinel then __right one must be, too. if (_M_losers[__left]._M_source == -1) _GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1); #endif if (!_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp)) { // Left one is less or equal. _M_losers[__root] = _M_losers[__right]; return __left; } else { // Right one is less. _M_losers[__root] = _M_losers[__left]; return __right; } } } void __init() { _M_losers[0] = _M_losers[__init_winner(1)]; #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top at the beginning // (0 sequences!) _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif } void __delete_min_insert(const _Tp& __key, bool __sup) { #if _GLIBCXX_ASSERTIONS // no dummy sequence can ever be at the top! _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1); #endif const _Tp* __keyp = &__key; int __source = _M_losers[0]._M_source; for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0; __pos /= 2) { // The smaller one gets promoted. if (_M_comp(*(_M_losers[__pos]._M_keyp), *__keyp)) { // The other one is smaller. std::swap(_M_losers[__pos]._M_source, __source); std::swap(_M_losers[__pos]._M_keyp, __keyp); } } _M_losers[0]._M_source = __source; _M_losers[0]._M_keyp = __keyp; } }; } // namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_LOSERTREE_H */ 4.8.2/parallel/unique_copy.h000064400000014025147547540550011544 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/unique_copy.h * @brief Parallel implementations of std::unique_copy(). * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Robert Geisberger and Robin Dapp. #ifndef _GLIBCXX_PARALLEL_UNIQUE_COPY_H #define _GLIBCXX_PARALLEL_UNIQUE_COPY_H 1 #include #include namespace __gnu_parallel { /** @brief Parallel std::unique_copy(), w/__o explicit equality predicate. * @param __first Begin iterator of input sequence. * @param __last End iterator of input sequence. * @param __result Begin iterator of result __sequence. * @param __binary_pred Equality predicate. * @return End iterator of result __sequence. */ template _OutputIterator __parallel_unique_copy(_IIter __first, _IIter __last, _OutputIterator __result, _BinaryPredicate __binary_pred) { _GLIBCXX_CALL(__last - __first) typedef std::iterator_traits<_IIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __size = __last - __first; if (__size == 0) return __result; // Let the first thread process two parts. _DifferenceType *__counter; _DifferenceType *__borders; _ThreadIndex __num_threads = __get_max_threads(); // First part contains at least one element. # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __borders = new _DifferenceType[__num_threads + 2]; __equally_split(__size, __num_threads + 1, __borders); __counter = new _DifferenceType[__num_threads + 1]; } _ThreadIndex __iam = omp_get_thread_num(); _DifferenceType __begin, __end; // Check for length without duplicates // Needed for position in output _DifferenceType __i = 0; _OutputIterator __out = __result; if (__iam == 0) { __begin = __borders[0] + 1; // == 1 __end = __borders[__iam + 1]; ++__i; *__out++ = *__first; for (_IIter __iter = __first + __begin; __iter < __first + __end; ++__iter) { if (!__binary_pred(*__iter, *(__iter - 1))) { ++__i; *__out++ = *__iter; } } } else { __begin = __borders[__iam]; //one part __end = __borders[__iam + 1]; for (_IIter __iter = __first + __begin; __iter < __first + __end; ++__iter) { if (!__binary_pred(*__iter, *(__iter - 1))) ++__i; } } __counter[__iam] = __i; // Last part still untouched. _DifferenceType __begin_output; # pragma omp barrier // Store result in output on calculated positions. __begin_output = 0; if (__iam == 0) { for (_ThreadIndex __t = 0; __t < __num_threads; ++__t) __begin_output += __counter[__t]; __i = 0; _OutputIterator __iter_out = __result + __begin_output; __begin = __borders[__num_threads]; __end = __size; for (_IIter __iter = __first + __begin; __iter < __first + __end; ++__iter) { if (__iter == __first || !__binary_pred(*__iter, *(__iter - 1))) { ++__i; *__iter_out++ = *__iter; } } __counter[__num_threads] = __i; } else { for (_ThreadIndex __t = 0; __t < __iam; __t++) __begin_output += __counter[__t]; _OutputIterator __iter_out = __result + __begin_output; for (_IIter __iter = __first + __begin; __iter < __first + __end; ++__iter) { if (!__binary_pred(*__iter, *(__iter - 1))) *__iter_out++ = *__iter; } } } _DifferenceType __end_output = 0; for (_ThreadIndex __t = 0; __t < __num_threads + 1; __t++) __end_output += __counter[__t]; delete[] __borders; return __result + __end_output; } /** @brief Parallel std::unique_copy(), without explicit equality predicate * @param __first Begin iterator of input sequence. * @param __last End iterator of input sequence. * @param __result Begin iterator of result __sequence. * @return End iterator of result __sequence. */ template inline _OutputIterator __parallel_unique_copy(_IIter __first, _IIter __last, _OutputIterator __result) { typedef typename std::iterator_traits<_IIter>::value_type _ValueType; return __parallel_unique_copy(__first, __last, __result, std::equal_to<_ValueType>()); } }//namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_UNIQUE_COPY_H */ 4.8.2/parallel/omp_loop.h000064400000007677147547540550011047 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/omp_loop.h * @brief Parallelization of embarrassingly parallel execution by * means of an OpenMP for loop. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_OMP_LOOP_H #define _GLIBCXX_PARALLEL_OMP_LOOP_H 1 #include #include #include #include namespace __gnu_parallel { /** @brief Embarrassingly parallel algorithm for random access * iterators, using an OpenMP for loop. * * @param __begin Begin iterator of element sequence. * @param __end End iterator of element sequence. * @param __o User-supplied functor (comparator, predicate, adding * functor, etc.). * @param __f Functor to @a process an element with __op (depends on * desired functionality, e. g. for std::for_each(), ...). * @param __r Functor to @a add a single __result to the already * processed elements (depends on functionality). * @param __base Base value for reduction. * @param __output Pointer to position where final result is written to * @param __bound Maximum number of elements processed (e. g. for * std::count_n()). * @return User-supplied functor (that may contain a part of the result). */ template _Op __for_each_template_random_access_omp_loop(_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _Result __base, _Result& __output, typename std::iterator_traits<_RAIter>::difference_type __bound) { typedef typename std::iterator_traits<_RAIter>::difference_type _DifferenceType; _DifferenceType __length = __end - __begin; _ThreadIndex __num_threads = __gnu_parallel::min<_DifferenceType> (__get_max_threads(), __length); _Result *__thread_results; # pragma omp parallel num_threads(__num_threads) { # pragma omp single { __num_threads = omp_get_num_threads(); __thread_results = new _Result[__num_threads]; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __thread_results[__i] = _Result(); } _ThreadIndex __iam = omp_get_thread_num(); #pragma omp for schedule(dynamic, _Settings::get().workstealing_chunk_size) for (_DifferenceType __pos = 0; __pos < __length; ++__pos) __thread_results[__iam] = __r(__thread_results[__iam], __f(__o, __begin+__pos)); } //parallel for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) __output = __r(__output, __thread_results[__i]); delete [] __thread_results; // Points to last element processed (needed as return value for // some algorithms like transform). __f._M_finish_iterator = __begin + __length; return __o; } } // end namespace #endif /* _GLIBCXX_PARALLEL_OMP_LOOP_H */ 4.8.2/parallel/balanced_quicksort.h000064400000040612147547540550013042 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/balanced_quicksort.h * @brief Implementation of a dynamically load-balanced parallel quicksort. * * It works in-place and needs only logarithmic extra memory. * The algorithm is similar to the one proposed in * * P. Tsigas and Y. Zhang. * A simple, fast parallel implementation of quicksort and * its performance evaluation on SUN enterprise 10000. * In 11th Euromicro Conference on Parallel, Distributed and * Network-Based Processing, page 372, 2003. * * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Johannes Singler. #ifndef _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H #define _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H 1 #include #include #include #include #include #include #include #if _GLIBCXX_ASSERTIONS #include #endif namespace __gnu_parallel { /** @brief Information local to one thread in the parallel quicksort run. */ template struct _QSBThreadLocal { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::difference_type _DifferenceType; /** @brief Continuous part of the sequence, described by an iterator pair. */ typedef std::pair<_RAIter, _RAIter> _Piece; /** @brief Initial piece to work on. */ _Piece _M_initial; /** @brief Work-stealing queue. */ _RestrictedBoundedConcurrentQueue<_Piece> _M_leftover_parts; /** @brief Number of threads involved in this algorithm. */ _ThreadIndex _M_num_threads; /** @brief Pointer to a counter of elements left over to sort. */ volatile _DifferenceType* _M_elements_leftover; /** @brief The complete sequence to sort. */ _Piece _M_global; /** @brief Constructor. * @param __queue_size size of the work-stealing queue. */ _QSBThreadLocal(int __queue_size) : _M_leftover_parts(__queue_size) { } }; /** @brief Balanced quicksort divide step. * @param __begin Begin iterator of subsequence. * @param __end End iterator of subsequence. * @param __comp Comparator. * @param __num_threads Number of threads that are allowed to work on * this part. * @pre @c (__end-__begin)>=1 */ template typename std::iterator_traits<_RAIter>::difference_type __qsb_divide(_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads) { _GLIBCXX_PARALLEL_ASSERT(__num_threads > 0); typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _RAIter __pivot_pos = __median_of_three_iterators(__begin, __begin + (__end - __begin) / 2, __end - 1, __comp); #if defined(_GLIBCXX_ASSERTIONS) // Must be in between somewhere. _DifferenceType __n = __end - __begin; _GLIBCXX_PARALLEL_ASSERT((!__comp(*__pivot_pos, *__begin) && !__comp(*(__begin + __n / 2), *__pivot_pos)) || (!__comp(*__pivot_pos, *__begin) && !__comp(*(__end - 1), *__pivot_pos)) || (!__comp(*__pivot_pos, *(__begin + __n / 2)) && !__comp(*__begin, *__pivot_pos)) || (!__comp(*__pivot_pos, *(__begin + __n / 2)) && !__comp(*(__end - 1), *__pivot_pos)) || (!__comp(*__pivot_pos, *(__end - 1)) && !__comp(*__begin, *__pivot_pos)) || (!__comp(*__pivot_pos, *(__end - 1)) && !__comp(*(__begin + __n / 2), *__pivot_pos))); #endif // Swap pivot value to end. if (__pivot_pos != (__end - 1)) std::iter_swap(__pivot_pos, __end - 1); __pivot_pos = __end - 1; __gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool> __pred(__comp, *__pivot_pos); // Divide, returning __end - __begin - 1 in the worst case. _DifferenceType __split_pos = __parallel_partition(__begin, __end - 1, __pred, __num_threads); // Swap back pivot to middle. std::iter_swap(__begin + __split_pos, __pivot_pos); __pivot_pos = __begin + __split_pos; #if _GLIBCXX_ASSERTIONS _RAIter __r; for (__r = __begin; __r != __pivot_pos; ++__r) _GLIBCXX_PARALLEL_ASSERT(__comp(*__r, *__pivot_pos)); for (; __r != __end; ++__r) _GLIBCXX_PARALLEL_ASSERT(!__comp(*__r, *__pivot_pos)); #endif return __split_pos; } /** @brief Quicksort conquer step. * @param __tls Array of thread-local storages. * @param __begin Begin iterator of subsequence. * @param __end End iterator of subsequence. * @param __comp Comparator. * @param __iam Number of the thread processing this function. * @param __num_threads * Number of threads that are allowed to work on this part. */ template void __qsb_conquer(_QSBThreadLocal<_RAIter>** __tls, _RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __iam, _ThreadIndex __num_threads, bool __parent_wait) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; _DifferenceType __n = __end - __begin; if (__num_threads <= 1 || __n <= 1) { __tls[__iam]->_M_initial.first = __begin; __tls[__iam]->_M_initial.second = __end; __qsb_local_sort_with_helping(__tls, __comp, __iam, __parent_wait); return; } // Divide step. _DifferenceType __split_pos = __qsb_divide(__begin, __end, __comp, __num_threads); #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(0 <= __split_pos && __split_pos < (__end - __begin)); #endif _ThreadIndex __num_threads_leftside = std::max<_ThreadIndex> (1, std::min<_ThreadIndex>(__num_threads - 1, __split_pos * __num_threads / __n)); # pragma omp atomic *__tls[__iam]->_M_elements_leftover -= (_DifferenceType)1; // Conquer step. # pragma omp parallel num_threads(2) { bool __wait; if(omp_get_num_threads() < 2) __wait = false; else __wait = __parent_wait; # pragma omp sections { # pragma omp section { __qsb_conquer(__tls, __begin, __begin + __split_pos, __comp, __iam, __num_threads_leftside, __wait); __wait = __parent_wait; } // The pivot_pos is left in place, to ensure termination. # pragma omp section { __qsb_conquer(__tls, __begin + __split_pos + 1, __end, __comp, __iam + __num_threads_leftside, __num_threads - __num_threads_leftside, __wait); __wait = __parent_wait; } } } } /** * @brief Quicksort step doing load-balanced local sort. * @param __tls Array of thread-local storages. * @param __comp Comparator. * @param __iam Number of the thread processing this function. */ template void __qsb_local_sort_with_helping(_QSBThreadLocal<_RAIter>** __tls, _Compare& __comp, _ThreadIndex __iam, bool __wait) { typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; typedef std::pair<_RAIter, _RAIter> _Piece; _QSBThreadLocal<_RAIter>& __tl = *__tls[__iam]; _DifferenceType __base_case_n = _Settings::get().sort_qsb_base_case_maximal_n; if (__base_case_n < 2) __base_case_n = 2; _ThreadIndex __num_threads = __tl._M_num_threads; // Every thread has its own random number generator. _RandomNumber __rng(__iam + 1); _Piece __current = __tl._M_initial; _DifferenceType __elements_done = 0; #if _GLIBCXX_ASSERTIONS _DifferenceType __total_elements_done = 0; #endif for (;;) { // Invariant: __current must be a valid (maybe empty) range. _RAIter __begin = __current.first, __end = __current.second; _DifferenceType __n = __end - __begin; if (__n > __base_case_n) { // Divide. _RAIter __pivot_pos = __begin + __rng(__n); // Swap __pivot_pos value to end. if (__pivot_pos != (__end - 1)) std::iter_swap(__pivot_pos, __end - 1); __pivot_pos = __end - 1; __gnu_parallel::__binder2nd <_Compare, _ValueType, _ValueType, bool> __pred(__comp, *__pivot_pos); // Divide, leave pivot unchanged in last place. _RAIter __split_pos1, __split_pos2; __split_pos1 = __gnu_sequential::partition(__begin, __end - 1, __pred); // Left side: < __pivot_pos; __right side: >= __pivot_pos. #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(__begin <= __split_pos1 && __split_pos1 < __end); #endif // Swap pivot back to middle. if (__split_pos1 != __pivot_pos) std::iter_swap(__split_pos1, __pivot_pos); __pivot_pos = __split_pos1; // In case all elements are equal, __split_pos1 == 0. if ((__split_pos1 + 1 - __begin) < (__n >> 7) || (__end - __split_pos1) < (__n >> 7)) { // Very unequal split, one part smaller than one 128th // elements not strictly larger than the pivot. __gnu_parallel::__unary_negate<__gnu_parallel::__binder1st <_Compare, _ValueType, _ValueType, bool>, _ValueType> __pred(__gnu_parallel::__binder1st <_Compare, _ValueType, _ValueType, bool> (__comp, *__pivot_pos)); // Find other end of pivot-equal range. __split_pos2 = __gnu_sequential::partition(__split_pos1 + 1, __end, __pred); } else // Only skip the pivot. __split_pos2 = __split_pos1 + 1; // Elements equal to pivot are done. __elements_done += (__split_pos2 - __split_pos1); #if _GLIBCXX_ASSERTIONS __total_elements_done += (__split_pos2 - __split_pos1); #endif // Always push larger part onto stack. if (((__split_pos1 + 1) - __begin) < (__end - (__split_pos2))) { // Right side larger. if ((__split_pos2) != __end) __tl._M_leftover_parts.push_front (std::make_pair(__split_pos2, __end)); //__current.first = __begin; //already set anyway __current.second = __split_pos1; continue; } else { // Left side larger. if (__begin != __split_pos1) __tl._M_leftover_parts.push_front(std::make_pair (__begin, __split_pos1)); __current.first = __split_pos2; //__current.second = __end; //already set anyway continue; } } else { __gnu_sequential::sort(__begin, __end, __comp); __elements_done += __n; #if _GLIBCXX_ASSERTIONS __total_elements_done += __n; #endif // Prefer own stack, small pieces. if (__tl._M_leftover_parts.pop_front(__current)) continue; # pragma omp atomic *__tl._M_elements_leftover -= __elements_done; __elements_done = 0; #if _GLIBCXX_ASSERTIONS double __search_start = omp_get_wtime(); #endif // Look for new work. bool __successfully_stolen = false; while (__wait && *__tl._M_elements_leftover > 0 && !__successfully_stolen #if _GLIBCXX_ASSERTIONS // Possible dead-lock. && (omp_get_wtime() < (__search_start + 1.0)) #endif ) { _ThreadIndex __victim; __victim = __rng(__num_threads); // Large pieces. __successfully_stolen = (__victim != __iam) && __tls[__victim]->_M_leftover_parts.pop_back(__current); if (!__successfully_stolen) __yield(); #if !defined(__ICC) && !defined(__ECC) # pragma omp flush #endif } #if _GLIBCXX_ASSERTIONS if (omp_get_wtime() >= (__search_start + 1.0)) { sleep(1); _GLIBCXX_PARALLEL_ASSERT(omp_get_wtime() < (__search_start + 1.0)); } #endif if (!__successfully_stolen) { #if _GLIBCXX_ASSERTIONS _GLIBCXX_PARALLEL_ASSERT(*__tl._M_elements_leftover == 0); #endif return; } } } } /** @brief Top-level quicksort routine. * @param __begin Begin iterator of sequence. * @param __end End iterator of sequence. * @param __comp Comparator. * @param __num_threads Number of threads that are allowed to work on * this part. */ template void __parallel_sort_qsb(_RAIter __begin, _RAIter __end, _Compare __comp, _ThreadIndex __num_threads) { _GLIBCXX_CALL(__end - __begin) typedef std::iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::difference_type _DifferenceType; typedef std::pair<_RAIter, _RAIter> _Piece; typedef _QSBThreadLocal<_RAIter> _TLSType; _DifferenceType __n = __end - __begin; if (__n <= 1) return; // At least one element per processor. if (__num_threads > __n) __num_threads = static_cast<_ThreadIndex>(__n); // Initialize thread local storage _TLSType** __tls = new _TLSType*[__num_threads]; _DifferenceType __queue_size = (__num_threads * (_ThreadIndex)(__rd_log2(__n) + 1)); for (_ThreadIndex __t = 0; __t < __num_threads; ++__t) __tls[__t] = new _QSBThreadLocal<_RAIter>(__queue_size); // There can never be more than ceil(__rd_log2(__n)) ranges on the // stack, because // 1. Only one processor pushes onto the stack // 2. The largest range has at most length __n // 3. Each range is larger than half of the range remaining volatile _DifferenceType __elements_leftover = __n; for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) { __tls[__i]->_M_elements_leftover = &__elements_leftover; __tls[__i]->_M_num_threads = __num_threads; __tls[__i]->_M_global = std::make_pair(__begin, __end); // Just in case nothing is left to assign. __tls[__i]->_M_initial = std::make_pair(__end, __end); } // Main recursion call. __qsb_conquer(__tls, __begin, __begin + __n, __comp, 0, __num_threads, true); #if _GLIBCXX_ASSERTIONS // All stack must be empty. _Piece __dummy; for (_ThreadIndex __i = 1; __i < __num_threads; ++__i) _GLIBCXX_PARALLEL_ASSERT( !__tls[__i]->_M_leftover_parts.pop_back(__dummy)); #endif for (_ThreadIndex __i = 0; __i < __num_threads; ++__i) delete __tls[__i]; delete[] __tls; } } // namespace __gnu_parallel #endif /* _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H */ 4.8.2/parallel/find_selectors.h000064400000015520147547540550012210 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file parallel/find_selectors.h * @brief _Function objects representing different tasks to be plugged * into the parallel find algorithm. * This file is a GNU parallel extension to the Standard C++ Library. */ // Written by Felix Putze. #ifndef _GLIBCXX_PARALLEL_FIND_SELECTORS_H #define _GLIBCXX_PARALLEL_FIND_SELECTORS_H 1 #include #include #include namespace __gnu_parallel { /** @brief Base class of all __gnu_parallel::__find_template selectors. */ struct __generic_find_selector { }; /** * @brief Test predicate on a single element, used for std::find() * and std::find_if (). */ struct __find_if_selector : public __generic_find_selector { /** @brief Test on one position. * @param __i1 _Iterator on first sequence. * @param __i2 _Iterator on second sequence (unused). * @param __pred Find predicate. */ template bool operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred) { return __pred(*__i1); } /** @brief Corresponding sequential algorithm on a sequence. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __pred Find predicate. */ template std::pair<_RAIter1, _RAIter2> _M_sequential_algorithm(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred) { return std::make_pair(find_if(__begin1, __end1, __pred, sequential_tag()), __begin2); } }; /** @brief Test predicate on two adjacent elements. */ struct __adjacent_find_selector : public __generic_find_selector { /** @brief Test on one position. * @param __i1 _Iterator on first sequence. * @param __i2 _Iterator on second sequence (unused). * @param __pred Find predicate. */ template bool operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred) { // Passed end iterator is one short. return __pred(*__i1, *(__i1 + 1)); } /** @brief Corresponding sequential algorithm on a sequence. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __pred Find predicate. */ template std::pair<_RAIter1, _RAIter2> _M_sequential_algorithm(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred) { // Passed end iterator is one short. _RAIter1 __spot = adjacent_find(__begin1, __end1 + 1, __pred, sequential_tag()); if (__spot == (__end1 + 1)) __spot = __end1; return std::make_pair(__spot, __begin2); } }; /** @brief Test inverted predicate on a single element. */ struct __mismatch_selector : public __generic_find_selector { /** * @brief Test on one position. * @param __i1 _Iterator on first sequence. * @param __i2 _Iterator on second sequence (unused). * @param __pred Find predicate. */ template bool operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred) { return !__pred(*__i1, *__i2); } /** * @brief Corresponding sequential algorithm on a sequence. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __pred Find predicate. */ template std::pair<_RAIter1, _RAIter2> _M_sequential_algorithm(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred) { return mismatch(__begin1, __end1, __begin2, __pred, sequential_tag()); } }; /** @brief Test predicate on several elements. */ template struct __find_first_of_selector : public __generic_find_selector { _FIterator _M_begin; _FIterator _M_end; explicit __find_first_of_selector(_FIterator __begin, _FIterator __end) : _M_begin(__begin), _M_end(__end) { } /** @brief Test on one position. * @param __i1 _Iterator on first sequence. * @param __i2 _Iterator on second sequence (unused). * @param __pred Find predicate. */ template bool operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred) { for (_FIterator __pos_in_candidates = _M_begin; __pos_in_candidates != _M_end; ++__pos_in_candidates) if (__pred(*__i1, *__pos_in_candidates)) return true; return false; } /** @brief Corresponding sequential algorithm on a sequence. * @param __begin1 Begin iterator of first sequence. * @param __end1 End iterator of first sequence. * @param __begin2 Begin iterator of second sequence. * @param __pred Find predicate. */ template std::pair<_RAIter1, _RAIter2> _M_sequential_algorithm(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred) { return std::make_pair(find_first_of(__begin1, __end1, _M_begin, _M_end, __pred, sequential_tag()), __begin2); } }; } #endif /* _GLIBCXX_PARALLEL_FIND_SELECTORS_H */ 4.8.2/clocale000064400000003561147547540550006567 0ustar00// -*- C++ -*- forwarding header. // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file clocale * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c locale.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 18.2.2 Implementation properties: C library // #pragma GCC system_header #include #include #ifndef _GLIBCXX_CLOCALE #define _GLIBCXX_CLOCALE 1 // Get rid of those macros defined in in lieu of real functions. #undef setlocale #undef localeconv namespace std { using ::lconv; using ::setlocale; using ::localeconv; } // namespace std #endif 4.8.2/atomic000064400000102465147547540550006444 0ustar00// -*- C++ -*- header. // Copyright (C) 2008-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/atomic * This is a Standard C++ Library header. */ // Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl. // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html #ifndef _GLIBCXX_ATOMIC #define _GLIBCXX_ATOMIC 1 #pragma GCC system_header #if __cplusplus < 201103L # include #endif #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @addtogroup atomics * @{ */ /// atomic_bool // NB: No operators or fetch-operations for this type. struct atomic_bool { private: __atomic_base _M_base; public: atomic_bool() noexcept = default; ~atomic_bool() noexcept = default; atomic_bool(const atomic_bool&) = delete; atomic_bool& operator=(const atomic_bool&) = delete; atomic_bool& operator=(const atomic_bool&) volatile = delete; constexpr atomic_bool(bool __i) noexcept : _M_base(__i) { } bool operator=(bool __i) noexcept { return _M_base.operator=(__i); } bool operator=(bool __i) volatile noexcept { return _M_base.operator=(__i); } operator bool() const noexcept { return _M_base.load(); } operator bool() const volatile noexcept { return _M_base.load(); } bool is_lock_free() const noexcept { return _M_base.is_lock_free(); } bool is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); } void store(bool __i, memory_order __m = memory_order_seq_cst) noexcept { _M_base.store(__i, __m); } void store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept { _M_base.store(__i, __m); } bool load(memory_order __m = memory_order_seq_cst) const noexcept { return _M_base.load(__m); } bool load(memory_order __m = memory_order_seq_cst) const volatile noexcept { return _M_base.load(__m); } bool exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.exchange(__i, __m); } bool exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.exchange(__i, __m); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m); } }; /** * @brief Generic atomic type, primary class template. * * @tparam _Tp Type to be made atomic, must be trivally copyable. */ template struct atomic { private: _Tp _M_i; public: atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(_Tp __i) noexcept : _M_i(__i) { } operator _Tp() const noexcept { return load(); } operator _Tp() const volatile noexcept { return load(); } _Tp operator=(_Tp __i) noexcept { store(__i); return __i; } _Tp operator=(_Tp __i) volatile noexcept { store(__i); return __i; } bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } bool is_lock_free() const volatile noexcept { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } void store(_Tp __i, memory_order _m = memory_order_seq_cst) noexcept { __atomic_store(&_M_i, &__i, _m); } void store(_Tp __i, memory_order _m = memory_order_seq_cst) volatile noexcept { __atomic_store(&_M_i, &__i, _m); } _Tp load(memory_order _m = memory_order_seq_cst) const noexcept { _Tp tmp; __atomic_load(&_M_i, &tmp, _m); return tmp; } _Tp load(memory_order _m = memory_order_seq_cst) const volatile noexcept { _Tp tmp; __atomic_load(&_M_i, &tmp, _m); return tmp; } _Tp exchange(_Tp __i, memory_order _m = memory_order_seq_cst) noexcept { _Tp tmp; __atomic_exchange(&_M_i, &__i, &tmp, _m); return tmp; } _Tp exchange(_Tp __i, memory_order _m = memory_order_seq_cst) volatile noexcept { _Tp tmp; __atomic_exchange(&_M_i, &__i, &tmp, _m); return tmp; } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(&_M_i, &__e, &__i, true, __s, __f); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(&_M_i, &__e, &__i, true, __s, __f); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_weak(__e, __i, __m, __m); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_weak(__e, __i, __m, __m); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(&_M_i, &__e, &__i, false, __s, __f); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(&_M_i, &__e, &__i, false, __s, __f); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_strong(__e, __i, __m, __m); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_strong(__e, __i, __m, __m); } }; /// Partial specialization for pointer types. template struct atomic<_Tp*> { typedef _Tp* __pointer_type; typedef __atomic_base<_Tp*> __base_type; __base_type _M_b; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { } operator __pointer_type() const noexcept { return __pointer_type(_M_b); } operator __pointer_type() const volatile noexcept { return __pointer_type(_M_b); } __pointer_type operator=(__pointer_type __p) noexcept { return _M_b.operator=(__p); } __pointer_type operator=(__pointer_type __p) volatile noexcept { return _M_b.operator=(__p); } __pointer_type operator++(int) noexcept { return _M_b++; } __pointer_type operator++(int) volatile noexcept { return _M_b++; } __pointer_type operator--(int) noexcept { return _M_b--; } __pointer_type operator--(int) volatile noexcept { return _M_b--; } __pointer_type operator++() noexcept { return ++_M_b; } __pointer_type operator++() volatile noexcept { return ++_M_b; } __pointer_type operator--() noexcept { return --_M_b; } __pointer_type operator--() volatile noexcept { return --_M_b; } __pointer_type operator+=(ptrdiff_t __d) noexcept { return _M_b.operator+=(__d); } __pointer_type operator+=(ptrdiff_t __d) volatile noexcept { return _M_b.operator+=(__d); } __pointer_type operator-=(ptrdiff_t __d) noexcept { return _M_b.operator-=(__d); } __pointer_type operator-=(ptrdiff_t __d) volatile noexcept { return _M_b.operator-=(__d); } bool is_lock_free() const noexcept { return _M_b.is_lock_free(); } bool is_lock_free() const volatile noexcept { return _M_b.is_lock_free(); } void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.store(__p, __m); } void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.store(__p, __m); } __pointer_type load(memory_order __m = memory_order_seq_cst) const noexcept { return _M_b.load(__m); } __pointer_type load(memory_order __m = memory_order_seq_cst) const volatile noexcept { return _M_b.load(__m); } __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.exchange(__p, __m); } __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.exchange(__p, __m); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_weak(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_weak(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m, __cmpexch_failure_order(__m)); } __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.fetch_add(__d, __m); } __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.fetch_add(__d, __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.fetch_sub(__d, __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.fetch_sub(__d, __m); } }; /// Explicit specialization for bool. template<> struct atomic : public atomic_bool { typedef bool __integral_type; typedef atomic_bool __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for char. template<> struct atomic : public atomic_char { typedef char __integral_type; typedef atomic_char __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for signed char. template<> struct atomic : public atomic_schar { typedef signed char __integral_type; typedef atomic_schar __base_type; atomic() noexcept= default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for unsigned char. template<> struct atomic : public atomic_uchar { typedef unsigned char __integral_type; typedef atomic_uchar __base_type; atomic() noexcept= default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for short. template<> struct atomic : public atomic_short { typedef short __integral_type; typedef atomic_short __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for unsigned short. template<> struct atomic : public atomic_ushort { typedef unsigned short __integral_type; typedef atomic_ushort __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for int. template<> struct atomic : atomic_int { typedef int __integral_type; typedef atomic_int __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for unsigned int. template<> struct atomic : public atomic_uint { typedef unsigned int __integral_type; typedef atomic_uint __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for long. template<> struct atomic : public atomic_long { typedef long __integral_type; typedef atomic_long __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for unsigned long. template<> struct atomic : public atomic_ulong { typedef unsigned long __integral_type; typedef atomic_ulong __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for long long. template<> struct atomic : public atomic_llong { typedef long long __integral_type; typedef atomic_llong __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for unsigned long long. template<> struct atomic : public atomic_ullong { typedef unsigned long long __integral_type; typedef atomic_ullong __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for wchar_t. template<> struct atomic : public atomic_wchar_t { typedef wchar_t __integral_type; typedef atomic_wchar_t __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for char16_t. template<> struct atomic : public atomic_char16_t { typedef char16_t __integral_type; typedef atomic_char16_t __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; /// Explicit specialization for char32_t. template<> struct atomic : public atomic_char32_t { typedef char32_t __integral_type; typedef atomic_char32_t __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; // Function definitions, atomic_flag operations. inline bool atomic_flag_test_and_set_explicit(atomic_flag* __a, memory_order __m) noexcept { return __a->test_and_set(__m); } inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag* __a, memory_order __m) noexcept { return __a->test_and_set(__m); } inline void atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept { __a->clear(__m); } inline void atomic_flag_clear_explicit(volatile atomic_flag* __a, memory_order __m) noexcept { __a->clear(__m); } inline bool atomic_flag_test_and_set(atomic_flag* __a) noexcept { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } inline bool atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } inline void atomic_flag_clear(atomic_flag* __a) noexcept { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } inline void atomic_flag_clear(volatile atomic_flag* __a) noexcept { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } // Function templates generally applicable to atomic types. template inline bool atomic_is_lock_free(const atomic<_ITp>* __a) noexcept { return __a->is_lock_free(); } template inline bool atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept { return __a->is_lock_free(); } template inline void atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept; template inline void atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept; template inline void atomic_store_explicit(atomic<_ITp>* __a, _ITp __i, memory_order __m) noexcept { __a->store(__i, __m); } template inline void atomic_store_explicit(volatile atomic<_ITp>* __a, _ITp __i, memory_order __m) noexcept { __a->store(__i, __m); } template inline _ITp atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept { return __a->load(__m); } template inline _ITp atomic_load_explicit(const volatile atomic<_ITp>* __a, memory_order __m) noexcept { return __a->load(__m); } template inline _ITp atomic_exchange_explicit(atomic<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template inline _ITp atomic_exchange_explicit(volatile atomic<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template inline bool atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a, _ITp* __i1, _ITp __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } template inline bool atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a, _ITp* __i1, _ITp __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } template inline bool atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a, _ITp* __i1, _ITp __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } template inline bool atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a, _ITp* __i1, _ITp __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } template inline void atomic_store(atomic<_ITp>* __a, _ITp __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template inline void atomic_store(volatile atomic<_ITp>* __a, _ITp __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_load(const atomic<_ITp>* __a) noexcept { return atomic_load_explicit(__a, memory_order_seq_cst); } template inline _ITp atomic_load(const volatile atomic<_ITp>* __a) noexcept { return atomic_load_explicit(__a, memory_order_seq_cst); } template inline _ITp atomic_exchange(atomic<_ITp>* __a, _ITp __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_exchange(volatile atomic<_ITp>* __a, _ITp __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template inline bool atomic_compare_exchange_weak(atomic<_ITp>* __a, _ITp* __i1, _ITp __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template inline bool atomic_compare_exchange_weak(volatile atomic<_ITp>* __a, _ITp* __i1, _ITp __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template inline bool atomic_compare_exchange_strong(atomic<_ITp>* __a, _ITp* __i1, _ITp __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template inline bool atomic_compare_exchange_strong(volatile atomic<_ITp>* __a, _ITp* __i1, _ITp __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } // Function templates for atomic_integral operations only, using // __atomic_base. Template argument should be constricted to // intergral types as specified in the standard, excluding address // types. template inline _ITp atomic_fetch_add_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_add(__i, __m); } template inline _ITp atomic_fetch_add_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_add(__i, __m); } template inline _ITp atomic_fetch_sub_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_sub(__i, __m); } template inline _ITp atomic_fetch_sub_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_sub(__i, __m); } template inline _ITp atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_and(__i, __m); } template inline _ITp atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_and(__i, __m); } template inline _ITp atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_or(__i, __m); } template inline _ITp atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_or(__i, __m); } template inline _ITp atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_xor(__i, __m); } template inline _ITp atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i, memory_order __m) noexcept { return __a->fetch_xor(__i, __m); } template inline _ITp atomic_fetch_add(__atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_add(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_sub(__atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_sub(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_and(__atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_and(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_or(__atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_or(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_xor(__atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } // Partial specializations for pointers. template inline _ITp* atomic_fetch_add_explicit(atomic<_ITp*>* __a, ptrdiff_t __d, memory_order __m) noexcept { return __a->fetch_add(__d, __m); } template inline _ITp* atomic_fetch_add_explicit(volatile atomic<_ITp*>* __a, ptrdiff_t __d, memory_order __m) noexcept { return __a->fetch_add(__d, __m); } template inline _ITp* atomic_fetch_add(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept { return __a->fetch_add(__d); } template inline _ITp* atomic_fetch_add(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept { return __a->fetch_add(__d); } template inline _ITp* atomic_fetch_sub_explicit(volatile atomic<_ITp*>* __a, ptrdiff_t __d, memory_order __m) noexcept { return __a->fetch_sub(__d, __m); } template inline _ITp* atomic_fetch_sub_explicit(atomic<_ITp*>* __a, ptrdiff_t __d, memory_order __m) noexcept { return __a->fetch_sub(__d, __m); } template inline _ITp* atomic_fetch_sub(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept { return __a->fetch_sub(__d); } template inline _ITp* atomic_fetch_sub(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept { return __a->fetch_sub(__d); } // @} group atomics _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ctime000064400000004115147547540550006262 0ustar00// -*- C++ -*- forwarding header. // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/ctime * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c time.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 20.5 Date and time // #pragma GCC system_header #include #include #ifndef _GLIBCXX_CTIME #define _GLIBCXX_CTIME 1 // Get rid of those macros defined in in lieu of real functions. #undef clock #undef difftime #undef mktime #undef time #undef asctime #undef ctime #undef gmtime #undef localtime #undef strftime namespace std { using ::clock_t; using ::time_t; using ::tm; using ::clock; using ::difftime; using ::mktime; using ::time; using ::asctime; using ::ctime; using ::gmtime; using ::localtime; using ::strftime; } // namespace #endif 4.8.2/stdexcept000064400000011156147547540550007167 0ustar00// Standard exception classes -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/stdexcept * This is a Standard C++ Library header. */ // // ISO C++ 19.1 Exception classes // #ifndef _GLIBCXX_STDEXCEPT #define _GLIBCXX_STDEXCEPT 1 #pragma GCC system_header #include #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @addtogroup exceptions * @{ */ /** Logic errors represent problems in the internal logic of a program; * in theory, these are preventable, and even detectable before the * program runs (e.g., violations of class invariants). * @brief One of two subclasses of exception. */ class logic_error : public exception { string _M_msg; public: /** Takes a character string describing the error. */ explicit logic_error(const string& __arg); virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT; /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; /** Thrown by the library, or by you, to report domain errors (domain in * the mathematical sense). */ class domain_error : public logic_error { public: explicit domain_error(const string& __arg); virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to report invalid arguments to functions. */ class invalid_argument : public logic_error { public: explicit invalid_argument(const string& __arg); virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown when an object is constructed that would exceed its maximum * permitted size (e.g., a basic_string instance). */ class length_error : public logic_error { public: explicit length_error(const string& __arg); virtual ~length_error() _GLIBCXX_USE_NOEXCEPT; }; /** This represents an argument whose value is not within the expected * range (e.g., boundary checks in basic_string). */ class out_of_range : public logic_error { public: explicit out_of_range(const string& __arg); virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT; }; /** Runtime errors represent problems outside the scope of a program; * they cannot be easily predicted and can generally only be caught as * the program executes. * @brief One of two subclasses of exception. */ class runtime_error : public exception { string _M_msg; public: /** Takes a character string describing the error. */ explicit runtime_error(const string& __arg); virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT; /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate range errors in internal computations. */ class range_error : public runtime_error { public: explicit range_error(const string& __arg); virtual ~range_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate arithmetic overflow. */ class overflow_error : public runtime_error { public: explicit overflow_error(const string& __arg); virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate arithmetic underflow. */ class underflow_error : public runtime_error { public: explicit underflow_error(const string& __arg); virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT; }; // @} group exceptions _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif /* _GLIBCXX_STDEXCEPT */ 4.8.2/csetjmp000064400000003635147547540550006634 0ustar00// -*- C++ -*- forwarding header. // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file csetjmp * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c setjmp.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 20.4.6 C library // #pragma GCC system_header #include #include #ifndef _GLIBCXX_CSETJMP #define _GLIBCXX_CSETJMP 1 // Get rid of those macros defined in in lieu of real functions. #undef longjmp // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 #ifndef setjmp #define setjmp(env) setjmp (env) #endif namespace std { using ::jmp_buf; using ::longjmp; } // namespace std #endif 4.8.2/ios000064400000003102147547540550005746 0ustar00// Iostreams base classes -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/ios * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.4 Iostreams base classes // #ifndef _GLIBCXX_IOS #define _GLIBCXX_IOS 1 #pragma GCC system_header #include #include // For ios_base::failure #include // For char_traits, streamoff, streamsize, fpos #include // For class locale #include // For ios_base declarations. #include #include #endif /* _GLIBCXX_IOS */ 4.8.2/cstring000064400000006063147547540550006636 0ustar00// -*- C++ -*- forwarding header. // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file cstring * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c string.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 20.4.6 C library // #pragma GCC system_header #include #include #ifndef _GLIBCXX_CSTRING #define _GLIBCXX_CSTRING 1 // Get rid of those macros defined in in lieu of real functions. #undef memchr #undef memcmp #undef memcpy #undef memmove #undef memset #undef strcat #undef strchr #undef strcmp #undef strcoll #undef strcpy #undef strcspn #undef strerror #undef strlen #undef strncat #undef strncmp #undef strncpy #undef strpbrk #undef strrchr #undef strspn #undef strstr #undef strtok #undef strxfrm namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using ::memchr; using ::memcmp; using ::memcpy; using ::memmove; using ::memset; using ::strcat; using ::strcmp; using ::strcoll; using ::strcpy; using ::strcspn; using ::strerror; using ::strlen; using ::strncat; using ::strncmp; using ::strncpy; using ::strspn; using ::strtok; using ::strxfrm; using ::strchr; using ::strpbrk; using ::strrchr; using ::strstr; #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO inline void* memchr(void* __s, int __c, size_t __n) { return __builtin_memchr(__s, __c, __n); } inline char* strchr(char* __s, int __n) { return __builtin_strchr(__s, __n); } inline char* strpbrk(char* __s1, const char* __s2) { return __builtin_strpbrk(__s1, __s2); } inline char* strrchr(char* __s, int __n) { return __builtin_strrchr(__s, __n); } inline char* strstr(char* __s1, const char* __s2) { return __builtin_strstr(__s1, __s2); } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/type_traits000064400000163063147547540550007540 0ustar00// C++11 -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/type_traits * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_TYPE_TRAITS #define _GLIBCXX_TYPE_TRAITS 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @defgroup metaprogramming Metaprogramming * @ingroup utilities * * Template utilities for compile-time introspection and modification, * including type classification traits, type property inspection traits * and type transformation traits. * * @{ */ /// integral_constant template struct integral_constant { static constexpr _Tp value = __v; typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; constexpr operator value_type() { return value; } }; template constexpr _Tp integral_constant<_Tp, __v>::value; /// The type used as a compile-time boolean with true value. typedef integral_constant true_type; /// The type used as a compile-time boolean with false value. typedef integral_constant false_type; // Meta programming helper types. template struct conditional; template struct __or_; template<> struct __or_<> : public false_type { }; template struct __or_<_B1> : public _B1 { }; template struct __or_<_B1, _B2> : public conditional<_B1::value, _B1, _B2>::type { }; template struct __or_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type { }; template struct __and_; template<> struct __and_<> : public true_type { }; template struct __and_<_B1> : public _B1 { }; template struct __and_<_B1, _B2> : public conditional<_B1::value, _B2, _B1>::type { }; template struct __and_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type { }; template struct __not_ : public integral_constant { }; struct __sfinae_types { typedef char __one; typedef struct { char __arr[2]; } __two; }; // For several sfinae-friendly trait implementations we transport both the // result information (as the member type) and the failure information (no // member type). This is very similar to std::enable_if, but we cannot use // them, because we need to derive from them as an implementation detail. template struct __success_type { typedef _Tp type; }; struct __failure_type { }; // Primary type categories. template struct remove_cv; template struct __is_void_helper : public false_type { }; template<> struct __is_void_helper : public true_type { }; /// is_void template struct is_void : public integral_constant::type>::value)> { }; template struct __is_integral_helper : public false_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; #ifdef _GLIBCXX_USE_WCHAR_T template<> struct __is_integral_helper : public true_type { }; #endif template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; template<> struct __is_integral_helper : public true_type { }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) template<> struct __is_integral_helper<__int128> : public true_type { }; template<> struct __is_integral_helper : public true_type { }; #endif /// is_integral template struct is_integral : public integral_constant::type>::value)> { }; template struct __is_floating_point_helper : public false_type { }; template<> struct __is_floating_point_helper : public true_type { }; template<> struct __is_floating_point_helper : public true_type { }; template<> struct __is_floating_point_helper : public true_type { }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) template<> struct __is_floating_point_helper<__float128> : public true_type { }; #endif /// is_floating_point template struct is_floating_point : public integral_constant::type>::value)> { }; /// is_array template struct is_array : public false_type { }; template struct is_array<_Tp[_Size]> : public true_type { }; template struct is_array<_Tp[]> : public true_type { }; template struct __is_pointer_helper : public false_type { }; template struct __is_pointer_helper<_Tp*> : public true_type { }; /// is_pointer template struct is_pointer : public integral_constant::type>::value)> { }; /// is_lvalue_reference template struct is_lvalue_reference : public false_type { }; template struct is_lvalue_reference<_Tp&> : public true_type { }; /// is_rvalue_reference template struct is_rvalue_reference : public false_type { }; template struct is_rvalue_reference<_Tp&&> : public true_type { }; template struct is_function; template struct __is_member_object_pointer_helper : public false_type { }; template struct __is_member_object_pointer_helper<_Tp _Cp::*> : public integral_constant::value> { }; /// is_member_object_pointer template struct is_member_object_pointer : public integral_constant::type>::value)> { }; template struct __is_member_function_pointer_helper : public false_type { }; template struct __is_member_function_pointer_helper<_Tp _Cp::*> : public integral_constant::value> { }; /// is_member_function_pointer template struct is_member_function_pointer : public integral_constant::type>::value)> { }; /// is_enum template struct is_enum : public integral_constant { }; /// is_union template struct is_union : public integral_constant { }; /// is_class template struct is_class : public integral_constant { }; /// is_function template struct is_function : public false_type { }; template struct is_function<_Res(_ArgTypes...)> : public true_type { }; template struct is_function<_Res(_ArgTypes......)> : public true_type { }; template struct is_function<_Res(_ArgTypes...) const> : public true_type { }; template struct is_function<_Res(_ArgTypes......) const> : public true_type { }; template struct is_function<_Res(_ArgTypes...) volatile> : public true_type { }; template struct is_function<_Res(_ArgTypes......) volatile> : public true_type { }; template struct is_function<_Res(_ArgTypes...) const volatile> : public true_type { }; template struct is_function<_Res(_ArgTypes......) const volatile> : public true_type { }; template struct __is_nullptr_t_helper : public false_type { }; template<> struct __is_nullptr_t_helper : public true_type { }; // __is_nullptr_t (extension). template struct __is_nullptr_t : public integral_constant::type>::value)> { }; // Composite type categories. /// is_reference template struct is_reference : public __or_, is_rvalue_reference<_Tp>>::type { }; /// is_arithmetic template struct is_arithmetic : public __or_, is_floating_point<_Tp>>::type { }; /// is_fundamental template struct is_fundamental : public __or_, is_void<_Tp>, __is_nullptr_t<_Tp>>::type { }; /// is_object template struct is_object : public __not_<__or_, is_reference<_Tp>, is_void<_Tp>>>::type { }; template struct is_member_pointer; /// is_scalar template struct is_scalar : public __or_, is_enum<_Tp>, is_pointer<_Tp>, is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type { }; /// is_compound template struct is_compound : public integral_constant::value> { }; template struct __is_member_pointer_helper : public false_type { }; template struct __is_member_pointer_helper<_Tp _Cp::*> : public true_type { }; /// is_member_pointer template struct is_member_pointer : public integral_constant::type>::value)> { }; // Type properties. /// is_const template struct is_const : public false_type { }; template struct is_const<_Tp const> : public true_type { }; /// is_volatile template struct is_volatile : public false_type { }; template struct is_volatile<_Tp volatile> : public true_type { }; /// is_trivial template struct is_trivial : public integral_constant { }; // is_trivially_copyable (still unimplemented) /// is_standard_layout template struct is_standard_layout : public integral_constant { }; /// is_pod // Could use is_standard_layout && is_trivial instead of the builtin. template struct is_pod : public integral_constant { }; /// is_literal_type template struct is_literal_type : public integral_constant { }; /// is_empty template struct is_empty : public integral_constant { }; /// is_polymorphic template struct is_polymorphic : public integral_constant { }; /// is_abstract template struct is_abstract : public integral_constant { }; template::value, bool = is_floating_point<_Tp>::value> struct __is_signed_helper : public false_type { }; template struct __is_signed_helper<_Tp, false, true> : public true_type { }; template struct __is_signed_helper<_Tp, true, false> : public integral_constant(_Tp(-1) < _Tp(0))> { }; /// is_signed template struct is_signed : public integral_constant::value> { }; /// is_unsigned template struct is_unsigned : public __and_, __not_>>::type { }; // Destructible and constructible type properties. template struct add_rvalue_reference; /** * @brief Utility to simplify expressions used in unevaluated operands * @ingroup utilities */ template typename add_rvalue_reference<_Tp>::type declval() noexcept; template struct extent; template struct remove_all_extents; template struct __is_array_known_bounds : public integral_constant::value > 0)> { }; template struct __is_array_unknown_bounds : public __and_, __not_>>::type { }; // In N3290 is_destructible does not say anything about function // types and abstract types, see LWG 2049. This implementation // describes function types as non-destructible and all complete // object types as destructible, iff the explicit destructor // call expression is wellformed. struct __do_is_destructible_impl { template().~_Tp())> static true_type __test(int); template static false_type __test(...); }; template struct __is_destructible_impl : public __do_is_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_, is_scalar<_Tp>>::value> struct __is_destructible_safe; template struct __is_destructible_safe<_Tp, false, false> : public __is_destructible_impl::type>::type { }; template struct __is_destructible_safe<_Tp, true, false> : public false_type { }; template struct __is_destructible_safe<_Tp, false, true> : public true_type { }; /// is_destructible template struct is_destructible : public integral_constant::value)> { }; // is_nothrow_destructible requires that is_destructible is // satisfied as well. We realize that by mimicing the // implementation of is_destructible but refer to noexcept(expr) // instead of decltype(expr). struct __do_is_nt_destructible_impl { template static integral_constant().~_Tp())> __test(int); template static false_type __test(...); }; template struct __is_nt_destructible_impl : public __do_is_nt_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_, is_scalar<_Tp>>::value> struct __is_nt_destructible_safe; template struct __is_nt_destructible_safe<_Tp, false, false> : public __is_nt_destructible_impl::type>::type { }; template struct __is_nt_destructible_safe<_Tp, true, false> : public false_type { }; template struct __is_nt_destructible_safe<_Tp, false, true> : public true_type { }; /// is_nothrow_destructible template struct is_nothrow_destructible : public integral_constant::value)> { }; struct __do_is_default_constructible_impl { template static true_type __test(int); template static false_type __test(...); }; template struct __is_default_constructible_impl : public __do_is_default_constructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template struct __is_default_constructible_atom : public __and_<__not_>, __is_default_constructible_impl<_Tp>>::type { }; template::value> struct __is_default_constructible_safe; // The following technique is a workaround for a current core language // restriction, which does not allow for array types to occur in // functional casts of the form T(). Complete arrays can be default- // constructed, if the element type is default-constructible, but // arrays with unknown bounds are not. template struct __is_default_constructible_safe<_Tp, true> : public __and_<__is_array_known_bounds<_Tp>, __is_default_constructible_atom::type>>::type { }; template struct __is_default_constructible_safe<_Tp, false> : public __is_default_constructible_atom<_Tp>::type { }; /// is_default_constructible template struct is_default_constructible : public integral_constant::value)> { }; // Implementation of is_constructible. // The hardest part of this trait is the binary direct-initialization // case, because we hit into a functional cast of the form T(arg). // This implementation uses different strategies depending on the // target type to reduce the test overhead as much as possible: // // a) For a reference target type, we use a static_cast expression // modulo its extra cases. // // b) For a non-reference target type we use a ::new expression. struct __do_is_static_castable_impl { template(declval<_From>()))> static true_type __test(int); template static false_type __test(...); }; template struct __is_static_castable_impl : public __do_is_static_castable_impl { typedef decltype(__test<_From, _To>(0)) type; }; template struct __is_static_castable_safe : public __is_static_castable_impl<_From, _To>::type { }; // __is_static_castable template struct __is_static_castable : public integral_constant::value)> { }; // Implementation for non-reference types. To meet the proper // variable definition semantics, we also need to test for // is_destructible in this case. // This form should be simplified by a single expression: // ::delete ::new _Tp(declval<_Arg>()), see c++/51222. struct __do_is_direct_constructible_impl { template()))> static true_type __test(int); template static false_type __test(...); }; template struct __is_direct_constructible_impl : public __do_is_direct_constructible_impl { typedef decltype(__test<_Tp, _Arg>(0)) type; }; template struct __is_direct_constructible_new_safe : public __and_, __is_direct_constructible_impl<_Tp, _Arg>>::type { }; template struct is_same; template struct is_base_of; template struct remove_reference; template, is_function<_From>>>::value> struct __is_base_to_derived_ref; // Detect whether we have a downcast situation during // reference binding. template struct __is_base_to_derived_ref<_From, _To, true> { typedef typename remove_cv::type>::type __src_t; typedef typename remove_cv::type>::type __dst_t; typedef __and_<__not_>, is_base_of<__src_t, __dst_t>> type; static constexpr bool value = type::value; }; template struct __is_base_to_derived_ref<_From, _To, false> : public false_type { }; template, is_rvalue_reference<_To>>::value> struct __is_lvalue_to_rvalue_ref; // Detect whether we have an lvalue of non-function type // bound to a reference-compatible rvalue-reference. template struct __is_lvalue_to_rvalue_ref<_From, _To, true> { typedef typename remove_cv::type>::type __src_t; typedef typename remove_cv::type>::type __dst_t; typedef __and_<__not_>, __or_, is_base_of<__dst_t, __src_t>>> type; static constexpr bool value = type::value; }; template struct __is_lvalue_to_rvalue_ref<_From, _To, false> : public false_type { }; // Here we handle direct-initialization to a reference type as // equivalent to a static_cast modulo overshooting conversions. // These are restricted to the following conversions: // a) A base class value to a derived class reference // b) An lvalue to an rvalue-reference of reference-compatible // types that are not functions template struct __is_direct_constructible_ref_cast : public __and_<__is_static_castable<_Arg, _Tp>, __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>, __is_lvalue_to_rvalue_ref<_Arg, _Tp> >>>::type { }; template struct __is_direct_constructible_new : public conditional::value, __is_direct_constructible_ref_cast<_Tp, _Arg>, __is_direct_constructible_new_safe<_Tp, _Arg> >::type { }; template struct __is_direct_constructible : public integral_constant::value)> { }; // Since default-construction and binary direct-initialization have // been handled separately, the implementation of the remaining // n-ary construction cases is rather straightforward. We can use // here a functional cast, because array types are excluded anyway // and this form is never interpreted as a C cast. struct __do_is_nary_constructible_impl { template()...))> static true_type __test(int); template static false_type __test(...); }; template struct __is_nary_constructible_impl : public __do_is_nary_constructible_impl { typedef decltype(__test<_Tp, _Args...>(0)) type; }; template struct __is_nary_constructible : public __is_nary_constructible_impl<_Tp, _Args...>::type { static_assert(sizeof...(_Args) > 1, "Only useful for > 1 arguments"); }; template struct __is_constructible_impl : public __is_nary_constructible<_Tp, _Args...> { }; template struct __is_constructible_impl<_Tp, _Arg> : public __is_direct_constructible<_Tp, _Arg> { }; template struct __is_constructible_impl<_Tp> : public is_default_constructible<_Tp> { }; /// is_constructible template struct is_constructible : public integral_constant::value)> { }; template::value> struct __is_copy_constructible_impl; template struct __is_copy_constructible_impl<_Tp, true> : public false_type { }; template struct __is_copy_constructible_impl<_Tp, false> : public is_constructible<_Tp, const _Tp&> { }; /// is_copy_constructible template struct is_copy_constructible : public __is_copy_constructible_impl<_Tp> { }; template::value> struct __is_move_constructible_impl; template struct __is_move_constructible_impl<_Tp, true> : public false_type { }; template struct __is_move_constructible_impl<_Tp, false> : public is_constructible<_Tp, _Tp&&> { }; /// is_move_constructible template struct is_move_constructible : public __is_move_constructible_impl<_Tp> { }; template struct __is_nt_default_constructible_atom : public integral_constant { }; template::value> struct __is_nt_default_constructible_impl; template struct __is_nt_default_constructible_impl<_Tp, true> : public __and_<__is_array_known_bounds<_Tp>, __is_nt_default_constructible_atom::type>>::type { }; template struct __is_nt_default_constructible_impl<_Tp, false> : public __is_nt_default_constructible_atom<_Tp> { }; /// is_nothrow_default_constructible template struct is_nothrow_default_constructible : public __and_, __is_nt_default_constructible_impl<_Tp>>::type { }; template struct __is_nt_constructible_impl : public integral_constant()...))> { }; template struct __is_nt_constructible_impl<_Tp, _Arg> : public integral_constant(declval<_Arg>()))> { }; template struct __is_nt_constructible_impl<_Tp> : public is_nothrow_default_constructible<_Tp> { }; /// is_nothrow_constructible template struct is_nothrow_constructible : public __and_, __is_nt_constructible_impl<_Tp, _Args...>>::type { }; template::value> struct __is_nothrow_copy_constructible_impl; template struct __is_nothrow_copy_constructible_impl<_Tp, true> : public false_type { }; template struct __is_nothrow_copy_constructible_impl<_Tp, false> : public is_nothrow_constructible<_Tp, const _Tp&> { }; /// is_nothrow_copy_constructible template struct is_nothrow_copy_constructible : public __is_nothrow_copy_constructible_impl<_Tp> { }; template::value> struct __is_nothrow_move_constructible_impl; template struct __is_nothrow_move_constructible_impl<_Tp, true> : public false_type { }; template struct __is_nothrow_move_constructible_impl<_Tp, false> : public is_nothrow_constructible<_Tp, _Tp&&> { }; /// is_nothrow_move_constructible template struct is_nothrow_move_constructible : public __is_nothrow_move_constructible_impl<_Tp> { }; template class __is_assignable_helper : public __sfinae_types { template static decltype(declval<_Tp1>() = declval<_Up1>(), __one()) __test(int); template static __two __test(...); public: static constexpr bool value = sizeof(__test<_Tp, _Up>(0)) == 1; }; /// is_assignable template struct is_assignable : public integral_constant::value> { }; template::value> struct __is_copy_assignable_impl; template struct __is_copy_assignable_impl<_Tp, true> : public false_type { }; template struct __is_copy_assignable_impl<_Tp, false> : public is_assignable<_Tp&, const _Tp&> { }; /// is_copy_assignable template struct is_copy_assignable : public __is_copy_assignable_impl<_Tp> { }; template::value> struct __is_move_assignable_impl; template struct __is_move_assignable_impl<_Tp, true> : public false_type { }; template struct __is_move_assignable_impl<_Tp, false> : public is_assignable<_Tp&, _Tp&&> { }; /// is_move_assignable template struct is_move_assignable : public __is_move_assignable_impl<_Tp> { }; template struct __is_nt_assignable_impl : public integral_constant() = declval<_Up>())> { }; /// is_nothrow_assignable template struct is_nothrow_assignable : public __and_, __is_nt_assignable_impl<_Tp, _Up>>::type { }; template::value> struct __is_nt_copy_assignable_impl; template struct __is_nt_copy_assignable_impl<_Tp, true> : public false_type { }; template struct __is_nt_copy_assignable_impl<_Tp, false> : public is_nothrow_assignable<_Tp&, const _Tp&> { }; /// is_nothrow_copy_assignable template struct is_nothrow_copy_assignable : public __is_nt_copy_assignable_impl<_Tp> { }; template::value> struct __is_nt_move_assignable_impl; template struct __is_nt_move_assignable_impl<_Tp, true> : public false_type { }; template struct __is_nt_move_assignable_impl<_Tp, false> : public is_nothrow_assignable<_Tp&, _Tp&&> { }; /// is_nothrow_move_assignable template struct is_nothrow_move_assignable : public __is_nt_move_assignable_impl<_Tp> { }; /// is_trivially_constructible (still unimplemented) /// is_trivially_default_constructible (still unimplemented) /// is_trivially_copy_constructible (still unimplemented) /// is_trivially_move_constructible (still unimplemented) /// is_trivially_assignable (still unimplemented) /// is_trivially_copy_assignable (still unimplemented) /// is_trivially_move_assignable (still unimplemented) /// is_trivially_destructible template struct is_trivially_destructible : public __and_, integral_constant>::type { }; /// has_trivial_default_constructor (temporary legacy) template struct has_trivial_default_constructor : public integral_constant { }; /// has_trivial_copy_constructor (temporary legacy) template struct has_trivial_copy_constructor : public integral_constant { }; /// has_trivial_copy_assign (temporary legacy) template struct has_trivial_copy_assign : public integral_constant { }; /// has_virtual_destructor template struct has_virtual_destructor : public integral_constant { }; // type property queries. /// alignment_of template struct alignment_of : public integral_constant { }; /// rank template struct rank : public integral_constant { }; template struct rank<_Tp[_Size]> : public integral_constant::value> { }; template struct rank<_Tp[]> : public integral_constant::value> { }; /// extent template struct extent : public integral_constant { }; template struct extent<_Tp[_Size], _Uint> : public integral_constant::value> { }; template struct extent<_Tp[], _Uint> : public integral_constant::value> { }; // Type relations. /// is_same template struct is_same : public false_type { }; template struct is_same<_Tp, _Tp> : public true_type { }; /// is_base_of template struct is_base_of : public integral_constant { }; template, is_function<_To>, is_array<_To>>::value> struct __is_convertible_helper { static constexpr bool value = is_void<_To>::value; }; template class __is_convertible_helper<_From, _To, false> : public __sfinae_types { template static void __test_aux(_To1); template static decltype(__test_aux<_To1>(std::declval<_From1>()), __one()) __test(int); template static __two __test(...); public: static constexpr bool value = sizeof(__test<_From, _To>(0)) == 1; }; /// is_convertible template struct is_convertible : public integral_constant::value> { }; // Const-volatile modifications. /// remove_const template struct remove_const { typedef _Tp type; }; template struct remove_const<_Tp const> { typedef _Tp type; }; /// remove_volatile template struct remove_volatile { typedef _Tp type; }; template struct remove_volatile<_Tp volatile> { typedef _Tp type; }; /// remove_cv template struct remove_cv { typedef typename remove_const::type>::type type; }; /// add_const template struct add_const { typedef _Tp const type; }; /// add_volatile template struct add_volatile { typedef _Tp volatile type; }; /// add_cv template struct add_cv { typedef typename add_const::type>::type type; }; // Reference transformations. /// remove_reference template struct remove_reference { typedef _Tp type; }; template struct remove_reference<_Tp&> { typedef _Tp type; }; template struct remove_reference<_Tp&&> { typedef _Tp type; }; template>, __not_>>::value, bool = is_rvalue_reference<_Tp>::value> struct __add_lvalue_reference_helper { typedef _Tp type; }; template struct __add_lvalue_reference_helper<_Tp, true, false> { typedef _Tp& type; }; template struct __add_lvalue_reference_helper<_Tp, false, true> { typedef typename remove_reference<_Tp>::type& type; }; /// add_lvalue_reference template struct add_lvalue_reference : public __add_lvalue_reference_helper<_Tp> { }; template>, __not_>>::value> struct __add_rvalue_reference_helper { typedef _Tp type; }; template struct __add_rvalue_reference_helper<_Tp, true> { typedef _Tp&& type; }; /// add_rvalue_reference template struct add_rvalue_reference : public __add_rvalue_reference_helper<_Tp> { }; // Sign modifications. // Utility for constructing identically cv-qualified types. template struct __cv_selector; template struct __cv_selector<_Unqualified, false, false> { typedef _Unqualified __type; }; template struct __cv_selector<_Unqualified, false, true> { typedef volatile _Unqualified __type; }; template struct __cv_selector<_Unqualified, true, false> { typedef const _Unqualified __type; }; template struct __cv_selector<_Unqualified, true, true> { typedef const volatile _Unqualified __type; }; template::value, bool _IsVol = is_volatile<_Qualified>::value> class __match_cv_qualifiers { typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; public: typedef typename __match::__type __type; }; // Utility for finding the unsigned versions of signed integral types. template struct __make_unsigned { typedef _Tp __type; }; template<> struct __make_unsigned { typedef unsigned char __type; }; template<> struct __make_unsigned { typedef unsigned char __type; }; template<> struct __make_unsigned { typedef unsigned short __type; }; template<> struct __make_unsigned { typedef unsigned int __type; }; template<> struct __make_unsigned { typedef unsigned long __type; }; template<> struct __make_unsigned { typedef unsigned long long __type; }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) template<> struct __make_unsigned<__int128> { typedef unsigned __int128 __type; }; #endif // Select between integral and enum: not possible to be both. template::value, bool _IsEnum = is_enum<_Tp>::value> class __make_unsigned_selector; template class __make_unsigned_selector<_Tp, true, false> { typedef __make_unsigned::type> __unsignedt; typedef typename __unsignedt::__type __unsigned_type; typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; public: typedef typename __cv_unsigned::__type __type; }; template class __make_unsigned_selector<_Tp, false, true> { // With -fshort-enums, an enum may be as small as a char. typedef unsigned char __smallest; static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short); static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int); typedef conditional<__b2, unsigned int, unsigned long> __cond2; typedef typename __cond2::type __cond2_type; typedef conditional<__b1, unsigned short, __cond2_type> __cond1; typedef typename __cond1::type __cond1_type; public: typedef typename conditional<__b0, __smallest, __cond1_type>::type __type; }; // Given an integral/enum type, return the corresponding unsigned // integer type. // Primary template. /// make_unsigned template struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; // Integral, but don't define. template<> struct make_unsigned; // Utility for finding the signed versions of unsigned integral types. template struct __make_signed { typedef _Tp __type; }; template<> struct __make_signed { typedef signed char __type; }; template<> struct __make_signed { typedef signed char __type; }; template<> struct __make_signed { typedef signed short __type; }; template<> struct __make_signed { typedef signed int __type; }; template<> struct __make_signed { typedef signed long __type; }; template<> struct __make_signed { typedef signed long long __type; }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) template<> struct __make_signed { typedef __int128 __type; }; #endif // Select between integral and enum: not possible to be both. template::value, bool _IsEnum = is_enum<_Tp>::value> class __make_signed_selector; template class __make_signed_selector<_Tp, true, false> { typedef __make_signed::type> __signedt; typedef typename __signedt::__type __signed_type; typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; public: typedef typename __cv_signed::__type __type; }; template class __make_signed_selector<_Tp, false, true> { // With -fshort-enums, an enum may be as small as a char. typedef signed char __smallest; static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); static const bool __b1 = sizeof(_Tp) <= sizeof(signed short); static const bool __b2 = sizeof(_Tp) <= sizeof(signed int); typedef conditional<__b2, signed int, signed long> __cond2; typedef typename __cond2::type __cond2_type; typedef conditional<__b1, signed short, __cond2_type> __cond1; typedef typename __cond1::type __cond1_type; public: typedef typename conditional<__b0, __smallest, __cond1_type>::type __type; }; // Given an integral/enum type, return the corresponding signed // integer type. // Primary template. /// make_signed template struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; // Integral, but don't define. template<> struct make_signed; // Array modifications. /// remove_extent template struct remove_extent { typedef _Tp type; }; template struct remove_extent<_Tp[_Size]> { typedef _Tp type; }; template struct remove_extent<_Tp[]> { typedef _Tp type; }; /// remove_all_extents template struct remove_all_extents { typedef _Tp type; }; template struct remove_all_extents<_Tp[_Size]> { typedef typename remove_all_extents<_Tp>::type type; }; template struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; // Pointer modifications. template struct __remove_pointer_helper { typedef _Tp type; }; template struct __remove_pointer_helper<_Tp, _Up*> { typedef _Up type; }; /// remove_pointer template struct remove_pointer : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> { }; /// add_pointer template struct add_pointer { typedef typename remove_reference<_Tp>::type* type; }; template struct __aligned_storage_msa { union __type { unsigned char __data[_Len]; struct __attribute__((__aligned__)) { } __align; }; }; /** * @brief Alignment type. * * The value of _Align is a default-alignment which shall be the * most stringent alignment requirement for any C++ object type * whose size is no greater than _Len (3.9). The member typedef * type shall be a POD type suitable for use as uninitialized * storage for any object whose size is at most _Len and whose * alignment is a divisor of _Align. */ template::__type)> struct aligned_storage { union type { unsigned char __data[_Len]; struct __attribute__((__aligned__((_Align)))) { } __align; }; }; // Decay trait for arrays and functions, used for perfect forwarding // in make_pair, make_tuple, etc. template::value, bool _IsFunction = is_function<_Up>::value> struct __decay_selector; // NB: DR 705. template struct __decay_selector<_Up, false, false> { typedef typename remove_cv<_Up>::type __type; }; template struct __decay_selector<_Up, true, false> { typedef typename remove_extent<_Up>::type* __type; }; template struct __decay_selector<_Up, false, true> { typedef typename add_pointer<_Up>::type __type; }; /// decay template class decay { typedef typename remove_reference<_Tp>::type __remove_type; public: typedef typename __decay_selector<__remove_type>::__type type; }; template class reference_wrapper; // Helper which adds a reference to a type when given a reference_wrapper template struct __strip_reference_wrapper { typedef _Tp __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template struct __decay_and_strip { typedef typename __strip_reference_wrapper< typename decay<_Tp>::type>::__type __type; }; // Primary template. /// Define a member typedef @c type only if a boolean constant is true. template struct enable_if { }; // Partial specialization for true. template struct enable_if { typedef _Tp type; }; template using _Require = typename enable_if<__and_<_Cond...>::value>::type; // Primary template. /// Define a member typedef @c type to one of two argument types. template struct conditional { typedef _Iftrue type; }; // Partial specialization for false. template struct conditional { typedef _Iffalse type; }; /// common_type template struct common_type; // Sfinae-friendly common_type implementation: struct __do_common_type_impl { template static __success_type() : std::declval<_Up>())>::type> _S_test(int); template static __failure_type _S_test(...); }; template struct __common_type_impl : private __do_common_type_impl { typedef decltype(_S_test<_Tp, _Up>(0)) type; }; struct __do_member_type_wrapper { template static __success_type _S_test(int); template static __failure_type _S_test(...); }; template struct __member_type_wrapper : private __do_member_type_wrapper { typedef decltype(_S_test<_Tp>(0)) type; }; template struct __expanded_common_type_wrapper { typedef common_type type; }; template struct __expanded_common_type_wrapper<__failure_type, _Args...> { typedef __failure_type type; }; template struct common_type<_Tp> { typedef typename decay<_Tp>::type type; }; template struct common_type<_Tp, _Up> : public __common_type_impl<_Tp, _Up>::type { }; template struct common_type<_Tp, _Up, _Vp...> : public __expanded_common_type_wrapper>::type, _Vp...>::type { }; /// The underlying type of an enum. template struct underlying_type { typedef __underlying_type(_Tp) type; }; template struct __declval_protector { static const bool __stop = false; static typename add_rvalue_reference<_Tp>::type __delegate(); }; template inline typename add_rvalue_reference<_Tp>::type declval() noexcept { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); return __declval_protector<_Tp>::__delegate(); } /// result_of template class result_of; // Sfinae-friendly result_of implementation: // [func.require] paragraph 1 bullet 1: struct __result_of_memfun_ref_impl { template static __success_type().*std::declval<_Fp>())(std::declval<_Args>()...) )> _S_test(int); template static __failure_type _S_test(...); }; template struct __result_of_memfun_ref : private __result_of_memfun_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; // [func.require] paragraph 1 bullet 2: struct __result_of_memfun_deref_impl { template static __success_type()).*std::declval<_Fp>())(std::declval<_Args>()...) )> _S_test(int); template static __failure_type _S_test(...); }; template struct __result_of_memfun_deref : private __result_of_memfun_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; // [func.require] paragraph 1 bullet 3: struct __result_of_memobj_ref_impl { template static __success_type().*std::declval<_Fp>() )> _S_test(int); template static __failure_type _S_test(...); }; template struct __result_of_memobj_ref : private __result_of_memobj_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; // [func.require] paragraph 1 bullet 4: struct __result_of_memobj_deref_impl { template static __success_type()).*std::declval<_Fp>() )> _S_test(int); template static __failure_type _S_test(...); }; template struct __result_of_memobj_deref : private __result_of_memobj_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; template struct __result_of_memobj; template struct __result_of_memobj<_Res _Class::*, _Arg> { typedef typename remove_cv::type>::type _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<__or_, is_base_of<_Class, _Argval>>::value, __result_of_memobj_ref<_MemPtr, _Arg>, __result_of_memobj_deref<_MemPtr, _Arg> >::type::type type; }; template struct __result_of_memfun; template struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> { typedef typename remove_cv::type>::type _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<__or_, is_base_of<_Class, _Argval>>::value, __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, __result_of_memfun_deref<_MemPtr, _Arg, _Args...> >::type::type type; }; template struct __result_of_impl { typedef __failure_type type; }; template struct __result_of_impl : public __result_of_memobj::type, _Arg> { }; template struct __result_of_impl : public __result_of_memfun::type, _Arg, _Args...> { }; // [func.require] paragraph 1 bullet 5: struct __result_of_other_impl { template static __success_type()(std::declval<_Args>()...) )> _S_test(int); template static __failure_type _S_test(...); }; template struct __result_of_impl : private __result_of_other_impl { typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; }; template struct result_of<_Functor(_ArgTypes...)> : public __result_of_impl< is_member_object_pointer< typename remove_reference<_Functor>::type >::value, is_member_function_pointer< typename remove_reference<_Functor>::type >::value, _Functor, _ArgTypes... >::type { }; /// @} group metaprogramming /** * Use SFINAE to determine if the type _Tp has a publicly-accessible * member type _NTYPE. */ #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ template \ class __has_##_NTYPE##_helper \ : __sfinae_types \ { \ template \ struct _Wrap_type \ { }; \ \ template \ static __one __test(_Wrap_type*); \ \ template \ static __two __test(...); \ \ public: \ static constexpr bool value = sizeof(__test<_Tp>(0)) == 1; \ }; \ \ template \ struct __has_##_NTYPE \ : integral_constant::type>::value> \ { }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_TYPE_TRAITS 4.8.2/iomanip000064400000026327147547540550006626 0ustar00// Standard stream manipulators -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/iomanip * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.6.3 Standard manipulators // #ifndef _GLIBCXX_IOMANIP #define _GLIBCXX_IOMANIP 1 #pragma GCC system_header #include #include #include #if __cplusplus >= 201103L #include #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // [27.6.3] standard manipulators // Also see DR 183. struct _Resetiosflags { ios_base::fmtflags _M_mask; }; /** * @brief Manipulator for @c setf. * @param __mask A format flags mask. * * Sent to a stream object, this manipulator resets the specified flags, * via @e stream.setf(0,__mask). */ inline _Resetiosflags resetiosflags(ios_base::fmtflags __mask) { return { __mask }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) { __is.setf(ios_base::fmtflags(0), __f._M_mask); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f) { __os.setf(ios_base::fmtflags(0), __f._M_mask); return __os; } struct _Setiosflags { ios_base::fmtflags _M_mask; }; /** * @brief Manipulator for @c setf. * @param __mask A format flags mask. * * Sent to a stream object, this manipulator sets the format flags * to @a __mask. */ inline _Setiosflags setiosflags(ios_base::fmtflags __mask) { return { __mask }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) { __is.setf(__f._M_mask); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f) { __os.setf(__f._M_mask); return __os; } struct _Setbase { int _M_base; }; /** * @brief Manipulator for @c setf. * @param __base A numeric base. * * Sent to a stream object, this manipulator changes the * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base * is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value. */ inline _Setbase setbase(int __base) { return { __base }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) { __is.setf(__f._M_base == 8 ? ios_base::oct : __f._M_base == 10 ? ios_base::dec : __f._M_base == 16 ? ios_base::hex : ios_base::fmtflags(0), ios_base::basefield); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f) { __os.setf(__f._M_base == 8 ? ios_base::oct : __f._M_base == 10 ? ios_base::dec : __f._M_base == 16 ? ios_base::hex : ios_base::fmtflags(0), ios_base::basefield); return __os; } template struct _Setfill { _CharT _M_c; }; /** * @brief Manipulator for @c fill. * @param __c The new fill character. * * Sent to a stream object, this manipulator calls @c fill(__c) for that * object. */ template inline _Setfill<_CharT> setfill(_CharT __c) { return { __c }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f) { __is.fill(__f._M_c); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f) { __os.fill(__f._M_c); return __os; } struct _Setprecision { int _M_n; }; /** * @brief Manipulator for @c precision. * @param __n The new precision. * * Sent to a stream object, this manipulator calls @c precision(__n) for * that object. */ inline _Setprecision setprecision(int __n) { return { __n }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f) { __is.precision(__f._M_n); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f) { __os.precision(__f._M_n); return __os; } struct _Setw { int _M_n; }; /** * @brief Manipulator for @c width. * @param __n The new width. * * Sent to a stream object, this manipulator calls @c width(__n) for * that object. */ inline _Setw setw(int __n) { return { __n }; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f) { __is.width(__f._M_n); return __is; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f) { __os.width(__f._M_n); return __os; } #if __cplusplus >= 201103L template struct _Get_money { _MoneyT& _M_mon; bool _M_intl; }; /** * @brief Extended manipulator for extracting money. * @param __mon Either long double or a specialization of @c basic_string. * @param __intl A bool indicating whether international format * is to be used. * * Sent to a stream object, this manipulator extracts @a __mon. */ template inline _Get_money<_MoneyT> get_money(_MoneyT& __mon, bool __intl = false) { return { __mon, __intl }; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f) { typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false); if (__cerb) { ios_base::iostate __err = ios_base::goodbit; __try { typedef istreambuf_iterator<_CharT, _Traits> _Iter; typedef money_get<_CharT, _Iter> _MoneyGet; const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc()); __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl, __is, __err, __f._M_mon); } __catch(__cxxabiv1::__forced_unwind&) { __is._M_setstate(ios_base::badbit); __throw_exception_again; } __catch(...) { __is._M_setstate(ios_base::badbit); } if (__err) __is.setstate(__err); } return __is; } template struct _Put_money { const _MoneyT& _M_mon; bool _M_intl; }; /** * @brief Extended manipulator for inserting money. * @param __mon Either long double or a specialization of @c basic_string. * @param __intl A bool indicating whether international format * is to be used. * * Sent to a stream object, this manipulator inserts @a __mon. */ template inline _Put_money<_MoneyT> put_money(const _MoneyT& __mon, bool __intl = false) { return { __mon, __intl }; } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f) { typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); if (__cerb) { ios_base::iostate __err = ios_base::goodbit; __try { typedef ostreambuf_iterator<_CharT, _Traits> _Iter; typedef money_put<_CharT, _Iter> _MoneyPut; const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc()); if (__mp.put(_Iter(__os.rdbuf()), __f._M_intl, __os, __os.fill(), __f._M_mon).failed()) __err |= ios_base::badbit; } __catch(__cxxabiv1::__forced_unwind&) { __os._M_setstate(ios_base::badbit); __throw_exception_again; } __catch(...) { __os._M_setstate(ios_base::badbit); } if (__err) __os.setstate(__err); } return __os; } #endif // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. #if _GLIBCXX_EXTERN_TEMPLATE extern template ostream& operator<<(ostream&, _Setfill); extern template ostream& operator<<(ostream&, _Setiosflags); extern template ostream& operator<<(ostream&, _Resetiosflags); extern template ostream& operator<<(ostream&, _Setbase); extern template ostream& operator<<(ostream&, _Setprecision); extern template ostream& operator<<(ostream&, _Setw); extern template istream& operator>>(istream&, _Setfill); extern template istream& operator>>(istream&, _Setiosflags); extern template istream& operator>>(istream&, _Resetiosflags); extern template istream& operator>>(istream&, _Setbase); extern template istream& operator>>(istream&, _Setprecision); extern template istream& operator>>(istream&, _Setw); #ifdef _GLIBCXX_USE_WCHAR_T extern template wostream& operator<<(wostream&, _Setfill); extern template wostream& operator<<(wostream&, _Setiosflags); extern template wostream& operator<<(wostream&, _Resetiosflags); extern template wostream& operator<<(wostream&, _Setbase); extern template wostream& operator<<(wostream&, _Setprecision); extern template wostream& operator<<(wostream&, _Setw); extern template wistream& operator>>(wistream&, _Setfill); extern template wistream& operator>>(wistream&, _Setiosflags); extern template wistream& operator>>(wistream&, _Resetiosflags); extern template wistream& operator>>(wistream&, _Setbase); extern template wistream& operator>>(wistream&, _Setprecision); extern template wistream& operator>>(wistream&, _Setw); #endif #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif /* _GLIBCXX_IOMANIP */ 4.8.2/cstdint000064400000004167147547540550006640 0ustar00// -*- C++ -*- // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/cstdint * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_CSTDINT #define _GLIBCXX_CSTDINT 1 #pragma GCC system_header #if __cplusplus < 201103L # include #else #include #if _GLIBCXX_HAVE_STDINT_H # include #endif #ifdef _GLIBCXX_USE_C99_STDINT_TR1 namespace std { using ::int8_t; using ::int16_t; using ::int32_t; using ::int64_t; using ::int_fast8_t; using ::int_fast16_t; using ::int_fast32_t; using ::int_fast64_t; using ::int_least8_t; using ::int_least16_t; using ::int_least32_t; using ::int_least64_t; using ::intmax_t; using ::intptr_t; using ::uint8_t; using ::uint16_t; using ::uint32_t; using ::uint64_t; using ::uint_fast8_t; using ::uint_fast16_t; using ::uint_fast32_t; using ::uint_fast64_t; using ::uint_least8_t; using ::uint_least16_t; using ::uint_least32_t; using ::uint_least64_t; using ::uintmax_t; using ::uintptr_t; } // namespace std #endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 #endif // _GLIBCXX_CSTDINT 4.8.2/limits000064400000203266147547540550006472 0ustar00// The template and inlines for the numeric_limits classes. -*- C++ -*- // Copyright (C) 1999-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/limits * This is a Standard C++ Library header. */ // Note: this is not a conforming implementation. // Written by Gabriel Dos Reis // // ISO 14882:1998 // 18.2.1 // #ifndef _GLIBCXX_NUMERIC_LIMITS #define _GLIBCXX_NUMERIC_LIMITS 1 #pragma GCC system_header #include // // The numeric_limits<> traits document implementation-defined aspects // of fundamental arithmetic data types (integers and floating points). // From Standard C++ point of view, there are 14 such types: // * integers // bool (1) // char, signed char, unsigned char, wchar_t (4) // short, unsigned short (2) // int, unsigned (2) // long, unsigned long (2) // // * floating points // float (1) // double (1) // long double (1) // // GNU C++ understands (where supported by the host C-library) // * integer // long long, unsigned long long (2) // // which brings us to 16 fundamental arithmetic data types in GNU C++. // // // Since a numeric_limits<> is a bit tricky to get right, we rely on // an interface composed of macros which should be defined in config/os // or config/cpu when they differ from the generic (read arbitrary) // definitions given here. // // These values can be overridden in the target configuration file. // The default values are appropriate for many 32-bit targets. // GCC only intrinsically supports modulo integral types. The only remaining // integral exceptional values is division by zero. Only targets that do not // signal division by zero in some "hard to ignore" way should use false. #ifndef __glibcxx_integral_traps # define __glibcxx_integral_traps true #endif // float // // Default values. Should be overridden in configuration files if necessary. #ifndef __glibcxx_float_has_denorm_loss # define __glibcxx_float_has_denorm_loss false #endif #ifndef __glibcxx_float_traps # define __glibcxx_float_traps false #endif #ifndef __glibcxx_float_tinyness_before # define __glibcxx_float_tinyness_before false #endif // double // Default values. Should be overridden in configuration files if necessary. #ifndef __glibcxx_double_has_denorm_loss # define __glibcxx_double_has_denorm_loss false #endif #ifndef __glibcxx_double_traps # define __glibcxx_double_traps false #endif #ifndef __glibcxx_double_tinyness_before # define __glibcxx_double_tinyness_before false #endif // long double // Default values. Should be overridden in configuration files if necessary. #ifndef __glibcxx_long_double_has_denorm_loss # define __glibcxx_long_double_has_denorm_loss false #endif #ifndef __glibcxx_long_double_traps # define __glibcxx_long_double_traps false #endif #ifndef __glibcxx_long_double_tinyness_before # define __glibcxx_long_double_tinyness_before false #endif // You should not need to define any macros below this point. #define __glibcxx_signed(T) ((T)(-1) < 0) #define __glibcxx_min(T) \ (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0) #define __glibcxx_max(T) \ (__glibcxx_signed (T) ? \ (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0) #define __glibcxx_digits(T) \ (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T)) // The fraction 643/2136 approximates log10(2) to 7 significant digits. #define __glibcxx_digits10(T) \ (__glibcxx_digits (T) * 643L / 2136) #define __glibcxx_max_digits10(T) \ (2 + (T) * 643L / 2136) namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Describes the rounding style for floating-point types. * * This is used in the std::numeric_limits class. */ enum float_round_style { round_indeterminate = -1, /// Intermediate. round_toward_zero = 0, /// To zero. round_to_nearest = 1, /// To the nearest representable value. round_toward_infinity = 2, /// To infinity. round_toward_neg_infinity = 3 /// To negative infinity. }; /** * @brief Describes the denormalization for floating-point types. * * These values represent the presence or absence of a variable number * of exponent bits. This type is used in the std::numeric_limits class. */ enum float_denorm_style { /// Indeterminate at compile time whether denormalized values are allowed. denorm_indeterminate = -1, /// The type does not allow denormalized values. denorm_absent = 0, /// The type allows denormalized values. denorm_present = 1 }; /** * @brief Part of std::numeric_limits. * * The @c static @c const members are usable as integral constant * expressions. * * @note This is a separate class for purposes of efficiency; you * should only access these members as part of an instantiation * of the std::numeric_limits class. */ struct __numeric_limits_base { /** This will be true for all fundamental types (which have specializations), and false for everything else. */ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = false; /** The number of @c radix digits that be represented without change: for integer types, the number of non-sign bits in the mantissa; for floating types, the number of @c radix digits in the mantissa. */ static _GLIBCXX_USE_CONSTEXPR int digits = 0; /** The number of base 10 digits that can be represented without change. */ static _GLIBCXX_USE_CONSTEXPR int digits10 = 0; #if __cplusplus >= 201103L /** The number of base 10 digits required to ensure that values which differ are always differentiated. */ static constexpr int max_digits10 = 0; #endif /** True if the type is signed. */ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; /** True if the type is integer. */ static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; /** True if the type uses an exact representation. All integer types are exact, but not all exact types are integer. For example, rational and fixed-exponent representations are exact but not integer. */ static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; /** For integer types, specifies the base of the representation. For floating types, specifies the base of the exponent representation. */ static _GLIBCXX_USE_CONSTEXPR int radix = 0; /** The minimum negative integer such that @c radix raised to the power of (one less than that integer) is a normalized floating point number. */ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; /** The minimum negative integer such that 10 raised to that power is in the range of normalized floating point numbers. */ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; /** The maximum positive integer such that @c radix raised to the power of (one less than that integer) is a representable finite floating point number. */ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; /** The maximum positive integer such that 10 raised to that power is in the range of representable finite floating point numbers. */ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; /** True if the type has a representation for positive infinity. */ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; /** True if the type has a representation for a quiet (non-signaling) Not a Number. */ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; /** True if the type has a representation for a signaling Not a Number. */ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; /** See std::float_denorm_style for more information. */ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; /** True if loss of accuracy is detected as a denormalization loss, rather than as an inexact result. */ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; /** True if-and-only-if the type adheres to the IEC 559 standard, also known as IEEE 754. (Only makes sense for floating point types.) */ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; /** True if the set of values representable by the type is finite. All built-in types are bounded, this member would be false for arbitrary precision types. */ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = false; /** True if the type is @e modulo. A type is modulo if, for any operation involving +, -, or * on values of that type whose result would fall outside the range [min(),max()], the value returned differs from the true value by an integer multiple of max() - min() + 1. On most machines, this is false for floating types, true for unsigned integers, and true for signed integers. See PR22200 about signed integers. */ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; /** True if trapping is implemented for this type. */ static _GLIBCXX_USE_CONSTEXPR bool traps = false; /** True if tininess is detected before rounding. (see IEC 559) */ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; /** See std::float_round_style for more information. This is only meaningful for floating types; integer types will all be round_toward_zero. */ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /** * @brief Properties of fundamental types. * * This class allows a program to obtain information about the * representation of a fundamental type on a given platform. For * non-fundamental types, the functions will return 0 and the data * members will all be @c false. * * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are * noted, but not incorporated in this documented (yet). */ template struct numeric_limits : public __numeric_limits_base { /** The minimum finite value, or for floating types with denormalization, the minimum positive normalized value. */ static _GLIBCXX_CONSTEXPR _Tp min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The maximum finite value. */ static _GLIBCXX_CONSTEXPR _Tp max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } #if __cplusplus >= 201103L /** A finite value x such that there is no other finite value y * where y < x. */ static constexpr _Tp lowest() noexcept { return _Tp(); } #endif /** The @e machine @e epsilon: the difference between 1 and the least value greater than 1 that is representable. */ static _GLIBCXX_CONSTEXPR _Tp epsilon() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The maximum rounding error measurement (see LIA-1). */ static _GLIBCXX_CONSTEXPR _Tp round_error() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The representation of positive infinity, if @c has_infinity. */ static _GLIBCXX_CONSTEXPR _Tp infinity() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The representation of a quiet Not a Number, if @c has_quiet_NaN. */ static _GLIBCXX_CONSTEXPR _Tp quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The representation of a signaling Not a Number, if @c has_signaling_NaN. */ static _GLIBCXX_CONSTEXPR _Tp signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } /** The minimum positive denormalized value. For types where @c has_denorm is false, this is the minimum positive normalized value. */ static _GLIBCXX_CONSTEXPR _Tp denorm_min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } }; #if __cplusplus >= 201103L template struct numeric_limits : public numeric_limits<_Tp> { }; template struct numeric_limits : public numeric_limits<_Tp> { }; template struct numeric_limits : public numeric_limits<_Tp> { }; #endif // Now there follow 16 explicit specializations. Yes, 16. Make sure // you get the count right. (18 in c++0x mode) /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR bool min() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_CONSTEXPR bool max() _GLIBCXX_USE_NOEXCEPT { return true; } #if __cplusplus >= 201103L static constexpr bool lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = 1; static _GLIBCXX_USE_CONSTEXPR int digits10 = 0; #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR bool epsilon() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_CONSTEXPR bool round_error() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR bool infinity() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_CONSTEXPR bool quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_CONSTEXPR bool signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_CONSTEXPR bool denorm_min() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; // It is not clear what it means for a boolean type to trap. // This is a DR on the LWG issue list. Here, I use integer // promotion semantics. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR char min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); } static _GLIBCXX_CONSTEXPR char max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); } #if __cplusplus >= 201103L static constexpr char lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (char); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (char); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (char); static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR char infinity() _GLIBCXX_USE_NOEXCEPT { return char(); } static _GLIBCXX_CONSTEXPR char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } static _GLIBCXX_CONSTEXPR char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } static _GLIBCXX_CONSTEXPR char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR signed char min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; } static _GLIBCXX_CONSTEXPR signed char max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; } #if __cplusplus >= 201103L static constexpr signed char lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (signed char); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (signed char); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR signed char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR signed char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR signed char infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR signed char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR signed char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR signed char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned char min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned char max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; } #if __cplusplus >= 201103L static constexpr unsigned char lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned char); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned char); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned char infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR wchar_t min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); } static _GLIBCXX_CONSTEXPR wchar_t max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); } #if __cplusplus >= 201103L static constexpr wchar_t lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (wchar_t); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (wchar_t); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (wchar_t); static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR wchar_t epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR wchar_t round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR wchar_t infinity() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } static _GLIBCXX_CONSTEXPR wchar_t quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } static _GLIBCXX_CONSTEXPR wchar_t signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } static _GLIBCXX_CONSTEXPR wchar_t denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; #if __cplusplus >= 201103L /// numeric_limits specialization. template<> struct numeric_limits { static constexpr bool is_specialized = true; static constexpr char16_t min() noexcept { return __glibcxx_min (char16_t); } static constexpr char16_t max() noexcept { return __glibcxx_max (char16_t); } static constexpr char16_t lowest() noexcept { return min(); } static constexpr int digits = __glibcxx_digits (char16_t); static constexpr int digits10 = __glibcxx_digits10 (char16_t); static constexpr int max_digits10 = 0; static constexpr bool is_signed = __glibcxx_signed (char16_t); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr char16_t epsilon() noexcept { return 0; } static constexpr char16_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr char16_t infinity() noexcept { return char16_t(); } static constexpr char16_t quiet_NaN() noexcept { return char16_t(); } static constexpr char16_t signaling_NaN() noexcept { return char16_t(); } static constexpr char16_t denorm_min() noexcept { return char16_t(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = __glibcxx_integral_traps; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static constexpr bool is_specialized = true; static constexpr char32_t min() noexcept { return __glibcxx_min (char32_t); } static constexpr char32_t max() noexcept { return __glibcxx_max (char32_t); } static constexpr char32_t lowest() noexcept { return min(); } static constexpr int digits = __glibcxx_digits (char32_t); static constexpr int digits10 = __glibcxx_digits10 (char32_t); static constexpr int max_digits10 = 0; static constexpr bool is_signed = __glibcxx_signed (char32_t); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr char32_t epsilon() noexcept { return 0; } static constexpr char32_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr char32_t infinity() noexcept { return char32_t(); } static constexpr char32_t quiet_NaN() noexcept { return char32_t(); } static constexpr char32_t signaling_NaN() noexcept { return char32_t(); } static constexpr char32_t denorm_min() noexcept { return char32_t(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = __glibcxx_integral_traps; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; #endif /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR short min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; } static _GLIBCXX_CONSTEXPR short max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; } #if __cplusplus >= 201103L static constexpr short lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (short); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (short); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR short epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR short round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR short infinity() _GLIBCXX_USE_NOEXCEPT { return short(); } static _GLIBCXX_CONSTEXPR short quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } static _GLIBCXX_CONSTEXPR short signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } static _GLIBCXX_CONSTEXPR short denorm_min() _GLIBCXX_USE_NOEXCEPT { return short(); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned short min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned short max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; } #if __cplusplus >= 201103L static constexpr unsigned short lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned short); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned short); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned short epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned short round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned short infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned short quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned short signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned short denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR int min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; } static _GLIBCXX_CONSTEXPR int max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; } #if __cplusplus >= 201103L static constexpr int lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (int); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (int); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR int epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR int round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR int infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR int quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR int signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR int denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned int min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned int max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; } #if __cplusplus >= 201103L static constexpr unsigned int lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned int); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned int); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned int epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned int round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned int infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned int quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned int signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned int denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR long min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; } static _GLIBCXX_CONSTEXPR long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; } #if __cplusplus >= 201103L static constexpr long lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned long min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; } #if __cplusplus >= 201103L static constexpr unsigned long lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned long); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR long long min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; } static _GLIBCXX_CONSTEXPR long long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; } #if __cplusplus >= 201103L static constexpr long long lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long long); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR long long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR long long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR long long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR long long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned long long min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned long long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; } #if __cplusplus >= 201103L static constexpr unsigned long long lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned long long); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned long long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned long long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned long long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned long long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned long long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) /// numeric_limits<__int128> specialization. template<> struct numeric_limits<__int128> { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR __int128 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (__int128); } static _GLIBCXX_CONSTEXPR __int128 max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (__int128); } #if __cplusplus >= 201103L static constexpr __int128 lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (__int128); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (__int128); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR __int128 epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR __int128 round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR __int128 infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<__int128>(0); } static _GLIBCXX_CONSTEXPR __int128 quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<__int128>(0); } static _GLIBCXX_CONSTEXPR __int128 signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<__int128>(0); } static _GLIBCXX_CONSTEXPR __int128 denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<__int128>(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR unsigned __int128 min() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned __int128 max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (unsigned __int128); } #if __cplusplus >= 201103L static constexpr unsigned __int128 lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned __int128); static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned __int128); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; static _GLIBCXX_CONSTEXPR unsigned __int128 epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_CONSTEXPR unsigned __int128 round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; static _GLIBCXX_CONSTEXPR unsigned __int128 infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned __int128 quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned __int128 signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_CONSTEXPR unsigned __int128 denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; #endif /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR float min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; } static _GLIBCXX_CONSTEXPR float max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; } #if __cplusplus >= 201103L static constexpr float lowest() noexcept { return -__FLT_MAX__; } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __FLT_MANT_DIG__; static _GLIBCXX_USE_CONSTEXPR int digits10 = __FLT_DIG__; #if __cplusplus >= 201103L static constexpr int max_digits10 = __glibcxx_max_digits10 (__FLT_MANT_DIG__); #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; static _GLIBCXX_CONSTEXPR float epsilon() _GLIBCXX_USE_NOEXCEPT { return __FLT_EPSILON__; } static _GLIBCXX_CONSTEXPR float round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __FLT_MIN_EXP__; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __FLT_MIN_10_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent = __FLT_MAX_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __FLT_MAX_10_EXP__; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __FLT_HAS_INFINITY__; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_float_has_denorm_loss; static _GLIBCXX_CONSTEXPR float infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_valf(); } static _GLIBCXX_CONSTEXPR float quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanf(""); } static _GLIBCXX_CONSTEXPR float signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansf(""); } static _GLIBCXX_CONSTEXPR float denorm_min() _GLIBCXX_USE_NOEXCEPT { return __FLT_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_float_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_float_tinyness_before; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; #undef __glibcxx_float_has_denorm_loss #undef __glibcxx_float_traps #undef __glibcxx_float_tinyness_before /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR double min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; } static _GLIBCXX_CONSTEXPR double max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; } #if __cplusplus >= 201103L static constexpr double lowest() noexcept { return -__DBL_MAX__; } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __DBL_MANT_DIG__; static _GLIBCXX_USE_CONSTEXPR int digits10 = __DBL_DIG__; #if __cplusplus >= 201103L static constexpr int max_digits10 = __glibcxx_max_digits10 (__DBL_MANT_DIG__); #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; static _GLIBCXX_CONSTEXPR double epsilon() _GLIBCXX_USE_NOEXCEPT { return __DBL_EPSILON__; } static _GLIBCXX_CONSTEXPR double round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __DBL_MIN_EXP__; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __DBL_MIN_10_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent = __DBL_MAX_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __DBL_MAX_10_EXP__; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __DBL_HAS_INFINITY__; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_double_has_denorm_loss; static _GLIBCXX_CONSTEXPR double infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_val(); } static _GLIBCXX_CONSTEXPR double quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nan(""); } static _GLIBCXX_CONSTEXPR double signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nans(""); } static _GLIBCXX_CONSTEXPR double denorm_min() _GLIBCXX_USE_NOEXCEPT { return __DBL_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_double_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_double_tinyness_before; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; #undef __glibcxx_double_has_denorm_loss #undef __glibcxx_double_traps #undef __glibcxx_double_tinyness_before /// numeric_limits specialization. template<> struct numeric_limits { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; static _GLIBCXX_CONSTEXPR long double min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; } static _GLIBCXX_CONSTEXPR long double max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; } #if __cplusplus >= 201103L static constexpr long double lowest() noexcept { return -__LDBL_MAX__; } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __LDBL_MANT_DIG__; static _GLIBCXX_USE_CONSTEXPR int digits10 = __LDBL_DIG__; #if __cplusplus >= 201103L static _GLIBCXX_USE_CONSTEXPR int max_digits10 = __glibcxx_max_digits10 (__LDBL_MANT_DIG__); #endif static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; static _GLIBCXX_CONSTEXPR long double epsilon() _GLIBCXX_USE_NOEXCEPT { return __LDBL_EPSILON__; } static _GLIBCXX_CONSTEXPR long double round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5L; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __LDBL_MIN_EXP__; static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __LDBL_MIN_10_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent = __LDBL_MAX_EXP__; static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __LDBL_MAX_10_EXP__; static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __LDBL_HAS_INFINITY__; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_long_double_has_denorm_loss; static _GLIBCXX_CONSTEXPR long double infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_vall(); } static _GLIBCXX_CONSTEXPR long double quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanl(""); } static _GLIBCXX_CONSTEXPR long double signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansl(""); } static _GLIBCXX_CONSTEXPR long double denorm_min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_long_double_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_long_double_tinyness_before; static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; #undef __glibcxx_long_double_has_denorm_loss #undef __glibcxx_long_double_traps #undef __glibcxx_long_double_tinyness_before _GLIBCXX_END_NAMESPACE_VERSION } // namespace #undef __glibcxx_signed #undef __glibcxx_min #undef __glibcxx_max #undef __glibcxx_digits #undef __glibcxx_digits10 #undef __glibcxx_max_digits10 #endif // _GLIBCXX_NUMERIC_LIMITS 4.8.2/fstream000064400000072502147547540550006627 0ustar00// File based streams -*- C++ -*- // Copyright (C) 1997-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/fstream * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.8 File-based streams // #ifndef _GLIBCXX_FSTREAM #define _GLIBCXX_FSTREAM 1 #pragma GCC system_header #include #include #include #include // For BUFSIZ #include // For __basic_file, __c_lock #if __cplusplus >= 201103L #include // For std::string overloads. #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // [27.8.1.1] template class basic_filebuf /** * @brief The actual work of input and output (for files). * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class associates both its input and output sequence with an * external disk file, and maintains a joint file position for both * sequences. Many of its semantics are described in terms of similar * behavior in the Standard C Library's @c FILE streams. * * Requirements on traits_type, specific to this class: * - traits_type::pos_type must be fpos * - traits_type::off_type must be streamoff * - traits_type::state_type must be Assignable and DefaultConstructible, * - traits_type::state_type() must be the initial state for codecvt. */ template class basic_filebuf : public basic_streambuf<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef basic_streambuf __streambuf_type; typedef basic_filebuf __filebuf_type; typedef __basic_file __file_type; typedef typename traits_type::state_type __state_type; typedef codecvt __codecvt_type; friend class ios_base; // For sync_with_stdio. protected: // Data Members: // MT lock inherited from libio or other low-level io library. __c_lock _M_lock; // External buffer. __file_type _M_file; /// Place to stash in || out || in | out settings for current filebuf. ios_base::openmode _M_mode; // Beginning state type for codecvt. __state_type _M_state_beg; // During output, the state that corresponds to pptr(), // during input, the state that corresponds to egptr() and // _M_ext_next. __state_type _M_state_cur; // Not used for output. During input, the state that corresponds // to eback() and _M_ext_buf. __state_type _M_state_last; /// Pointer to the beginning of internal buffer. char_type* _M_buf; /** * Actual size of internal buffer. This number is equal to the size * of the put area + 1 position, reserved for the overflow char of * a full area. */ size_t _M_buf_size; // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. bool _M_buf_allocated; /** * _M_reading == false && _M_writing == false for @b uncommitted mode; * _M_reading == true for @b read mode; * _M_writing == true for @b write mode; * * NB: _M_reading == true && _M_writing == true is unused. */ bool _M_reading; bool _M_writing; //@{ /** * Necessary bits for putback buffer management. * * @note pbacks of over one character are not currently supported. */ char_type _M_pback; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; //@} // Cached codecvt facet. const __codecvt_type* _M_codecvt; /** * Buffer for external characters. Used for input when * codecvt::always_noconv() == false. When valid, this corresponds * to eback(). */ char* _M_ext_buf; /** * Size of buffer held by _M_ext_buf. */ streamsize _M_ext_buf_size; /** * Pointers into the buffer held by _M_ext_buf that delimit a * subsequence of bytes that have been read but not yet converted. * When valid, _M_ext_next corresponds to egptr(). */ const char* _M_ext_next; char* _M_ext_end; /** * Initializes pback buffers, and moves normal buffers to safety. * Assumptions: * _M_in_cur has already been moved back */ void _M_create_pback() { if (!_M_pback_init) { _M_pback_cur_save = this->gptr(); _M_pback_end_save = this->egptr(); this->setg(&_M_pback, &_M_pback, &_M_pback + 1); _M_pback_init = true; } } /** * Deactivates pback buffer contents, and restores normal buffer. * Assumptions: * The pback buffer has only moved forward. */ void _M_destroy_pback() throw() { if (_M_pback_init) { // Length _M_in_cur moved in the pback buffer. _M_pback_cur_save += this->gptr() != this->eback(); this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save); _M_pback_init = false; } } public: // Constructors/destructor: /** * @brief Does not open any files. * * The default constructor initializes the parent class using its * own default ctor. */ basic_filebuf(); /** * @brief The destructor closes the file first. */ virtual ~basic_filebuf() { this->close(); } // Members: /** * @brief Returns true if the external file is open. */ bool is_open() const throw() { return _M_file.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * @return @c this on success, NULL on failure * * If a file is already open, this function immediately fails. * Otherwise it tries to open the file named @a __s using the flags * given in @a __mode. * * Table 92, adapted here, gives the relation between openmode * combinations and the equivalent fopen() flags. * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, * and binary|in|app per DR 596) * +---------------------------------------------------------+ * | ios_base Flag combination stdio equivalent | * |binary in out trunc app | * +---------------------------------------------------------+ * | + w | * | + + a | * | + a | * | + + w | * | + r | * | + + r+ | * | + + + w+ | * | + + + a+ | * | + + a+ | * +---------------------------------------------------------+ * | + + wb | * | + + + ab | * | + + ab | * | + + + wb | * | + + rb | * | + + + r+b | * | + + + + w+b | * | + + + + a+b | * | + + + a+b | * +---------------------------------------------------------+ */ __filebuf_type* open(const char* __s, ios_base::openmode __mode); #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * @return @c this on success, NULL on failure */ __filebuf_type* open(const std::string& __s, ios_base::openmode __mode) { return open(__s.c_str(), __mode); } #endif /** * @brief Closes the currently associated file. * @return @c this on success, NULL on failure * * If no file is currently open, this function immediately fails. * * If a put buffer area exists, @c overflow(eof) is * called to flush all the characters. The file is then * closed. * * If any operations fail, this function also fails. */ __filebuf_type* close(); protected: void _M_allocate_internal_buffer(); void _M_destroy_internal_buffer() throw(); // [27.8.1.4] overridden virtual functions virtual streamsize showmanyc(); // Stroustrup, 1998, p. 628 // underflow() and uflow() functions are called to get the next // character from the real input source when the buffer is empty. // Buffered input uses underflow() virtual int_type underflow(); virtual int_type pbackfail(int_type __c = _Traits::eof()); // Stroustrup, 1998, p 648 // The overflow() function is called to transfer characters to the // real output destination when the buffer is full. A call to // overflow(c) outputs the contents of the buffer plus the // character c. // 27.5.2.4.5 // Consume some sequence of the characters in the pending sequence. virtual int_type overflow(int_type __c = _Traits::eof()); // Convert internal byte sequence to external, char-based // sequence via codecvt. bool _M_convert_to_external(char_type*, streamsize); /** * @brief Manipulates the buffer. * @param __s Pointer to a buffer area. * @param __n Size of @a __s. * @return @c this * * If no file has been opened, and both @a __s and @a __n are zero, then * the stream becomes unbuffered. Otherwise, @c __s is used as a * buffer; see * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html * for more. */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n); virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode = ios_base::in | ios_base::out); // Common code for seekoff, seekpos, and overflow pos_type _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); int _M_get_ext_pos(__state_type &__state); virtual int sync(); virtual void imbue(const locale& __loc); virtual streamsize xsgetn(char_type* __s, streamsize __n); virtual streamsize xsputn(const char_type* __s, streamsize __n); // Flushes output buffer, then writes unshift sequence. bool _M_terminate_output(); /** * This function sets the pointers of the internal buffer, both get * and put areas. Typically: * * __off == egptr() - eback() upon underflow/uflow (@b read mode); * __off == 0 upon overflow (@b write mode); * __off == -1 upon open, setbuf, seekoff/pos (@b uncommitted mode). * * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size * reflects the actual allocated memory and the last cell is reserved * for the overflow char of a full put area. */ void _M_set_buffer(streamsize __off) { const bool __testin = _M_mode & ios_base::in; const bool __testout = _M_mode & ios_base::out; if (__testin && __off > 0) this->setg(_M_buf, _M_buf, _M_buf + __off); else this->setg(_M_buf, _M_buf, _M_buf); if (__testout && __off == 0 && _M_buf_size > 1 ) this->setp(_M_buf, _M_buf + _M_buf_size - 1); else this->setp(0, 0); } }; // [27.8.1.5] Template class basic_ifstream /** * @brief Controlling input for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from named files, using the inherited * functions from std::basic_istream. To control the associated * sequence, an instance of std::basic_filebuf is used, which this page * refers to as @c sb. */ template class basic_ifstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf __filebuf_type; typedef basic_istream __istream_type; private: __filebuf_type _M_filebuf; public: // Constructors/Destructors: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_ifstream() : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an input file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201103L /** * @brief Create an input file stream. * @param __s std::string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. */ explicit basic_ifstream(const std::string& __s, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_ifstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ void open(const char* __s, ios_base::openmode __mode = ios_base::in) { if (!_M_filebuf.open(__s, __mode | ios_base::in)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::in) { if (!_M_filebuf.open(__s, __mode | ios_base::in)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #endif /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; // [27.8.1.8] Template class basic_ofstream /** * @brief Controlling output for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from named files, using the inherited * functions from std::basic_ostream. To control the associated * sequence, an instance of std::basic_filebuf is used, which this page * refers to as @c sb. */ template class basic_ofstream : public basic_ostream<_CharT,_Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf __filebuf_type; typedef basic_ostream __ostream_type; private: __filebuf_type _M_filebuf; public: // Constructors: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_ofstream(): __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out | @c ios_base::trunc is automatically included in * @a __mode. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out|ios_base::trunc) : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201103L /** * @brief Create an output file stream. * @param __s std::string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out | @c ios_base::trunc is automatically included in * @a __mode. */ explicit basic_ofstream(const std::string& __s, ios_base::openmode __mode = ios_base::out|ios_base::trunc) : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_ofstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|out|trunc). If that * function fails, @c failbit is set in the stream's error state. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ void open(const char* __s, ios_base::openmode __mode = ios_base::out | ios_base::trunc) { if (!_M_filebuf.open(__s, __mode | ios_base::out)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that * function fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::out | ios_base::trunc) { if (!_M_filebuf.open(__s, __mode | ios_base::out)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #endif /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; // [27.8.1.11] Template class basic_fstream /** * @brief Controlling input and output for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from and writing to named files, using * the inherited functions from std::basic_iostream. To control the * associated sequence, an instance of std::basic_filebuf is used, which * this page refers to as @c sb. */ template class basic_fstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf __filebuf_type; typedef basic_ios __ios_type; typedef basic_iostream __iostream_type; private: __filebuf_type _M_filebuf; public: // Constructors/destructor: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_fstream() : __iostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an input/output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(0), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201103L /** * @brief Create an input/output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). */ explicit basic_fstream(const std::string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(0), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_fstream() { } // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #endif /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #include #endif /* _GLIBCXX_FSTREAM */ 4.8.2/bitset000064400000131060147547540550006453 0ustar00// -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * Copyright (c) 1998 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/bitset * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_BITSET #define _GLIBCXX_BITSET 1 #pragma GCC system_header #include #include // For invalid_argument, out_of_range, // overflow_error #include #include #define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__) #define _GLIBCXX_BITSET_WORDS(__n) \ ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \ ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1)) #define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** * Base class, general case. It is a class invariant that _Nw will be * nonnegative. * * See documentation for bitset. */ template struct _Base_bitset { typedef unsigned long _WordT; /// 0 is the least significant word. _WordT _M_w[_Nw]; _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT : _M_w() { } #if __cplusplus >= 201103L constexpr _Base_bitset(unsigned long long __val) noexcept : _M_w{ _WordT(__val) #if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ , _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD) #endif } { } #else _Base_bitset(unsigned long __val) : _M_w() { _M_w[0] = __val; } #endif static _GLIBCXX_CONSTEXPR size_t _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR size_t _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static _GLIBCXX_CONSTEXPR size_t _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR _WordT _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } _WordT& _M_getword(size_t __pos) _GLIBCXX_NOEXCEPT { return _M_w[_S_whichword(__pos)]; } _GLIBCXX_CONSTEXPR _WordT _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT { return _M_w[_S_whichword(__pos)]; } #if __cplusplus >= 201103L const _WordT* _M_getdata() const noexcept { return _M_w; } #endif _WordT& _M_hiword() _GLIBCXX_NOEXCEPT { return _M_w[_Nw - 1]; } _GLIBCXX_CONSTEXPR _WordT _M_hiword() const _GLIBCXX_NOEXCEPT { return _M_w[_Nw - 1]; } void _M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] &= __x._M_w[__i]; } void _M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] |= __x._M_w[__i]; } void _M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] ^= __x._M_w[__i]; } void _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT; void _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT; void _M_do_flip() _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] = ~_M_w[__i]; } void _M_do_set() _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] = ~static_cast<_WordT>(0); } void _M_do_reset() _GLIBCXX_NOEXCEPT { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } bool _M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; ++__i) if (_M_w[__i] != __x._M_w[__i]) return false; return true; } template bool _M_are_all() const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw - 1; __i++) if (_M_w[__i] != ~static_cast<_WordT>(0)) return false; return _M_hiword() == (~static_cast<_WordT>(0) >> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); } bool _M_is_any() const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) if (_M_w[__i] != static_cast<_WordT>(0)) return true; return false; } size_t _M_do_count() const _GLIBCXX_NOEXCEPT { size_t __result = 0; for (size_t __i = 0; __i < _Nw; __i++) __result += __builtin_popcountl(_M_w[__i]); return __result; } unsigned long _M_do_to_ulong() const; #if __cplusplus >= 201103L unsigned long long _M_do_to_ullong() const; #endif // find first "on" bit size_t _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT; // find the next "on" bit that follows "prev" size_t _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT; }; // Definitions of non-inline functions from _Base_bitset. template void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__shift != 0, 1)) { const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; if (__offset == 0) for (size_t __n = _Nw - 1; __n >= __wshift; --__n) _M_w[__n] = _M_w[__n - __wshift]; else { const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD - __offset); for (size_t __n = _Nw - 1; __n > __wshift; --__n) _M_w[__n] = ((_M_w[__n - __wshift] << __offset) | (_M_w[__n - __wshift - 1] >> __sub_offset)); _M_w[__wshift] = _M_w[0] << __offset; } std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); } } template void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__shift != 0, 1)) { const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; const size_t __limit = _Nw - __wshift - 1; if (__offset == 0) for (size_t __n = 0; __n <= __limit; ++__n) _M_w[__n] = _M_w[__n + __wshift]; else { const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD - __offset); for (size_t __n = 0; __n < __limit; ++__n) _M_w[__n] = ((_M_w[__n + __wshift] >> __offset) | (_M_w[__n + __wshift + 1] << __sub_offset)); _M_w[__limit] = _M_w[_Nw-1] >> __offset; } std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); } } template unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const { for (size_t __i = 1; __i < _Nw; ++__i) if (_M_w[__i]) __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong")); return _M_w[0]; } #if __cplusplus >= 201103L template unsigned long long _Base_bitset<_Nw>::_M_do_to_ullong() const { const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long); for (size_t __i = 1 + __dw; __i < _Nw; ++__i) if (_M_w[__i]) __throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong")); if (__dw) return _M_w[0] + (static_cast(_M_w[1]) << _GLIBCXX_BITSET_BITS_PER_WORD); return _M_w[0]; } #endif template size_t _Base_bitset<_Nw>:: _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) { _WordT __thisword = _M_w[__i]; if (__thisword != static_cast<_WordT>(0)) return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + __builtin_ctzl(__thisword)); } // not found, so return an indication of failure. return __not_found; } template size_t _Base_bitset<_Nw>:: _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT { // make bound inclusive ++__prev; // check out of bounds if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD) return __not_found; // search first word size_t __i = _S_whichword(__prev); _WordT __thisword = _M_w[__i]; // mask off bits below bound __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); if (__thisword != static_cast<_WordT>(0)) return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + __builtin_ctzl(__thisword)); // check subsequent words __i++; for (; __i < _Nw; __i++) { __thisword = _M_w[__i]; if (__thisword != static_cast<_WordT>(0)) return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + __builtin_ctzl(__thisword)); } // not found, so return an indication of failure. return __not_found; } // end _M_do_find_next /** * Base class, specialization for a single word. * * See documentation for bitset. */ template<> struct _Base_bitset<1> { typedef unsigned long _WordT; _WordT _M_w; _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT : _M_w(0) { } #if __cplusplus >= 201103L constexpr _Base_bitset(unsigned long long __val) noexcept #else _Base_bitset(unsigned long __val) #endif : _M_w(__val) { } static _GLIBCXX_CONSTEXPR size_t _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR size_t _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static _GLIBCXX_CONSTEXPR size_t _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR _WordT _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } _WordT& _M_getword(size_t) _GLIBCXX_NOEXCEPT { return _M_w; } _GLIBCXX_CONSTEXPR _WordT _M_getword(size_t) const _GLIBCXX_NOEXCEPT { return _M_w; } #if __cplusplus >= 201103L const _WordT* _M_getdata() const noexcept { return &_M_w; } #endif _WordT& _M_hiword() _GLIBCXX_NOEXCEPT { return _M_w; } _GLIBCXX_CONSTEXPR _WordT _M_hiword() const _GLIBCXX_NOEXCEPT { return _M_w; } void _M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w &= __x._M_w; } void _M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w |= __x._M_w; } void _M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w ^= __x._M_w; } void _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT { _M_w <<= __shift; } void _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT { _M_w >>= __shift; } void _M_do_flip() _GLIBCXX_NOEXCEPT { _M_w = ~_M_w; } void _M_do_set() _GLIBCXX_NOEXCEPT { _M_w = ~static_cast<_WordT>(0); } void _M_do_reset() _GLIBCXX_NOEXCEPT { _M_w = 0; } bool _M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT { return _M_w == __x._M_w; } template bool _M_are_all() const _GLIBCXX_NOEXCEPT { return _M_w == (~static_cast<_WordT>(0) >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); } bool _M_is_any() const _GLIBCXX_NOEXCEPT { return _M_w != 0; } size_t _M_do_count() const _GLIBCXX_NOEXCEPT { return __builtin_popcountl(_M_w); } unsigned long _M_do_to_ulong() const _GLIBCXX_NOEXCEPT { return _M_w; } #if __cplusplus >= 201103L unsigned long long _M_do_to_ullong() const noexcept { return _M_w; } #endif size_t _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT { if (_M_w != 0) return __builtin_ctzl(_M_w); else return __not_found; } // find the next "on" bit that follows "prev" size_t _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT { ++__prev; if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD)) return __not_found; _WordT __x = _M_w >> __prev; if (__x != 0) return __builtin_ctzl(__x) + __prev; else return __not_found; } }; /** * Base class, specialization for no storage (zero-length %bitset). * * See documentation for bitset. */ template<> struct _Base_bitset<0> { typedef unsigned long _WordT; _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT { } #if __cplusplus >= 201103L constexpr _Base_bitset(unsigned long long) noexcept #else _Base_bitset(unsigned long) #endif { } static _GLIBCXX_CONSTEXPR size_t _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR size_t _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static _GLIBCXX_CONSTEXPR size_t _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _GLIBCXX_CONSTEXPR _WordT _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } // This would normally give access to the data. The bounds-checking // in the bitset class will prevent the user from getting this far, // but (1) it must still return an lvalue to compile, and (2) the // user might call _Unchecked_set directly, in which case this /needs/ // to fail. Let's not penalize zero-length users unless they actually // make an unchecked call; all the memory ugliness is therefore // localized to this single should-never-get-this-far function. _WordT& _M_getword(size_t) _GLIBCXX_NOEXCEPT { __throw_out_of_range(__N("_Base_bitset::_M_getword")); return *new _WordT; } _GLIBCXX_CONSTEXPR _WordT _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT { return 0; } _GLIBCXX_CONSTEXPR _WordT _M_hiword() const _GLIBCXX_NOEXCEPT { return 0; } void _M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } void _M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } void _M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } void _M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT { } void _M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT { } void _M_do_flip() _GLIBCXX_NOEXCEPT { } void _M_do_set() _GLIBCXX_NOEXCEPT { } void _M_do_reset() _GLIBCXX_NOEXCEPT { } // Are all empty bitsets equal to each other? Are they equal to // themselves? How to compare a thing which has no state? What is // the sound of one zero-length bitset clapping? bool _M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT { return true; } template bool _M_are_all() const _GLIBCXX_NOEXCEPT { return true; } bool _M_is_any() const _GLIBCXX_NOEXCEPT { return false; } size_t _M_do_count() const _GLIBCXX_NOEXCEPT { return 0; } unsigned long _M_do_to_ulong() const _GLIBCXX_NOEXCEPT { return 0; } #if __cplusplus >= 201103L unsigned long long _M_do_to_ullong() const noexcept { return 0; } #endif // Normally "not found" is the size, but that could also be // misinterpreted as an index in this corner case. Oh well. size_t _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT { return 0; } size_t _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT { return 0; } }; // Helper class to zero out the unused high-order bits in the highest word. template struct _Sanitize { typedef unsigned long _WordT; static void _S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); } }; template<> struct _Sanitize<0> { typedef unsigned long _WordT; static void _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } }; #if __cplusplus >= 201103L template struct _Sanitize_val { static constexpr unsigned long long _S_do_sanitize_val(unsigned long long __val) { return __val; } }; template struct _Sanitize_val<_Nb, true> { static constexpr unsigned long long _S_do_sanitize_val(unsigned long long __val) { return __val & ~((~static_cast(0)) << _Nb); } }; #endif /** * The %bitset class represents a @e fixed-size sequence of bits. * * @ingroup containers * * (Note that %bitset does @e not meet the formal requirements of a * container. Mainly, it lacks iterators.) * * The template argument, @a Nb, may be any non-negative number, * specifying the number of bits (e.g., "0", "12", "1024*1024"). * * In the general unoptimized case, storage is allocated in word-sized * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B * words will be used for storage. B - Nb%B bits are unused. (They are * the high-order bits in the highest word.) It is a class invariant * that those unused bits are always zero. * * If you think of %bitset as a simple array of bits, be * aware that your mental picture is reversed: a %bitset behaves * the same way as bits in integers do, with the bit at index 0 in * the least significant / right-hand position, and the bit at * index Nb-1 in the most significant / left-hand position. * Thus, unlike other containers, a %bitset's index counts from * right to left, to put it very loosely. * * This behavior is preserved when translating to and from strings. For * example, the first line of the following program probably prints * b('a') is 0001100001 on a modern ASCII system. * * @code * #include * #include * #include * * using namespace std; * * int main() * { * long a = 'a'; * bitset<10> b(a); * * cout << "b('a') is " << b << endl; * * ostringstream s; * s << b; * string str = s.str(); * cout << "index 3 in the string is " << str[3] << " but\n" * << "index 3 in the bitset is " << b[3] << endl; * } * @endcode * * Also see: * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch33s02.html * for a description of extensions. * * Most of the actual code isn't contained in %bitset<> itself, but in the * base class _Base_bitset. The base class works with whole words, not with * individual bits. This allows us to specialize _Base_bitset for the * important special case where the %bitset is only a single word. * * Extra confusion can result due to the fact that the storage for * _Base_bitset @e is a regular array, and is indexed as such. This is * carefully encapsulated. */ template class bitset : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> { private: typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base; typedef unsigned long _WordT; void _M_do_sanitize() _GLIBCXX_NOEXCEPT { typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type; __sanitize_type::_S_do_sanitize(this->_M_hiword()); } #if __cplusplus >= 201103L template friend struct hash; #endif public: /** * This encapsulates the concept of a single bit. An instance of this * class is a proxy for an actual bit; this way the individual bit * operations are done as faster word-size bitwise instructions. * * Most users will never need to use this class directly; conversions * to and from bool are automatic and should be transparent. Overloaded * operators help to preserve the illusion. * * (On a typical system, this bit %reference is 64 * times the size of an actual bit. Ha.) */ class reference { friend class bitset; _WordT* _M_wp; size_t _M_bpos; // left undefined reference(); public: reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT { _M_wp = &__b._M_getword(__pos); _M_bpos = _Base::_S_whichbit(__pos); } ~reference() _GLIBCXX_NOEXCEPT { } // For b[i] = __x; reference& operator=(bool __x) _GLIBCXX_NOEXCEPT { if (__x) *_M_wp |= _Base::_S_maskbit(_M_bpos); else *_M_wp &= ~_Base::_S_maskbit(_M_bpos); return *this; } // For b[i] = b[__j]; reference& operator=(const reference& __j) _GLIBCXX_NOEXCEPT { if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos))) *_M_wp |= _Base::_S_maskbit(_M_bpos); else *_M_wp &= ~_Base::_S_maskbit(_M_bpos); return *this; } // Flips the bit bool operator~() const _GLIBCXX_NOEXCEPT { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } // For __x = b[i]; operator bool() const _GLIBCXX_NOEXCEPT { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } // For b[i].flip(); reference& flip() _GLIBCXX_NOEXCEPT { *_M_wp ^= _Base::_S_maskbit(_M_bpos); return *this; } }; friend class reference; // 23.3.5.1 constructors: /// All bits set to zero. _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT { } /// Initial bits bitwise-copied from a single word (others set to zero). #if __cplusplus >= 201103L constexpr bitset(unsigned long long __val) noexcept : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { } #else bitset(unsigned long __val) : _Base(__val) { _M_do_sanitize(); } #endif /** * Use a subset of a string. * @param __s A string of @a 0 and @a 1 characters. * @param __position Index of the first character in @a __s to use; * defaults to zero. * @throw std::out_of_range If @a pos is bigger the size of @a __s. * @throw std::invalid_argument If a character appears in the string * which is neither @a 0 nor @a 1. */ template explicit bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position = 0) : _Base() { if (__position > __s.size()) __throw_out_of_range(__N("bitset::bitset initial position " "not valid")); _M_copy_from_string(__s, __position, std::basic_string<_CharT, _Traits, _Alloc>::npos, _CharT('0'), _CharT('1')); } /** * Use a subset of a string. * @param __s A string of @a 0 and @a 1 characters. * @param __position Index of the first character in @a __s to use. * @param __n The number of characters to copy. * @throw std::out_of_range If @a __position is bigger the size * of @a __s. * @throw std::invalid_argument If a character appears in the string * which is neither @a 0 nor @a 1. */ template bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position, size_t __n) : _Base() { if (__position > __s.size()) __throw_out_of_range(__N("bitset::bitset initial position " "not valid")); _M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1')); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position, size_t __n, _CharT __zero, _CharT __one = _CharT('1')) : _Base() { if (__position > __s.size()) __throw_out_of_range(__N("bitset::bitset initial position " "not valid")); _M_copy_from_string(__s, __position, __n, __zero, __one); } #if __cplusplus >= 201103L /** * Construct from a character %array. * @param __str An %array of characters @a zero and @a one. * @param __n The number of characters to use. * @param __zero The character corresponding to the value 0. * @param __one The character corresponding to the value 1. * @throw std::invalid_argument If a character appears in the string * which is neither @a __zero nor @a __one. */ template explicit bitset(const _CharT* __str, typename std::basic_string<_CharT>::size_type __n = std::basic_string<_CharT>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) : _Base() { if (!__str) __throw_logic_error(__N("bitset::bitset(const _CharT*, ...)")); if (__n == std::basic_string<_CharT>::npos) __n = std::char_traits<_CharT>::length(__str); _M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0, __n, __zero, __one); } #endif // 23.3.5.2 bitset operations: //@{ /** * Operations on bitsets. * @param __rhs A same-sized bitset. * * These should be self-explanatory. */ bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { this->_M_do_and(__rhs); return *this; } bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { this->_M_do_or(__rhs); return *this; } bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { this->_M_do_xor(__rhs); return *this; } //@} //@{ /** * Operations on bitsets. * @param __position The number of places to shift. * * These should be self-explanatory. */ bitset<_Nb>& operator<<=(size_t __position) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__position < _Nb, 1)) { this->_M_do_left_shift(__position); this->_M_do_sanitize(); } else this->_M_do_reset(); return *this; } bitset<_Nb>& operator>>=(size_t __position) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__position < _Nb, 1)) { this->_M_do_right_shift(__position); this->_M_do_sanitize(); } else this->_M_do_reset(); return *this; } //@} //@{ /** * These versions of single-bit set, reset, flip, and test are * extensions from the SGI version. They do no range checking. * @ingroup SGIextensions */ bitset<_Nb>& _Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT { this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); return *this; } bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT { if (__val) this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); else this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); return *this; } bitset<_Nb>& _Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT { this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); return *this; } bitset<_Nb>& _Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT { this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); return *this; } _GLIBCXX_CONSTEXPR bool _Unchecked_test(size_t __pos) const _GLIBCXX_NOEXCEPT { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) != static_cast<_WordT>(0)); } //@} // Set, reset, and flip. /** * @brief Sets every bit to true. */ bitset<_Nb>& set() _GLIBCXX_NOEXCEPT { this->_M_do_set(); this->_M_do_sanitize(); return *this; } /** * @brief Sets a given bit to a particular value. * @param __position The index of the bit. * @param __val Either true or false, defaults to true. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bitset<_Nb>& set(size_t __position, bool __val = true) { if (__position >= _Nb) __throw_out_of_range(__N("bitset::set")); return _Unchecked_set(__position, __val); } /** * @brief Sets every bit to false. */ bitset<_Nb>& reset() _GLIBCXX_NOEXCEPT { this->_M_do_reset(); return *this; } /** * @brief Sets a given bit to false. * @param __position The index of the bit. * @throw std::out_of_range If @a pos is bigger the size of the %set. * * Same as writing @c set(pos,false). */ bitset<_Nb>& reset(size_t __position) { if (__position >= _Nb) __throw_out_of_range(__N("bitset::reset")); return _Unchecked_reset(__position); } /** * @brief Toggles every bit to its opposite value. */ bitset<_Nb>& flip() _GLIBCXX_NOEXCEPT { this->_M_do_flip(); this->_M_do_sanitize(); return *this; } /** * @brief Toggles a given bit to its opposite value. * @param __position The index of the bit. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bitset<_Nb>& flip(size_t __position) { if (__position >= _Nb) __throw_out_of_range(__N("bitset::flip")); return _Unchecked_flip(__position); } /// See the no-argument flip(). bitset<_Nb> operator~() const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this).flip(); } //@{ /** * @brief Array-indexing support. * @param __position Index into the %bitset. * @return A bool for a const %bitset. For non-const * bitsets, an instance of the reference proxy class. * @note These operators do no range checking and throw no exceptions, * as required by DR 11 to the standard. * * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already * resolves DR 11 (items 1 and 2), but does not do the range-checking * required by that DR's resolution. -pme * The DR has since been changed: range-checking is a precondition * (users' responsibility), and these functions must not throw. -pme */ reference operator[](size_t __position) { return reference(*this, __position); } _GLIBCXX_CONSTEXPR bool operator[](size_t __position) const { return _Unchecked_test(__position); } //@} /** * @brief Returns a numerical interpretation of the %bitset. * @return The integral equivalent of the bits. * @throw std::overflow_error If there are too many bits to be * represented in an @c unsigned @c long. */ unsigned long to_ulong() const { return this->_M_do_to_ulong(); } #if __cplusplus >= 201103L unsigned long long to_ullong() const { return this->_M_do_to_ullong(); } #endif /** * @brief Returns a character interpretation of the %bitset. * @return The string equivalent of the bits. * * Note the ordering of the bits: decreasing character positions * correspond to increasing bit positions (see the main class notes for * an example). */ template std::basic_string<_CharT, _Traits, _Alloc> to_string() const { std::basic_string<_CharT, _Traits, _Alloc> __result; _M_copy_to_string(__result, _CharT('0'), _CharT('1')); return __result; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template std::basic_string<_CharT, _Traits, _Alloc> to_string(_CharT __zero, _CharT __one = _CharT('1')) const { std::basic_string<_CharT, _Traits, _Alloc> __result; _M_copy_to_string(__result, __zero, __one); return __result; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 434. bitset::to_string() hard to use. template std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string() const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 853. to_string needs updating with zero and one. template std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(__zero, __one); } template std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string() const { return to_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> >(); } template std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> >(__zero, __one); } std::basic_string, std::allocator > to_string() const { return to_string, std::allocator >(); } std::basic_string, std::allocator > to_string(char __zero, char __one = '1') const { return to_string, std::allocator >(__zero, __one); } // Helper functions for string operations. template void _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, _CharT, _CharT); template void _M_copy_from_string(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __pos, size_t __n, _CharT __zero, _CharT __one) { _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n, __zero, __one); } template void _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&, _CharT, _CharT) const; // NB: Backward compat. template void _M_copy_from_string(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __pos, size_t __n) { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); } template void _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); } /// Returns the number of bits which are set. size_t count() const _GLIBCXX_NOEXCEPT { return this->_M_do_count(); } /// Returns the total number of bits. _GLIBCXX_CONSTEXPR size_t size() const _GLIBCXX_NOEXCEPT { return _Nb; } //@{ /// These comparisons for equality/inequality are, well, @e bitwise. bool operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return this->_M_is_equal(__rhs); } bool operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return !this->_M_is_equal(__rhs); } //@} /** * @brief Tests the value of a bit. * @param __position The index of a bit. * @return The value at @a pos. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bool test(size_t __position) const { if (__position >= _Nb) __throw_out_of_range(__N("bitset::test")); return _Unchecked_test(__position); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 693. std::bitset::all() missing. /** * @brief Tests whether all the bits are on. * @return True if all the bits are set. */ bool all() const _GLIBCXX_NOEXCEPT { return this->template _M_are_all<_Nb>(); } /** * @brief Tests whether any of the bits are on. * @return True if at least one bit is set. */ bool any() const _GLIBCXX_NOEXCEPT { return this->_M_is_any(); } /** * @brief Tests whether any of the bits are on. * @return True if none of the bits are set. */ bool none() const _GLIBCXX_NOEXCEPT { return !this->_M_is_any(); } //@{ /// Self-explanatory. bitset<_Nb> operator<<(size_t __position) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this) <<= __position; } bitset<_Nb> operator>>(size_t __position) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this) >>= __position; } //@} /** * @brief Finds the index of the first "on" bit. * @return The index of the first bit set, or size() if not found. * @ingroup SGIextensions * @sa _Find_next */ size_t _Find_first() const _GLIBCXX_NOEXCEPT { return this->_M_do_find_first(_Nb); } /** * @brief Finds the index of the next "on" bit after prev. * @return The index of the next bit set, or size() if not found. * @param __prev Where to start searching. * @ingroup SGIextensions * @sa _Find_first */ size_t _Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT { return this->_M_do_find_next(__prev, _Nb); } }; // Definitions of non-inline member functions. template template void bitset<_Nb>:: _M_copy_from_ptr(const _CharT* __s, size_t __len, size_t __pos, size_t __n, _CharT __zero, _CharT __one) { reset(); const size_t __nbits = std::min(_Nb, std::min(__n, size_t(__len - __pos))); for (size_t __i = __nbits; __i > 0; --__i) { const _CharT __c = __s[__pos + __nbits - __i]; if (_Traits::eq(__c, __zero)) ; else if (_Traits::eq(__c, __one)) _Unchecked_set(__i - 1); else __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); } } template template void bitset<_Nb>:: _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s, _CharT __zero, _CharT __one) const { __s.assign(_Nb, __zero); for (size_t __i = _Nb; __i > 0; --__i) if (_Unchecked_test(__i - 1)) _Traits::assign(__s[_Nb - __i], __one); } // 23.3.5.3 bitset operations: //@{ /** * @brief Global bitwise operations on bitsets. * @param __x A bitset. * @param __y A bitset of the same size as @a __x. * @return A new bitset. * * These should be self-explanatory. */ template inline bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { bitset<_Nb> __result(__x); __result &= __y; return __result; } template inline bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { bitset<_Nb> __result(__x); __result |= __y; return __result; } template inline bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { bitset<_Nb> __result(__x); __result ^= __y; return __result; } //@} //@{ /** * @brief Global I/O operators for bitsets. * * Direct I/O between streams and bitsets is supported. Output is * straightforward. Input will skip whitespace, only accept @a 0 and @a 1 * characters, and will only extract as many digits as the %bitset will * hold. */ template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) { typedef typename _Traits::char_type char_type; typedef std::basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; std::basic_string<_CharT, _Traits> __tmp; __tmp.reserve(_Nb); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 303. Bitset input operator underspecified const char_type __zero = __is.widen('0'); const char_type __one = __is.widen('1'); typename __ios_base::iostate __state = __ios_base::goodbit; typename __istream_type::sentry __sentry(__is); if (__sentry) { __try { for (size_t __i = _Nb; __i > 0; --__i) { static typename _Traits::int_type __eof = _Traits::eof(); typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__c1, __eof)) { __state |= __ios_base::eofbit; break; } else { const char_type __c2 = _Traits::to_char_type(__c1); if (_Traits::eq(__c2, __zero)) __tmp.push_back(__zero); else if (_Traits::eq(__c2, __one)) __tmp.push_back(__one); else if (_Traits:: eq_int_type(__is.rdbuf()->sputbackc(__c2), __eof)) { __state |= __ios_base::failbit; break; } } } } __catch(__cxxabiv1::__forced_unwind&) { __is._M_setstate(__ios_base::badbit); __throw_exception_again; } __catch(...) { __is._M_setstate(__ios_base::badbit); } } if (__tmp.empty() && _Nb) __state |= __ios_base::failbit; else __x._M_copy_from_string(__tmp, static_cast(0), _Nb, __zero, __one); if (__state) __is.setstate(__state); return __is; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { std::basic_string<_CharT, _Traits> __tmp; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. const ctype<_CharT>& __ct = use_facet >(__os.getloc()); __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1')); return __os << __tmp; } //@} _GLIBCXX_END_NAMESPACE_CONTAINER } // namespace std #undef _GLIBCXX_BITSET_WORDS #undef _GLIBCXX_BITSET_BITS_PER_WORD #undef _GLIBCXX_BITSET_BITS_PER_ULL #if __cplusplus >= 201103L #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // DR 1182. /// std::hash specialization for bitset. template struct hash<_GLIBCXX_STD_C::bitset<_Nb>> : public __hash_base> { size_t operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept { const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__; return std::_Hash_impl::hash(__b._M_getdata(), __clength); } }; template<> struct hash<_GLIBCXX_STD_C::bitset<0>> : public __hash_base> { size_t operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept { return 0; } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++11 #ifdef _GLIBCXX_DEBUG # include #endif #ifdef _GLIBCXX_PROFILE # include #endif #endif /* _GLIBCXX_BITSET */ 4.8.2/new000064400000010130147547540550005744 0ustar00// The -*- C++ -*- dynamic memory management header. // Copyright (C) 1994-2013 Free Software Foundation, Inc. // This file is part of GCC. // // GCC is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3, or (at your option) // any later version. // // GCC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file new * This is a Standard C++ Library header. * * The header @c new defines several functions to manage dynamic memory and * handling memory allocation errors; see * http://gcc.gnu.org/onlinedocs/libstdc++/18_support/howto.html#4 for more. */ #ifndef _NEW #define _NEW #pragma GCC system_header #include #include #pragma GCC visibility push(default) extern "C++" { namespace std { /** * @brief Exception possibly thrown by @c new. * @ingroup exceptions * * @c bad_alloc (or classes derived from it) is used to report allocation * errors from the throwing forms of @c new. */ class bad_alloc : public exception { public: bad_alloc() throw() { } // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_alloc() throw(); // See comment in eh_exception.cc. virtual const char* what() const throw(); }; struct nothrow_t { }; extern const nothrow_t nothrow; /** If you write your own error handler to be called by @c new, it must * be of this type. */ typedef void (*new_handler)(); /// Takes a replacement handler as the argument, returns the /// previous handler. new_handler set_new_handler(new_handler) throw(); } // namespace std //@{ /** These are replaceable signatures: * - normal single new and delete (no arguments, throw @c bad_alloc on error) * - normal array new and delete (same) * - @c nothrow single new and delete (take a @c nothrow argument, return * @c NULL on error) * - @c nothrow array new and delete (same) * * Placement new and delete signatures (take a memory address argument, * does nothing) may not be replaced by a user's program. */ void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); void operator delete(void*) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); // Default placement versions of operator new. inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT { return __p; } inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT { return __p; } // Default placement versions of operator delete. inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } //@} } // extern "C++" #pragma GCC visibility pop #endif 4.8.2/cstdalign000064400000002577147547540550007143 0ustar00// -*- C++ -*- // Copyright (C) 2011-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file include/cstdalign * This is a Standard C++ Library header. */ #pragma GCC system_header #ifndef _GLIBCXX_CSTDALIGN #define _GLIBCXX_CSTDALIGN 1 #if __cplusplus < 201103L # include #else # include # if _GLIBCXX_HAVE_STDALIGN_H # include # endif #endif #endif 4.8.2/cxxabi.h000064400000052363147547540550006675 0ustar00// ABI Support -*- C++ -*- // Copyright (C) 2000-2013 Free Software Foundation, Inc. // // This file is part of GCC. // // GCC is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3, or (at your option) // any later version. // // GCC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Written by Nathan Sidwell, Codesourcery LLC, /* This file declares the new abi entry points into the runtime. It is not normally necessary for user programs to include this header, or use the entry points directly. However, this header is available should that be needed. Some of the entry points are intended for both C and C++, thus this header is includable from both C and C++. Though the C++ specific parts are not available in C, naturally enough. */ /** @file cxxabi.h * The header provides an interface to the C++ ABI. */ #ifndef _CXXABI_H #define _CXXABI_H 1 #pragma GCC system_header #pragma GCC visibility push(default) #include #include #include #include #ifndef _GLIBCXX_CDTOR_CALLABI #define _GLIBCXX_CDTOR_CALLABI #endif #ifdef __cplusplus namespace __cxxabiv1 { extern "C" { #endif typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); // Allocate array. void* __cxa_vec_new(size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __constructor, __cxa_cdtor_type __destructor); void* __cxa_vec_new2(size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __constructor, __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), void (*__dealloc) (void*)); void* __cxa_vec_new3(size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __constructor, __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), void (*__dealloc) (void*, size_t)); // Construct array. __cxa_vec_ctor_return_type __cxa_vec_ctor(void* __array_address, size_t __element_count, size_t __element_size, __cxa_cdtor_type __constructor, __cxa_cdtor_type __destructor); __cxa_vec_ctor_return_type __cxa_vec_cctor(void* __dest_array, void* __src_array, size_t __element_count, size_t __element_size, __cxa_cdtor_return_type (*__constructor) (void*, void*), __cxa_cdtor_type __destructor); // Destruct array. void __cxa_vec_dtor(void* __array_address, size_t __element_count, size_t __element_size, __cxa_cdtor_type __destructor); void __cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s, __cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW; // Destruct and release array. void __cxa_vec_delete(void* __array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __destructor); void __cxa_vec_delete2(void* __array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __destructor, void (*__dealloc) (void*)); void __cxa_vec_delete3(void* __array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type __destructor, void (*__dealloc) (void*, size_t)); int __cxa_guard_acquire(__guard*); void __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW; void __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW; // DSO destruction. int __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW; int __cxa_finalize(void*); // TLS destruction. int __cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW; // Pure virtual functions. void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); // Exception handling auxillary. void __cxa_bad_cast() __attribute__((__noreturn__)); void __cxa_bad_typeid() __attribute__((__noreturn__)); /** * @brief Demangling routine. * ABI-mandated entry point in the C++ runtime library for demangling. * * @param __mangled_name A NUL-terminated character string * containing the name to be demangled. * * @param __output_buffer A region of memory, allocated with * malloc, of @a *__length bytes, into which the demangled name is * stored. If @a __output_buffer is not long enough, it is * expanded using realloc. @a __output_buffer may instead be NULL; * in that case, the demangled name is placed in a region of memory * allocated with malloc. * * @param __length If @a __length is non-NULL, the length of the * buffer containing the demangled name is placed in @a *__length. * * @param __status @a *__status is set to one of the following values: * 0: The demangling operation succeeded. * -1: A memory allocation failure occurred. * -2: @a mangled_name is not a valid name under the C++ ABI mangling rules. * -3: One of the arguments is invalid. * * @return A pointer to the start of the NUL-terminated demangled * name, or NULL if the demangling fails. The caller is * responsible for deallocating this memory using @c free. * * The demangling is performed using the C++ ABI mangling rules, * with GNU extensions. For example, this function is used in * __gnu_cxx::__verbose_terminate_handler. * * See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch39.html * for other examples of use. * * @note The same demangling functionality is available via * libiberty (@c and @c libiberty.a) in GCC * 3.1 and later, but that requires explicit installation (@c * --enable-install-libiberty) and uses a different API, although * the ABI is unchanged. */ char* __cxa_demangle(const char* __mangled_name, char* __output_buffer, size_t* __length, int* __status); #ifdef __cplusplus } } // namespace __cxxabiv1 #endif #ifdef __cplusplus #include namespace __cxxabiv1 { // Type information for int, float etc. class __fundamental_type_info : public std::type_info { public: explicit __fundamental_type_info(const char* __n) : std::type_info(__n) { } virtual ~__fundamental_type_info(); }; // Type information for array objects. class __array_type_info : public std::type_info { public: explicit __array_type_info(const char* __n) : std::type_info(__n) { } virtual ~__array_type_info(); }; // Type information for functions (both member and non-member). class __function_type_info : public std::type_info { public: explicit __function_type_info(const char* __n) : std::type_info(__n) { } virtual ~__function_type_info(); protected: // Implementation defined member function. virtual bool __is_function_p() const; }; // Type information for enumerations. class __enum_type_info : public std::type_info { public: explicit __enum_type_info(const char* __n) : std::type_info(__n) { } virtual ~__enum_type_info(); }; // Common type information for simple pointers and pointers to member. class __pbase_type_info : public std::type_info { public: unsigned int __flags; // Qualification of the target object. const std::type_info* __pointee; // Type of pointed to object. explicit __pbase_type_info(const char* __n, int __quals, const std::type_info* __type) : std::type_info(__n), __flags(__quals), __pointee(__type) { } virtual ~__pbase_type_info(); // Implementation defined type. enum __masks { __const_mask = 0x1, __volatile_mask = 0x2, __restrict_mask = 0x4, __incomplete_mask = 0x8, __incomplete_class_mask = 0x10 }; protected: __pbase_type_info(const __pbase_type_info&); __pbase_type_info& operator=(const __pbase_type_info&); // Implementation defined member functions. virtual bool __do_catch(const std::type_info* __thr_type, void** __thr_obj, unsigned int __outer) const; inline virtual bool __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, unsigned __outer) const; }; // Type information for simple pointers. class __pointer_type_info : public __pbase_type_info { public: explicit __pointer_type_info(const char* __n, int __quals, const std::type_info* __type) : __pbase_type_info (__n, __quals, __type) { } virtual ~__pointer_type_info(); protected: // Implementation defined member functions. virtual bool __is_pointer_p() const; virtual bool __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, unsigned __outer) const; }; class __class_type_info; // Type information for a pointer to member variable. class __pointer_to_member_type_info : public __pbase_type_info { public: __class_type_info* __context; // Class of the member. explicit __pointer_to_member_type_info(const char* __n, int __quals, const std::type_info* __type, __class_type_info* __klass) : __pbase_type_info(__n, __quals, __type), __context(__klass) { } virtual ~__pointer_to_member_type_info(); protected: __pointer_to_member_type_info(const __pointer_to_member_type_info&); __pointer_to_member_type_info& operator=(const __pointer_to_member_type_info&); // Implementation defined member function. virtual bool __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, unsigned __outer) const; }; // Helper class for __vmi_class_type. class __base_class_type_info { public: const __class_type_info* __base_type; // Base class type. #ifdef _GLIBCXX_LLP64 long long __offset_flags; // Offset and info. #else long __offset_flags; // Offset and info. #endif enum __offset_flags_masks { __virtual_mask = 0x1, __public_mask = 0x2, __hwm_bit = 2, __offset_shift = 8 // Bits to shift offset. }; // Implementation defined member functions. bool __is_virtual_p() const { return __offset_flags & __virtual_mask; } bool __is_public_p() const { return __offset_flags & __public_mask; } ptrdiff_t __offset() const { // This shift, being of a signed type, is implementation // defined. GCC implements such shifts as arithmetic, which is // what we want. return static_cast(__offset_flags) >> __offset_shift; } }; // Type information for a class. class __class_type_info : public std::type_info { public: explicit __class_type_info (const char *__n) : type_info(__n) { } virtual ~__class_type_info (); // Implementation defined types. // The type sub_kind tells us about how a base object is contained // within a derived object. We often do this lazily, hence the // UNKNOWN value. At other times we may use NOT_CONTAINED to mean // not publicly contained. enum __sub_kind { // We have no idea. __unknown = 0, // Not contained within us (in some circumstances this might // mean not contained publicly) __not_contained, // Contained ambiguously. __contained_ambig, // Via a virtual path. __contained_virtual_mask = __base_class_type_info::__virtual_mask, // Via a public path. __contained_public_mask = __base_class_type_info::__public_mask, // Contained within us. __contained_mask = 1 << __base_class_type_info::__hwm_bit, __contained_private = __contained_mask, __contained_public = __contained_mask | __contained_public_mask }; struct __upcast_result; struct __dyncast_result; protected: // Implementation defined member functions. virtual bool __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const; virtual bool __do_catch(const type_info* __thr_type, void** __thr_obj, unsigned __outer) const; public: // Helper for upcast. See if DST is us, or one of our bases. // Return false if not found, true if found. virtual bool __do_upcast(const __class_type_info* __dst, const void* __obj, __upcast_result& __restrict __result) const; // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly // within OBJ_PTR. OBJ_PTR points to a base object of our type, // which is the destination type. SRC2DST indicates how SRC // objects might be contained within this type. If SRC_PTR is one // of our SRC_TYPE bases, indicate the virtuality. Returns // not_contained for non containment or private containment. inline __sub_kind __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr) const; // Helper for dynamic cast. ACCESS_PATH gives the access from the // most derived object to this base. DST_TYPE indicates the // desired type we want. OBJ_PTR points to a base of our type // within the complete object. SRC_TYPE indicates the static type // started from and SRC_PTR points to that base within the most // derived object. Fill in RESULT with what we find. Return true // if we have located an ambiguous match. virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info* __dst_type, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr, __dyncast_result& __result) const; // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE // bases are inherited by the type started from -- which is not // necessarily the current type. The current type will be a base // of the destination type. OBJ_PTR points to the current base. virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr) const; }; // Type information for a class with a single non-virtual base. class __si_class_type_info : public __class_type_info { public: const __class_type_info* __base_type; explicit __si_class_type_info(const char *__n, const __class_type_info *__base) : __class_type_info(__n), __base_type(__base) { } virtual ~__si_class_type_info(); protected: __si_class_type_info(const __si_class_type_info&); __si_class_type_info& operator=(const __si_class_type_info&); // Implementation defined member functions. virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info* __dst_type, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr, __dyncast_result& __result) const; virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, const __class_type_info* __src_type, const void* __sub_ptr) const; virtual bool __do_upcast(const __class_type_info*__dst, const void*__obj, __upcast_result& __restrict __result) const; }; // Type information for a class with multiple and/or virtual bases. class __vmi_class_type_info : public __class_type_info { public: unsigned int __flags; // Details about the class hierarchy. unsigned int __base_count; // Number of direct bases. // The array of bases uses the trailing array struct hack so this // class is not constructable with a normal constructor. It is // internally generated by the compiler. __base_class_type_info __base_info[1]; // Array of bases. explicit __vmi_class_type_info(const char* __n, int ___flags) : __class_type_info(__n), __flags(___flags), __base_count(0) { } virtual ~__vmi_class_type_info(); // Implementation defined types. enum __flags_masks { __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base. __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance. __flags_unknown_mask = 0x10 }; protected: // Implementation defined member functions. virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info* __dst_type, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr, __dyncast_result& __result) const; virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, const __class_type_info* __src_type, const void* __src_ptr) const; virtual bool __do_upcast(const __class_type_info* __dst, const void* __obj, __upcast_result& __restrict __result) const; }; // Exception handling forward declarations. struct __cxa_exception; struct __cxa_refcounted_exception; struct __cxa_dependent_exception; struct __cxa_eh_globals; extern "C" { // Dynamic cast runtime. // src2dst has the following possible values // >-1: src_type is a unique public non-virtual base of dst_type // dst_ptr + src2dst == src_ptr // -1: unspecified relationship // -2: src_type is not a public base of dst_type // -3: src_type is a multiple public non-virtual base of dst_type void* __dynamic_cast(const void* __src_ptr, // Starting object. const __class_type_info* __src_type, // Static type of object. const __class_type_info* __dst_type, // Desired target type. ptrdiff_t __src2dst); // How src and dst are related. // Exception handling runtime. // The __cxa_eh_globals for the current thread can be obtained by using // either of the following functions. The "fast" version assumes at least // one prior call of __cxa_get_globals has been made from the current // thread, so no initialization is necessary. __cxa_eh_globals* __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__)); __cxa_eh_globals* __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__)); // Allocate memory for the primary exception plus the thrown object. void* __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW; // Free the space allocated for the primary exception. void __cxa_free_exception(void*) _GLIBCXX_NOTHROW; // Throw the exception. void __cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *)) __attribute__((__noreturn__)); // Used to implement exception handlers. void* __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__)); void* __cxa_begin_catch(void*) _GLIBCXX_NOTHROW; void __cxa_end_catch(); void __cxa_rethrow() __attribute__((__noreturn__)); // Returns the type_info for the currently handled exception [15.3/8], or // null if there is none. std::type_info* __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__)); // GNU Extensions. // Allocate memory for a dependent exception. __cxa_dependent_exception* __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW; // Free the space allocated for the dependent exception. void __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW; } // extern "C" // A magic placeholder class that can be caught by reference // to recognize foreign exceptions. class __foreign_exception { virtual ~__foreign_exception() throw(); virtual void __pure_dummy() = 0; // prevent catch by value }; } // namespace __cxxabiv1 /** @namespace abi * @brief The cross-vendor C++ Application Binary Interface. A * namespace alias to __cxxabiv1, but user programs should use the * alias 'abi'. * * A brief overview of an ABI is given in the libstdc++ FAQ, question * 5.8 (you may have a copy of the FAQ locally, or you can view the online * version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ). * * GCC subscribes to a cross-vendor ABI for C++, sometimes * called the IA64 ABI because it happens to be the native ABI for that * platform. It is summarized at http://www.codesourcery.com/cxx-abi/ * along with the current specification. * * For users of GCC greater than or equal to 3.x, entry points are * available in , which notes, 'It is not normally * necessary for user programs to include this header, or use the * entry points directly. However, this header is available should * that be needed.' */ namespace abi = __cxxabiv1; namespace __gnu_cxx { /** * @brief Exception thrown by __cxa_guard_acquire. * @ingroup exceptions * * 6.7[stmt.dcl]/4: If control re-enters the declaration (recursively) * while the object is being initialized, the behavior is undefined. * * Since we already have a library function to handle locking, we might * as well check for this situation and throw an exception. * We use the second byte of the guard variable to remember that we're * in the middle of an initialization. */ class recursive_init_error: public std::exception { public: recursive_init_error() throw() { } virtual ~recursive_init_error() throw (); }; } #endif // __cplusplus #pragma GCC visibility pop #endif // __CXXABI_H 4.8.2/ext/vstring.h000064400000317700147547540550007712 0ustar00// Versatile string -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/vstring.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _VSTRING_H #define _VSTRING_H 1 #pragma GCC system_header #if __cplusplus >= 201103L #include #endif #include #include #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @class __versa_string vstring.h * @brief Template class __versa_string. * @ingroup extensions * * Data structure managing sequences of characters and * character-like objects. */ template class _Base> class __versa_string : private _Base<_CharT, _Traits, _Alloc> { typedef _Base<_CharT, _Traits, _Alloc> __vstring_base; typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type; // Types: public: typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef _Alloc allocator_type; typedef typename _CharT_alloc_type::size_type size_type; typedef typename _CharT_alloc_type::difference_type difference_type; typedef value_type& reference; typedef const value_type& const_reference; typedef typename _CharT_alloc_type::pointer pointer; typedef typename _CharT_alloc_type::const_pointer const_pointer; typedef __gnu_cxx::__normal_iterator iterator; typedef __gnu_cxx::__normal_iterator const_iterator; typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; // Data Member (public): /// Value returned by various member functions when they fail. static const size_type npos = static_cast(-1); private: size_type _M_check(size_type __pos, const char* __s) const { if (__pos > this->size()) std::__throw_out_of_range(__N(__s)); return __pos; } void _M_check_length(size_type __n1, size_type __n2, const char* __s) const { if (this->max_size() - (this->size() - __n1) < __n2) std::__throw_length_error(__N(__s)); } // NB: _M_limit doesn't check for a bad __pos value. size_type _M_limit(size_type __pos, size_type __off) const { const bool __testoff = __off < this->size() - __pos; return __testoff ? __off : this->size() - __pos; } // True if _Rep and source do not overlap. bool _M_disjunct(const _CharT* __s) const { return (std::less()(__s, this->_M_data()) || std::less()(this->_M_data() + this->size(), __s)); } // For the internal use we have functions similar to `begin'/`end' // but they do not call _M_leak. iterator _M_ibegin() const { return iterator(this->_M_data()); } iterator _M_iend() const { return iterator(this->_M_data() + this->_M_length()); } public: // Construct/copy/destroy: // NB: We overload ctors in some cases instead of using default // arguments, per 17.4.4.4 para. 2 item 2. /** * @brief Default constructor creates an empty string. */ __versa_string() : __vstring_base() { } /** * @brief Construct an empty string using allocator @a a. */ explicit __versa_string(const _Alloc& __a) : __vstring_base(__a) { } // NB: per LWG issue 42, semantics different from IS: /** * @brief Construct string with copy of value of @a __str. * @param __str Source string. */ __versa_string(const __versa_string& __str) : __vstring_base(__str) { } #if __cplusplus >= 201103L /** * @brief String move constructor. * @param __str Source string. * * The newly-constructed %string contains the exact contents of * @a __str. The contents of @a __str are a valid, but unspecified * string. */ __versa_string(__versa_string&& __str) noexcept : __vstring_base(std::move(__str)) { } /** * @brief Construct string from an initializer list. * @param __l std::initializer_list of characters. * @param __a Allocator to use (default is default allocator). */ __versa_string(std::initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) : __vstring_base(__l.begin(), __l.end(), __a) { } #endif /** * @brief Construct string as copy of a substring. * @param __str Source string. * @param __pos Index of first character to copy from. * @param __n Number of characters to copy (default remainder). */ __versa_string(const __versa_string& __str, size_type __pos, size_type __n = npos) : __vstring_base(__str._M_data() + __str._M_check(__pos, "__versa_string::__versa_string"), __str._M_data() + __str._M_limit(__pos, __n) + __pos, _Alloc()) { } /** * @brief Construct string as copy of a substring. * @param __str Source string. * @param __pos Index of first character to copy from. * @param __n Number of characters to copy. * @param __a Allocator to use. */ __versa_string(const __versa_string& __str, size_type __pos, size_type __n, const _Alloc& __a) : __vstring_base(__str._M_data() + __str._M_check(__pos, "__versa_string::__versa_string"), __str._M_data() + __str._M_limit(__pos, __n) + __pos, __a) { } /** * @brief Construct string initialized by a character array. * @param __s Source character array. * @param __n Number of characters to copy. * @param __a Allocator to use (default is default allocator). * * NB: @a __s must have at least @a __n characters, '\\0' has no special * meaning. */ __versa_string(const _CharT* __s, size_type __n, const _Alloc& __a = _Alloc()) : __vstring_base(__s, __s + __n, __a) { } /** * @brief Construct string as copy of a C string. * @param __s Source C string. * @param __a Allocator to use (default is default allocator). */ __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc()) : __vstring_base(__s, __s ? __s + traits_type::length(__s) : __s + npos, __a) { } /** * @brief Construct string as multiple characters. * @param __n Number of characters. * @param __c Character to use. * @param __a Allocator to use (default is default allocator). */ __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) : __vstring_base(__n, __c, __a) { } /** * @brief Construct string as copy of a range. * @param __beg Start of range. * @param __end End of range. * @param __a Allocator to use (default is default allocator). */ #if __cplusplus >= 201103L template> #else template #endif __versa_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc()) : __vstring_base(__beg, __end, __a) { } /** * @brief Destroy the string instance. */ ~__versa_string() _GLIBCXX_NOEXCEPT { } /** * @brief Assign the value of @a str to this string. * @param __str Source string. */ __versa_string& operator=(const __versa_string& __str) { return this->assign(__str); } #if __cplusplus >= 201103L /** * @brief String move assignment operator. * @param __str Source string. * * The contents of @a __str are moved into this string (without * copying). @a __str is a valid, but unspecified string. */ __versa_string& operator=(__versa_string&& __str) { // NB: DR 1204. this->swap(__str); return *this; } /** * @brief Set value to string constructed from initializer list. * @param __l std::initializer_list. */ __versa_string& operator=(std::initializer_list<_CharT> __l) { this->assign(__l.begin(), __l.end()); return *this; } #endif /** * @brief Copy contents of @a __s into this string. * @param __s Source null-terminated string. */ __versa_string& operator=(const _CharT* __s) { return this->assign(__s); } /** * @brief Set value to string of length 1. * @param __c Source character. * * Assigning to a character makes this string length 1 and * (*this)[0] == @a __c. */ __versa_string& operator=(_CharT __c) { this->assign(1, __c); return *this; } // Iterators: /** * Returns a read/write iterator that points to the first character in * the %string. Unshares the string. */ iterator begin() _GLIBCXX_NOEXCEPT { this->_M_leak(); return iterator(this->_M_data()); } /** * Returns a read-only (constant) iterator that points to the first * character in the %string. */ const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(this->_M_data()); } /** * Returns a read/write iterator that points one past the last * character in the %string. Unshares the string. */ iterator end() _GLIBCXX_NOEXCEPT { this->_M_leak(); return iterator(this->_M_data() + this->size()); } /** * Returns a read-only (constant) iterator that points one past the * last character in the %string. */ const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(this->_M_data() + this->size()); } /** * Returns a read/write reverse iterator that points to the last * character in the %string. Iteration is done in reverse element * order. Unshares the string. */ reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(this->end()); } /** * Returns a read-only (constant) reverse iterator that points * to the last character in the %string. Iteration is done in * reverse element order. */ const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(this->end()); } /** * Returns a read/write reverse iterator that points to one before the * first character in the %string. Iteration is done in reverse * element order. Unshares the string. */ reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(this->begin()); } /** * Returns a read-only (constant) reverse iterator that points * to one before the first character in the %string. Iteration * is done in reverse element order. */ const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(this->begin()); } #if __cplusplus >= 201103L /** * Returns a read-only (constant) iterator that points to the first * character in the %string. */ const_iterator cbegin() const noexcept { return const_iterator(this->_M_data()); } /** * Returns a read-only (constant) iterator that points one past the * last character in the %string. */ const_iterator cend() const noexcept { return const_iterator(this->_M_data() + this->size()); } /** * Returns a read-only (constant) reverse iterator that points * to the last character in the %string. Iteration is done in * reverse element order. */ const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); } /** * Returns a read-only (constant) reverse iterator that points * to one before the first character in the %string. Iteration * is done in reverse element order. */ const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); } #endif public: // Capacity: /// Returns the number of characters in the string, not including any /// null-termination. size_type size() const _GLIBCXX_NOEXCEPT { return this->_M_length(); } /// Returns the number of characters in the string, not including any /// null-termination. size_type length() const _GLIBCXX_NOEXCEPT { return this->_M_length(); } /// Returns the size() of the largest possible %string. size_type max_size() const _GLIBCXX_NOEXCEPT { return this->_M_max_size(); } /** * @brief Resizes the %string to the specified number of characters. * @param __n Number of characters the %string should contain. * @param __c Character to fill any new elements. * * This function will %resize the %string to the specified * number of characters. If the number is smaller than the * %string's current size the %string is truncated, otherwise * the %string is extended and new elements are set to @a __c. */ void resize(size_type __n, _CharT __c); /** * @brief Resizes the %string to the specified number of characters. * @param __n Number of characters the %string should contain. * * This function will resize the %string to the specified * length. If the new size is smaller than the %string's * current size the %string is truncated, otherwise the %string * is extended and new characters are default-constructed. For * basic types such as char, this means setting them to 0. */ void resize(size_type __n) { this->resize(__n, _CharT()); } #if __cplusplus >= 201103L /// A non-binding request to reduce capacity() to size(). void shrink_to_fit() { if (capacity() > size()) { __try { this->reserve(0); } __catch(...) { } } } #endif /** * Returns the total number of characters that the %string can * hold before needing to allocate more memory. */ size_type capacity() const _GLIBCXX_NOEXCEPT { return this->_M_capacity(); } /** * @brief Attempt to preallocate enough memory for specified number of * characters. * @param __res_arg Number of characters required. * @throw std::length_error If @a __res_arg exceeds @c max_size(). * * This function attempts to reserve enough memory for the * %string to hold the specified number of characters. If the * number requested is more than max_size(), length_error is * thrown. * * The advantage of this function is that if optimal code is a * necessity and the user can determine the string length that * will be required, the user can reserve the memory in * %advance, and thus prevent a possible reallocation of memory * and copying of %string data. */ void reserve(size_type __res_arg = 0) { this->_M_reserve(__res_arg); } /** * Erases the string, making it empty. */ void clear() _GLIBCXX_NOEXCEPT { this->_M_clear(); } /** * Returns true if the %string is empty. Equivalent to * *this == "". */ bool empty() const _GLIBCXX_NOEXCEPT { return this->size() == 0; } // Element access: /** * @brief Subscript access to the data contained in the %string. * @param __pos The index of the character to access. * @return Read-only (constant) reference to the character. * * This operator allows for easy, array-style, data access. * Note that data access with this operator is unchecked and * out_of_range lookups are not defined. (For checked lookups * see at().) */ const_reference operator[] (size_type __pos) const { _GLIBCXX_DEBUG_ASSERT(__pos <= this->size()); return this->_M_data()[__pos]; } /** * @brief Subscript access to the data contained in the %string. * @param __pos The index of the character to access. * @return Read/write reference to the character. * * This operator allows for easy, array-style, data access. * Note that data access with this operator is unchecked and * out_of_range lookups are not defined. (For checked lookups * see at().) Unshares the string. */ reference operator[](size_type __pos) { // allow pos == size() as v3 extension: _GLIBCXX_DEBUG_ASSERT(__pos <= this->size()); // but be strict in pedantic mode: _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size()); this->_M_leak(); return this->_M_data()[__pos]; } /** * @brief Provides access to the data contained in the %string. * @param __n The index of the character to access. * @return Read-only (const) reference to the character. * @throw std::out_of_range If @a __n is an invalid index. * * This function provides for safer data access. The parameter * is first checked that it is in the range of the string. The * function throws out_of_range if the check fails. */ const_reference at(size_type __n) const { if (__n >= this->size()) std::__throw_out_of_range(__N("__versa_string::at")); return this->_M_data()[__n]; } /** * @brief Provides access to the data contained in the %string. * @param __n The index of the character to access. * @return Read/write reference to the character. * @throw std::out_of_range If @a __n is an invalid index. * * This function provides for safer data access. The parameter * is first checked that it is in the range of the string. The * function throws out_of_range if the check fails. Success * results in unsharing the string. */ reference at(size_type __n) { if (__n >= this->size()) std::__throw_out_of_range(__N("__versa_string::at")); this->_M_leak(); return this->_M_data()[__n]; } #if __cplusplus >= 201103L /** * Returns a read/write reference to the data at the first * element of the %string. */ reference front() { return operator[](0); } /** * Returns a read-only (constant) reference to the data at the first * element of the %string. */ const_reference front() const { return operator[](0); } /** * Returns a read/write reference to the data at the last * element of the %string. */ reference back() { return operator[](this->size() - 1); } /** * Returns a read-only (constant) reference to the data at the * last element of the %string. */ const_reference back() const { return operator[](this->size() - 1); } #endif // Modifiers: /** * @brief Append a string to this string. * @param __str The string to append. * @return Reference to this string. */ __versa_string& operator+=(const __versa_string& __str) { return this->append(__str); } /** * @brief Append a C string. * @param __s The C string to append. * @return Reference to this string. */ __versa_string& operator+=(const _CharT* __s) { return this->append(__s); } /** * @brief Append a character. * @param __c The character to append. * @return Reference to this string. */ __versa_string& operator+=(_CharT __c) { this->push_back(__c); return *this; } #if __cplusplus >= 201103L /** * @brief Append an initializer_list of characters. * @param __l The initializer_list of characters to be appended. * @return Reference to this string. */ __versa_string& operator+=(std::initializer_list<_CharT> __l) { return this->append(__l.begin(), __l.end()); } #endif // C++11 /** * @brief Append a string to this string. * @param __str The string to append. * @return Reference to this string. */ __versa_string& append(const __versa_string& __str) { return _M_append(__str._M_data(), __str.size()); } /** * @brief Append a substring. * @param __str The string to append. * @param __pos Index of the first character of str to append. * @param __n The number of characters to append. * @return Reference to this string. * @throw std::out_of_range if @a pos is not a valid index. * * This function appends @a __n characters from @a __str * starting at @a __pos to this string. If @a __n is is larger * than the number of available characters in @a __str, the * remainder of @a __str is appended. */ __versa_string& append(const __versa_string& __str, size_type __pos, size_type __n) { return _M_append(__str._M_data() + __str._M_check(__pos, "__versa_string::append"), __str._M_limit(__pos, __n)); } /** * @brief Append a C substring. * @param __s The C string to append. * @param __n The number of characters to append. * @return Reference to this string. */ __versa_string& append(const _CharT* __s, size_type __n) { __glibcxx_requires_string_len(__s, __n); _M_check_length(size_type(0), __n, "__versa_string::append"); return _M_append(__s, __n); } /** * @brief Append a C string. * @param __s The C string to append. * @return Reference to this string. */ __versa_string& append(const _CharT* __s) { __glibcxx_requires_string(__s); const size_type __n = traits_type::length(__s); _M_check_length(size_type(0), __n, "__versa_string::append"); return _M_append(__s, __n); } /** * @brief Append multiple characters. * @param __n The number of characters to append. * @param __c The character to use. * @return Reference to this string. * * Appends n copies of c to this string. */ __versa_string& append(size_type __n, _CharT __c) { return _M_replace_aux(this->size(), size_type(0), __n, __c); } #if __cplusplus >= 201103L /** * @brief Append an initializer_list of characters. * @param __l The initializer_list of characters to append. * @return Reference to this string. */ __versa_string& append(std::initializer_list<_CharT> __l) { return this->append(__l.begin(), __l.end()); } #endif // C++11 /** * @brief Append a range of characters. * @param __first Iterator referencing the first character to append. * @param __last Iterator marking the end of the range. * @return Reference to this string. * * Appends characters in the range [first,last) to this string. */ #if __cplusplus >= 201103L template> #else template #endif __versa_string& append(_InputIterator __first, _InputIterator __last) { return this->replace(_M_iend(), _M_iend(), __first, __last); } /** * @brief Append a single character. * @param __c Character to append. */ void push_back(_CharT __c) { const size_type __size = this->size(); if (__size + 1 > this->capacity() || this->_M_is_shared()) this->_M_mutate(__size, size_type(0), 0, size_type(1)); traits_type::assign(this->_M_data()[__size], __c); this->_M_set_length(__size + 1); } /** * @brief Set value to contents of another string. * @param __str Source string to use. * @return Reference to this string. */ __versa_string& assign(const __versa_string& __str) { this->_M_assign(__str); return *this; } #if __cplusplus >= 201103L /** * @brief Set value to contents of another string. * @param __str Source string to use. * @return Reference to this string. * * This function sets this string to the exact contents of @a __str. * @a __str is a valid, but unspecified string. */ __versa_string& assign(__versa_string&& __str) { this->swap(__str); return *this; } #endif // C++11 /** * @brief Set value to a substring of a string. * @param __str The string to use. * @param __pos Index of the first character of str. * @param __n Number of characters to use. * @return Reference to this string. * @throw std::out_of_range if @a __pos is not a valid index. * * This function sets this string to the substring of @a __str * consisting of @a __n characters at @a __pos. If @a __n is * is larger than the number of available characters in @a * __str, the remainder of @a __str is used. */ __versa_string& assign(const __versa_string& __str, size_type __pos, size_type __n) { return _M_replace(size_type(0), this->size(), __str._M_data() + __str._M_check(__pos, "__versa_string::assign"), __str._M_limit(__pos, __n)); } /** * @brief Set value to a C substring. * @param __s The C string to use. * @param __n Number of characters to use. * @return Reference to this string. * * This function sets the value of this string to the first @a * __n characters of @a __s. If @a __n is is larger than the * number of available characters in @a __s, the remainder of * @a __s is used. */ __versa_string& assign(const _CharT* __s, size_type __n) { __glibcxx_requires_string_len(__s, __n); return _M_replace(size_type(0), this->size(), __s, __n); } /** * @brief Set value to contents of a C string. * @param __s The C string to use. * @return Reference to this string. * * This function sets the value of this string to the value of * @a __s. The data is copied, so there is no dependence on @a * __s once the function returns. */ __versa_string& assign(const _CharT* __s) { __glibcxx_requires_string(__s); return _M_replace(size_type(0), this->size(), __s, traits_type::length(__s)); } /** * @brief Set value to multiple characters. * @param __n Length of the resulting string. * @param __c The character to use. * @return Reference to this string. * * This function sets the value of this string to @a __n copies of * character @a __c. */ __versa_string& assign(size_type __n, _CharT __c) { return _M_replace_aux(size_type(0), this->size(), __n, __c); } /** * @brief Set value to a range of characters. * @param __first Iterator referencing the first character to append. * @param __last Iterator marking the end of the range. * @return Reference to this string. * * Sets value of string to characters in the range * [first,last). */ #if __cplusplus >= 201103L template> #else template #endif __versa_string& assign(_InputIterator __first, _InputIterator __last) { return this->replace(_M_ibegin(), _M_iend(), __first, __last); } #if __cplusplus >= 201103L /** * @brief Set value to an initializer_list of characters. * @param __l The initializer_list of characters to assign. * @return Reference to this string. */ __versa_string& assign(std::initializer_list<_CharT> __l) { return this->assign(__l.begin(), __l.end()); } #endif // C++11 /** * @brief Insert multiple characters. * @param __p Iterator referencing location in string to insert at. * @param __n Number of characters to insert * @param __c The character to insert. * @throw std::length_error If new length exceeds @c max_size(). * * Inserts @a __n copies of character @a __c starting at the * position referenced by iterator @a __p. If adding * characters causes the length to exceed max_size(), * length_error is thrown. The value of the string doesn't * change if an error is thrown. */ void insert(iterator __p, size_type __n, _CharT __c) { this->replace(__p, __p, __n, __c); } /** * @brief Insert a range of characters. * @param __p Iterator referencing location in string to insert at. * @param __beg Start of range. * @param __end End of range. * @throw std::length_error If new length exceeds @c max_size(). * * Inserts characters in range [beg,end). If adding characters * causes the length to exceed max_size(), length_error is * thrown. The value of the string doesn't change if an error * is thrown. */ #if __cplusplus >= 201103L template> #else template #endif void insert(iterator __p, _InputIterator __beg, _InputIterator __end) { this->replace(__p, __p, __beg, __end); } #if __cplusplus >= 201103L /** * @brief Insert an initializer_list of characters. * @param __p Iterator referencing location in string to insert at. * @param __l The initializer_list of characters to insert. * @throw std::length_error If new length exceeds @c max_size(). */ void insert(iterator __p, std::initializer_list<_CharT> __l) { this->insert(__p, __l.begin(), __l.end()); } #endif // C++11 /** * @brief Insert value of a string. * @param __pos1 Iterator referencing location in string to insert at. * @param __str The string to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Inserts value of @a __str starting at @a __pos1. If adding * characters causes the length to exceed max_size(), * length_error is thrown. The value of the string doesn't * change if an error is thrown. */ __versa_string& insert(size_type __pos1, const __versa_string& __str) { return this->replace(__pos1, size_type(0), __str._M_data(), __str.size()); } /** * @brief Insert a substring. * @param __pos1 Iterator referencing location in string to insert at. * @param __str The string to insert. * @param __pos2 Start of characters in str to insert. * @param __n Number of characters to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * @throw std::out_of_range If @a __pos1 > size() or * @a __pos2 > @a __str.size(). * * Starting at @a __pos1, insert @a __n character of @a __str * beginning with @a __pos2. If adding characters causes the * length to exceed max_size(), length_error is thrown. If @a * __pos1 is beyond the end of this string or @a __pos2 is * beyond the end of @a __str, out_of_range is thrown. The * value of the string doesn't change if an error is thrown. */ __versa_string& insert(size_type __pos1, const __versa_string& __str, size_type __pos2, size_type __n) { return this->replace(__pos1, size_type(0), __str._M_data() + __str._M_check(__pos2, "__versa_string::insert"), __str._M_limit(__pos2, __n)); } /** * @brief Insert a C substring. * @param __pos Iterator referencing location in string to insert at. * @param __s The C string to insert. * @param __n The number of characters to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * @throw std::out_of_range If @a __pos is beyond the end of this * string. * * Inserts the first @a __n characters of @a __s starting at @a * __pos. If adding characters causes the length to exceed * max_size(), length_error is thrown. If @a __pos is beyond * end(), out_of_range is thrown. The value of the string * doesn't change if an error is thrown. */ __versa_string& insert(size_type __pos, const _CharT* __s, size_type __n) { return this->replace(__pos, size_type(0), __s, __n); } /** * @brief Insert a C string. * @param __pos Iterator referencing location in string to insert at. * @param __s The C string to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * @throw std::out_of_range If @a __pos is beyond the end of this * string. * * Inserts the first @a __n characters of @a __s starting at @a * __pos. If adding characters causes the length to exceed * max_size(), length_error is thrown. If @a __pos is beyond * end(), out_of_range is thrown. The value of the string * doesn't change if an error is thrown. */ __versa_string& insert(size_type __pos, const _CharT* __s) { __glibcxx_requires_string(__s); return this->replace(__pos, size_type(0), __s, traits_type::length(__s)); } /** * @brief Insert multiple characters. * @param __pos Index in string to insert at. * @param __n Number of characters to insert * @param __c The character to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * @throw std::out_of_range If @a __pos is beyond the end of this * string. * * Inserts @a __n copies of character @a __c starting at index * @a __pos. If adding characters causes the length to exceed * max_size(), length_error is thrown. If @a __pos > length(), * out_of_range is thrown. The value of the string doesn't * change if an error is thrown. */ __versa_string& insert(size_type __pos, size_type __n, _CharT __c) { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"), size_type(0), __n, __c); } /** * @brief Insert one character. * @param __p Iterator referencing position in string to insert at. * @param __c The character to insert. * @return Iterator referencing newly inserted char. * @throw std::length_error If new length exceeds @c max_size(). * * Inserts character @a __c at position referenced by @a __p. * If adding character causes the length to exceed max_size(), * length_error is thrown. If @a __p is beyond end of string, * out_of_range is thrown. The value of the string doesn't * change if an error is thrown. */ iterator insert(iterator __p, _CharT __c) { _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); const size_type __pos = __p - _M_ibegin(); _M_replace_aux(__pos, size_type(0), size_type(1), __c); this->_M_set_leaked(); return iterator(this->_M_data() + __pos); } /** * @brief Remove characters. * @param __pos Index of first character to remove (default 0). * @param __n Number of characters to remove (default remainder). * @return Reference to this string. * @throw std::out_of_range If @a __pos is beyond the end of this * string. * * Removes @a __n characters from this string starting at @a * __pos. The length of the string is reduced by @a __n. If * there are < @a __n characters to remove, the remainder of * the string is truncated. If @a __p is beyond end of string, * out_of_range is thrown. The value of the string doesn't * change if an error is thrown. */ __versa_string& erase(size_type __pos = 0, size_type __n = npos) { this->_M_erase(_M_check(__pos, "__versa_string::erase"), _M_limit(__pos, __n)); return *this; } /** * @brief Remove one character. * @param __position Iterator referencing the character to remove. * @return iterator referencing same location after removal. * * Removes the character at @a __position from this string. The * value of the string doesn't change if an error is thrown. */ iterator erase(iterator __position) { _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin() && __position < _M_iend()); const size_type __pos = __position - _M_ibegin(); this->_M_erase(__pos, size_type(1)); this->_M_set_leaked(); return iterator(this->_M_data() + __pos); } /** * @brief Remove a range of characters. * @param __first Iterator referencing the first character to remove. * @param __last Iterator referencing the end of the range. * @return Iterator referencing location of first after removal. * * Removes the characters in the range [first,last) from this * string. The value of the string doesn't change if an error * is thrown. */ iterator erase(iterator __first, iterator __last) { _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last && __last <= _M_iend()); const size_type __pos = __first - _M_ibegin(); this->_M_erase(__pos, __last - __first); this->_M_set_leaked(); return iterator(this->_M_data() + __pos); } #if __cplusplus >= 201103L /** * @brief Remove the last character. * * The string must be non-empty. */ void pop_back() { this->_M_erase(size()-1, 1); } #endif // C++11 /** * @brief Replace characters with value from another string. * @param __pos Index of first character to replace. * @param __n Number of characters to be replaced. * @param __str String to insert. * @return Reference to this string. * @throw std::out_of_range If @a __pos is beyond the end of this * string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos+n) from this * string. In place, the value of @a __str is inserted. If @a * __pos is beyond end of string, out_of_range is thrown. If * the length of the result exceeds max_size(), length_error is * thrown. The value of the string doesn't change if an error * is thrown. */ __versa_string& replace(size_type __pos, size_type __n, const __versa_string& __str) { return this->replace(__pos, __n, __str._M_data(), __str.size()); } /** * @brief Replace characters with value from another string. * @param __pos1 Index of first character to replace. * @param __n1 Number of characters to be replaced. * @param __str String to insert. * @param __pos2 Index of first character of str to use. * @param __n2 Number of characters from str to use. * @return Reference to this string. * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 > * str.size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos1,pos1 + n) from * this string. In place, the value of @a __str is inserted. * If @a __pos is beyond end of string, out_of_range is thrown. * If the length of the result exceeds max_size(), length_error * is thrown. The value of the string doesn't change if an * error is thrown. */ __versa_string& replace(size_type __pos1, size_type __n1, const __versa_string& __str, size_type __pos2, size_type __n2) { return this->replace(__pos1, __n1, __str._M_data() + __str._M_check(__pos2, "__versa_string::replace"), __str._M_limit(__pos2, __n2)); } /** * @brief Replace characters with value of a C substring. * @param __pos Index of first character to replace. * @param __n1 Number of characters to be replaced. * @param __s C string to insert. * @param __n2 Number of characters from @a __s to use. * @return Reference to this string. * @throw std::out_of_range If @a __pos1 > size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos + n1) from this * string. In place, the first @a __n2 characters of @a __s * are inserted, or all of @a __s if @a __n2 is too large. If * @a __pos is beyond end of string, out_of_range is thrown. * If the length of result exceeds max_size(), length_error is * thrown. The value of the string doesn't change if an error * is thrown. */ __versa_string& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) { __glibcxx_requires_string_len(__s, __n2); return _M_replace(_M_check(__pos, "__versa_string::replace"), _M_limit(__pos, __n1), __s, __n2); } /** * @brief Replace characters with value of a C string. * @param __pos Index of first character to replace. * @param __n1 Number of characters to be replaced. * @param __s C string to insert. * @return Reference to this string. * @throw std::out_of_range If @a __pos > size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos + n1) from this * string. In place, the characters of @a __s are inserted. If * @a pos is beyond end of string, out_of_range is thrown. If * the length of result exceeds max_size(), length_error is thrown. * The value of the string doesn't change if an error is thrown. */ __versa_string& replace(size_type __pos, size_type __n1, const _CharT* __s) { __glibcxx_requires_string(__s); return this->replace(__pos, __n1, __s, traits_type::length(__s)); } /** * @brief Replace characters with multiple characters. * @param __pos Index of first character to replace. * @param __n1 Number of characters to be replaced. * @param __n2 Number of characters to insert. * @param __c Character to insert. * @return Reference to this string. * @throw std::out_of_range If @a __pos > size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos + n1) from this * string. In place, @a __n2 copies of @a __c are inserted. * If @a __pos is beyond end of string, out_of_range is thrown. * If the length of result exceeds max_size(), length_error is * thrown. The value of the string doesn't change if an error * is thrown. */ __versa_string& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"), _M_limit(__pos, __n1), __n2, __c); } /** * @brief Replace range of characters with string. * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __str String value to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, the * value of @a __str is inserted. If the length of result * exceeds max_size(), length_error is thrown. The value of * the string doesn't change if an error is thrown. */ __versa_string& replace(iterator __i1, iterator __i2, const __versa_string& __str) { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } /** * @brief Replace range of characters with C substring. * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __s C string value to insert. * @param __n Number of characters from s to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, the * first @a n characters of @a __s are inserted. If the length * of result exceeds max_size(), length_error is thrown. The * value of the string doesn't change if an error is thrown. */ __versa_string& replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n); } /** * @brief Replace range of characters with C string. * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __s C string value to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, the * characters of @a __s are inserted. If the length of result * exceeds max_size(), length_error is thrown. The value of * the string doesn't change if an error is thrown. */ __versa_string& replace(iterator __i1, iterator __i2, const _CharT* __s) { __glibcxx_requires_string(__s); return this->replace(__i1, __i2, __s, traits_type::length(__s)); } /** * @brief Replace range of characters with multiple characters * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __n Number of characters to insert. * @param __c Character to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, @a * __n copies of @a __c are inserted. If the length of result * exceeds max_size(), length_error is thrown. The value of * the string doesn't change if an error is thrown. */ __versa_string& replace(iterator __i1, iterator __i2, size_type __n, _CharT __c) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c); } /** * @brief Replace range of characters with range. * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __k1 Iterator referencing start of range to insert. * @param __k2 Iterator referencing end of range to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, * characters in the range [k1,k2) are inserted. If the length * of result exceeds max_size(), length_error is thrown. The * value of the string doesn't change if an error is thrown. */ #if __cplusplus >= 201103L template> __versa_string& replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, std::__false_type()); } #else template __versa_string& replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); typedef typename std::__is_integer<_InputIterator>::__type _Integral; return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); } #endif // Specializations for the common case of pointer and iterator: // useful to avoid the overhead of temporary buffering in _M_replace. __versa_string& replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __k1, __k2 - __k1); } __versa_string& replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __k1, __k2 - __k1); } __versa_string& replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __k1.base(), __k2 - __k1); } __versa_string& replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __k1.base(), __k2 - __k1); } #if __cplusplus >= 201103L /** * @brief Replace range of characters with initializer_list. * @param __i1 Iterator referencing start of range to replace. * @param __i2 Iterator referencing end of range to replace. * @param __l The initializer_list of characters to insert. * @return Reference to this string. * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [i1,i2). In place, * characters in the range [k1,k2) are inserted. If the length * of result exceeds max_size(), length_error is thrown. The * value of the string doesn't change if an error is thrown. */ __versa_string& replace(iterator __i1, iterator __i2, std::initializer_list<_CharT> __l) { return this->replace(__i1, __i2, __l.begin(), __l.end()); } #endif // C++11 private: template __versa_string& _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n, _Integer __val, std::__true_type) { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); } template __versa_string& _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2, std::__false_type); __versa_string& _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c); __versa_string& _M_replace(size_type __pos, size_type __len1, const _CharT* __s, const size_type __len2); __versa_string& _M_append(const _CharT* __s, size_type __n); public: /** * @brief Copy substring into C string. * @param __s C string to copy value into. * @param __n Number of characters to copy. * @param __pos Index of first character to copy. * @return Number of characters actually copied * @throw std::out_of_range If pos > size(). * * Copies up to @a __n characters starting at @a __pos into the * C string @a s. If @a __pos is greater than size(), * out_of_range is thrown. */ size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const; /** * @brief Swap contents with another string. * @param __s String to swap with. * * Exchanges the contents of this string with that of @a __s in * constant time. */ void swap(__versa_string& __s) { this->_M_swap(__s); } // String operations: /** * @brief Return const pointer to null-terminated contents. * * This is a handle to internal data. Do not modify or dire things may * happen. */ const _CharT* c_str() const _GLIBCXX_NOEXCEPT { return this->_M_data(); } /** * @brief Return const pointer to contents. * * This is a handle to internal data. Do not modify or dire things may * happen. */ const _CharT* data() const _GLIBCXX_NOEXCEPT { return this->_M_data(); } /** * @brief Return copy of allocator used to construct this string. */ allocator_type get_allocator() const _GLIBCXX_NOEXCEPT { return allocator_type(this->_M_get_allocator()); } /** * @brief Find position of a C substring. * @param __s C string to locate. * @param __pos Index of character to search from. * @param __n Number of characters from @a __s to search for. * @return Index of start of first occurrence. * * Starting from @a __pos, searches forward for the first @a * __n characters in @a __s within this string. If found, * returns the index where it begins. If not found, returns * npos. */ size_type find(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find position of a string. * @param __str String to locate. * @param __pos Index of character to search from (default 0). * @return Index of start of first occurrence. * * Starting from @a __pos, searches forward for value of @a * __str within this string. If found, returns the index where * it begins. If not found, returns npos. */ size_type find(const __versa_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find(__str.data(), __pos, __str.size()); } /** * @brief Find position of a C string. * @param __s C string to locate. * @param __pos Index of character to search from (default 0). * @return Index of start of first occurrence. * * Starting from @a __pos, searches forward for the value of @a * __s within this string. If found, returns the index where * it begins. If not found, returns npos. */ size_type find(const _CharT* __s, size_type __pos = 0) const { __glibcxx_requires_string(__s); return this->find(__s, __pos, traits_type::length(__s)); } /** * @brief Find position of a character. * @param __c Character to locate. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for @a __c within * this string. If found, returns the index where it was * found. If not found, returns npos. */ size_type find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; /** * @brief Find last position of a string. * @param __str String to locate. * @param __pos Index of character to search back from (default end). * @return Index of start of last occurrence. * * Starting from @a __pos, searches backward for value of @a * __str within this string. If found, returns the index where * it begins. If not found, returns npos. */ size_type rfind(const __versa_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->rfind(__str.data(), __pos, __str.size()); } /** * @brief Find last position of a C substring. * @param __s C string to locate. * @param __pos Index of character to search back from. * @param __n Number of characters from s to search for. * @return Index of start of last occurrence. * * Starting from @a __pos, searches backward for the first @a * __n characters in @a __s within this string. If found, * returns the index where it begins. If not found, returns * npos. */ size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find last position of a C string. * @param __s C string to locate. * @param __pos Index of character to start search at (default end). * @return Index of start of last occurrence. * * Starting from @a __pos, searches backward for the value of * @a __s within this string. If found, returns the index * where it begins. If not found, returns npos. */ size_type rfind(const _CharT* __s, size_type __pos = npos) const { __glibcxx_requires_string(__s); return this->rfind(__s, __pos, traits_type::length(__s)); } /** * @brief Find last position of a character. * @param __c Character to locate. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for @a __c within * this string. If found, returns the index where it was * found. If not found, returns npos. */ size_type rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; /** * @brief Find position of a character of string. * @param __str String containing characters to locate. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for one of the characters of * @a __str within this string. If found, returns the index where it was * found. If not found, returns npos. */ size_type find_first_of(const __versa_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find_first_of(__str.data(), __pos, __str.size()); } /** * @brief Find position of a character of C substring. * @param __s String containing characters to locate. * @param __pos Index of character to search from. * @param __n Number of characters from s to search for. * @return Index of first occurrence. * * Starting from @a __pos, searches forward for one of the * first @a __n characters of @a __s within this string. If * found, returns the index where it was found. If not found, * returns npos. */ size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find position of a character of C string. * @param __s String containing characters to locate. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for one of the * characters of @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ size_type find_first_of(const _CharT* __s, size_type __pos = 0) const { __glibcxx_requires_string(__s); return this->find_first_of(__s, __pos, traits_type::length(__s)); } /** * @brief Find position of a character. * @param __c Character to locate. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for the character * @a __c within this string. If found, returns the index * where it was found. If not found, returns npos. * * Note: equivalent to find(c, pos). */ size_type find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find(__c, __pos); } /** * @brief Find last position of a character of string. * @param __str String containing characters to locate. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for one of the * characters of @a __str within this string. If found, * returns the index where it was found. If not found, returns * npos. */ size_type find_last_of(const __versa_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->find_last_of(__str.data(), __pos, __str.size()); } /** * @brief Find last position of a character of C substring. * @param __s C string containing characters to locate. * @param __pos Index of character to search back from. * @param __n Number of characters from s to search for. * @return Index of last occurrence. * * Starting from @a __pos, searches backward for one of the * first @a __n characters of @a __s within this string. If * found, returns the index where it was found. If not found, * returns npos. */ size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find last position of a character of C string. * @param __s C string containing characters to locate. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for one of the * characters of @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ size_type find_last_of(const _CharT* __s, size_type __pos = npos) const { __glibcxx_requires_string(__s); return this->find_last_of(__s, __pos, traits_type::length(__s)); } /** * @brief Find last position of a character. * @param __c Character to locate. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for @a __c within * this string. If found, returns the index where it was * found. If not found, returns npos. * * Note: equivalent to rfind(c, pos). */ size_type find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->rfind(__c, __pos); } /** * @brief Find position of a character not in string. * @param __str String containing characters to avoid. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for a character not * contained in @a __str within this string. If found, returns * the index where it was found. If not found, returns npos. */ size_type find_first_not_of(const __versa_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find_first_not_of(__str.data(), __pos, __str.size()); } /** * @brief Find position of a character not in C substring. * @param __s C string containing characters to avoid. * @param __pos Index of character to search from. * @param __n Number of characters from s to consider. * @return Index of first occurrence. * * Starting from @a __pos, searches forward for a character not * contained in the first @a __n characters of @a __s within * this string. If found, returns the index where it was * found. If not found, returns npos. */ size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find position of a character not in C string. * @param __s C string containing characters to avoid. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for a character not * contained in @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const { __glibcxx_requires_string(__s); return this->find_first_not_of(__s, __pos, traits_type::length(__s)); } /** * @brief Find position of a different character. * @param __c Character to avoid. * @param __pos Index of character to search from (default 0). * @return Index of first occurrence. * * Starting from @a __pos, searches forward for a character * other than @a __c within this string. If found, returns the * index where it was found. If not found, returns npos. */ size_type find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; /** * @brief Find last position of a character not in string. * @param __str String containing characters to avoid. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for a character * not contained in @a __str within this string. If found, * returns the index where it was found. If not found, returns * npos. */ size_type find_last_not_of(const __versa_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->find_last_not_of(__str.data(), __pos, __str.size()); } /** * @brief Find last position of a character not in C substring. * @param __s C string containing characters to avoid. * @param __pos Index of character to search back from. * @param __n Number of characters from s to consider. * @return Index of last occurrence. * * Starting from @a __pos, searches backward for a character * not contained in the first @a __n characters of @a __s * within this string. If found, returns the index where it * was found. If not found, returns npos. */ size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const; /** * @brief Find last position of a character not in C string. * @param __s C string containing characters to avoid. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for a character * not contained in @a __s within this string. If found, * returns the index where it was found. If not found, returns * npos. */ size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const { __glibcxx_requires_string(__s); return this->find_last_not_of(__s, __pos, traits_type::length(__s)); } /** * @brief Find last position of a different character. * @param __c Character to avoid. * @param __pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a __pos, searches backward for a character * other than @a __c within this string. If found, returns the * index where it was found. If not found, returns npos. */ size_type find_last_not_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; /** * @brief Get a substring. * @param __pos Index of first character (default 0). * @param __n Number of characters in substring (default remainder). * @return The new string. * @throw std::out_of_range If pos > size(). * * Construct and return a new string using the @a __n * characters starting at @a __pos. If the string is too * short, use the remainder of the characters. If @a __pos is * beyond the end of the string, out_of_range is thrown. */ __versa_string substr(size_type __pos = 0, size_type __n = npos) const { return __versa_string(*this, _M_check(__pos, "__versa_string::substr"), __n); } /** * @brief Compare to a string. * @param __str String to compare against. * @return Integer < 0, 0, or > 0. * * Returns an integer < 0 if this string is ordered before @a * __str, 0 if their values are equivalent, or > 0 if this * string is ordered after @a __str. Determines the effective * length rlen of the strings to compare as the smallest of * size() and str.size(). The function then compares the two * strings by calling traits::compare(data(), str.data(),rlen). * If the result of the comparison is nonzero returns it, * otherwise the shorter one is ordered first. */ int compare(const __versa_string& __str) const { if (this->_M_compare(__str)) return 0; const size_type __size = this->size(); const size_type __osize = __str.size(); const size_type __len = std::min(__size, __osize); int __r = traits_type::compare(this->_M_data(), __str.data(), __len); if (!__r) __r = this->_S_compare(__size, __osize); return __r; } /** * @brief Compare substring to a string. * @param __pos Index of first character of substring. * @param __n Number of characters in substring. * @param __str String to compare against. * @return Integer < 0, 0, or > 0. * * Form the substring of this string from the @a __n characters * starting at @a __pos. Returns an integer < 0 if the * substring is ordered before @a __str, 0 if their values are * equivalent, or > 0 if the substring is ordered after @a * __str. Determines the effective length rlen of the strings * to compare as the smallest of the length of the substring * and @a __str.size(). The function then compares the two * strings by calling * traits::compare(substring.data(),str.data(),rlen). If the * result of the comparison is nonzero returns it, otherwise * the shorter one is ordered first. */ int compare(size_type __pos, size_type __n, const __versa_string& __str) const; /** * @brief Compare substring to a substring. * @param __pos1 Index of first character of substring. * @param __n1 Number of characters in substring. * @param __str String to compare against. * @param __pos2 Index of first character of substring of str. * @param __n2 Number of characters in substring of str. * @return Integer < 0, 0, or > 0. * * Form the substring of this string from the @a __n1 * characters starting at @a __pos1. Form the substring of @a * __str from the @a __n2 characters starting at @a __pos2. * Returns an integer < 0 if this substring is ordered before * the substring of @a __str, 0 if their values are equivalent, * or > 0 if this substring is ordered after the substring of * @a __str. Determines the effective length rlen of the * strings to compare as the smallest of the lengths of the * substrings. The function then compares the two strings by * calling * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). * If the result of the comparison is nonzero returns it, * otherwise the shorter one is ordered first. */ int compare(size_type __pos1, size_type __n1, const __versa_string& __str, size_type __pos2, size_type __n2) const; /** * @brief Compare to a C string. * @param __s C string to compare against. * @return Integer < 0, 0, or > 0. * * Returns an integer < 0 if this string is ordered before @a * __s, 0 if their values are equivalent, or > 0 if this string * is ordered after @a __s. Determines the effective length * rlen of the strings to compare as the smallest of size() and * the length of a string constructed from @a __s. The * function then compares the two strings by calling * traits::compare(data(),s,rlen). If the result of the * comparison is nonzero returns it, otherwise the shorter one * is ordered first. */ int compare(const _CharT* __s) const; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 5 String::compare specification questionable /** * @brief Compare substring to a C string. * @param __pos Index of first character of substring. * @param __n1 Number of characters in substring. * @param __s C string to compare against. * @return Integer < 0, 0, or > 0. * * Form the substring of this string from the @a __n1 * characters starting at @a __pos. Returns an integer < 0 if * the substring is ordered before @a __s, 0 if their values * are equivalent, or > 0 if the substring is ordered after @a * __s. Determines the effective length rlen of the strings to * compare as the smallest of the length of the substring and * the length of a string constructed from @a __s. The * function then compares the two string by calling * traits::compare(substring.data(),s,rlen). If the result of * the comparison is nonzero returns it, otherwise the shorter * one is ordered first. */ int compare(size_type __pos, size_type __n1, const _CharT* __s) const; /** * @brief Compare substring against a character array. * @param __pos Index of first character of substring. * @param __n1 Number of characters in substring. * @param __s character array to compare against. * @param __n2 Number of characters of s. * @return Integer < 0, 0, or > 0. * * Form the substring of this string from the @a __n1 * characters starting at @a __pos. Form a string from the * first @a __n2 characters of @a __s. Returns an integer < 0 * if this substring is ordered before the string from @a __s, * 0 if their values are equivalent, or > 0 if this substring * is ordered after the string from @a __s. Determines the * effective length rlen of the strings to compare as the * smallest of the length of the substring and @a __n2. The * function then compares the two strings by calling * traits::compare(substring.data(),__s,rlen). If the result of * the comparison is nonzero returns it, otherwise the shorter * one is ordered first. * * NB: __s must have at least n2 characters, \\0 has no special * meaning. */ int compare(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) const; }; // operator+ /** * @brief Concatenate two strings. * @param __lhs First string. * @param __rhs Last string. * @return New string with value of @a __lhs followed by @a __rhs. */ template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs); /** * @brief Concatenate C string and string. * @param __lhs First string. * @param __rhs Last string. * @return New string with value of @a __lhs followed by @a __rhs. */ template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs); /** * @brief Concatenate character and string. * @param __lhs First string. * @param __rhs Last string. * @return New string with @a __lhs followed by @a __rhs. */ template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(_CharT __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs); /** * @brief Concatenate string and C string. * @param __lhs First string. * @param __rhs Last string. * @return New string with @a __lhs followed by @a __rhs. */ template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs); /** * @brief Concatenate string and character. * @param __lhs First string. * @param __rhs Last string. * @return New string with @a __lhs followed by @a __rhs. */ template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, _CharT __rhs); #if __cplusplus >= 201103L template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return std::move(__lhs.append(__rhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs, __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs) { const auto __size = __lhs.size() + __rhs.size(); const bool __cond = (__size > __lhs.capacity() && __size <= __rhs.capacity()); return __cond ? std::move(__rhs.insert(0, __lhs)) : std::move(__lhs.append(__rhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const _CharT* __lhs, __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(_CharT __lhs, __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs) { return std::move(__rhs.insert(0, 1, __lhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs, const _CharT* __rhs) { return std::move(__lhs.append(__rhs)); } template class _Base> inline __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs, _CharT __rhs) { return std::move(__lhs.append(1, __rhs)); } #endif // operator == /** * @brief Test equivalence of two strings. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. */ template class _Base> inline bool operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) == 0; } template class _Base> inline typename __enable_if::__value, bool>::__type operator==(const __versa_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT>, _Base>& __lhs, const __versa_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT>, _Base>& __rhs) { return (__lhs.size() == __rhs.size() && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), __lhs.size())); } /** * @brief Test equivalence of C string and string. * @param __lhs C string. * @param __rhs String. * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise. */ template class _Base> inline bool operator==(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __rhs.compare(__lhs) == 0; } /** * @brief Test equivalence of string and C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. */ template class _Base> inline bool operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) == 0; } // operator != /** * @brief Test difference of two strings. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. */ template class _Base> inline bool operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return !(__lhs == __rhs); } /** * @brief Test difference of C string and string. * @param __lhs C string. * @param __rhs String. * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise. */ template class _Base> inline bool operator!=(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return !(__lhs == __rhs); } /** * @brief Test difference of string and C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. */ template class _Base> inline bool operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return !(__lhs == __rhs); } // operator < /** * @brief Test if string precedes string. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template class _Base> inline bool operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) < 0; } /** * @brief Test if string precedes C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template class _Base> inline bool operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) < 0; } /** * @brief Test if C string precedes string. * @param __lhs C string. * @param __rhs String. * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template class _Base> inline bool operator<(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __rhs.compare(__lhs) > 0; } // operator > /** * @brief Test if string follows string. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs follows @a __rhs. False otherwise. */ template class _Base> inline bool operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) > 0; } /** * @brief Test if string follows C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs follows @a __rhs. False otherwise. */ template class _Base> inline bool operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) > 0; } /** * @brief Test if C string follows string. * @param __lhs C string. * @param __rhs String. * @return True if @a __lhs follows @a __rhs. False otherwise. */ template class _Base> inline bool operator>(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __rhs.compare(__lhs) < 0; } // operator <= /** * @brief Test if string doesn't follow string. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template class _Base> inline bool operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) <= 0; } /** * @brief Test if string doesn't follow C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template class _Base> inline bool operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) <= 0; } /** * @brief Test if C string doesn't follow string. * @param __lhs C string. * @param __rhs String. * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template class _Base> inline bool operator<=(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __rhs.compare(__lhs) >= 0; } // operator >= /** * @brief Test if string doesn't precede string. * @param __lhs First string. * @param __rhs Second string. * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template class _Base> inline bool operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) >= 0; } /** * @brief Test if string doesn't precede C string. * @param __lhs String. * @param __rhs C string. * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template class _Base> inline bool operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) >= 0; } /** * @brief Test if C string doesn't precede string. * @param __lhs C string. * @param __rhs String. * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template class _Base> inline bool operator>=(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __rhs.compare(__lhs) <= 0; } /** * @brief Swap contents of two strings. * @param __lhs First string. * @param __rhs Second string. * * Exchanges the contents of @a __lhs and @a __rhs in constant time. */ template class _Base> inline void swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { __lhs.swap(__rhs); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Read stream into a string. * @param __is Input stream. * @param __str Buffer to store into. * @return Reference to the input stream. * * Stores characters from @a __is into @a __str until whitespace is * found, the end of the stream is encountered, or str.max_size() * is reached. If is.width() is non-zero, that is the limit on the * number of characters stored into @a __str. Any previous * contents of @a __str are erased. */ template class _Base> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str); /** * @brief Write string to a stream. * @param __os Output stream. * @param __str String to write out. * @return Reference to the output stream. * * Output characters of @a __str into os following the same rules as for * writing a C string. */ template class _Base> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 586. string inserter not a formatted function return __ostream_insert(__os, __str.data(), __str.size()); } /** * @brief Read a line from stream into a string. * @param __is Input stream. * @param __str Buffer to store into. * @param __delim Character marking end of line. * @return Reference to the input stream. * * Stores characters from @a __is into @a __str until @a __delim is * found, the end of the stream is encountered, or str.max_size() * is reached. If is.width() is non-zero, that is the limit on the * number of characters stored into @a __str. Any previous * contents of @a __str are erased. If @a delim was encountered, * it is extracted but not stored into @a __str. */ template class _Base> basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str, _CharT __delim); /** * @brief Read a line from stream into a string. * @param __is Input stream. * @param __str Buffer to store into. * @return Reference to the input stream. * * Stores characters from is into @a __str until '\n' is * found, the end of the stream is encountered, or str.max_size() * is reached. If is.width() is non-zero, that is the limit on the * number of characters stored into @a __str. Any previous * contents of @a __str are erased. If end of line was * encountered, it is extracted but not stored into @a __str. */ template class _Base> inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str) { return getline(__is, __str, __is.widen('\n')); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99)) #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // 21.4 Numeric Conversions [string.conversions]. inline int stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtol, "stoi", __str.c_str(), __idx, __base); } inline long stol(const __vstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(), __idx, __base); } inline unsigned long stoul(const __vstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(), __idx, __base); } inline long long stoll(const __vstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(), __idx, __base); } inline unsigned long long stoull(const __vstring& __str, std::size_t* __idx, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(), __idx, __base); } // NB: strtof vs strtod. inline float stof(const __vstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); } inline double stod(const __vstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } inline long double stold(const __vstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); } // NB: (v)snprintf vs sprintf. // DR 1261. inline __vstring to_string(int __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(int), "%d", __val); } inline __vstring to_string(unsigned __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(unsigned), "%u", __val); } inline __vstring to_string(long __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(long), "%ld", __val); } inline __vstring to_string(unsigned long __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(unsigned long), "%lu", __val); } inline __vstring to_string(long long __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(long long), "%lld", __val); } inline __vstring to_string(unsigned long long __val) { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(unsigned long long), "%llu", __val); } inline __vstring to_string(float __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n, "%f", __val); } inline __vstring to_string(double __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n, "%f", __val); } inline __vstring to_string(long double __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n, "%Lf", __val); } #ifdef _GLIBCXX_USE_WCHAR_T inline int stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstol, "stoi", __str.c_str(), __idx, __base); } inline long stol(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(), __idx, __base); } inline unsigned long stoul(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(), __idx, __base); } inline long long stoll(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(), __idx, __base); } inline unsigned long long stoull(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(), __idx, __base); } // NB: wcstof vs wcstod. inline float stof(const __wvstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); } inline double stod(const __wvstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); } inline long double stold(const __wvstring& __str, std::size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); } #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF // DR 1261. inline __wvstring to_wstring(int __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(int), L"%d", __val); } inline __wvstring to_wstring(unsigned __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(unsigned), L"%u", __val); } inline __wvstring to_wstring(long __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(long), L"%ld", __val); } inline __wvstring to_wstring(unsigned long __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(unsigned long), L"%lu", __val); } inline __wvstring to_wstring(long long __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(long long), L"%lld", __val); } inline __wvstring to_wstring(unsigned long long __val) { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, 4 * sizeof(unsigned long long), L"%llu", __val); } inline __wvstring to_wstring(float __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n, L"%f", __val); } inline __wvstring to_wstring(double __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n, L"%f", __val); } inline __wvstring to_wstring(long double __val) { const int __n = __numeric_traits::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n, L"%Lf", __val); } #endif #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif #if __cplusplus >= 201103L #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// std::hash specialization for __vstring. template<> struct hash<__gnu_cxx::__vstring> : public __hash_base { size_t operator()(const __gnu_cxx::__vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length()); } }; #ifdef _GLIBCXX_USE_WCHAR_T /// std::hash specialization for __wvstring. template<> struct hash<__gnu_cxx::__wvstring> : public __hash_base { size_t operator()(const __gnu_cxx::__wvstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } }; #endif #ifdef _GLIBCXX_USE_C99_STDINT_TR1 /// std::hash specialization for __u16vstring. template<> struct hash<__gnu_cxx::__u16vstring> : public __hash_base { size_t operator()(const __gnu_cxx::__u16vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char16_t)); } }; /// std::hash specialization for __u32vstring. template<> struct hash<__gnu_cxx::__u32vstring> : public __hash_base { size_t operator()(const __gnu_cxx::__u32vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++11 #include "vstring.tcc" #endif /* _VSTRING_H */ 4.8.2/ext/rb_tree000064400000006357147547540550007415 0ustar00// rb_tree extension -*- C++ -*- // Copyright (C) 2002-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file ext/rb_tree * This file is a GNU extension to the Standard C++ Library (possibly * containing extensions from the HP/SGI STL subset). */ #ifndef _RB_TREE #define _RB_TREE 1 #pragma GCC system_header #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::_Rb_tree; using std::allocator; // Class rb_tree is not part of the C++ standard. It is provided for // compatibility with the HP STL. /** * This is an SGI extension. * @ingroup SGIextensions * @doctodo */ template > struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> { typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base; typedef typename _Base::allocator_type allocator_type; rb_tree(const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _Base(__comp, __a) { } ~rb_tree() { } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/malloc_allocator.h000064400000010562147547540550011521 0ustar00// Allocator that wraps "C" malloc -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/malloc_allocator.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _MALLOC_ALLOCATOR_H #define _MALLOC_ALLOCATOR_H 1 #include #include #include #include #if __cplusplus >= 201103L #include #endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::size_t; using std::ptrdiff_t; /** * @brief An allocator that uses malloc. * @ingroup allocators * * This is precisely the allocator defined in the C++ Standard. * - all allocation calls malloc * - all deallocation calls free */ template class malloc_allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; template struct rebind { typedef malloc_allocator<_Tp1> other; }; #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2103. propagate_on_container_move_assignment typedef std::true_type propagate_on_container_move_assignment; #endif malloc_allocator() _GLIBCXX_USE_NOEXCEPT { } malloc_allocator(const malloc_allocator&) _GLIBCXX_USE_NOEXCEPT { } template malloc_allocator(const malloc_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { } ~malloc_allocator() _GLIBCXX_USE_NOEXCEPT { } pointer address(reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } const_pointer address(const_reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } // NB: __n is permitted to be 0. The C++ standard says nothing // about what the return value is when __n == 0. pointer allocate(size_type __n, const void* = 0) { if (__n > this->max_size()) std::__throw_bad_alloc(); pointer __ret = static_cast<_Tp*>(std::malloc(__n * sizeof(_Tp))); if (!__ret) std::__throw_bad_alloc(); return __ret; } // __p is not permitted to be a null pointer. void deallocate(pointer __p, size_type) { std::free(static_cast(__p)); } size_type max_size() const _GLIBCXX_USE_NOEXCEPT { return size_t(-1) / sizeof(_Tp); } #if __cplusplus >= 201103L template void construct(_Up* __p, _Args&&... __args) { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } template void destroy(_Up* __p) { __p->~_Up(); } #else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 402. wrong new expression in [some_] allocator::construct void construct(pointer __p, const _Tp& __val) { ::new((void *)__p) value_type(__val); } void destroy(pointer __p) { __p->~_Tp(); } #endif }; template inline bool operator==(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&) { return true; } template inline bool operator!=(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&) { return false; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/typelist.h000064400000040703147547540550010067 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice and // this permission notice appear in supporting documentation. None of // the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied warranty. /** * @file ext/typelist.h * This file is a GNU extension to the Standard C++ Library. * * Contains typelist_chain definitions. * Typelists are an idea by Andrei Alexandrescu. */ #ifndef _TYPELIST_H #define _TYPELIST_H 1 #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** @namespace __gnu_cxx::typelist * @brief GNU typelist extensions for public compile-time use. */ namespace typelist { struct null_type { }; template struct node { typedef Root root; }; // Forward declarations of functors. template struct chain { typedef Hd head; typedef Typelist tail; }; // Apply all typelist types to unary functor. template void apply(Fn&, Typelist); /// Apply all typelist types to generator functor. template void apply_generator(Gn&, Typelist); // Apply all typelist types and values to generator functor. template void apply_generator(Gn&, TypelistT, TypelistV); template struct append; template struct append_typelist; template struct contains; template class Pred> struct filter; template struct at_index; template class Transform> struct transform; template struct flatten; template struct from_first; template struct create1; template struct create2; template struct create3; template struct create4; template struct create5; template struct create6; } // namespace typelist _GLIBCXX_END_NAMESPACE_VERSION } // namespace namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace typelist { namespace detail { template struct apply_; template struct apply_ > { void operator()(Fn& f) { f.operator()(Hd()); apply_ next; next(f); } }; template struct apply_ { void operator()(Fn&) { } }; template struct apply_generator1_; template struct apply_generator1_ > { void operator()(Gn& g) { g.template operator()(); apply_generator1_ next; next(g); } }; template struct apply_generator1_ { void operator()(Gn&) { } }; template struct apply_generator2_; template struct apply_generator2_, chain > { void operator()(Gn& g) { g.template operator()(); apply_generator2_ next; next(g); } }; template struct apply_generator2_ { void operator()(Gn&) { } }; template struct append_; template struct append_, Typelist_Chain> { private: typedef append_ append_type; public: typedef chain type; }; template struct append_ { typedef Typelist_Chain type; }; template struct append_ { typedef Typelist_Chain type; }; template<> struct append_ { typedef null_type type; }; template struct append_typelist_; template struct append_typelist_ > { typedef chain type; }; template struct append_typelist_ > { private: typedef typename append_typelist_::type rest_type; public: typedef typename append >::type::root type; }; template struct contains_; template struct contains_ { enum { value = false }; }; template struct contains_, T> { enum { value = contains_::value }; }; template struct contains_, T> { enum { value = true }; }; template class Pred> struct chain_filter_; template class Pred> struct chain_filter_ { typedef null_type type; }; template class Pred> struct chain_filter_, Pred> { private: enum { include_hd = Pred::value }; typedef typename chain_filter_::type rest_type; typedef chain chain_type; public: typedef typename __conditional_type::__type type; }; template struct chain_at_index_; template struct chain_at_index_, 0> { typedef Hd type; }; template struct chain_at_index_, i> { typedef typename chain_at_index_::type type; }; template class Transform> struct chain_transform_; template class Transform> struct chain_transform_ { typedef null_type type; }; template class Transform> struct chain_transform_, Transform> { private: typedef typename chain_transform_::type rest_type; typedef typename Transform::type transform_type; public: typedef chain type; }; template struct chain_flatten_; template struct chain_flatten_ > { typedef typename Hd_Tl::root type; }; template struct chain_flatten_ > { private: typedef typename chain_flatten_::type rest_type; typedef append > append_type; public: typedef typename append_type::type::root type; }; } // namespace detail } // namespace typelist _GLIBCXX_END_NAMESPACE_VERSION } // namespace #define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN16(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN17(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN18(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN19(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18) __gnu_cxx::typelist::chain #define _GLIBCXX_TYPELIST_CHAIN20(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19) __gnu_cxx::typelist::chain namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace typelist { template void apply(Fn& fn, Typelist) { detail::apply_ a; a(fn); } template void apply_generator(Fn& fn, Typelist) { detail::apply_generator1_ a; a(fn); } template void apply_generator(Fn& fn, TypelistT, TypelistV) { typedef typename TypelistT::root rootT; typedef typename TypelistV::root rootV; detail::apply_generator2_ a; a(fn); } template struct append { private: typedef typename Typelist0::root root0_type; typedef typename Typelist1::root root1_type; typedef detail::append_ append_type; public: typedef node type; }; template struct append_typelist { private: typedef typename Typelist_Typelist::root root_type; typedef detail::append_typelist_ append_type; public: typedef node type; }; template struct contains { private: typedef typename Typelist::root root_type; public: enum { value = detail::contains_::value }; }; template class Pred> struct filter { private: typedef typename Typelist::root root_type; typedef detail::chain_filter_ filter_type; public: typedef node type; }; template struct at_index { private: typedef typename Typelist::root root_type; typedef detail::chain_at_index_ index_type; public: typedef typename index_type::type type; }; template class Transform> struct transform { private: typedef typename Typelist::root root_type; typedef detail::chain_transform_ transform_type; public: typedef node type; }; template struct flatten { private: typedef typename Typelist_Typelist::root root_type; typedef typename detail::chain_flatten_::type flatten_type; public: typedef node type; }; template struct from_first { private: typedef typename at_index::type first_type; public: typedef node > type; }; template struct create1 { typedef node<_GLIBCXX_TYPELIST_CHAIN1(T1)> type; }; template struct create2 { typedef node<_GLIBCXX_TYPELIST_CHAIN2(T1,T2)> type; }; template struct create3 { typedef node<_GLIBCXX_TYPELIST_CHAIN3(T1,T2,T3)> type; }; template struct create4 { typedef node<_GLIBCXX_TYPELIST_CHAIN4(T1,T2,T3,T4)> type; }; template struct create5 { typedef node<_GLIBCXX_TYPELIST_CHAIN5(T1,T2,T3,T4,T5)> type; }; template struct create6 { typedef node<_GLIBCXX_TYPELIST_CHAIN6(T1,T2,T3,T4,T5,T6)> type; }; } // namespace typelist _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/pool_allocator.h000064400000020347147547540550011225 0ustar00// Allocators -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * Copyright (c) 1996-1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file ext/pool_allocator.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _POOL_ALLOCATOR_H #define _POOL_ALLOCATOR_H 1 #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::size_t; using std::ptrdiff_t; /** * @brief Base class for __pool_alloc. * * Uses various allocators to fulfill underlying requests (and makes as * few requests as possible when in default high-speed pool mode). * * Important implementation properties: * 0. If globally mandated, then allocate objects from new * 1. If the clients request an object of size > _S_max_bytes, the resulting * object will be obtained directly from new * 2. In all other cases, we allocate an object of size exactly * _S_round_up(requested_size). Thus the client has enough size * information that we can return the object to the proper free list * without permanently losing part of the object. */ class __pool_alloc_base { protected: enum { _S_align = 8 }; enum { _S_max_bytes = 128 }; enum { _S_free_list_size = (size_t)_S_max_bytes / (size_t)_S_align }; union _Obj { union _Obj* _M_free_list_link; char _M_client_data[1]; // The client sees this. }; static _Obj* volatile _S_free_list[_S_free_list_size]; // Chunk allocation state. static char* _S_start_free; static char* _S_end_free; static size_t _S_heap_size; size_t _M_round_up(size_t __bytes) { return ((__bytes + (size_t)_S_align - 1) & ~((size_t)_S_align - 1)); } _GLIBCXX_CONST _Obj* volatile* _M_get_free_list(size_t __bytes) throw (); __mutex& _M_get_mutex() throw (); // Returns an object of size __n, and optionally adds to size __n // free list. void* _M_refill(size_t __n); // Allocates a chunk for nobjs of size size. nobjs may be reduced // if it is inconvenient to allocate the requested number. char* _M_allocate_chunk(size_t __n, int& __nobjs); }; /** * @brief Allocator using a memory pool with a single lock. * @ingroup allocators */ template class __pool_alloc : private __pool_alloc_base { private: static _Atomic_word _S_force_new; public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; template struct rebind { typedef __pool_alloc<_Tp1> other; }; #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2103. propagate_on_container_move_assignment typedef std::true_type propagate_on_container_move_assignment; #endif __pool_alloc() _GLIBCXX_USE_NOEXCEPT { } __pool_alloc(const __pool_alloc&) _GLIBCXX_USE_NOEXCEPT { } template __pool_alloc(const __pool_alloc<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { } ~__pool_alloc() _GLIBCXX_USE_NOEXCEPT { } pointer address(reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } const_pointer address(const_reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } size_type max_size() const _GLIBCXX_USE_NOEXCEPT { return size_t(-1) / sizeof(_Tp); } #if __cplusplus >= 201103L template void construct(_Up* __p, _Args&&... __args) { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } template void destroy(_Up* __p) { __p->~_Up(); } #else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 402. wrong new expression in [some_] allocator::construct void construct(pointer __p, const _Tp& __val) { ::new((void *)__p) _Tp(__val); } void destroy(pointer __p) { __p->~_Tp(); } #endif pointer allocate(size_type __n, const void* = 0); void deallocate(pointer __p, size_type __n); }; template inline bool operator==(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&) { return true; } template inline bool operator!=(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&) { return false; } template _Atomic_word __pool_alloc<_Tp>::_S_force_new; template _Tp* __pool_alloc<_Tp>::allocate(size_type __n, const void*) { pointer __ret = 0; if (__builtin_expect(__n != 0, true)) { if (__n > this->max_size()) std::__throw_bad_alloc(); // If there is a race through here, assume answer from getenv // will resolve in same direction. Inspired by techniques // to efficiently support threading found in basic_string.h. if (_S_force_new == 0) { if (std::getenv("GLIBCXX_FORCE_NEW")) __atomic_add_dispatch(&_S_force_new, 1); else __atomic_add_dispatch(&_S_force_new, -1); } const size_t __bytes = __n * sizeof(_Tp); if (__bytes > size_t(_S_max_bytes) || _S_force_new > 0) __ret = static_cast<_Tp*>(::operator new(__bytes)); else { _Obj* volatile* __free_list = _M_get_free_list(__bytes); __scoped_lock sentry(_M_get_mutex()); _Obj* __restrict__ __result = *__free_list; if (__builtin_expect(__result == 0, 0)) __ret = static_cast<_Tp*>(_M_refill(_M_round_up(__bytes))); else { *__free_list = __result->_M_free_list_link; __ret = reinterpret_cast<_Tp*>(__result); } if (__ret == 0) std::__throw_bad_alloc(); } } return __ret; } template void __pool_alloc<_Tp>::deallocate(pointer __p, size_type __n) { if (__builtin_expect(__n != 0 && __p != 0, true)) { const size_t __bytes = __n * sizeof(_Tp); if (__bytes > static_cast(_S_max_bytes) || _S_force_new > 0) ::operator delete(__p); else { _Obj* volatile* __free_list = _M_get_free_list(__bytes); _Obj* __q = reinterpret_cast<_Obj*>(__p); __scoped_lock sentry(_M_get_mutex()); __q ->_M_free_list_link = *__free_list; *__free_list = __q; } } } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/atomicity.h000064400000006645147547540550010223 0ustar00// Support for atomic operations -*- C++ -*- // Copyright (C) 2004-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/atomicity.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _GLIBCXX_ATOMICITY_H #define _GLIBCXX_ATOMICITY_H 1 #pragma GCC system_header #include #include #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Functions for portable atomic access. // To abstract locking primitives across all thread policies, use: // __exchange_and_add_dispatch // __atomic_add_dispatch #ifdef _GLIBCXX_ATOMIC_BUILTINS static inline _Atomic_word __exchange_and_add(volatile _Atomic_word* __mem, int __val) { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } static inline void __atomic_add(volatile _Atomic_word* __mem, int __val) { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } #else _Atomic_word __attribute__ ((__unused__)) __exchange_and_add(volatile _Atomic_word*, int) throw (); void __attribute__ ((__unused__)) __atomic_add(volatile _Atomic_word*, int) throw (); #endif static inline _Atomic_word __exchange_and_add_single(_Atomic_word* __mem, int __val) { _Atomic_word __result = *__mem; *__mem += __val; return __result; } static inline void __atomic_add_single(_Atomic_word* __mem, int __val) { *__mem += __val; } static inline _Atomic_word __attribute__ ((__unused__)) __exchange_and_add_dispatch(_Atomic_word* __mem, int __val) { #ifdef __GTHREADS if (__gthread_active_p()) return __exchange_and_add(__mem, __val); else return __exchange_and_add_single(__mem, __val); #else return __exchange_and_add_single(__mem, __val); #endif } static inline void __attribute__ ((__unused__)) __atomic_add_dispatch(_Atomic_word* __mem, int __val) { #ifdef __GTHREADS if (__gthread_active_p()) __atomic_add(__mem, __val); else __atomic_add_single(__mem, __val); #else __atomic_add_single(__mem, __val); #endif } _GLIBCXX_END_NAMESPACE_VERSION } // namespace // Even if the CPU doesn't need a memory barrier, we need to ensure // that the compiler doesn't reorder memory accesses across the // barriers. #ifndef _GLIBCXX_READ_MEM_BARRIER #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory") #endif #ifndef _GLIBCXX_WRITE_MEM_BARRIER #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory") #endif #endif 4.8.2/ext/rope000064400000253132147547540550006733 0ustar00// SGI's rope class -*- C++ -*- // Copyright (C) 2001-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * Copyright (c) 1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file ext/rope * This file is a GNU extension to the Standard C++ Library (possibly * containing extensions from the HP/SGI STL subset). */ #ifndef _ROPE #define _ROPE 1 #pragma GCC system_header #include #include #include #include #include #include #include #include #include # ifdef __GC # define __GC_CONST const # else # define __GC_CONST // constant except for deallocation # endif #include // For uninitialized_copy_n namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { namespace __detail { enum { _S_max_rope_depth = 45 }; enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function}; } // namespace __detail using std::size_t; using std::ptrdiff_t; using std::allocator; using std::_Destroy; _GLIBCXX_BEGIN_NAMESPACE_VERSION // See libstdc++/36832. template void _Destroy_const(_ForwardIterator __first, _ForwardIterator __last, _Allocator __alloc) { for (; __first != __last; ++__first) __alloc.destroy(&*__first); } template inline void _Destroy_const(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>) { _Destroy(__first, __last); } // The _S_eos function is used for those functions that // convert to/from C-like strings to detect the end of the string. // The end-of-C-string character. // This is what the draft standard says it should be. template inline _CharT _S_eos(_CharT*) { return _CharT(); } // Test for basic character types. // For basic character types leaves having a trailing eos. template inline bool _S_is_basic_char_type(_CharT*) { return false; } template inline bool _S_is_one_byte_char_type(_CharT*) { return false; } inline bool _S_is_basic_char_type(char*) { return true; } inline bool _S_is_one_byte_char_type(char*) { return true; } inline bool _S_is_basic_char_type(wchar_t*) { return true; } // Store an eos iff _CharT is a basic character type. // Do not reference _S_eos if it isn't. template inline void _S_cond_store_eos(_CharT&) { } inline void _S_cond_store_eos(char& __c) { __c = 0; } inline void _S_cond_store_eos(wchar_t& __c) { __c = 0; } // char_producers are logically functions that generate a section of // a string. These can be converted to ropes. The resulting rope // invokes the char_producer on demand. This allows, for example, // files to be viewed as ropes without reading the entire file. template class char_producer { public: virtual ~char_producer() { }; virtual void operator()(size_t __start_pos, size_t __len, _CharT* __buffer) = 0; // Buffer should really be an arbitrary output iterator. // That way we could flatten directly into an ostream, etc. // This is thoroughly impossible, since iterator types don't // have runtime descriptions. }; // Sequence buffers: // // Sequence must provide an append operation that appends an // array to the sequence. Sequence buffers are useful only if // appending an entire array is cheaper than appending element by element. // This is true for many string representations. // This should perhaps inherit from ostream // and be implemented correspondingly, so that they can be used // for formatted. For the sake of portability, we don't do this yet. // // For now, sequence buffers behave as output iterators. But they also // behave a little like basic_ostringstream and a // little like containers. template class sequence_buffer : public std::iterator { public: typedef typename _Sequence::value_type value_type; protected: _Sequence* _M_prefix; value_type _M_buffer[_Buf_sz]; size_t _M_buf_count; public: void flush() { _M_prefix->append(_M_buffer, _M_buffer + _M_buf_count); _M_buf_count = 0; } ~sequence_buffer() { flush(); } sequence_buffer() : _M_prefix(0), _M_buf_count(0) { } sequence_buffer(const sequence_buffer& __x) { _M_prefix = __x._M_prefix; _M_buf_count = __x._M_buf_count; std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); } sequence_buffer(sequence_buffer& __x) { __x.flush(); _M_prefix = __x._M_prefix; _M_buf_count = 0; } sequence_buffer(_Sequence& __s) : _M_prefix(&__s), _M_buf_count(0) { } sequence_buffer& operator=(sequence_buffer& __x) { __x.flush(); _M_prefix = __x._M_prefix; _M_buf_count = 0; return *this; } sequence_buffer& operator=(const sequence_buffer& __x) { _M_prefix = __x._M_prefix; _M_buf_count = __x._M_buf_count; std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); return *this; } void push_back(value_type __x) { if (_M_buf_count < _Buf_sz) { _M_buffer[_M_buf_count] = __x; ++_M_buf_count; } else { flush(); _M_buffer[0] = __x; _M_buf_count = 1; } } void append(value_type* __s, size_t __len) { if (__len + _M_buf_count <= _Buf_sz) { size_t __i = _M_buf_count; for (size_t __j = 0; __j < __len; __i++, __j++) _M_buffer[__i] = __s[__j]; _M_buf_count += __len; } else if (0 == _M_buf_count) _M_prefix->append(__s, __s + __len); else { flush(); append(__s, __len); } } sequence_buffer& write(value_type* __s, size_t __len) { append(__s, __len); return *this; } sequence_buffer& put(value_type __x) { push_back(__x); return *this; } sequence_buffer& operator=(const value_type& __rhs) { push_back(__rhs); return *this; } sequence_buffer& operator*() { return *this; } sequence_buffer& operator++() { return *this; } sequence_buffer operator++(int) { return *this; } }; // The following should be treated as private, at least for now. template class _Rope_char_consumer { public: // If we had member templates, these should not be virtual. // For now we need to use run-time parametrization where // compile-time would do. Hence this should all be private // for now. // The symmetry with char_producer is accidental and temporary. virtual ~_Rope_char_consumer() { }; virtual bool operator()(const _CharT* __buffer, size_t __len) = 0; }; // First a lot of forward declarations. The standard seems to require // much stricter "declaration before use" than many of the implementations // that preceded it. template > class rope; template struct _Rope_RopeConcatenation; template struct _Rope_RopeLeaf; template struct _Rope_RopeFunction; template struct _Rope_RopeSubstring; template class _Rope_iterator; template class _Rope_const_iterator; template class _Rope_char_ref_proxy; template class _Rope_char_ptr_proxy; template bool operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x, const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y); template _Rope_const_iterator<_CharT, _Alloc> operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n); template _Rope_const_iterator<_CharT, _Alloc> operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n); template _Rope_const_iterator<_CharT, _Alloc> operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT, _Alloc>& __x); template bool operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y); template bool operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y); template ptrdiff_t operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y); template _Rope_iterator<_CharT, _Alloc> operator-(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n); template _Rope_iterator<_CharT, _Alloc> operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n); template _Rope_iterator<_CharT, _Alloc> operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x); template bool operator==(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y); template bool operator<(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y); template ptrdiff_t operator-(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y); template rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, const rope<_CharT, _Alloc>& __right); template rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, const _CharT* __right); template rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, _CharT __right); // Some helpers, so we can use power on ropes. // See below for why this isn't local to the implementation. // This uses a nonstandard refcount convention. // The result has refcount 0. template struct _Rope_Concat_fn : public std::binary_function, rope<_CharT, _Alloc>, rope<_CharT, _Alloc> > { rope<_CharT, _Alloc> operator()(const rope<_CharT, _Alloc>& __x, const rope<_CharT, _Alloc>& __y) { return __x + __y; } }; template inline rope<_CharT, _Alloc> identity_element(_Rope_Concat_fn<_CharT, _Alloc>) { return rope<_CharT, _Alloc>(); } // Class _Refcount_Base provides a type, _RC_t, a data member, // _M_ref_count, and member functions _M_incr and _M_decr, which perform // atomic preincrement/predecrement. The constructor initializes // _M_ref_count. struct _Refcount_Base { // The type _RC_t typedef size_t _RC_t; // The data member _M_ref_count volatile _RC_t _M_ref_count; // Constructor #ifdef __GTHREAD_MUTEX_INIT __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT; #else __gthread_mutex_t _M_ref_count_lock; #endif _Refcount_Base(_RC_t __n) : _M_ref_count(__n) { #ifndef __GTHREAD_MUTEX_INIT #ifdef __GTHREAD_MUTEX_INIT_FUNCTION __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock); #else #error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org. #endif #endif } #ifndef __GTHREAD_MUTEX_INIT ~_Refcount_Base() { __gthread_mutex_destroy(&_M_ref_count_lock); } #endif void _M_incr() { __gthread_mutex_lock(&_M_ref_count_lock); ++_M_ref_count; __gthread_mutex_unlock(&_M_ref_count_lock); } _RC_t _M_decr() { __gthread_mutex_lock(&_M_ref_count_lock); volatile _RC_t __tmp = --_M_ref_count; __gthread_mutex_unlock(&_M_ref_count_lock); return __tmp; } }; // // What follows should really be local to rope. Unfortunately, // that doesn't work, since it makes it impossible to define generic // equality on rope iterators. According to the draft standard, the // template parameters for such an equality operator cannot be inferred // from the occurrence of a member class as a parameter. // (SGI compilers in fact allow this, but the __result wouldn't be // portable.) // Similarly, some of the static member functions are member functions // only to avoid polluting the global namespace, and to circumvent // restrictions on type inference for template functions. // // // The internal data structure for representing a rope. This is // private to the implementation. A rope is really just a pointer // to one of these. // // A few basic functions for manipulating this data structure // are members of _RopeRep. Most of the more complex algorithms // are implemented as rope members. // // Some of the static member functions of _RopeRep have identically // named functions in rope that simply invoke the _RopeRep versions. #define __ROPE_DEFINE_ALLOCS(__a) \ __ROPE_DEFINE_ALLOC(_CharT,_Data) /* character data */ \ typedef _Rope_RopeConcatenation<_CharT,__a> __C; \ __ROPE_DEFINE_ALLOC(__C,_C) \ typedef _Rope_RopeLeaf<_CharT,__a> __L; \ __ROPE_DEFINE_ALLOC(__L,_L) \ typedef _Rope_RopeFunction<_CharT,__a> __F; \ __ROPE_DEFINE_ALLOC(__F,_F) \ typedef _Rope_RopeSubstring<_CharT,__a> __S; \ __ROPE_DEFINE_ALLOC(__S,_S) // Internal rope nodes potentially store a copy of the allocator // instance used to allocate them. This is mostly redundant. // But the alternative would be to pass allocator instances around // in some form to nearly all internal functions, since any pointer // assignment may result in a zero reference count and thus require // deallocation. #define __STATIC_IF_SGI_ALLOC /* not static */ template struct _Rope_rep_base : public _Alloc { typedef _Alloc allocator_type; allocator_type get_allocator() const { return *static_cast(this); } allocator_type& _M_get_allocator() { return *static_cast<_Alloc*>(this); } const allocator_type& _M_get_allocator() const { return *static_cast(this); } _Rope_rep_base(size_t __size, const allocator_type&) : _M_size(__size) { } size_t _M_size; # define __ROPE_DEFINE_ALLOC(_Tp, __name) \ typedef typename \ _Alloc::template rebind<_Tp>::other __name##Alloc; \ static _Tp* __name##_allocate(size_t __n) \ { return __name##Alloc().allocate(__n); } \ static void __name##_deallocate(_Tp *__p, size_t __n) \ { __name##Alloc().deallocate(__p, __n); } __ROPE_DEFINE_ALLOCS(_Alloc) # undef __ROPE_DEFINE_ALLOC }; template struct _Rope_RopeRep : public _Rope_rep_base<_CharT, _Alloc> # ifndef __GC , _Refcount_Base # endif { public: __detail::_Tag _M_tag:8; bool _M_is_balanced:8; unsigned char _M_depth; __GC_CONST _CharT* _M_c_string; #ifdef __GTHREAD_MUTEX_INIT __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT; #else __gthread_mutex_t _M_c_string_lock; #endif /* Flattened version of string, if needed. */ /* typically 0. */ /* If it's not 0, then the memory is owned */ /* by this node. */ /* In the case of a leaf, this may point to */ /* the same memory as the data field. */ typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type allocator_type; using _Rope_rep_base<_CharT, _Alloc>::get_allocator; using _Rope_rep_base<_CharT, _Alloc>::_M_get_allocator; _Rope_RopeRep(__detail::_Tag __t, int __d, bool __b, size_t __size, const allocator_type& __a) : _Rope_rep_base<_CharT, _Alloc>(__size, __a), #ifndef __GC _Refcount_Base(1), #endif _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0) #ifdef __GTHREAD_MUTEX_INIT { } #else { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); } ~_Rope_RopeRep() { __gthread_mutex_destroy (&_M_c_string_lock); } #endif #ifdef __GC void _M_incr () { } #endif static void _S_free_string(__GC_CONST _CharT*, size_t __len, allocator_type& __a); #define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a); // Deallocate data section of a leaf. // This shouldn't be a member function. // But its hard to do anything else at the // moment, because it's templatized w.r.t. // an allocator. // Does nothing if __GC is defined. #ifndef __GC void _M_free_c_string(); void _M_free_tree(); // Deallocate t. Assumes t is not 0. void _M_unref_nonnil() { if (0 == _M_decr()) _M_free_tree(); } void _M_ref_nonnil() { _M_incr(); } static void _S_unref(_Rope_RopeRep* __t) { if (0 != __t) __t->_M_unref_nonnil(); } static void _S_ref(_Rope_RopeRep* __t) { if (0 != __t) __t->_M_incr(); } static void _S_free_if_unref(_Rope_RopeRep* __t) { if (0 != __t && 0 == __t->_M_ref_count) __t->_M_free_tree(); } # else /* __GC */ void _M_unref_nonnil() { } void _M_ref_nonnil() { } static void _S_unref(_Rope_RopeRep*) { } static void _S_ref(_Rope_RopeRep*) { } static void _S_free_if_unref(_Rope_RopeRep*) { } # endif protected: _Rope_RopeRep& operator=(const _Rope_RopeRep&); _Rope_RopeRep(const _Rope_RopeRep&); }; template struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT, _Alloc> { public: // Apparently needed by VC++ // The data fields of leaves are allocated with some // extra space, to accommodate future growth and for basic // character types, to hold a trailing eos character. enum { _S_alloc_granularity = 8 }; static size_t _S_rounded_up_size(size_t __n) { size_t __size_with_eos; if (_S_is_basic_char_type((_CharT*)0)) __size_with_eos = __n + 1; else __size_with_eos = __n; #ifdef __GC return __size_with_eos; #else // Allow slop for in-place expansion. return ((__size_with_eos + size_t(_S_alloc_granularity) - 1) &~ (size_t(_S_alloc_granularity) - 1)); #endif } __GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */ /* The allocated size is */ /* _S_rounded_up_size(size), except */ /* in the GC case, in which it */ /* doesn't matter. */ typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size, const allocator_type& __a) : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_leaf, 0, true, __size, __a), _M_data(__d) { if (_S_is_basic_char_type((_CharT *)0)) { // already eos terminated. this->_M_c_string = __d; } } // The constructor assumes that d has been allocated with // the proper allocator and the properly padded size. // In contrast, the destructor deallocates the data: #ifndef __GC ~_Rope_RopeLeaf() throw() { if (_M_data != this->_M_c_string) this->_M_free_c_string(); this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator()); } #endif protected: _Rope_RopeLeaf& operator=(const _Rope_RopeLeaf&); _Rope_RopeLeaf(const _Rope_RopeLeaf&); }; template struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT, _Alloc> { public: _Rope_RopeRep<_CharT, _Alloc>* _M_left; _Rope_RopeRep<_CharT, _Alloc>* _M_right; typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type allocator_type; _Rope_RopeConcatenation(_Rope_RopeRep<_CharT, _Alloc>* __l, _Rope_RopeRep<_CharT, _Alloc>* __r, const allocator_type& __a) : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_concat, std::max(__l->_M_depth, __r->_M_depth) + 1, false, __l->_M_size + __r->_M_size, __a), _M_left(__l), _M_right(__r) { } #ifndef __GC ~_Rope_RopeConcatenation() throw() { this->_M_free_c_string(); _M_left->_M_unref_nonnil(); _M_right->_M_unref_nonnil(); } #endif protected: _Rope_RopeConcatenation& operator=(const _Rope_RopeConcatenation&); _Rope_RopeConcatenation(const _Rope_RopeConcatenation&); }; template struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT, _Alloc> { public: char_producer<_CharT>* _M_fn; #ifndef __GC bool _M_delete_when_done; // Char_producer is owned by the // rope and should be explicitly // deleted when the rope becomes // inaccessible. #else // In the GC case, we either register the rope for // finalization, or not. Thus the field is unnecessary; // the information is stored in the collector data structures. // We do need a finalization procedure to be invoked by the // collector. static void _S_fn_finalization_proc(void * __tree, void *) { delete ((_Rope_RopeFunction *)__tree) -> _M_fn; } #endif typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type allocator_type; _Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d, const allocator_type& __a) : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_function, 0, true, __size, __a) , _M_fn(__f) #ifndef __GC , _M_delete_when_done(__d) #endif { #ifdef __GC if (__d) { GC_REGISTER_FINALIZER(this, _Rope_RopeFunction:: _S_fn_finalization_proc, 0, 0, 0); } #endif } #ifndef __GC ~_Rope_RopeFunction() throw() { this->_M_free_c_string(); if (_M_delete_when_done) delete _M_fn; } # endif protected: _Rope_RopeFunction& operator=(const _Rope_RopeFunction&); _Rope_RopeFunction(const _Rope_RopeFunction&); }; // Substring results are usually represented using just // concatenation nodes. But in the case of very long flat ropes // or ropes with a functional representation that isn't practical. // In that case, we represent the __result as a special case of // RopeFunction, whose char_producer points back to the rope itself. // In all cases except repeated substring operations and // deallocation, we treat the __result as a RopeFunction. template struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT, _Alloc>, public char_producer<_CharT> { public: // XXX this whole class should be rewritten. _Rope_RopeRep<_CharT,_Alloc>* _M_base; // not 0 size_t _M_start; virtual void operator()(size_t __start_pos, size_t __req_len, _CharT* __buffer) { switch(_M_base->_M_tag) { case __detail::_S_function: case __detail::_S_substringfn: { char_producer<_CharT>* __fn = ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn; (*__fn)(__start_pos + _M_start, __req_len, __buffer); } break; case __detail::_S_leaf: { __GC_CONST _CharT* __s = ((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data; uninitialized_copy_n(__s + __start_pos + _M_start, __req_len, __buffer); } break; default: break; } } typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type allocator_type; _Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_t __s, size_t __l, const allocator_type& __a) : _Rope_RopeFunction<_CharT, _Alloc>(this, __l, false, __a), char_producer<_CharT>(), _M_base(__b), _M_start(__s) { #ifndef __GC _M_base->_M_ref_nonnil(); #endif this->_M_tag = __detail::_S_substringfn; } virtual ~_Rope_RopeSubstring() throw() { #ifndef __GC _M_base->_M_unref_nonnil(); // _M_free_c_string(); -- done by parent class #endif } }; // Self-destructing pointers to Rope_rep. // These are not conventional smart pointers. Their // only purpose in life is to ensure that unref is called // on the pointer either at normal exit or if an exception // is raised. It is the caller's responsibility to // adjust reference counts when these pointers are initialized // or assigned to. (This convention significantly reduces // the number of potentially expensive reference count // updates.) #ifndef __GC template struct _Rope_self_destruct_ptr { _Rope_RopeRep<_CharT, _Alloc>* _M_ptr; ~_Rope_self_destruct_ptr() { _Rope_RopeRep<_CharT, _Alloc>::_S_unref(_M_ptr); } #ifdef __EXCEPTIONS _Rope_self_destruct_ptr() : _M_ptr(0) { }; #else _Rope_self_destruct_ptr() { }; #endif _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT, _Alloc>* __p) : _M_ptr(__p) { } _Rope_RopeRep<_CharT, _Alloc>& operator*() { return *_M_ptr; } _Rope_RopeRep<_CharT, _Alloc>* operator->() { return _M_ptr; } operator _Rope_RopeRep<_CharT, _Alloc>*() { return _M_ptr; } _Rope_self_destruct_ptr& operator=(_Rope_RopeRep<_CharT, _Alloc>* __x) { _M_ptr = __x; return *this; } }; #endif // Dereferencing a nonconst iterator has to return something // that behaves almost like a reference. It's not possible to // return an actual reference since assignment requires extra // work. And we would get into the same problems as with the // CD2 version of basic_string. template class _Rope_char_ref_proxy { friend class rope<_CharT, _Alloc>; friend class _Rope_iterator<_CharT, _Alloc>; friend class _Rope_char_ptr_proxy<_CharT, _Alloc>; #ifdef __GC typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr; #else typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr; #endif typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; typedef rope<_CharT, _Alloc> _My_rope; size_t _M_pos; _CharT _M_current; bool _M_current_valid; _My_rope* _M_root; // The whole rope. public: _Rope_char_ref_proxy(_My_rope* __r, size_t __p) : _M_pos(__p), _M_current(), _M_current_valid(false), _M_root(__r) { } _Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x) : _M_pos(__x._M_pos), _M_current(__x._M_current), _M_current_valid(false), _M_root(__x._M_root) { } // Don't preserve cache if the reference can outlive the // expression. We claim that's not possible without calling // a copy constructor or generating reference to a proxy // reference. We declare the latter to have undefined semantics. _Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c) : _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) { } inline operator _CharT () const; _Rope_char_ref_proxy& operator=(_CharT __c); _Rope_char_ptr_proxy<_CharT, _Alloc> operator&() const; _Rope_char_ref_proxy& operator=(const _Rope_char_ref_proxy& __c) { return operator=((_CharT)__c); } }; template inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, _Rope_char_ref_proxy <_CharT, __Alloc > __b) { _CharT __tmp = __a; __a = __b; __b = __tmp; } template class _Rope_char_ptr_proxy { // XXX this class should be rewritten. friend class _Rope_char_ref_proxy<_CharT, _Alloc>; size_t _M_pos; rope<_CharT,_Alloc>* _M_root; // The whole rope. public: _Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x) : _M_pos(__x._M_pos), _M_root(__x._M_root) { } _Rope_char_ptr_proxy(const _Rope_char_ptr_proxy& __x) : _M_pos(__x._M_pos), _M_root(__x._M_root) { } _Rope_char_ptr_proxy() { } _Rope_char_ptr_proxy(_CharT* __x) : _M_root(0), _M_pos(0) { } _Rope_char_ptr_proxy& operator=(const _Rope_char_ptr_proxy& __x) { _M_pos = __x._M_pos; _M_root = __x._M_root; return *this; } template friend bool operator==(const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __x, const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __y); _Rope_char_ref_proxy<_CharT, _Alloc> operator*() const { return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root, _M_pos); } }; // Rope iterators: // Unlike in the C version, we cache only part of the stack // for rope iterators, since they must be efficiently copyable. // When we run out of cache, we have to reconstruct the iterator // value. // Pointers from iterators are not included in reference counts. // Iterators are assumed to be thread private. Ropes can // be shared. template class _Rope_iterator_base : public std::iterator { friend class rope<_CharT, _Alloc>; public: typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; // Borland doesn't want this to be protected. protected: enum { _S_path_cache_len = 4 }; // Must be <= 9. enum { _S_iterator_buf_len = 15 }; size_t _M_current_pos; _RopeRep* _M_root; // The whole rope. size_t _M_leaf_pos; // Starting position for current leaf __GC_CONST _CharT* _M_buf_start; // Buffer possibly // containing current char. __GC_CONST _CharT* _M_buf_ptr; // Pointer to current char in buffer. // != 0 ==> buffer valid. __GC_CONST _CharT* _M_buf_end; // One past __last valid char in buffer. // What follows is the path cache. We go out of our // way to make this compact. // Path_end contains the bottom section of the path from // the root to the current leaf. const _RopeRep* _M_path_end[_S_path_cache_len]; int _M_leaf_index; // Last valid __pos in path_end; // _M_path_end[0] ... _M_path_end[leaf_index-1] // point to concatenation nodes. unsigned char _M_path_directions; // (path_directions >> __i) & 1 is 1 // iff we got from _M_path_end[leaf_index - __i - 1] // to _M_path_end[leaf_index - __i] by going to the // __right. Assumes path_cache_len <= 9. _CharT _M_tmp_buf[_S_iterator_buf_len]; // Short buffer for surrounding chars. // This is useful primarily for // RopeFunctions. We put the buffer // here to avoid locking in the // multithreaded case. // The cached path is generally assumed to be valid // only if the buffer is valid. static void _S_setbuf(_Rope_iterator_base& __x); // Set buffer contents given // path cache. static void _S_setcache(_Rope_iterator_base& __x); // Set buffer contents and // path cache. static void _S_setcache_for_incr(_Rope_iterator_base& __x); // As above, but assumes path // cache is valid for previous posn. _Rope_iterator_base() { } _Rope_iterator_base(_RopeRep* __root, size_t __pos) : _M_current_pos(__pos), _M_root(__root), _M_buf_ptr(0) { } void _M_incr(size_t __n); void _M_decr(size_t __n); public: size_t index() const { return _M_current_pos; } _Rope_iterator_base(const _Rope_iterator_base& __x) { if (0 != __x._M_buf_ptr) *this = __x; else { _M_current_pos = __x._M_current_pos; _M_root = __x._M_root; _M_buf_ptr = 0; } } }; template class _Rope_iterator; template class _Rope_const_iterator : public _Rope_iterator_base<_CharT, _Alloc> { friend class rope<_CharT, _Alloc>; protected: typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; // The one from the base class may not be directly visible. _Rope_const_iterator(const _RopeRep* __root, size_t __pos) : _Rope_iterator_base<_CharT, _Alloc>(const_cast<_RopeRep*>(__root), __pos) // Only nonconst iterators modify root ref count { } public: typedef _CharT reference; // Really a value. Returning a reference // Would be a mess, since it would have // to be included in refcount. typedef const _CharT* pointer; public: _Rope_const_iterator() { }; _Rope_const_iterator(const _Rope_const_iterator& __x) : _Rope_iterator_base<_CharT,_Alloc>(__x) { } _Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x); _Rope_const_iterator(const rope<_CharT, _Alloc>& __r, size_t __pos) : _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) { } _Rope_const_iterator& operator=(const _Rope_const_iterator& __x) { if (0 != __x._M_buf_ptr) *(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x; else { this->_M_current_pos = __x._M_current_pos; this->_M_root = __x._M_root; this->_M_buf_ptr = 0; } return(*this); } reference operator*() { if (0 == this->_M_buf_ptr) this->_S_setcache(*this); return *this->_M_buf_ptr; } // Without this const version, Rope iterators do not meet the // requirements of an Input Iterator. reference operator*() const { return *const_cast<_Rope_const_iterator&>(*this); } _Rope_const_iterator& operator++() { __GC_CONST _CharT* __next; if (0 != this->_M_buf_ptr && (__next = this->_M_buf_ptr + 1) < this->_M_buf_end) { this->_M_buf_ptr = __next; ++this->_M_current_pos; } else this->_M_incr(1); return *this; } _Rope_const_iterator& operator+=(ptrdiff_t __n) { if (__n >= 0) this->_M_incr(__n); else this->_M_decr(-__n); return *this; } _Rope_const_iterator& operator--() { this->_M_decr(1); return *this; } _Rope_const_iterator& operator-=(ptrdiff_t __n) { if (__n >= 0) this->_M_decr(__n); else this->_M_incr(-__n); return *this; } _Rope_const_iterator operator++(int) { size_t __old_pos = this->_M_current_pos; this->_M_incr(1); return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); // This makes a subsequent dereference expensive. // Perhaps we should instead copy the iterator // if it has a valid cache? } _Rope_const_iterator operator--(int) { size_t __old_pos = this->_M_current_pos; this->_M_decr(1); return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); } template friend _Rope_const_iterator<_CharT2, _Alloc2> operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n); template friend _Rope_const_iterator<_CharT2, _Alloc2> operator+(const _Rope_const_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n); template friend _Rope_const_iterator<_CharT2, _Alloc2> operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT2, _Alloc2>& __x); reference operator[](size_t __n) { return rope<_CharT, _Alloc>::_S_fetch(this->_M_root, this->_M_current_pos + __n); } template friend bool operator==(const _Rope_const_iterator<_CharT2, _Alloc2>& __x, const _Rope_const_iterator<_CharT2, _Alloc2>& __y); template friend bool operator<(const _Rope_const_iterator<_CharT2, _Alloc2>& __x, const _Rope_const_iterator<_CharT2, _Alloc2>& __y); template friend ptrdiff_t operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x, const _Rope_const_iterator<_CharT2, _Alloc2>& __y); }; template class _Rope_iterator : public _Rope_iterator_base<_CharT, _Alloc> { friend class rope<_CharT, _Alloc>; protected: typedef typename _Rope_iterator_base<_CharT, _Alloc>::_RopeRep _RopeRep; rope<_CharT, _Alloc>* _M_root_rope; // root is treated as a cached version of this, and is used to // detect changes to the underlying rope. // Root is included in the reference count. This is necessary // so that we can detect changes reliably. Unfortunately, it // requires careful bookkeeping for the nonGC case. _Rope_iterator(rope<_CharT, _Alloc>* __r, size_t __pos) : _Rope_iterator_base<_CharT, _Alloc>(__r->_M_tree_ptr, __pos), _M_root_rope(__r) { _RopeRep::_S_ref(this->_M_root); if (!(__r -> empty())) this->_S_setcache(*this); } void _M_check(); public: typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference; typedef _Rope_char_ref_proxy<_CharT, _Alloc>* pointer; rope<_CharT, _Alloc>& container() { return *_M_root_rope; } _Rope_iterator() { this->_M_root = 0; // Needed for reference counting. }; _Rope_iterator(const _Rope_iterator& __x) : _Rope_iterator_base<_CharT, _Alloc>(__x) { _M_root_rope = __x._M_root_rope; _RopeRep::_S_ref(this->_M_root); } _Rope_iterator(rope<_CharT, _Alloc>& __r, size_t __pos); ~_Rope_iterator() { _RopeRep::_S_unref(this->_M_root); } _Rope_iterator& operator=(const _Rope_iterator& __x) { _RopeRep* __old = this->_M_root; _RopeRep::_S_ref(__x._M_root); if (0 != __x._M_buf_ptr) { _M_root_rope = __x._M_root_rope; *(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x; } else { this->_M_current_pos = __x._M_current_pos; this->_M_root = __x._M_root; _M_root_rope = __x._M_root_rope; this->_M_buf_ptr = 0; } _RopeRep::_S_unref(__old); return(*this); } reference operator*() { _M_check(); if (0 == this->_M_buf_ptr) return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope, this->_M_current_pos); else return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope, this->_M_current_pos, *this->_M_buf_ptr); } // See above comment. reference operator*() const { return *const_cast<_Rope_iterator&>(*this); } _Rope_iterator& operator++() { this->_M_incr(1); return *this; } _Rope_iterator& operator+=(ptrdiff_t __n) { if (__n >= 0) this->_M_incr(__n); else this->_M_decr(-__n); return *this; } _Rope_iterator& operator--() { this->_M_decr(1); return *this; } _Rope_iterator& operator-=(ptrdiff_t __n) { if (__n >= 0) this->_M_decr(__n); else this->_M_incr(-__n); return *this; } _Rope_iterator operator++(int) { size_t __old_pos = this->_M_current_pos; this->_M_incr(1); return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); } _Rope_iterator operator--(int) { size_t __old_pos = this->_M_current_pos; this->_M_decr(1); return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); } reference operator[](ptrdiff_t __n) { return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope, this->_M_current_pos + __n); } template friend bool operator==(const _Rope_iterator<_CharT2, _Alloc2>& __x, const _Rope_iterator<_CharT2, _Alloc2>& __y); template friend bool operator<(const _Rope_iterator<_CharT2, _Alloc2>& __x, const _Rope_iterator<_CharT2, _Alloc2>& __y); template friend ptrdiff_t operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x, const _Rope_iterator<_CharT2, _Alloc2>& __y); template friend _Rope_iterator<_CharT2, _Alloc2> operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n); template friend _Rope_iterator<_CharT2, _Alloc2> operator+(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n); template friend _Rope_iterator<_CharT2, _Alloc2> operator+(ptrdiff_t __n, const _Rope_iterator<_CharT2, _Alloc2>& __x); }; template struct _Rope_base : public _Alloc { typedef _Alloc allocator_type; allocator_type get_allocator() const { return *static_cast(this); } allocator_type& _M_get_allocator() { return *static_cast<_Alloc*>(this); } const allocator_type& _M_get_allocator() const { return *static_cast(this); } typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; // The one in _Base may not be visible due to template rules. _Rope_base(_RopeRep* __t, const allocator_type&) : _M_tree_ptr(__t) { } _Rope_base(const allocator_type&) { } // The only data member of a rope: _RopeRep *_M_tree_ptr; #define __ROPE_DEFINE_ALLOC(_Tp, __name) \ typedef typename \ _Alloc::template rebind<_Tp>::other __name##Alloc; \ static _Tp* __name##_allocate(size_t __n) \ { return __name##Alloc().allocate(__n); } \ static void __name##_deallocate(_Tp *__p, size_t __n) \ { __name##Alloc().deallocate(__p, __n); } __ROPE_DEFINE_ALLOCS(_Alloc) #undef __ROPE_DEFINE_ALLOC protected: _Rope_base& operator=(const _Rope_base&); _Rope_base(const _Rope_base&); }; /** * This is an SGI extension. * @ingroup SGIextensions * @doctodo */ template class rope : public _Rope_base<_CharT, _Alloc> { public: typedef _CharT value_type; typedef ptrdiff_t difference_type; typedef size_t size_type; typedef _CharT const_reference; typedef const _CharT* const_pointer; typedef _Rope_iterator<_CharT, _Alloc> iterator; typedef _Rope_const_iterator<_CharT, _Alloc> const_iterator; typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference; typedef _Rope_char_ptr_proxy<_CharT, _Alloc> pointer; friend class _Rope_iterator<_CharT, _Alloc>; friend class _Rope_const_iterator<_CharT, _Alloc>; friend struct _Rope_RopeRep<_CharT, _Alloc>; friend class _Rope_iterator_base<_CharT, _Alloc>; friend class _Rope_char_ptr_proxy<_CharT, _Alloc>; friend class _Rope_char_ref_proxy<_CharT, _Alloc>; friend struct _Rope_RopeSubstring<_CharT, _Alloc>; protected: typedef _Rope_base<_CharT, _Alloc> _Base; typedef typename _Base::allocator_type allocator_type; using _Base::_M_tree_ptr; using _Base::get_allocator; using _Base::_M_get_allocator; typedef __GC_CONST _CharT* _Cstrptr; static _CharT _S_empty_c_str[1]; static bool _S_is0(_CharT __c) { return __c == _S_eos((_CharT*)0); } enum { _S_copy_max = 23 }; // For strings shorter than _S_copy_max, we copy to // concatenate. typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; typedef _Rope_RopeConcatenation<_CharT, _Alloc> _RopeConcatenation; typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf; typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction; typedef _Rope_RopeSubstring<_CharT, _Alloc> _RopeSubstring; // Retrieve a character at the indicated position. static _CharT _S_fetch(_RopeRep* __r, size_type __pos); #ifndef __GC // Obtain a pointer to the character at the indicated position. // The pointer can be used to change the character. // If such a pointer cannot be produced, as is frequently the // case, 0 is returned instead. // (Returns nonzero only if all nodes in the path have a refcount // of 1.) static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos); #endif static bool _S_apply_to_pieces(// should be template parameter _Rope_char_consumer<_CharT>& __c, const _RopeRep* __r, size_t __begin, size_t __end); // begin and end are assumed to be in range. #ifndef __GC static void _S_unref(_RopeRep* __t) { _RopeRep::_S_unref(__t); } static void _S_ref(_RopeRep* __t) { _RopeRep::_S_ref(__t); } #else /* __GC */ static void _S_unref(_RopeRep*) { } static void _S_ref(_RopeRep*) { } #endif #ifdef __GC typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr; #else typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr; #endif // _Result is counted in refcount. static _RopeRep* _S_substring(_RopeRep* __base, size_t __start, size_t __endp1); static _RopeRep* _S_concat_char_iter(_RopeRep* __r, const _CharT* __iter, size_t __slen); // Concatenate rope and char ptr, copying __s. // Should really take an arbitrary iterator. // Result is counted in refcount. static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r, const _CharT* __iter, size_t __slen) // As above, but one reference to __r is about to be // destroyed. Thus the pieces may be recycled if all // relevant reference counts are 1. #ifdef __GC // We can't really do anything since refcounts are unavailable. { return _S_concat_char_iter(__r, __iter, __slen); } #else ; #endif static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right); // General concatenation on _RopeRep. _Result // has refcount of 1. Adjusts argument refcounts. public: void apply_to_pieces(size_t __begin, size_t __end, _Rope_char_consumer<_CharT>& __c) const { _S_apply_to_pieces(__c, this->_M_tree_ptr, __begin, __end); } protected: static size_t _S_rounded_up_size(size_t __n) { return _RopeLeaf::_S_rounded_up_size(__n); } static size_t _S_allocated_capacity(size_t __n) { if (_S_is_basic_char_type((_CharT*)0)) return _S_rounded_up_size(__n) - 1; else return _S_rounded_up_size(__n); } // Allocate and construct a RopeLeaf using the supplied allocator // Takes ownership of s instead of copying. static _RopeLeaf* _S_new_RopeLeaf(__GC_CONST _CharT *__s, size_t __size, allocator_type& __a) { _RopeLeaf* __space = typename _Base::_LAlloc(__a).allocate(1); return new(__space) _RopeLeaf(__s, __size, __a); } static _RopeConcatenation* _S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right, allocator_type& __a) { _RopeConcatenation* __space = typename _Base::_CAlloc(__a).allocate(1); return new(__space) _RopeConcatenation(__left, __right, __a); } static _RopeFunction* _S_new_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d, allocator_type& __a) { _RopeFunction* __space = typename _Base::_FAlloc(__a).allocate(1); return new(__space) _RopeFunction(__f, __size, __d, __a); } static _RopeSubstring* _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s, size_t __l, allocator_type& __a) { _RopeSubstring* __space = typename _Base::_SAlloc(__a).allocate(1); return new(__space) _RopeSubstring(__b, __s, __l, __a); } static _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s, size_t __size, allocator_type& __a) #define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \ _S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a) { if (0 == __size) return 0; _CharT* __buf = __a.allocate(_S_rounded_up_size(__size)); __uninitialized_copy_n_a(__s, __size, __buf, __a); _S_cond_store_eos(__buf[__size]); __try { return _S_new_RopeLeaf(__buf, __size, __a); } __catch(...) { _RopeRep::__STL_FREE_STRING(__buf, __size, __a); __throw_exception_again; } } // Concatenation of nonempty strings. // Always builds a concatenation node. // Rebalances if the result is too deep. // Result has refcount 1. // Does not increment left and right ref counts even though // they are referenced. static _RopeRep* _S_tree_concat(_RopeRep* __left, _RopeRep* __right); // Concatenation helper functions static _RopeLeaf* _S_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter, size_t __slen); // Concatenate by copying leaf. // should take an arbitrary iterator // result has refcount 1. #ifndef __GC static _RopeLeaf* _S_destr_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter, size_t __slen); // A version that potentially clobbers __r if __r->_M_ref_count == 1. #endif private: static size_t _S_char_ptr_len(const _CharT* __s); // slightly generalized strlen rope(_RopeRep* __t, const allocator_type& __a = allocator_type()) : _Base(__t, __a) { } // Copy __r to the _CharT buffer. // Returns __buffer + __r->_M_size. // Assumes that buffer is uninitialized. static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer); // Again, with explicit starting position and length. // Assumes that buffer is uninitialized. static _CharT* _S_flatten(_RopeRep* __r, size_t __start, size_t __len, _CharT* __buffer); static const unsigned long _S_min_len[__detail::_S_max_rope_depth + 1]; static bool _S_is_balanced(_RopeRep* __r) { return (__r->_M_size >= _S_min_len[__r->_M_depth]); } static bool _S_is_almost_balanced(_RopeRep* __r) { return (__r->_M_depth == 0 || __r->_M_size >= _S_min_len[__r->_M_depth - 1]); } static bool _S_is_roughly_balanced(_RopeRep* __r) { return (__r->_M_depth <= 1 || __r->_M_size >= _S_min_len[__r->_M_depth - 2]); } // Assumes the result is not empty. static _RopeRep* _S_concat_and_set_balanced(_RopeRep* __left, _RopeRep* __right) { _RopeRep* __result = _S_concat(__left, __right); if (_S_is_balanced(__result)) __result->_M_is_balanced = true; return __result; } // The basic rebalancing operation. Logically copies the // rope. The result has refcount of 1. The client will // usually decrement the reference count of __r. // The result is within height 2 of balanced by the above // definition. static _RopeRep* _S_balance(_RopeRep* __r); // Add all unbalanced subtrees to the forest of balanced trees. // Used only by balance. static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest); // Add __r to forest, assuming __r is already balanced. static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest); // Print to stdout, exposing structure static void _S_dump(_RopeRep* __r, int __indent = 0); // Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp. static int _S_compare(const _RopeRep* __x, const _RopeRep* __y); public: bool empty() const { return 0 == this->_M_tree_ptr; } // Comparison member function. This is public only for those // clients that need a ternary comparison. Others // should use the comparison operators below. int compare(const rope& __y) const { return _S_compare(this->_M_tree_ptr, __y._M_tree_ptr); } rope(const _CharT* __s, const allocator_type& __a = allocator_type()) : _Base(__a) { this->_M_tree_ptr = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s), _M_get_allocator()); } rope(const _CharT* __s, size_t __len, const allocator_type& __a = allocator_type()) : _Base(__a) { this->_M_tree_ptr = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, _M_get_allocator()); } // Should perhaps be templatized with respect to the iterator type // and use Sequence_buffer. (It should perhaps use sequence_buffer // even now.) rope(const _CharT* __s, const _CharT* __e, const allocator_type& __a = allocator_type()) : _Base(__a) { this->_M_tree_ptr = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, _M_get_allocator()); } rope(const const_iterator& __s, const const_iterator& __e, const allocator_type& __a = allocator_type()) : _Base(_S_substring(__s._M_root, __s._M_current_pos, __e._M_current_pos), __a) { } rope(const iterator& __s, const iterator& __e, const allocator_type& __a = allocator_type()) : _Base(_S_substring(__s._M_root, __s._M_current_pos, __e._M_current_pos), __a) { } rope(_CharT __c, const allocator_type& __a = allocator_type()) : _Base(__a) { _CharT* __buf = this->_Data_allocate(_S_rounded_up_size(1)); _M_get_allocator().construct(__buf, __c); __try { this->_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, _M_get_allocator()); } __catch(...) { _RopeRep::__STL_FREE_STRING(__buf, 1, _M_get_allocator()); __throw_exception_again; } } rope(size_t __n, _CharT __c, const allocator_type& __a = allocator_type()); rope(const allocator_type& __a = allocator_type()) : _Base(0, __a) { } // Construct a rope from a function that can compute its members rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn, const allocator_type& __a = allocator_type()) : _Base(__a) { this->_M_tree_ptr = (0 == __len) ? 0 : _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator()); } rope(const rope& __x, const allocator_type& __a = allocator_type()) : _Base(__x._M_tree_ptr, __a) { _S_ref(this->_M_tree_ptr); } ~rope() throw() { _S_unref(this->_M_tree_ptr); } rope& operator=(const rope& __x) { _RopeRep* __old = this->_M_tree_ptr; this->_M_tree_ptr = __x._M_tree_ptr; _S_ref(this->_M_tree_ptr); _S_unref(__old); return *this; } void clear() { _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = 0; } void push_back(_CharT __x) { _RopeRep* __old = this->_M_tree_ptr; this->_M_tree_ptr = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1); _S_unref(__old); } void pop_back() { _RopeRep* __old = this->_M_tree_ptr; this->_M_tree_ptr = _S_substring(this->_M_tree_ptr, 0, this->_M_tree_ptr->_M_size - 1); _S_unref(__old); } _CharT back() const { return _S_fetch(this->_M_tree_ptr, this->_M_tree_ptr->_M_size - 1); } void push_front(_CharT __x) { _RopeRep* __old = this->_M_tree_ptr; _RopeRep* __left = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, _M_get_allocator()); __try { this->_M_tree_ptr = _S_concat(__left, this->_M_tree_ptr); _S_unref(__old); _S_unref(__left); } __catch(...) { _S_unref(__left); __throw_exception_again; } } void pop_front() { _RopeRep* __old = this->_M_tree_ptr; this->_M_tree_ptr = _S_substring(this->_M_tree_ptr, 1, this->_M_tree_ptr->_M_size); _S_unref(__old); } _CharT front() const { return _S_fetch(this->_M_tree_ptr, 0); } void balance() { _RopeRep* __old = this->_M_tree_ptr; this->_M_tree_ptr = _S_balance(this->_M_tree_ptr); _S_unref(__old); } void copy(_CharT* __buffer) const { _Destroy_const(__buffer, __buffer + size(), _M_get_allocator()); _S_flatten(this->_M_tree_ptr, __buffer); } // This is the copy function from the standard, but // with the arguments reordered to make it consistent with the // rest of the interface. // Note that this guaranteed not to compile if the draft standard // order is assumed. size_type copy(size_type __pos, size_type __n, _CharT* __buffer) const { size_t __size = size(); size_t __len = (__pos + __n > __size? __size - __pos : __n); _Destroy_const(__buffer, __buffer + __len, _M_get_allocator()); _S_flatten(this->_M_tree_ptr, __pos, __len, __buffer); return __len; } // Print to stdout, exposing structure. May be useful for // performance debugging. void dump() { _S_dump(this->_M_tree_ptr); } // Convert to 0 terminated string in new allocated memory. // Embedded 0s in the input do not terminate the copy. const _CharT* c_str() const; // As above, but also use the flattened representation as // the new rope representation. const _CharT* replace_with_c_str(); // Reclaim memory for the c_str generated flattened string. // Intentionally undocumented, since it's hard to say when this // is safe for multiple threads. void delete_c_str () { if (0 == this->_M_tree_ptr) return; if (__detail::_S_leaf == this->_M_tree_ptr->_M_tag && ((_RopeLeaf*)this->_M_tree_ptr)->_M_data == this->_M_tree_ptr->_M_c_string) { // Representation shared return; } #ifndef __GC this->_M_tree_ptr->_M_free_c_string(); #endif this->_M_tree_ptr->_M_c_string = 0; } _CharT operator[] (size_type __pos) const { return _S_fetch(this->_M_tree_ptr, __pos); } _CharT at(size_type __pos) const { // if (__pos >= size()) throw out_of_range; // XXX return (*this)[__pos]; } const_iterator begin() const { return(const_iterator(this->_M_tree_ptr, 0)); } // An easy way to get a const iterator from a non-const container. const_iterator const_begin() const { return(const_iterator(this->_M_tree_ptr, 0)); } const_iterator end() const { return(const_iterator(this->_M_tree_ptr, size())); } const_iterator const_end() const { return(const_iterator(this->_M_tree_ptr, size())); } size_type size() const { return(0 == this->_M_tree_ptr? 0 : this->_M_tree_ptr->_M_size); } size_type length() const { return size(); } size_type max_size() const { return _S_min_len[int(__detail::_S_max_rope_depth) - 1] - 1; // Guarantees that the result can be sufficiently // balanced. Longer ropes will probably still work, // but it's harder to make guarantees. } typedef std::reverse_iterator const_reverse_iterator; const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator const_rbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } const_reverse_iterator const_rend() const { return const_reverse_iterator(begin()); } template friend rope<_CharT2, _Alloc2> operator+(const rope<_CharT2, _Alloc2>& __left, const rope<_CharT2, _Alloc2>& __right); template friend rope<_CharT2, _Alloc2> operator+(const rope<_CharT2, _Alloc2>& __left, const _CharT2* __right); template friend rope<_CharT2, _Alloc2> operator+(const rope<_CharT2, _Alloc2>& __left, _CharT2 __right); // The symmetric cases are intentionally omitted, since they're // presumed to be less common, and we don't handle them as well. // The following should really be templatized. The first // argument should be an input iterator or forward iterator with // value_type _CharT. rope& append(const _CharT* __iter, size_t __n) { _RopeRep* __result = _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; return *this; } rope& append(const _CharT* __c_string) { size_t __len = _S_char_ptr_len(__c_string); append(__c_string, __len); return(*this); } rope& append(const _CharT* __s, const _CharT* __e) { _RopeRep* __result = _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; return *this; } rope& append(const_iterator __s, const_iterator __e) { _Self_destruct_ptr __appendee(_S_substring(__s._M_root, __s._M_current_pos, __e._M_current_pos)); _RopeRep* __result = _S_concat(this->_M_tree_ptr, (_RopeRep*)__appendee); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; return *this; } rope& append(_CharT __c) { _RopeRep* __result = _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; return *this; } rope& append() { return append(_CharT()); } // XXX why? rope& append(const rope& __y) { _RopeRep* __result = _S_concat(this->_M_tree_ptr, __y._M_tree_ptr); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; return *this; } rope& append(size_t __n, _CharT __c) { rope<_CharT,_Alloc> __last(__n, __c); return append(__last); } void swap(rope& __b) { _RopeRep* __tmp = this->_M_tree_ptr; this->_M_tree_ptr = __b._M_tree_ptr; __b._M_tree_ptr = __tmp; } protected: // Result is included in refcount. static _RopeRep* replace(_RopeRep* __old, size_t __pos1, size_t __pos2, _RopeRep* __r) { if (0 == __old) { _S_ref(__r); return __r; } _Self_destruct_ptr __left(_S_substring(__old, 0, __pos1)); _Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size)); _RopeRep* __result; if (0 == __r) __result = _S_concat(__left, __right); else { _Self_destruct_ptr __left_result(_S_concat(__left, __r)); __result = _S_concat(__left_result, __right); } return __result; } public: void insert(size_t __p, const rope& __r) { _RopeRep* __result = replace(this->_M_tree_ptr, __p, __p, __r._M_tree_ptr); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; } void insert(size_t __p, size_t __n, _CharT __c) { rope<_CharT,_Alloc> __r(__n,__c); insert(__p, __r); } void insert(size_t __p, const _CharT* __i, size_t __n) { _Self_destruct_ptr __left(_S_substring(this->_M_tree_ptr, 0, __p)); _Self_destruct_ptr __right(_S_substring(this->_M_tree_ptr, __p, size())); _Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n)); // _S_ destr_concat_char_iter should be safe here. // But as it stands it's probably not a win, since __left // is likely to have additional references. _RopeRep* __result = _S_concat(__left_result, __right); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; } void insert(size_t __p, const _CharT* __c_string) { insert(__p, __c_string, _S_char_ptr_len(__c_string)); } void insert(size_t __p, _CharT __c) { insert(__p, &__c, 1); } void insert(size_t __p) { _CharT __c = _CharT(); insert(__p, &__c, 1); } void insert(size_t __p, const _CharT* __i, const _CharT* __j) { rope __r(__i, __j); insert(__p, __r); } void insert(size_t __p, const const_iterator& __i, const const_iterator& __j) { rope __r(__i, __j); insert(__p, __r); } void insert(size_t __p, const iterator& __i, const iterator& __j) { rope __r(__i, __j); insert(__p, __r); } // (position, length) versions of replace operations: void replace(size_t __p, size_t __n, const rope& __r) { _RopeRep* __result = replace(this->_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; } void replace(size_t __p, size_t __n, const _CharT* __i, size_t __i_len) { rope __r(__i, __i_len); replace(__p, __n, __r); } void replace(size_t __p, size_t __n, _CharT __c) { rope __r(__c); replace(__p, __n, __r); } void replace(size_t __p, size_t __n, const _CharT* __c_string) { rope __r(__c_string); replace(__p, __n, __r); } void replace(size_t __p, size_t __n, const _CharT* __i, const _CharT* __j) { rope __r(__i, __j); replace(__p, __n, __r); } void replace(size_t __p, size_t __n, const const_iterator& __i, const const_iterator& __j) { rope __r(__i, __j); replace(__p, __n, __r); } void replace(size_t __p, size_t __n, const iterator& __i, const iterator& __j) { rope __r(__i, __j); replace(__p, __n, __r); } // Single character variants: void replace(size_t __p, _CharT __c) { iterator __i(this, __p); *__i = __c; } void replace(size_t __p, const rope& __r) { replace(__p, 1, __r); } void replace(size_t __p, const _CharT* __i, size_t __i_len) { replace(__p, 1, __i, __i_len); } void replace(size_t __p, const _CharT* __c_string) { replace(__p, 1, __c_string); } void replace(size_t __p, const _CharT* __i, const _CharT* __j) { replace(__p, 1, __i, __j); } void replace(size_t __p, const const_iterator& __i, const const_iterator& __j) { replace(__p, 1, __i, __j); } void replace(size_t __p, const iterator& __i, const iterator& __j) { replace(__p, 1, __i, __j); } // Erase, (position, size) variant. void erase(size_t __p, size_t __n) { _RopeRep* __result = replace(this->_M_tree_ptr, __p, __p + __n, 0); _S_unref(this->_M_tree_ptr); this->_M_tree_ptr = __result; } // Erase, single character void erase(size_t __p) { erase(__p, __p + 1); } // Insert, iterator variants. iterator insert(const iterator& __p, const rope& __r) { insert(__p.index(), __r); return __p; } iterator insert(const iterator& __p, size_t __n, _CharT __c) { insert(__p.index(), __n, __c); return __p; } iterator insert(const iterator& __p, _CharT __c) { insert(__p.index(), __c); return __p; } iterator insert(const iterator& __p ) { insert(__p.index()); return __p; } iterator insert(const iterator& __p, const _CharT* c_string) { insert(__p.index(), c_string); return __p; } iterator insert(const iterator& __p, const _CharT* __i, size_t __n) { insert(__p.index(), __i, __n); return __p; } iterator insert(const iterator& __p, const _CharT* __i, const _CharT* __j) { insert(__p.index(), __i, __j); return __p; } iterator insert(const iterator& __p, const const_iterator& __i, const const_iterator& __j) { insert(__p.index(), __i, __j); return __p; } iterator insert(const iterator& __p, const iterator& __i, const iterator& __j) { insert(__p.index(), __i, __j); return __p; } // Replace, range variants. void replace(const iterator& __p, const iterator& __q, const rope& __r) { replace(__p.index(), __q.index() - __p.index(), __r); } void replace(const iterator& __p, const iterator& __q, _CharT __c) { replace(__p.index(), __q.index() - __p.index(), __c); } void replace(const iterator& __p, const iterator& __q, const _CharT* __c_string) { replace(__p.index(), __q.index() - __p.index(), __c_string); } void replace(const iterator& __p, const iterator& __q, const _CharT* __i, size_t __n) { replace(__p.index(), __q.index() - __p.index(), __i, __n); } void replace(const iterator& __p, const iterator& __q, const _CharT* __i, const _CharT* __j) { replace(__p.index(), __q.index() - __p.index(), __i, __j); } void replace(const iterator& __p, const iterator& __q, const const_iterator& __i, const const_iterator& __j) { replace(__p.index(), __q.index() - __p.index(), __i, __j); } void replace(const iterator& __p, const iterator& __q, const iterator& __i, const iterator& __j) { replace(__p.index(), __q.index() - __p.index(), __i, __j); } // Replace, iterator variants. void replace(const iterator& __p, const rope& __r) { replace(__p.index(), __r); } void replace(const iterator& __p, _CharT __c) { replace(__p.index(), __c); } void replace(const iterator& __p, const _CharT* __c_string) { replace(__p.index(), __c_string); } void replace(const iterator& __p, const _CharT* __i, size_t __n) { replace(__p.index(), __i, __n); } void replace(const iterator& __p, const _CharT* __i, const _CharT* __j) { replace(__p.index(), __i, __j); } void replace(const iterator& __p, const_iterator __i, const_iterator __j) { replace(__p.index(), __i, __j); } void replace(const iterator& __p, iterator __i, iterator __j) { replace(__p.index(), __i, __j); } // Iterator and range variants of erase iterator erase(const iterator& __p, const iterator& __q) { size_t __p_index = __p.index(); erase(__p_index, __q.index() - __p_index); return iterator(this, __p_index); } iterator erase(const iterator& __p) { size_t __p_index = __p.index(); erase(__p_index, 1); return iterator(this, __p_index); } rope substr(size_t __start, size_t __len = 1) const { return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr, __start, __start + __len)); } rope substr(iterator __start, iterator __end) const { return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr, __start.index(), __end.index())); } rope substr(iterator __start) const { size_t __pos = __start.index(); return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr, __pos, __pos + 1)); } rope substr(const_iterator __start, const_iterator __end) const { // This might eventually take advantage of the cache in the // iterator. return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr, __start.index(), __end.index())); } rope<_CharT, _Alloc> substr(const_iterator __start) { size_t __pos = __start.index(); return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr, __pos, __pos + 1)); } static const size_type npos; size_type find(_CharT __c, size_type __pos = 0) const; size_type find(const _CharT* __s, size_type __pos = 0) const { size_type __result_pos; const_iterator __result = std::search(const_begin() + __pos, const_end(), __s, __s + _S_char_ptr_len(__s)); __result_pos = __result.index(); #ifndef __STL_OLD_ROPE_SEMANTICS if (__result_pos == size()) __result_pos = npos; #endif return __result_pos; } iterator mutable_begin() { return(iterator(this, 0)); } iterator mutable_end() { return(iterator(this, size())); } typedef std::reverse_iterator reverse_iterator; reverse_iterator mutable_rbegin() { return reverse_iterator(mutable_end()); } reverse_iterator mutable_rend() { return reverse_iterator(mutable_begin()); } reference mutable_reference_at(size_type __pos) { return reference(this, __pos); } #ifdef __STD_STUFF reference operator[] (size_type __pos) { return _char_ref_proxy(this, __pos); } reference at(size_type __pos) { // if (__pos >= size()) throw out_of_range; // XXX return (*this)[__pos]; } void resize(size_type __n, _CharT __c) { } void resize(size_type __n) { } void reserve(size_type __res_arg = 0) { } size_type capacity() const { return max_size(); } // Stuff below this line is dangerous because it's error prone. // I would really like to get rid of it. // copy function with funny arg ordering. size_type copy(_CharT* __buffer, size_type __n, size_type __pos = 0) const { return copy(__pos, __n, __buffer); } iterator end() { return mutable_end(); } iterator begin() { return mutable_begin(); } reverse_iterator rend() { return mutable_rend(); } reverse_iterator rbegin() { return mutable_rbegin(); } #else const_iterator end() { return const_end(); } const_iterator begin() { return const_begin(); } const_reverse_iterator rend() { return const_rend(); } const_reverse_iterator rbegin() { return const_rbegin(); } #endif }; template const typename rope<_CharT, _Alloc>::size_type rope<_CharT, _Alloc>::npos = (size_type)(-1); template inline bool operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return (__x._M_current_pos == __y._M_current_pos && __x._M_root == __y._M_root); } template inline bool operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return (__x._M_current_pos < __y._M_current_pos); } template inline bool operator!=(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return !(__x == __y); } template inline bool operator>(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return __y < __x; } template inline bool operator<=(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return !(__y < __x); } template inline bool operator>=(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return !(__x < __y); } template inline ptrdiff_t operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, const _Rope_const_iterator<_CharT, _Alloc>& __y) { return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; } template inline _Rope_const_iterator<_CharT, _Alloc> operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n) { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root, __x._M_current_pos - __n); } template inline _Rope_const_iterator<_CharT, _Alloc> operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n) { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root, __x._M_current_pos + __n); } template inline _Rope_const_iterator<_CharT, _Alloc> operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT, _Alloc>& __x) { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root, __x._M_current_pos + __n); } template inline bool operator==(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) {return (__x._M_current_pos == __y._M_current_pos && __x._M_root_rope == __y._M_root_rope); } template inline bool operator<(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return (__x._M_current_pos < __y._M_current_pos); } template inline bool operator!=(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return !(__x == __y); } template inline bool operator>(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return __y < __x; } template inline bool operator<=(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return !(__y < __x); } template inline bool operator>=(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return !(__x < __y); } template inline ptrdiff_t operator-(const _Rope_iterator<_CharT, _Alloc>& __x, const _Rope_iterator<_CharT, _Alloc>& __y) { return ((ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos); } template inline _Rope_iterator<_CharT, _Alloc> operator-(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n) { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope, __x._M_current_pos - __n); } template inline _Rope_iterator<_CharT, _Alloc> operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n) { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope, __x._M_current_pos + __n); } template inline _Rope_iterator<_CharT, _Alloc> operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x) { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope, __x._M_current_pos + __n); } template inline rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, const rope<_CharT, _Alloc>& __right) { // Inlining this should make it possible to keep __left and // __right in registers. typedef rope<_CharT, _Alloc> rope_type; return rope_type(rope_type::_S_concat(__left._M_tree_ptr, __right._M_tree_ptr)); } template inline rope<_CharT, _Alloc>& operator+=(rope<_CharT, _Alloc>& __left, const rope<_CharT, _Alloc>& __right) { __left.append(__right); return __left; } template inline rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, const _CharT* __right) { typedef rope<_CharT, _Alloc> rope_type; size_t __rlen = rope_type::_S_char_ptr_len(__right); return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr, __right, __rlen)); } template inline rope<_CharT, _Alloc>& operator+=(rope<_CharT, _Alloc>& __left, const _CharT* __right) { __left.append(__right); return __left; } template inline rope<_CharT, _Alloc> operator+(const rope<_CharT, _Alloc>& __left, _CharT __right) { typedef rope<_CharT, _Alloc> rope_type; return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr, &__right, 1)); } template inline rope<_CharT, _Alloc>& operator+=(rope<_CharT, _Alloc>& __left, _CharT __right) { __left.append(__right); return __left; } template bool operator<(const rope<_CharT, _Alloc>& __left, const rope<_CharT, _Alloc>& __right) { return __left.compare(__right) < 0; } template bool operator==(const rope<_CharT, _Alloc>& __left, const rope<_CharT, _Alloc>& __right) { return __left.compare(__right) == 0; } template inline bool operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x, const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y) { return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); } template inline bool operator!=(const rope<_CharT, _Alloc>& __x, const rope<_CharT, _Alloc>& __y) { return !(__x == __y); } template inline bool operator>(const rope<_CharT, _Alloc>& __x, const rope<_CharT, _Alloc>& __y) { return __y < __x; } template inline bool operator<=(const rope<_CharT, _Alloc>& __x, const rope<_CharT, _Alloc>& __y) { return !(__y < __x); } template inline bool operator>=(const rope<_CharT, _Alloc>& __x, const rope<_CharT, _Alloc>& __y) { return !(__x < __y); } template inline bool operator!=(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x, const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y) { return !(__x == __y); } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __o, const rope<_CharT, _Alloc>& __r); typedef rope crope; typedef rope wrope; inline crope::reference __mutable_reference_at(crope& __c, size_t __i) { return __c.mutable_reference_at(__i); } inline wrope::reference __mutable_reference_at(wrope& __c, size_t __i) { return __c.mutable_reference_at(__i); } template inline void swap(rope<_CharT, _Alloc>& __x, rope<_CharT, _Alloc>& __y) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace namespace std _GLIBCXX_VISIBILITY(default) { namespace tr1 { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct hash<__gnu_cxx::crope> { size_t operator()(const __gnu_cxx::crope& __str) const { size_t __size = __str.size(); if (0 == __size) return 0; return 13 * __str[0] + 5 * __str[__size - 1] + __size; } }; template<> struct hash<__gnu_cxx::wrope> { size_t operator()(const __gnu_cxx::wrope& __str) const { size_t __size = __str.size(); if (0 == __size) return 0; return 13 * __str[0] + 5 * __str[__size - 1] + __size; } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace tr1 } // namespace std # include #endif 4.8.2/ext/enc_filebuf.h000064400000004307147547540550010453 0ustar00// filebuf with encoding state type -*- C++ -*- // Copyright (C) 2002-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/enc_filebuf.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _EXT_ENC_FILEBUF_H #define _EXT_ENC_FILEBUF_H 1 #include #include #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// class enc_filebuf. template class enc_filebuf : public std::basic_filebuf<_CharT, encoding_char_traits<_CharT> > { public: typedef encoding_char_traits<_CharT> traits_type; typedef typename traits_type::state_type state_type; typedef typename traits_type::pos_type pos_type; enc_filebuf(state_type& __state) : std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >() { this->_M_state_beg = __state; } private: // concept requirements: // Set state type to something useful. // Something more than copyconstructible is needed here, so // require default and copy constructible + assignment operator. __glibcxx_class_requires(state_type, _SGIAssignableConcept) }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/vstring.tcc000064400000056055147547540550010237 0ustar00// Versatile string -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/vstring.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ext/vstring.h} */ #ifndef _VSTRING_TCC #define _VSTRING_TCC 1 #pragma GCC system_header #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template class _Base> const typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>::npos; template class _Base> void __versa_string<_CharT, _Traits, _Alloc, _Base>:: resize(size_type __n, _CharT __c) { const size_type __size = this->size(); if (__size < __n) this->append(__n - __size, __c); else if (__n < __size) this->_M_erase(__n, __size - __n); } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base>& __versa_string<_CharT, _Traits, _Alloc, _Base>:: _M_append(const _CharT* __s, size_type __n) { const size_type __len = __n + this->size(); if (__len <= this->capacity() && !this->_M_is_shared()) { if (__n) this->_S_copy(this->_M_data() + this->size(), __s, __n); } else this->_M_mutate(this->size(), size_type(0), __s, __n); this->_M_set_length(__len); return *this; } template class _Base> template __versa_string<_CharT, _Traits, _Alloc, _Base>& __versa_string<_CharT, _Traits, _Alloc, _Base>:: _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2, std::__false_type) { const __versa_string __s(__k1, __k2); const size_type __n1 = __i2 - __i1; return _M_replace(__i1 - _M_ibegin(), __n1, __s._M_data(), __s.size()); } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base>& __versa_string<_CharT, _Traits, _Alloc, _Base>:: _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c) { _M_check_length(__n1, __n2, "__versa_string::_M_replace_aux"); const size_type __old_size = this->size(); const size_type __new_size = __old_size + __n2 - __n1; if (__new_size <= this->capacity() && !this->_M_is_shared()) { _CharT* __p = this->_M_data() + __pos1; const size_type __how_much = __old_size - __pos1 - __n1; if (__how_much && __n1 != __n2) this->_S_move(__p + __n2, __p + __n1, __how_much); } else this->_M_mutate(__pos1, __n1, 0, __n2); if (__n2) this->_S_assign(this->_M_data() + __pos1, __n2, __c); this->_M_set_length(__new_size); return *this; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base>& __versa_string<_CharT, _Traits, _Alloc, _Base>:: _M_replace(size_type __pos, size_type __len1, const _CharT* __s, const size_type __len2) { _M_check_length(__len1, __len2, "__versa_string::_M_replace"); const size_type __old_size = this->size(); const size_type __new_size = __old_size + __len2 - __len1; if (__new_size <= this->capacity() && !this->_M_is_shared()) { _CharT* __p = this->_M_data() + __pos; const size_type __how_much = __old_size - __pos - __len1; if (_M_disjunct(__s)) { if (__how_much && __len1 != __len2) this->_S_move(__p + __len2, __p + __len1, __how_much); if (__len2) this->_S_copy(__p, __s, __len2); } else { // Work in-place. if (__len2 && __len2 <= __len1) this->_S_move(__p, __s, __len2); if (__how_much && __len1 != __len2) this->_S_move(__p + __len2, __p + __len1, __how_much); if (__len2 > __len1) { if (__s + __len2 <= __p + __len1) this->_S_move(__p, __s, __len2); else if (__s >= __p + __len1) this->_S_copy(__p, __s + __len2 - __len1, __len2); else { const size_type __nleft = (__p + __len1) - __s; this->_S_move(__p, __s, __nleft); this->_S_copy(__p + __nleft, __p + __len2, __len2 - __nleft); } } } } else this->_M_mutate(__pos, __len1, __s, __len2); this->_M_set_length(__new_size); return *this; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { __versa_string<_CharT, _Traits, _Alloc, _Base> __str; __str.reserve(__lhs.size() + __rhs.size()); __str.append(__lhs); __str.append(__rhs); return __str; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { __glibcxx_requires_string(__lhs); typedef __versa_string<_CharT, _Traits, _Alloc, _Base> __string_type; typedef typename __string_type::size_type __size_type; const __size_type __len = _Traits::length(__lhs); __string_type __str; __str.reserve(__len + __rhs.size()); __str.append(__lhs, __len); __str.append(__rhs); return __str; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(_CharT __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { __versa_string<_CharT, _Traits, _Alloc, _Base> __str; __str.reserve(__rhs.size() + 1); __str.push_back(__lhs); __str.append(__rhs); return __str; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) { __glibcxx_requires_string(__rhs); typedef __versa_string<_CharT, _Traits, _Alloc, _Base> __string_type; typedef typename __string_type::size_type __size_type; const __size_type __len = _Traits::length(__rhs); __string_type __str; __str.reserve(__lhs.size() + __len); __str.append(__lhs); __str.append(__rhs, __len); return __str; } template class _Base> __versa_string<_CharT, _Traits, _Alloc, _Base> operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, _CharT __rhs) { __versa_string<_CharT, _Traits, _Alloc, _Base> __str; __str.reserve(__lhs.size() + 1); __str.append(__lhs); __str.push_back(__rhs); return __str; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: copy(_CharT* __s, size_type __n, size_type __pos) const { _M_check(__pos, "__versa_string::copy"); __n = _M_limit(__pos, __n); __glibcxx_requires_string_len(__s, __n); if (__n) this->_S_copy(__s, this->_M_data() + __pos, __n); // 21.3.5.7 par 3: do not append null. (good.) return __n; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); const size_type __size = this->size(); const _CharT* __data = this->_M_data(); if (__n == 0) return __pos <= __size ? __pos : npos; if (__n <= __size) { for (; __pos <= __size - __n; ++__pos) if (traits_type::eq(__data[__pos], __s[0]) && traits_type::compare(__data + __pos + 1, __s + 1, __n - 1) == 0) return __pos; } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT { size_type __ret = npos; const size_type __size = this->size(); if (__pos < __size) { const _CharT* __data = this->_M_data(); const size_type __n = __size - __pos; const _CharT* __p = traits_type::find(__data + __pos, __n, __c); if (__p) __ret = __p - __data; } return __ret; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: rfind(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); const size_type __size = this->size(); if (__n <= __size) { __pos = std::min(size_type(__size - __n), __pos); const _CharT* __data = this->_M_data(); do { if (traits_type::compare(__data + __pos, __s, __n) == 0) return __pos; } while (__pos-- > 0); } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT { size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; for (++__size; __size-- > 0; ) if (traits_type::eq(this->_M_data()[__size], __c)) return __size; } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_first_of(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); for (; __n && __pos < this->size(); ++__pos) { const _CharT* __p = traits_type::find(__s, __n, this->_M_data()[__pos]); if (__p) return __pos; } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_last_of(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); size_type __size = this->size(); if (__size && __n) { if (--__size > __pos) __size = __pos; do { if (traits_type::find(__s, __n, this->_M_data()[__size])) return __size; } while (__size-- != 0); } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); for (; __pos < this->size(); ++__pos) if (!traits_type::find(__s, __n, this->_M_data()[__pos])) return __pos; return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT { for (; __pos < this->size(); ++__pos) if (!traits_type::eq(this->_M_data()[__pos], __c)) return __pos; return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__s, __n); size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::find(__s, __n, this->_M_data()[__size])) return __size; } while (__size--); } return npos; } template class _Base> typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type __versa_string<_CharT, _Traits, _Alloc, _Base>:: find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT { size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::eq(this->_M_data()[__size], __c)) return __size; } while (__size--); } return npos; } template class _Base> int __versa_string<_CharT, _Traits, _Alloc, _Base>:: compare(size_type __pos, size_type __n, const __versa_string& __str) const { _M_check(__pos, "__versa_string::compare"); __n = _M_limit(__pos, __n); const size_type __osize = __str.size(); const size_type __len = std::min(__n, __osize); int __r = traits_type::compare(this->_M_data() + __pos, __str.data(), __len); if (!__r) __r = this->_S_compare(__n, __osize); return __r; } template class _Base> int __versa_string<_CharT, _Traits, _Alloc, _Base>:: compare(size_type __pos1, size_type __n1, const __versa_string& __str, size_type __pos2, size_type __n2) const { _M_check(__pos1, "__versa_string::compare"); __str._M_check(__pos2, "__versa_string::compare"); __n1 = _M_limit(__pos1, __n1); __n2 = __str._M_limit(__pos2, __n2); const size_type __len = std::min(__n1, __n2); int __r = traits_type::compare(this->_M_data() + __pos1, __str.data() + __pos2, __len); if (!__r) __r = this->_S_compare(__n1, __n2); return __r; } template class _Base> int __versa_string<_CharT, _Traits, _Alloc, _Base>:: compare(const _CharT* __s) const { __glibcxx_requires_string(__s); const size_type __size = this->size(); const size_type __osize = traits_type::length(__s); const size_type __len = std::min(__size, __osize); int __r = traits_type::compare(this->_M_data(), __s, __len); if (!__r) __r = this->_S_compare(__size, __osize); return __r; } template class _Base> int __versa_string <_CharT, _Traits, _Alloc, _Base>:: compare(size_type __pos, size_type __n1, const _CharT* __s) const { __glibcxx_requires_string(__s); _M_check(__pos, "__versa_string::compare"); __n1 = _M_limit(__pos, __n1); const size_type __osize = traits_type::length(__s); const size_type __len = std::min(__n1, __osize); int __r = traits_type::compare(this->_M_data() + __pos, __s, __len); if (!__r) __r = this->_S_compare(__n1, __osize); return __r; } template class _Base> int __versa_string <_CharT, _Traits, _Alloc, _Base>:: compare(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) const { __glibcxx_requires_string_len(__s, __n2); _M_check(__pos, "__versa_string::compare"); __n1 = _M_limit(__pos, __n1); const size_type __len = std::min(__n1, __n2); int __r = traits_type::compare(this->_M_data() + __pos, __s, __len); if (!__r) __r = this->_S_compare(__n1, __n2); return __r; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template class _Base> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str) { typedef basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base> __string_type; typedef typename __istream_type::int_type __int_type; typedef typename __string_type::size_type __size_type; typedef ctype<_CharT> __ctype_type; typedef typename __ctype_type::ctype_base __ctype_base; __size_type __extracted = 0; typename __ios_base::iostate __err = __ios_base::goodbit; typename __istream_type::sentry __cerb(__in, false); if (__cerb) { __try { // Avoid reallocation for common case. __str.erase(); _CharT __buf[128]; __size_type __len = 0; const streamsize __w = __in.width(); const __size_type __n = __w > 0 ? static_cast<__size_type>(__w) : __str.max_size(); const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); const __int_type __eof = _Traits::eof(); __int_type __c = __in.rdbuf()->sgetc(); while (__extracted < __n && !_Traits::eq_int_type(__c, __eof) && !__ct.is(__ctype_base::space, _Traits::to_char_type(__c))) { if (__len == sizeof(__buf) / sizeof(_CharT)) { __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); __len = 0; } __buf[__len++] = _Traits::to_char_type(__c); ++__extracted; __c = __in.rdbuf()->snextc(); } __str.append(__buf, __len); if (_Traits::eq_int_type(__c, __eof)) __err |= __ios_base::eofbit; __in.width(0); } __catch(__cxxabiv1::__forced_unwind&) { __in._M_setstate(__ios_base::badbit); __throw_exception_again; } __catch(...) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 91. Description of operator>> and getline() for string<> // might cause endless loop __in._M_setstate(__ios_base::badbit); } } // 211. operator>>(istream&, string&) doesn't set failbit if (!__extracted) __err |= __ios_base::failbit; if (__err) __in.setstate(__err); return __in; } template class _Base> basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __in, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str, _CharT __delim) { typedef basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base> __string_type; typedef typename __istream_type::int_type __int_type; typedef typename __string_type::size_type __size_type; __size_type __extracted = 0; const __size_type __n = __str.max_size(); typename __ios_base::iostate __err = __ios_base::goodbit; typename __istream_type::sentry __cerb(__in, true); if (__cerb) { __try { // Avoid reallocation for common case. __str.erase(); _CharT __buf[128]; __size_type __len = 0; const __int_type __idelim = _Traits::to_int_type(__delim); const __int_type __eof = _Traits::eof(); __int_type __c = __in.rdbuf()->sgetc(); while (__extracted < __n && !_Traits::eq_int_type(__c, __eof) && !_Traits::eq_int_type(__c, __idelim)) { if (__len == sizeof(__buf) / sizeof(_CharT)) { __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); __len = 0; } __buf[__len++] = _Traits::to_char_type(__c); ++__extracted; __c = __in.rdbuf()->snextc(); } __str.append(__buf, __len); if (_Traits::eq_int_type(__c, __eof)) __err |= __ios_base::eofbit; else if (_Traits::eq_int_type(__c, __idelim)) { ++__extracted; __in.rdbuf()->sbumpc(); } else __err |= __ios_base::failbit; } __catch(__cxxabiv1::__forced_unwind&) { __in._M_setstate(__ios_base::badbit); __throw_exception_again; } __catch(...) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 91. Description of operator>> and getline() for string<> // might cause endless loop __in._M_setstate(__ios_base::badbit); } } if (!__extracted) __err |= __ios_base::failbit; if (__err) __in.setstate(__err); return __in; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _VSTRING_TCC 4.8.2/ext/pb_ds/assoc_container.hpp000064400000072636147547540550013025 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file assoc_container.hpp * Contains associative containers. */ #ifndef PB_DS_ASSOC_CNTNR_HPP #define PB_DS_ASSOC_CNTNR_HPP #include #include #include #include #include #include namespace __gnu_pbds { /** * @defgroup containers-pbds Containers * @ingroup pbds * @{ */ /** * @defgroup hash-based Hash-Based * @ingroup containers-pbds * @{ */ #define PB_DS_HASH_BASE \ detail::container_base_dispatch >::type, Policy_Tl>::type>::type /** * @defgroup hash-detail Base and Policy Classes * @ingroup hash-based */ /** * A hashed container abstraction. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Hash_Fn Hashing functor. * @tparam Eq_Fn Equal functor. * @tparam Resize_Policy Resizes hash. * @tparam Store_Hash Indicates whether the hash value * will be stored along with each key. * @tparam Tag Instantiating data structure type, * see container_tag. * @tparam Policy_TL Policy typelist. * @tparam _Alloc Allocator type. * * Base is dispatched at compile time via Tag, from the following * choices: cc_hash_tag, gp_hash_tag, and descendants of basic_hash_tag. * * Base choices are: detail::cc_ht_map, detail::gp_ht_map */ template class basic_hash_table : public PB_DS_HASH_BASE { private: typedef typename PB_DS_HASH_BASE base_type; public: virtual ~basic_hash_table() { } protected: basic_hash_table() { } basic_hash_table(const basic_hash_table& other) : base_type((const base_type&)other) { } template basic_hash_table(T0 t0) : base_type(t0) { } template basic_hash_table(T0 t0, T1 t1) : base_type(t0, t1) { } template basic_hash_table(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3) : base_type(t0, t1, t2, t3) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) : base_type(t0, t1, t2, t3, t4) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : base_type(t0, t1, t2, t3, t4, t5) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : base_type(t0, t1, t2, t3, t4, t5, t6) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : base_type(t0, t1, t2, t3, t4, t5, t6, t7) { } template basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) : base_type(t0, t1, t2, t3, t4, t5, t6, t7, t8) { } private: basic_hash_table& operator=(const base_type&); }; #undef PB_DS_HASH_BASE #define PB_DS_CC_HASH_BASE \ basic_hash_table::type, _Alloc> /** * A collision-chaining hash-based associative container. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Hash_Fn Hashing functor. * @tparam Eq_Fn Equal functor. * @tparam Comb_Hash_Fn Combining hash functor. * If Hash_Fn is not null_type, then this * is the ranged-hash functor; otherwise, * this is the range-hashing functor. * XXX(See Design::Hash-Based Containers::Hash Policies.) * @tparam Resize_Policy Resizes hash. * @tparam Store_Hash Indicates whether the hash value * will be stored along with each key. * If Hash_Fn is null_type, then the * container will not compile if this * value is true * @tparam _Alloc Allocator type. * * Base tag choices are: cc_hash_tag. * * Base is basic_hash_table. */ template::type, typename Eq_Fn = typename detail::default_eq_fn::type, typename Comb_Hash_Fn = detail::default_comb_hash_fn::type, typename Resize_Policy = typename detail::default_resize_policy::type, bool Store_Hash = detail::default_store_hash, typename _Alloc = std::allocator > class cc_hash_table : public PB_DS_CC_HASH_BASE { private: typedef PB_DS_CC_HASH_BASE base_type; public: typedef cc_hash_tag container_category; typedef Hash_Fn hash_fn; typedef Eq_Fn eq_fn; typedef Resize_Policy resize_policy; typedef Comb_Hash_Fn comb_hash_fn; /// Default constructor. cc_hash_table() { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the Hash_Fn object of the container object. cc_hash_table(const hash_fn& h) : base_type(h) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, and /// r_eq_fn will be copied by the eq_fn object of the container /// object. cc_hash_table(const hash_fn& h, const eq_fn& e) : base_type(h, e) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, r_eq_fn /// will be copied by the eq_fn object of the container object, /// and r_comb_hash_fn will be copied by the comb_hash_fn object /// of the container object. cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch) : base_type(h, e, ch) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, r_eq_fn /// will be copied by the eq_fn object of the container object, /// r_comb_hash_fn will be copied by the comb_hash_fn object of /// the container object, and r_resize_policy will be copied by /// the resize_policy object of the container object. cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch, const resize_policy& rp) : base_type(h, e, ch, rp) { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template cc_hash_table(It first, It last) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. template cc_hash_table(It first, It last, const hash_fn& h) : base_type(h) { this->copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// and r_eq_fn will be copied by the eq_fn object of the /// container object. template cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e) : base_type(h, e) { this->copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// r_eq_fn will be copied by the eq_fn object of the container /// object, and r_comb_hash_fn will be copied by the comb_hash_fn /// object of the container object. template cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch) : base_type(h, e, ch) { this->copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// r_eq_fn will be copied by the eq_fn object of the container /// object, r_comb_hash_fn will be copied by the comb_hash_fn /// object of the container object, and r_resize_policy will be /// copied by the resize_policy object of the container object. template cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch, const resize_policy& rp) : base_type(h, e, ch, rp) { this->copy_from_range(first, last); } cc_hash_table(const cc_hash_table& other) : base_type((const base_type&)other) { } virtual ~cc_hash_table() { } cc_hash_table& operator=(const cc_hash_table& other) { if (this != &other) { cc_hash_table tmp(other); swap(tmp); } return *this; } void swap(cc_hash_table& other) { base_type::swap(other); } }; #undef PB_DS_CC_HASH_BASE #define PB_DS_GP_HASH_BASE \ basic_hash_table::type, _Alloc> /** * A general-probing hash-based associative container. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Hash_Fn Hashing functor. * @tparam Eq_Fn Equal functor. * @tparam Comb_Probe_Fn Combining probe functor. * If Hash_Fn is not null_type, then this * is the ranged-probe functor; otherwise, * this is the range-hashing functor. * XXX See Design::Hash-Based Containers::Hash Policies. * @tparam Probe_Fn Probe functor. * @tparam Resize_Policy Resizes hash. * @tparam Store_Hash Indicates whether the hash value * will be stored along with each key. * If Hash_Fn is null_type, then the * container will not compile if this * value is true * @tparam _Alloc Allocator type. * * Base tag choices are: gp_hash_tag. * * Base is basic_hash_table. */ template::type, typename Eq_Fn = typename detail::default_eq_fn::type, typename Comb_Probe_Fn = detail::default_comb_hash_fn::type, typename Probe_Fn = typename detail::default_probe_fn::type, typename Resize_Policy = typename detail::default_resize_policy::type, bool Store_Hash = detail::default_store_hash, typename _Alloc = std::allocator > class gp_hash_table : public PB_DS_GP_HASH_BASE { private: typedef PB_DS_GP_HASH_BASE base_type; public: typedef gp_hash_tag container_category; typedef Hash_Fn hash_fn; typedef Eq_Fn eq_fn; typedef Comb_Probe_Fn comb_probe_fn; typedef Probe_Fn probe_fn; typedef Resize_Policy resize_policy; /// Default constructor. gp_hash_table() { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object. gp_hash_table(const hash_fn& h) : base_type(h) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, and /// r_eq_fn will be copied by the eq_fn object of the container /// object. gp_hash_table(const hash_fn& h, const eq_fn& e) : base_type(h, e) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, r_eq_fn /// will be copied by the eq_fn object of the container object, /// and r_comb_probe_fn will be copied by the comb_probe_fn object /// of the container object. gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp) : base_type(h, e, cp) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, r_eq_fn /// will be copied by the eq_fn object of the container object, /// r_comb_probe_fn will be copied by the comb_probe_fn object of /// the container object, and r_probe_fn will be copied by the /// probe_fn object of the container object. gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, const probe_fn& p) : base_type(h, e, cp, p) { } /// Constructor taking some policy objects. r_hash_fn will be /// copied by the hash_fn object of the container object, r_eq_fn /// will be copied by the eq_fn object of the container object, /// r_comb_probe_fn will be copied by the comb_probe_fn object of /// the container object, r_probe_fn will be copied by the /// probe_fn object of the container object, and r_resize_policy /// will be copied by the Resize_Policy object of the container /// object. gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, const probe_fn& p, const resize_policy& rp) : base_type(h, e, cp, p, rp) { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template gp_hash_table(It first, It last) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object. template gp_hash_table(It first, It last, const hash_fn& h) : base_type(h) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// and r_eq_fn will be copied by the eq_fn object of the /// container object. template gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e) : base_type(h, e) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// r_eq_fn will be copied by the eq_fn object of the container /// object, and r_comb_probe_fn will be copied by the /// comb_probe_fn object of the container object. template gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp) : base_type(h, e, cp) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// r_eq_fn will be copied by the eq_fn object of the container /// object, r_comb_probe_fn will be copied by the comb_probe_fn /// object of the container object, and r_probe_fn will be copied /// by the probe_fn object of the container object. template gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, const probe_fn& p) : base_type(h, e, cp, p) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. r_hash_fn /// will be copied by the hash_fn object of the container object, /// r_eq_fn will be copied by the eq_fn object of the container /// object, r_comb_probe_fn will be copied by the comb_probe_fn /// object of the container object, r_probe_fn will be copied by /// the probe_fn object of the container object, and /// r_resize_policy will be copied by the resize_policy object of /// the container object. template gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, const probe_fn& p, const resize_policy& rp) : base_type(h, e, cp, p, rp) { base_type::copy_from_range(first, last); } gp_hash_table(const gp_hash_table& other) : base_type((const base_type&)other) { } virtual ~gp_hash_table() { } gp_hash_table& operator=(const gp_hash_table& other) { if (this != &other) { gp_hash_table tmp(other); swap(tmp); } return *this; } void swap(gp_hash_table& other) { base_type::swap(other); } }; //@} hash-based #undef PB_DS_GP_HASH_BASE /** * @defgroup branch-based Branch-Based * @ingroup containers-pbds * @{ */ #define PB_DS_BRANCH_BASE \ detail::container_base_dispatch::type /** * @defgroup branch-detail Base and Policy Classes * @ingroup branch-based */ /** * A branched, tree-like (tree, trie) container abstraction. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Tag Instantiating data structure type, * see container_tag. * @tparam Node_Update Updates nodes, restores invariants. * @tparam Policy_TL Policy typelist. * @tparam _Alloc Allocator type. * * Base is dispatched at compile time via Tag, from the following * choices: tree_tag, trie_tag, and their descendants. * * Base choices are: detail::ov_tree_map, detail::rb_tree_map, * detail::splay_tree_map, and detail::pat_trie_map. */ template class basic_branch : public PB_DS_BRANCH_BASE { private: typedef typename PB_DS_BRANCH_BASE base_type; public: typedef Node_Update node_update; virtual ~basic_branch() { } protected: basic_branch() { } basic_branch(const basic_branch& other) : base_type((const base_type&)other) { } template basic_branch(T0 t0) : base_type(t0) { } template basic_branch(T0 t0, T1 t1) : base_type(t0, t1) { } template basic_branch(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { } template basic_branch(T0 t0, T1 t1, T2 t2, T3 t3) : base_type(t0, t1, t2, t3) { } template basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) : base_type(t0, t1, t2, t3, t4) { } template basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : base_type(t0, t1, t2, t3, t4, t5) { } template basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : base_type(t0, t1, t2, t3, t4, t5, t6) { } }; #undef PB_DS_BRANCH_BASE #define PB_DS_TREE_NODE_AND_IT_TRAITS \ detail::tree_traits #define PB_DS_TREE_BASE \ basic_branch::type, _Alloc> /** * A tree-based container. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Cmp_Fn Comparison functor. * @tparam Tag Instantiating data structure type, * see container_tag. * @tparam Node_Update Updates tree internal-nodes, * restores invariants when invalidated. * XXX See design::tree-based-containers::node invariants. * @tparam _Alloc Allocator type. * * Base tag choices are: ov_tree_tag, rb_tree_tag, splay_tree_tag. * * Base is basic_branch. */ template, typename Tag = rb_tree_tag, template class Node_Update = null_node_update, typename _Alloc = std::allocator > class tree : public PB_DS_TREE_BASE { private: typedef PB_DS_TREE_BASE base_type; public: /// Comparison functor type. typedef Cmp_Fn cmp_fn; tree() { } /// Constructor taking some policy objects. r_cmp_fn will be /// copied by the Cmp_Fn object of the container object. tree(const cmp_fn& c) : base_type(c) { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template tree(It first, It last) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects The value_types between first_it and /// last_it will be inserted into the container object. r_cmp_fn /// will be copied by the cmp_fn object of the container object. template tree(It first, It last, const cmp_fn& c) : base_type(c) { base_type::copy_from_range(first, last); } tree(const tree& other) : base_type((const base_type&)other) { } virtual ~tree() { } tree& operator=(const tree& other) { if (this != &other) { tree tmp(other); swap(tmp); } return *this; } void swap(tree& other) { base_type::swap(other); } }; #undef PB_DS_TREE_BASE #undef PB_DS_TREE_NODE_AND_IT_TRAITS #define PB_DS_TRIE_NODE_AND_IT_TRAITS \ detail::trie_traits #define PB_DS_TRIE_BASE \ basic_branch::type, _Alloc> /** * A trie-based container. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam _ATraits Element access traits. * @tparam Tag Instantiating data structure type, * see container_tag. * @tparam Node_Update Updates trie internal-nodes, * restores invariants when invalidated. * XXX See design::tree-based-containers::node invariants. * @tparam _Alloc Allocator type. * * Base tag choice is pat_trie_tag. * * Base is basic_branch. */ template::type, typename Tag = pat_trie_tag, template class Node_Update = null_node_update, typename _Alloc = std::allocator > class trie : public PB_DS_TRIE_BASE { private: typedef PB_DS_TRIE_BASE base_type; public: /// Element access traits type. typedef _ATraits access_traits; trie() { } /// Constructor taking some policy objects. r_access_traits will /// be copied by the _ATraits object of the container object. trie(const access_traits& t) : base_type(t) { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template trie(It first, It last) { base_type::copy_from_range(first, last); } /// Constructor taking __iterators to a range of value_types and /// some policy objects. The value_types between first_it and /// last_it will be inserted into the container object. template trie(It first, It last, const access_traits& t) : base_type(t) { base_type::copy_from_range(first, last); } trie(const trie& other) : base_type((const base_type&)other) { } virtual ~trie() { } trie& operator=(const trie& other) { if (this != &other) { trie tmp(other); swap(tmp); } return *this; } void swap(trie& other) { base_type::swap(other); } }; //@} branch-based #undef PB_DS_TRIE_BASE #undef PB_DS_TRIE_NODE_AND_IT_TRAITS /** * @defgroup list-based List-Based * @ingroup containers-pbds * @{ */ #define PB_DS_LU_BASE \ detail::container_base_dispatch::type>::type /** * A list-update based associative container. * * @tparam Key Key type. * @tparam Mapped Map type. * @tparam Eq_Fn Equal functor. * @tparam Update_Policy Update policy, determines when an element * will be moved to the front of the list. * @tparam _Alloc Allocator type. * * Base is detail::lu_map. */ template::type, class Update_Policy = detail::default_update_policy::type, class _Alloc = std::allocator > class list_update : public PB_DS_LU_BASE { private: typedef typename PB_DS_LU_BASE base_type; public: typedef list_update_tag container_category; typedef Eq_Fn eq_fn; typedef Update_Policy update_policy; list_update() { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template list_update(It first, It last) { base_type::copy_from_range(first, last); } list_update(const list_update& other) : base_type((const base_type&)other) { } virtual ~list_update() { } list_update& operator=(const list_update& other) { if (this !=& other) { list_update tmp(other); swap(tmp); } return *this; } void swap(list_update& other) { base_type::swap(other); } }; //@} list-based #undef PB_DS_LU_BASE // @} group containers-pbds } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/exception.hpp000064400000005654147547540550011645 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file exception.hpp * Contains exception classes. */ #ifndef PB_DS_EXCEPTION_HPP #define PB_DS_EXCEPTION_HPP #include #include #include namespace __gnu_pbds { /** * @defgroup exceptions-pbds Exceptions * @ingroup pbds * @{ */ /// Base class for exceptions. struct container_error : public std::logic_error { container_error() : std::logic_error(__N("__gnu_pbds::container_error")) { } }; /// An entry cannot be inserted into a container object for logical /// reasons (not, e.g., if memory is unabvailable, in which case /// the allocator_type's exception will be thrown). struct insert_error : public container_error { }; /// A join cannot be performed logical reasons (i.e., the ranges of /// the two container objects being joined overlaps. struct join_error : public container_error { }; /// A container cannot be resized. struct resize_error : public container_error { }; inline void __throw_container_error() { _GLIBCXX_THROW_OR_ABORT(container_error()); } inline void __throw_insert_error() { _GLIBCXX_THROW_OR_ABORT(insert_error()); } inline void __throw_join_error() { _GLIBCXX_THROW_OR_ABORT(join_error()); } inline void __throw_resize_error() { _GLIBCXX_THROW_OR_ABORT(resize_error()); } //@} } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/tree_policy.hpp000064400000012711147547540550012155 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file tree_policy.hpp * Contains tree-related policies. */ #ifndef PB_DS_TREE_POLICY_HPP #define PB_DS_TREE_POLICY_HPP #include #include #include #include namespace __gnu_pbds { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ tree_order_statistics_node_update #define PB_DS_BRANCH_POLICY_BASE \ detail::branch_policy /// Functor updating ranks of entrees. template class tree_order_statistics_node_update : private PB_DS_BRANCH_POLICY_BASE { private: typedef PB_DS_BRANCH_POLICY_BASE base_type; public: typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; typedef typename base_type::key_type key_type; typedef typename base_type::key_const_reference key_const_reference; typedef size_type metadata_type; typedef Node_CItr node_const_iterator; typedef Node_Itr node_iterator; typedef typename node_const_iterator::value_type const_iterator; typedef typename node_iterator::value_type iterator; /// Finds an entry by __order. Returns a const_iterator to the /// entry with the __order order, or a const_iterator to the /// container object's end if order is at least the size of the /// container object. inline const_iterator find_by_order(size_type) const; /// Finds an entry by __order. Returns an iterator to the entry /// with the __order order, or an iterator to the container /// object's end if order is at least the size of the container /// object. inline iterator find_by_order(size_type); /// Returns the order of a key within a sequence. For exapmle, if /// r_key is the smallest key, this method will return 0; if r_key /// is a key between the smallest and next key, this method will /// return 1; if r_key is a key larger than the largest key, this /// method will return the size of r_c. inline size_type order_of_key(key_const_reference) const; private: /// Const reference to the container's value-type. typedef typename base_type::const_reference const_reference; /// Const pointer to the container's value-type. typedef typename base_type::const_pointer const_pointer; typedef typename _Alloc::template rebind::other __rebind_m; /// Const metadata reference. typedef typename __rebind_m::const_reference metadata_const_reference; /// Metadata reference. typedef typename __rebind_m::reference metadata_reference; /// Returns the node_const_iterator associated with the tree's root node. virtual node_const_iterator node_begin() const = 0; /// Returns the node_iterator associated with the tree's root node. virtual node_iterator node_begin() = 0; /// Returns the node_const_iterator associated with a just-after leaf node. virtual node_const_iterator node_end() const = 0; /// Returns the node_iterator associated with a just-after leaf node. virtual node_iterator node_end() = 0; /// Access to the cmp_fn object. virtual cmp_fn& get_cmp_fn() = 0; protected: /// Updates the rank of a node through a node_iterator node_it; /// end_nd_it is the end node iterator. inline void operator()(node_iterator, node_const_iterator) const; virtual ~tree_order_statistics_node_update(); }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_BRANCH_POLICY_BASE } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/trie_policy.hpp000064400000027701147547540550012166 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy.hpp * Contains trie-related policies. */ #ifndef PB_DS_TRIE_POLICY_HPP #define PB_DS_TRIE_POLICY_HPP #include #include #include #include namespace __gnu_pbds { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ trie_string_access_traits /** * Element access traits for string types. * * @tparam String String type. * @tparam Min_E_Val Minimal element value. * @tparam Max_E_Val Maximum element value. * @tparam Reverse Reverse iteration should be used. * Default: false. * @tparam _Alloc Allocator type. */ template::__min, typename String::value_type Max_E_Val = detail::__numeric_traits::__max, bool Reverse = false, typename _Alloc = std::allocator > struct trie_string_access_traits { public: typedef typename _Alloc::size_type size_type; typedef String key_type; typedef typename _Alloc::template rebind __rebind_k; typedef typename __rebind_k::other::const_reference key_const_reference; enum { reverse = Reverse }; /// Element const iterator type. typedef typename detail::__conditional_type::__type const_iterator; /// Element type. typedef typename std::iterator_traits::value_type e_type; enum { min_e_val = Min_E_Val, max_e_val = Max_E_Val, max_size = max_e_val - min_e_val + 1 }; PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2); /// Returns a const_iterator to the first element of /// key_const_reference agumnet. inline static const_iterator begin(key_const_reference); /// Returns a const_iterator to the after-last element of /// key_const_reference argument. inline static const_iterator end(key_const_reference); /// Maps an element to a position. inline static size_type e_pos(e_type e); private: inline static const_iterator begin_imp(key_const_reference, detail::false_type); inline static const_iterator begin_imp(key_const_reference, detail::true_type); inline static const_iterator end_imp(key_const_reference, detail::false_type); inline static const_iterator end_imp(key_const_reference, detail::true_type); static detail::integral_constant s_rev_ind; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ trie_prefix_search_node_update #define PB_DS_TRIE_POLICY_BASE \ detail::trie_policy_base /// A node updator that allows tries to be searched for the range of /// values that match a certain prefix. template class trie_prefix_search_node_update : private PB_DS_TRIE_POLICY_BASE { private: typedef PB_DS_TRIE_POLICY_BASE base_type; public: typedef typename base_type::key_type key_type; typedef typename base_type::key_const_reference key_const_reference; /// Element access traits. typedef _ATraits access_traits; /// Const element iterator. typedef typename access_traits::const_iterator a_const_iterator; /// _Alloc type. typedef _Alloc allocator_type; /// Size type. typedef typename allocator_type::size_type size_type; typedef null_type metadata_type; typedef Node_Itr node_iterator; typedef Node_CItr node_const_iterator; typedef typename node_iterator::value_type iterator; typedef typename node_const_iterator::value_type const_iterator; /// Finds the const iterator range corresponding to all values /// whose prefixes match r_key. std::pair prefix_range(key_const_reference) const; /// Finds the iterator range corresponding to all values whose /// prefixes match r_key. std::pair prefix_range(key_const_reference); /// Finds the const iterator range corresponding to all values /// whose prefixes match [b, e). std::pair prefix_range(a_const_iterator, a_const_iterator) const; /// Finds the iterator range corresponding to all values whose /// prefixes match [b, e). std::pair prefix_range(a_const_iterator, a_const_iterator); protected: /// Called to update a node's metadata. inline void operator()(node_iterator node_it, node_const_iterator end_nd_it) const; private: node_iterator next_child(node_iterator, a_const_iterator, a_const_iterator, node_iterator, const access_traits&); /// Returns the const iterator associated with the just-after last element. virtual const_iterator end() const = 0; /// Returns the iterator associated with the just-after last element. virtual iterator end() = 0; /// Returns the node_const_iterator associated with the trie's root node. virtual node_const_iterator node_begin() const = 0; /// Returns the node_iterator associated with the trie's root node. virtual node_iterator node_begin() = 0; /// Returns the node_const_iterator associated with a just-after leaf node. virtual node_const_iterator node_end() const = 0; /// Returns the node_iterator associated with a just-after leaf node. virtual node_iterator node_end() = 0; /// Access to the cmp_fn object. virtual const access_traits& get_access_traits() const = 0; }; #include #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_C_DEC \ trie_order_statistics_node_update /// Functor updating ranks of entrees. template class trie_order_statistics_node_update : private PB_DS_TRIE_POLICY_BASE { private: typedef PB_DS_TRIE_POLICY_BASE base_type; public: typedef _ATraits access_traits; typedef typename access_traits::const_iterator a_const_iterator; typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; typedef typename base_type::key_type key_type; typedef typename base_type::key_const_reference key_const_reference; typedef size_type metadata_type; typedef Node_CItr node_const_iterator; typedef Node_Itr node_iterator; typedef typename node_const_iterator::value_type const_iterator; typedef typename node_iterator::value_type iterator; /// Finds an entry by __order. Returns a const_iterator to the /// entry with the __order order, or a const_iterator to the /// container object's end if order is at least the size of the /// container object. inline const_iterator find_by_order(size_type) const; /// Finds an entry by __order. Returns an iterator to the entry /// with the __order order, or an iterator to the container /// object's end if order is at least the size of the container /// object. inline iterator find_by_order(size_type); /// Returns the order of a key within a sequence. For exapmle, if /// r_key is the smallest key, this method will return 0; if r_key /// is a key between the smallest and next key, this method will /// return 1; if r_key is a key larger than the largest key, this /// method will return the size of r_c. inline size_type order_of_key(key_const_reference) const; /// Returns the order of a prefix within a sequence. For exapmle, /// if [b, e] is the smallest prefix, this method will return 0; if /// r_key is a key between the smallest and next key, this method /// will return 1; if r_key is a key larger than the largest key, /// this method will return the size of r_c. inline size_type order_of_prefix(a_const_iterator, a_const_iterator) const; protected: /// Updates the rank of a node through a node_iterator node_it; /// end_nd_it is the end node iterator. inline void operator()(node_iterator, node_const_iterator) const; private: typedef typename base_type::const_reference const_reference; typedef typename base_type::const_pointer const_pointer; typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef typename __rebind_ma::const_reference metadata_const_reference; typedef typename __rebind_ma::reference metadata_reference; /// Returns true if the container is empty. virtual bool empty() const = 0; /// Returns the iterator associated with the trie's first element. virtual iterator begin() = 0; /// Returns the iterator associated with the trie's /// just-after-last element. virtual iterator end() = 0; /// Returns the node_const_iterator associated with the trie's root node. virtual node_const_iterator node_begin() const = 0; /// Returns the node_iterator associated with the trie's root node. virtual node_iterator node_begin() = 0; /// Returns the node_const_iterator associated with a just-after /// leaf node. virtual node_const_iterator node_end() const = 0; /// Returns the node_iterator associated with a just-after leaf node. virtual node_iterator node_end() = 0; /// Access to the cmp_fn object. virtual access_traits& get_access_traits() = 0; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_TRIE_POLICY_BASE } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp000064400000004473147547540550017453 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/trace_fn_imps.hpp * Contains implementations of cc_ht_map_'s trace-mode functions. */ #ifdef PB_DS_HT_MAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << static_cast(m_num_e) << " " << static_cast(m_num_used_e) << std::endl; for (size_type i = 0; i < m_num_e; ++i) { std::cerr << static_cast(i) << " "; trace_list(m_entries[i]); std::cerr << std::endl; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_list(const_entry_pointer p_l) const { size_type iterated_num_used_e = 0; while (p_l != 0) { std::cerr << PB_DS_V2F(p_l->m_value) << " "; p_l = p_l->m_p_next; } } #endif 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp000064400000006231147547540550021665 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/erase_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s erase related functions, * when the hash value is stored. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(key_const_reference r_key, const comp_hash& r_pos_hash_pair) { PB_DS_ASSERT_VALID((*this)) entry_pointer p_e = m_entries[r_pos_hash_pair.first]; resize_base::notify_erase_search_start(); if (p_e == 0) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, r_key, r_pos_hash_pair.second)) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(m_entries[r_pos_hash_pair.first]); do_resize_if_needed_no_throw(); PB_DS_ASSERT_VALID((*this)) return true; } while (true) { entry_pointer p_next_e = p_e->m_p_next; if (p_next_e == 0) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), p_next_e->m_hash, r_key, r_pos_hash_pair.second)) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(p_e->m_p_next); do_resize_if_needed_no_throw(); PB_DS_ASSERT_VALID((*this)) return true; } resize_base::notify_erase_search_collision(); p_e = p_next_e; } } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp000064400000004342147547540550022070 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/resize_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s resize related functions, when the * hash value is stored. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, true_type) { const comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash); entry_pointer const p_next_e = p_e->m_p_next; p_e->m_p_next = a_p_entries_resized[pos_hash_pair.first]; a_p_entries_resized[pos_hash_pair.first] = p_e; return p_next_e; } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp000064400000005205147547540550017435 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/debug_fn_imps.hpp * Contains implementations of cc_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { debug_base::check_size(m_num_used_e, __file, __line); assert_entry_pointer_array_valid(m_entries, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries, const char* __file, int __line) const { size_type iterated_num_used_e = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { entry_pointer p_e = a_p_entries[pos]; while (p_e != 0) { ++iterated_num_used_e; assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator, __file, __line); p_e = p_e->m_p_next; } } PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #include #include #endif 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp000064400000003720147547540550022350 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_entry_pointer_valid(const entry_pointer p, false_type, const char* __file, int __line) const { debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); } #endif 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp000064400000003550147547540550017654 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/insert_fn_imps.hpp * Contains implementations of cc_ht_map_'s insert related functions. */ #include #include 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp000064400000004402147547540550025427 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(const_reference r_val, size_type pos, true_type) { // Following lines might throw an exception. entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator); // At this point no exceptions can be thrown. p->m_p_next = m_entries[pos]; p->m_hash = ranged_hash_fn_base::operator()((key_const_reference)(PB_DS_V2F(p->m_value))).second; m_entries[pos] = p; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);) } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp000064400000005162147547540550022074 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/insert_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s insert related functions, * when the hash value is stored. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, true_type) { PB_DS_ASSERT_VALID((*this)) key_const_reference key = PB_DS_V2F(r_val); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key); entry_pointer p_e = m_entries[pos_hash_pair.first]; resize_base::notify_insert_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, key, pos_hash_pair.second)) { resize_base::notify_insert_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); if (p_e != 0) { PB_DS_CHECK_KEY_EXISTS(key) return std::make_pair(&p_e->m_value, false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp000064400000005315147547540550017130 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/cmp_fn_imps.hpp * Contains implementations of cc_ht_map_'s entire container comparison related * functions. */ PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: operator==(const Other_HT_Map_Type& other) const { return cmp_with_other(other); } PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: cmp_with_other(const Other_Map_Type& other) const { if (size() != other.size()) return false; for (typename Other_Map_Type::const_iterator it = other.begin(); it != other.end(); ++it) { key_const_reference r_key = key_const_reference(PB_DS_V2F(*it)); mapped_const_pointer p_mapped_value = const_cast(*this). find_key_pointer(r_key, traits_base::m_store_extra_indicator); if (p_mapped_value == 0) return false; #ifdef PB_DS_DATA_TRUE_INDICATOR if (p_mapped_value->second != it->second) return false; #endif } return true; } PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: operator!=(const Other_HT_Map_Type& other) const { return !operator==(other); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp000064400000005150147547540550020362 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/iterators_fn_imps.hpp * Contains implementations of cc_ht_map_'s iterators related functions, e.g., * begin(). */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC::s_end_it; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC::s_const_end_it; PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { pointer p_value; std::pair pos; get_start_it_state(p_value, pos); return iterator(p_value, pos, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return s_end_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { pointer p_value; std::pair pos; get_start_it_state(p_value, pos); return const_iterator(p_value, pos, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return s_const_end_it; } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp000064400000003363147547540550021511 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/find_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s find related functions, * when the hash value is stored. */ 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp000064400000006255147547540550017454 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/erase_fn_imps.hpp * Contains implementations of cc_ht_map_'s erase related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: erase_entry_pointer(entry_pointer& r_p_e) { _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(r_p_e->m_value))); entry_pointer p_e = r_p_e; r_p_e = r_p_e->m_p_next; rels_entry(p_e); _GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0); resize_base::notify_erased(--m_num_used_e); } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { size_type num_ersd = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { while (m_entries[pos] != 0 && pred(m_entries[pos]->m_value)) { ++num_ersd; entry_pointer p_next_e = m_entries[pos]->m_p_next; erase_entry_pointer(m_entries[pos]); m_entries[pos] = p_next_e; } entry_pointer p_e = m_entries[pos]; while (p_e != 0 && p_e->m_p_next != 0) { if (pred(p_e->m_p_next->m_value)) { ++num_ersd; erase_entry_pointer(p_e->m_p_next); } else p_e = p_e->m_p_next; } } do_resize_if_needed_no_throw(); return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { for (size_type pos = 0; pos < m_num_e; ++pos) while (m_entries[pos] != 0) erase_entry_pointer(m_entries[pos]); do_resize_if_needed_no_throw(); resize_base::notify_cleared(); } #include #include 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp000064400000004661147547540550021174 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/policy_access_fn_imps.hpp * Contains implementations of cc_ht_map_'s policy access * functions. */ PB_DS_CLASS_T_DEC Hash_Fn& PB_DS_CLASS_C_DEC:: get_hash_fn() { return *this; } PB_DS_CLASS_T_DEC const Hash_Fn& PB_DS_CLASS_C_DEC:: get_hash_fn() const { return *this; } PB_DS_CLASS_T_DEC Eq_Fn& PB_DS_CLASS_C_DEC:: get_eq_fn() { return *this; } PB_DS_CLASS_T_DEC const Eq_Fn& PB_DS_CLASS_C_DEC:: get_eq_fn() const { return *this; } PB_DS_CLASS_T_DEC Comb_Hash_Fn& PB_DS_CLASS_C_DEC:: get_comb_hash_fn() { return *this; } PB_DS_CLASS_T_DEC const Comb_Hash_Fn& PB_DS_CLASS_C_DEC:: get_comb_hash_fn() const { return *this; } PB_DS_CLASS_T_DEC Resize_Policy& PB_DS_CLASS_C_DEC:: get_resize_policy() { return *this; } PB_DS_CLASS_T_DEC const Resize_Policy& PB_DS_CLASS_C_DEC:: get_resize_policy() const { return *this; } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp000064400000007736147547540550017663 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/resize_fn_imps.hpp * Contains implementations of cc_ht_map_'s resize related functions. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: do_resize_if_needed() { if (!resize_base::is_resize_needed()) return false; resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e)); return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: do_resize(size_type len) { resize_imp(resize_base::get_nearest_larger_size(len)); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: do_resize_if_needed_no_throw() { if (!resize_base::is_resize_needed()) return; __try { resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e)); } __catch(...) { } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: resize_imp(size_type new_size) { PB_DS_ASSERT_VALID((*this)) if (new_size == m_num_e) return; const size_type old_size = m_num_e; entry_pointer_array a_p_entries_resized; // Following line might throw an exception. ranged_hash_fn_base::notify_resized(new_size); __try { // Following line might throw an exception. a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size); m_num_e = new_size; } __catch(...) { ranged_hash_fn_base::notify_resized(old_size); __throw_exception_again; } // At this point no exceptions can be thrown. resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size); Resize_Policy::notify_resized(new_size); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size) { std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e, entry_pointer(0)); for (size_type pos = 0; pos < old_size; ++pos) { entry_pointer p_e = m_entries[pos]; while (p_e != 0) p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, traits_base::m_store_extra_indicator); } m_num_e = new_size; _GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized, __FILE__, __LINE__);) s_entry_pointer_allocator.deallocate(m_entries, old_size); m_entries = a_p_entries_resized; PB_DS_ASSERT_VALID((*this)) } #include #include 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp000064400000013237147547540550023216 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/constructor_destructor_fn_imps.hpp * Contains implementations of cc_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_allocator PB_DS_CLASS_C_DEC::s_entry_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_pointer_allocator PB_DS_CLASS_C_DEC::s_entry_pointer_allocator; PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME() : ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn) : ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0); Resize_Policy::notify_cleared(); ranged_hash_fn_base::notify_resized(m_num_e); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn, const Resize_Policy& r_resize_policy) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), Resize_Policy(r_resize_policy), ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_HASH_EQ_FN_C_DEC(other), resize_base(other), ranged_hash_fn_base(other), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) __try { copy_from_range(other.begin(), other.end()); } __catch(...) { deallocate_all(); __throw_exception_again; } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_CC_HASH_NAME() { deallocate_all(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) std::swap(m_entries, other.m_entries); std::swap(m_num_e, other.m_num_e); std::swap(m_num_used_e, other.m_num_used_e); ranged_hash_fn_base::swap(other); hash_eq_fn_base::swap(other); resize_base::swap(other); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: deallocate_all() { clear(); s_entry_pointer_allocator.deallocate(m_entries, m_num_e); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { std::fill(m_entries, m_entries + m_num_e, entry_pointer(0)); Resize_Policy::notify_resized(m_num_e); Resize_Policy::notify_cleared(); ranged_hash_fn_base::notify_resized(m_num_e); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp000064400000005472147547540550022420 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp * Contains a conditional key destructor, used for exception handling. */ namespace __gnu_pbds { namespace detail { /// Conditional dey destructor, cc_hash. template class cond_dealtor { public: typedef typename HT_Map::entry entry; typedef typename HT_Map::entry_allocator entry_allocator; typedef typename HT_Map::key_type key_type; cond_dealtor(entry_allocator* p_a, entry* p_e) : m_p_a(p_a), m_p_e(p_e), m_key_destruct(false), m_no_action_destructor(false) { } inline ~cond_dealtor(); void set_key_destruct() { m_key_destruct = true; } void set_no_action_destructor() { m_no_action_destructor = true; } protected: entry_allocator* const m_p_a; entry* const m_p_e; bool m_key_destruct; bool m_no_action_destructor; }; template inline cond_dealtor:: ~cond_dealtor() { if (m_no_action_destructor) return; if (m_key_destruct) m_p_e->m_value.first.~key_type(); m_p_a->deallocate(m_p_e, 1); } } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp000064400000005072147547540550022570 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s insert related functions, * when the hash value is not stored. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, false_type) { PB_DS_ASSERT_VALID((*this)) key_const_reference r_key = PB_DS_V2F(r_val); const size_type pos = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos]; resize_base::notify_insert_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_insert_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); if (p_e != 0) { PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&p_e->m_value, false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos), true); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp000064400000004302147547540550022560 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s resize related functions, when the * hash value is not stored. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, false_type) { const size_type hash_pos = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value)); entry_pointer const p_next_e = p_e->m_p_next; p_e->m_p_next = a_p_entries_resized[hash_pos]; a_p_entries_resized[hash_pos] = p_e; return p_next_e; } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp000064400000046761147547540550016724 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/cc_ht_map_.hpp * Contains an implementation class for cc_ht_map_. */ #include #include #include #include #include #include #include #include #ifdef _GLIBCXX_DEBUG #include #endif #ifdef PB_DS_HT_MAP_TRACE_ #include #endif #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CC_HASH_NAME cc_ht_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_CC_HASH_NAME cc_ht_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_CC_HASH_NAME #define PB_DS_HASH_EQ_FN_C_DEC \ hash_eq_fn #define PB_DS_RANGED_HASH_FN_C_DEC \ ranged_hash_fn #define PB_DS_CC_HASH_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base::other::const_reference> #endif /** * A collision-chaining hash-based container. * * * @ingroup hash-detail * * @tparam Key Key type. * * @tparam Mapped Map type. * * @tparam Hash_Fn Hashing functor. * Default is __gnu_cxx::hash. * * @tparam Eq_Fn Equal functor. * Default std::equal_to * * @tparam _Alloc Allocator type. * * @tparam Store_Hash If key type stores extra metadata. * Defaults to false. * * @tparam Comb_Hash_Fn Combining hash functor. * If Hash_Fn is not null_type, then this * is the ranged-hash functor; otherwise, * this is the range-hashing functor. * XXX(See Design::Hash-Based Containers::Hash Policies.) * Default direct_mask_range_hashing. * * @tparam Resize_Policy Resizes hash. * Defaults to hash_standard_resize_policy, * using hash_exponential_size_policy and * hash_load_check_resize_trigger. * * * Bases are: detail::hash_eq_fn, Resize_Policy, detail::ranged_hash_fn, * detail::types_traits. (Optional: detail::debug_map_base.) */ template class PB_DS_CC_HASH_NAME: #ifdef _GLIBCXX_DEBUG protected PB_DS_DEBUG_MAP_BASE_C_DEC, #endif public PB_DS_HASH_EQ_FN_C_DEC, public Resize_Policy, public PB_DS_RANGED_HASH_FN_C_DEC, public PB_DS_CC_HASH_TRAITS_BASE { private: typedef PB_DS_CC_HASH_TRAITS_BASE traits_base; typedef typename traits_base::comp_hash comp_hash; typedef typename traits_base::value_type value_type_; typedef typename traits_base::pointer pointer_; typedef typename traits_base::const_pointer const_pointer_; typedef typename traits_base::reference reference_; typedef typename traits_base::const_reference const_reference_; struct entry : public traits_base::stored_data_type { typename _Alloc::template rebind::other::pointer m_p_next; }; typedef cond_dealtor cond_dealtor_t; typedef typename _Alloc::template rebind::other entry_allocator; typedef typename entry_allocator::pointer entry_pointer; typedef typename entry_allocator::const_pointer const_entry_pointer; typedef typename entry_allocator::reference entry_reference; typedef typename entry_allocator::const_reference const_entry_reference; typedef typename _Alloc::template rebind::other entry_pointer_allocator; typedef typename entry_pointer_allocator::pointer entry_pointer_array; typedef PB_DS_RANGED_HASH_FN_C_DEC ranged_hash_fn_base; typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base; typedef Resize_Policy resize_base; #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif #define PB_DS_GEN_POS std::pair #include #include #include #include #undef PB_DS_GEN_POS public: typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Hash_Fn hash_fn; typedef Eq_Fn eq_fn; typedef Comb_Hash_Fn comb_hash_fn; typedef Resize_Policy resize_policy; /// Value stores hash, true or false. enum { store_hash = Store_Hash }; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef point_iterator_ point_iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef point_const_iterator_ point_iterator; #endif typedef point_const_iterator_ point_const_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef iterator_ iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_iterator_ iterator; #endif typedef const_iterator_ const_iterator; PB_DS_CC_HASH_NAME(); PB_DS_CC_HASH_NAME(const Hash_Fn&); PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&); PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&); PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&, const Resize_Policy&); PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC&); virtual ~PB_DS_CC_HASH_NAME(); void swap(PB_DS_CLASS_C_DEC&); template void copy_from_range(It, It); void initialize(); inline size_type size() const; inline size_type max_size() const; /// True if size() == 0. inline bool empty() const; /// Return current hash_fn. Hash_Fn& get_hash_fn(); /// Return current const hash_fn. const Hash_Fn& get_hash_fn() const; /// Return current eq_fn. Eq_Fn& get_eq_fn(); /// Return current const eq_fn. const Eq_Fn& get_eq_fn() const; /// Return current comb_hash_fn. Comb_Hash_Fn& get_comb_hash_fn(); /// Return current const comb_hash_fn. const Comb_Hash_Fn& get_comb_hash_fn() const; /// Return current resize_policy. Resize_Policy& get_resize_policy(); /// Return current const resize_policy. const Resize_Policy& get_resize_policy() const; inline std::pair insert(const_reference r_val) { return insert_imp(r_val, traits_base::m_store_extra_indicator); } inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR return (subscript_imp(r_key, traits_base::m_store_extra_indicator)); #else insert(r_key); return traits_base::s_null_type; #endif } inline point_iterator find(key_const_reference); inline point_const_iterator find(key_const_reference) const; inline point_iterator find_end(); inline point_const_iterator find_end() const; inline bool erase(key_const_reference); template inline size_type erase_if(Pred); void clear(); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_HT_MAP_TRACE_ void trace() const; #endif private: void deallocate_all(); inline bool do_resize_if_needed(); inline void do_resize_if_needed_no_throw(); void resize_imp(size_type); void do_resize(size_type); void resize_imp_no_exceptions(size_type, entry_pointer_array, size_type); inline entry_pointer resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, false_type); inline entry_pointer resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, true_type); void deallocate_links_in_list(entry_pointer); inline entry_pointer get_entry(const_reference, false_type); inline entry_pointer get_entry(const_reference, true_type); inline void rels_entry(entry_pointer); #ifdef PB_DS_DATA_TRUE_INDICATOR inline mapped_reference subscript_imp(key_const_reference r_key, false_type) { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) const size_type pos = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos]; resize_base::notify_insert_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(p_e->m_value.first, r_key)) { resize_base::notify_insert_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); if (p_e != 0) { PB_DS_CHECK_KEY_EXISTS(r_key) return (p_e->m_value.second); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return insert_new_imp(value_type(r_key, mapped_type()), pos)->second; } inline mapped_reference subscript_imp(key_const_reference r_key, true_type) { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos_hash_pair.first]; resize_base::notify_insert_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_insert_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); if (p_e != 0) { PB_DS_CHECK_KEY_EXISTS(r_key) return p_e->m_value.second; } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return insert_new_imp(value_type(r_key, mapped_type()), pos_hash_pair)->second; } #endif inline std::pair insert_imp(const_reference, false_type); inline std::pair insert_imp(const_reference, true_type); inline pointer insert_new_imp(const_reference r_val, size_type pos) { if (do_resize_if_needed()) pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val)); // Following lines might throw an exception. entry_pointer p_e = get_entry(r_val, traits_base::m_no_throw_copies_indicator); // At this point no exceptions can be thrown. p_e->m_p_next = m_entries[pos]; m_entries[pos] = p_e; resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } inline pointer insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) { // Following lines might throw an exception. if (do_resize_if_needed()) r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val)); entry_pointer p_e = get_entry(r_val, traits_base::m_no_throw_copies_indicator); // At this point no exceptions can be thrown. p_e->m_hash = r_pos_hash_pair.second; p_e->m_p_next = m_entries[r_pos_hash_pair.first]; m_entries[r_pos_hash_pair.first] = p_e; resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } inline pointer find_key_pointer(key_const_reference r_key, false_type) { entry_pointer p_e = m_entries[ranged_hash_fn_base::operator()(r_key)]; resize_base::notify_find_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_find_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_find_search_end(); #ifdef _GLIBCXX_DEBUG if (p_e == 0) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) else PB_DS_CHECK_KEY_EXISTS(r_key) #endif return &p_e->m_value; } inline pointer find_key_pointer(key_const_reference r_key, true_type) { comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos_hash_pair.first]; resize_base::notify_find_search_start(); while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_find_search_collision(); p_e = p_e->m_p_next; } resize_base::notify_find_search_end(); #ifdef _GLIBCXX_DEBUG if (p_e == 0) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) else PB_DS_CHECK_KEY_EXISTS(r_key) #endif return &p_e->m_value; } inline bool erase_in_pos_imp(key_const_reference, size_type); inline bool erase_in_pos_imp(key_const_reference, const comp_hash&); inline void erase_entry_pointer(entry_pointer&); #ifdef PB_DS_DATA_TRUE_INDICATOR void inc_it_state(pointer& r_p_value, std::pair& r_pos) const { inc_it_state((mapped_const_pointer& )r_p_value, r_pos); } #endif void inc_it_state(const_pointer& r_p_value, std::pair& r_pos) const { _GLIBCXX_DEBUG_ASSERT(r_p_value != 0); r_pos.first = r_pos.first->m_p_next; if (r_pos.first != 0) { r_p_value = &r_pos.first->m_value; return; } for (++r_pos.second; r_pos.second < m_num_e; ++r_pos.second) if (m_entries[r_pos.second] != 0) { r_pos.first = m_entries[r_pos.second]; r_p_value = &r_pos.first->m_value; return; } r_p_value = 0; } void get_start_it_state(pointer& r_p_value, std::pair& r_pos) const { for (r_pos.second = 0; r_pos.second < m_num_e; ++r_pos.second) if (m_entries[r_pos.second] != 0) { r_pos.first = m_entries[r_pos.second]; r_p_value = &r_pos.first->m_value; return; } r_p_value = 0; } #ifdef _GLIBCXX_DEBUG void assert_entry_pointer_array_valid(const entry_pointer_array, const char*, int) const; void assert_entry_pointer_valid(const entry_pointer, true_type, const char*, int) const; void assert_entry_pointer_valid(const entry_pointer, false_type, const char*, int) const; #endif #ifdef PB_DS_HT_MAP_TRACE_ void trace_list(const_entry_pointer) const; #endif private: #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; #endif friend class const_iterator_; static entry_allocator s_entry_allocator; static entry_pointer_allocator s_entry_pointer_allocator; static iterator s_end_it; static const_iterator s_const_end_it; static point_iterator s_find_end_it; static point_const_iterator s_const_find_end_it; size_type m_num_e; size_type m_num_used_e; entry_pointer_array m_entries; enum { store_hash_ok = !Store_Hash || !is_same::value }; PB_DS_STATIC_ASSERT(sth, store_hash_ok); }; #include #include #include #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC #undef PB_DS_RANGED_HASH_FN_C_DEC #undef PB_DS_CC_HASH_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC #undef PB_DS_CC_HASH_NAME } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp000064400000004665147547540550017300 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/find_fn_imps.hpp * Contains implementations of cc_ht_map_'s find related functions. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) return find_key_pointer(r_key, traits_base::m_store_extra_indicator); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { PB_DS_ASSERT_VALID((*this)) return const_cast(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find_end() { return 0; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find_end() const { return 0; } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp000064400000005612147547540550020545 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/entry_list_fn_imps.hpp * Contains implementations of cc_ht_map_'s entry-list related functions. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: deallocate_links_in_list(entry_pointer p_e) { while (p_e != 0) { entry_pointer p_dealloc_e = p_e; p_e = p_e->m_p_next; s_entry_allocator.deallocate(p_dealloc_e, 1); } } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: get_entry(const_reference r_val, true_type) { // Following line might throw an exception. entry_pointer p_e = s_entry_allocator.allocate(1); // Following lines* cannot* throw an exception. new (&p_e->m_value) value_type(r_val); return p_e; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: get_entry(const_reference r_val, false_type) { // Following line might throw an exception. entry_pointer p_e = s_entry_allocator.allocate(1); cond_dealtor_t cond(p_e); // Following lines might throw an exception. new (&p_e->m_value) value_type(r_val); cond.set_no_action(); return p_e; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rels_entry(entry_pointer p_e) { // The following lines cannot throw exceptions (unless if key-data dtors do). p_e->m_value.~value_type(); s_entry_allocator.deallocate(p_e, 1); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp000064400000006047147547540550017307 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/info_fn_imps.hpp * Contains implementations of cc_ht_map_'s entire container info related * functions. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return m_num_used_e; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return m_entry_allocator.max_size(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (size() == 0); } PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: operator==(const Other_HT_Map_Type& other) const { return cmp_with_other(other); } PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: cmp_with_other(const Other_Map_Type& other) const { if (size() != other.size()) return false; for (typename Other_Map_Type::const_iterator it = other.begin(); it != other.end(); ++it) { key_const_reference r_key =(key_const_reference)PB_DS_V2F(*it); mapped_const_pointer p_mapped_value = const_cast(*this). find_key_pointer(r_key, traits_base::m_store_extra_indicator); if (p_mapped_value == 0) return false; #ifdef PB_DS_DATA_TRUE_INDICATOR if (p_mapped_value->second != it->second) return false; #endif } return true; } PB_DS_CLASS_T_DEC template bool PB_DS_CLASS_C_DEC:: operator!=(const Other_HT_Map_Type& other) const { return !operator==(other); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp000064400000004262147547540550026127 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(mapped_const_reference r_val, size_type pos, false_type) { // Following lines might throw an exception. entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator); // At this point no exceptions can be thrown. p->m_p_next = m_entries[pos]; m_entries[pos] = p; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);) } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp000064400000006300147547540550022356 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s erase related functions, * when the hash value is not stored. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key)); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(key_const_reference r_key, size_type pos) { PB_DS_ASSERT_VALID((*this)) entry_pointer p_e = m_entries[pos]; resize_base::notify_erase_search_start(); if (p_e == 0) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(m_entries[pos]); do_resize_if_needed_no_throw(); PB_DS_ASSERT_VALID((*this)) return true; } while (true) { entry_pointer p_next_e = p_e->m_p_next; if (p_next_e == 0) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key)) { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(p_e->m_p_next); do_resize_if_needed_no_throw(); PB_DS_ASSERT_VALID((*this)) return true; } resize_base::notify_erase_search_collision(); p_e = p_next_e; } } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp000064400000004075147547540550017325 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/size_fn_imps.hpp * Contains implementations of cc_ht_map_'s entire container size related * functions. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return m_num_used_e; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (size() == 0); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_entry_allocator.max_size(); } 4.8.2/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp000064400000004144147547540550021655 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_table_map_/debug_store_hash_fn_imps.hpp * Contains implementations of cc_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_entry_pointer_valid(const entry_pointer p_e, true_type, const char* __file, int __line) const { debug_base::check_key_exists(PB_DS_V2F(p_e->m_value), __file, __line); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value)); PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second); } #endif 4.8.2/ext/pb_ds/detail/cond_dealtor.hpp000064400000005244147547540550013541 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/cond_dealtor.hpp * Contains a conditional deallocator. */ #ifndef PB_DS_COND_DEALTOR_HPP #define PB_DS_COND_DEALTOR_HPP namespace __gnu_pbds { namespace detail { /// Conditional deallocate constructor argument. template class cond_dealtor { typedef typename _Alloc::template rebind __rebind_e; public: typedef typename __rebind_e::other entry_allocator; typedef typename entry_allocator::pointer entry_pointer; cond_dealtor(entry_pointer p_e) : m_p_e(p_e), m_no_action_destructor(false) { } ~cond_dealtor() { if (m_no_action_destructor) return; s_alloc.deallocate(m_p_e, 1); } void set_no_action() { m_no_action_destructor = true; } private: entry_pointer m_p_e; bool m_no_action_destructor; static entry_allocator s_alloc; }; template typename cond_dealtor::entry_allocator cond_dealtor::s_alloc; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_COND_DEALTOR_HPP 4.8.2/ext/pb_ds/detail/eq_fn/eq_by_less.hpp000064400000004432147547540550014317 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file eq_by_less.hpp * Contains an equivalence function. */ #ifndef PB_DS_EQ_BY_LESS_HPP #define PB_DS_EQ_BY_LESS_HPP #include #include #include #include #include namespace __gnu_pbds { namespace detail { /// Equivalence function. template struct eq_by_less : private Cmp_Fn { bool operator()(const Key& r_lhs, const Key& r_rhs) const { const bool l = Cmp_Fn::operator()(r_lhs, r_rhs); const bool g = Cmp_Fn::operator()(r_rhs, r_lhs); return !(l || g); } }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_EQ_BY_LESS_HPP 4.8.2/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp000064400000007355147547540550014274 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_eq_fn.hpp * Contains 2 eqivalence functions, one employing a hash value, * and one ignoring it. */ #ifndef PB_DS_HASH_EQ_FN_HPP #define PB_DS_HASH_EQ_FN_HPP #include #include namespace __gnu_pbds { namespace detail { /// Primary template. template struct hash_eq_fn; /// Specialization 1 - The client requests that hash values not be stored. template struct hash_eq_fn : public Eq_Fn { typedef Eq_Fn eq_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; hash_eq_fn() { } hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { } bool operator()(key_const_reference r_lhs_key, key_const_reference r_rhs_key) const { return eq_fn_base::operator()(r_lhs_key, r_rhs_key); } void swap(const hash_eq_fn& other) { std::swap((Eq_Fn&)(*this), (Eq_Fn&)other); } }; /// Specialization 2 - The client requests that hash values be stored. template struct hash_eq_fn : public Eq_Fn { typedef typename _Alloc::size_type size_type; typedef Eq_Fn eq_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; hash_eq_fn() { } hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { } bool operator()(key_const_reference r_lhs_key, size_type lhs_hash, key_const_reference r_rhs_key, size_type rhs_hash) const { _GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key) || lhs_hash == rhs_hash); return (lhs_hash == rhs_hash && eq_fn_base::operator()(r_lhs_key, r_rhs_key)); } void swap(const hash_eq_fn& other) { std::swap((Eq_Fn&)(*this), (Eq_Fn&)(other)); } }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/standard_policies.hpp000064400000011647147547540550014577 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/standard_policies.hpp * Contains standard policies for containers. */ #ifndef PB_DS_STANDARD_POLICIES_HPP #define PB_DS_STANDARD_POLICIES_HPP #include #include #include #include #include #include #include #include namespace __gnu_pbds { namespace detail { /// Primary template, default_hash_fn. template struct default_hash_fn { /// Dispatched type. typedef std::tr1::hash type; }; /// Primary template, default_eq_fn. template struct default_eq_fn { /// Dispatched type. typedef std::equal_to type; }; /// Enumeration for default behavior of stored hash data. enum { default_store_hash = false }; /// Primary template, default_comb_hash_fn. struct default_comb_hash_fn { /// Dispatched type. typedef direct_mask_range_hashing<> type; }; /// Primary template, default_resize_policy. template struct default_resize_policy { private: typedef typename Comb_Hash_Fn::size_type size_type; typedef direct_mask_range_hashing default_fn; typedef is_same same_type; typedef hash_exponential_size_policy iftrue; typedef hash_prime_size_policy iffalse; typedef __conditional_type cond_type; typedef typename cond_type::__type size_policy_type; typedef hash_load_check_resize_trigger trigger; public: /// Dispatched type. typedef hash_standard_resize_policy type; }; /// Default update policy. struct default_update_policy { /// Dispatched type. typedef lu_move_to_front_policy<> type; }; /// Primary template, default_probe_fn. template struct default_probe_fn { private: typedef typename Comb_Probe_Fn::size_type size_type; typedef direct_mask_range_hashing default_fn; typedef is_same same_type; typedef linear_probe_fn iftrue; typedef quadratic_probe_fn iffalse; typedef __conditional_type cond_type; public: /// Dispatched type. typedef typename cond_type::__type type; }; /// Primary template, default_trie_access_traits. template struct default_trie_access_traits; #define __dtrie_alloc std::allocator #define __dtrie_string std::basic_string /// Partial specialization, default_trie_access_traits. template struct default_trie_access_traits<__dtrie_string> { private: typedef __dtrie_string string_type; public: /// Dispatched type. typedef trie_string_access_traits type; }; #undef __dtrie_alloc #undef __dtrie_string } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_STANDARD_POLICIES_HPP 4.8.2/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp000064400000005442147547540550021017 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file lu_counter_metadata.hpp * Contains implementation of a lu counter policy's metadata. */ namespace __gnu_pbds { namespace detail { template class lu_counter_policy_base; /// A list-update metadata type that moves elements to the front of /// the list based on the counter algorithm. template class lu_counter_metadata { public: typedef Size_Type size_type; private: lu_counter_metadata(size_type init_count) : m_count(init_count) { } friend class lu_counter_policy_base; mutable size_type m_count; }; /// Base class for list-update counter policy. template class lu_counter_policy_base { protected: typedef Size_Type size_type; lu_counter_metadata operator()(size_type max_size) const { return lu_counter_metadata(std::rand() % max_size); } template bool operator()(Metadata_Reference r_data, size_type m_max_count) const { if (++r_data.m_count != m_max_count) return false; r_data.m_count = 0; return true; } }; } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp000064400000005160147547540550021177 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_update_policy.hpp * Contains a sample policy for list update containers. */ #ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP #define PB_DS_SAMPLE_UPDATE_POLICY_HPP namespace __gnu_pbds { /// A sample list-update policy. struct sample_update_policy { /// Default constructor. sample_update_policy(); /// Copy constructor. sample_update_policy(const sample_update_policy&); /// Swaps content. inline void swap(sample_update_policy& other); protected: /// Metadata on which this functor operates. typedef some_metadata_type metadata_type; /// Creates a metadata object. metadata_type operator()() const; /// Decides whether a metadata object should be moved to the front /// of the list. A list-update based containers object will call /// this method to decide whether to move a node to the front of /// the list. The method shoule return true if the node should be /// moved to the front of the list. bool operator()(metadata_reference) const; }; } #endif 4.8.2/ext/pb_ds/detail/debug_map_base.hpp000064400000020771147547540550014023 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/debug_map_base.hpp * Contains a debug-mode base for all maps. */ #ifndef PB_DS_DEBUG_MAP_BASE_HPP #define PB_DS_DEBUG_MAP_BASE_HPP #ifdef _GLIBCXX_DEBUG #include #include #include #include #include #include namespace __gnu_pbds { namespace detail { // Need std::pair ostream extractor. template inline std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __out, const std::pair<_Tp1, _Tp2>& p) { return (__out << '(' << p.first << ',' << p.second << ')'); } #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ debug_map_base /// Debug base class. template class debug_map_base { private: typedef Const_Key_Reference key_const_reference; typedef std::_GLIBCXX_STD_C::list key_repository; typedef typename key_repository::size_type size_type; typedef typename key_repository::iterator iterator; typedef typename key_repository::const_iterator const_iterator; protected: debug_map_base(); debug_map_base(const PB_DS_CLASS_C_DEC&); ~debug_map_base(); inline void insert_new(key_const_reference); inline void erase_existing(key_const_reference); void clear(); inline void check_key_exists(key_const_reference, const char*, int) const; inline void check_key_does_not_exist(key_const_reference, const char*, int) const; inline void check_size(size_type, const char*, int) const; void swap(PB_DS_CLASS_C_DEC&); template void split(key_const_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&); void join(PB_DS_CLASS_C_DEC&, bool with_cleanup = true); private: void assert_valid(const char*, int) const; const_iterator find(key_const_reference) const; iterator find(key_const_reference); key_repository m_keys; Eq_Fn m_eq; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: debug_map_base() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: debug_map_base(const PB_DS_CLASS_C_DEC& other) : m_keys(other.m_keys), m_eq(other.m_eq) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~debug_map_base() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_new(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) if (find(r_key) != m_keys.end()) { std::cerr << "insert_new key already present " << r_key << std::endl; std::abort(); } __try { m_keys.push_back(r_key); } __catch(...) { std::cerr << "insert_new " << r_key << std::endl; std::abort(); } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: erase_existing(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) iterator it = find(r_key); if (it == m_keys.end()) { std::cerr << "erase_existing" << r_key << std::endl; std::abort(); } m_keys.erase(it); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { PB_DS_ASSERT_VALID((*this)) m_keys.clear(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: check_key_exists(key_const_reference r_key, const char* __file, int __line) const { assert_valid(__file, __line); if (find(r_key) == m_keys.end()) { std::cerr << __file << ':' << __line << ": check_key_exists " << r_key << std::endl; std::abort(); } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: check_key_does_not_exist(key_const_reference r_key, const char* __file, int __line) const { assert_valid(__file, __line); if (find(r_key) != m_keys.end()) { using std::cerr; using std::endl; cerr << __file << ':' << __line << ": check_key_does_not_exist " << r_key << endl; std::abort(); } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: check_size(size_type size, const char* __file, int __line) const { assert_valid(__file, __line); const size_type keys_size = m_keys.size(); if (size != keys_size) { std::cerr << __file << ':' << __line << ": check_size " << size << " != " << keys_size << std::endl; std::abort(); } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) m_keys.swap(other.m_keys); std::swap(m_eq, other.m_eq); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { PB_DS_ASSERT_VALID((*this)) typedef const_iterator iterator_type; for (iterator_type it = m_keys.begin(); it != m_keys.end(); ++it) if (m_eq(*it, r_key)) return it; return m_keys.end(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) iterator it = m_keys.begin(); while (it != m_keys.end()) { if (m_eq(*it, r_key)) return it; ++it; } return it; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { const_iterator prime_it = m_keys.begin(); while (prime_it != m_keys.end()) { const_iterator sec_it = prime_it; ++sec_it; while (sec_it != m_keys.end()) { PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it)); PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it)); ++sec_it; } ++prime_it; } } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(key_const_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other) { other.clear(); iterator it = m_keys.begin(); while (it != m_keys.end()) if (cmp_fn(r_key, *it)) { other.insert_new(*it); it = m_keys.erase(it); } else ++it; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other, bool with_cleanup) { iterator it = other.m_keys.begin(); while (it != other.m_keys.end()) { insert_new(*it); if (with_cleanup) it = other.m_keys.erase(it); else ++it; } _GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_keys.empty()); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif #endif 4.8.2/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp000064400000003551147547540550016632 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/binomial_heap_/debug_fn_imps.hpp * Contains an implementation for binomial_heap_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { base_type::assert_valid(true, __file, __line); } #endif 4.8.2/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp000064400000004147147547540550022574 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/binomial_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation for binomial_heap_. */ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap(const PB_DS_CLASS_C_DEC& other) : base_type(other) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~binomial_heap() { } 4.8.2/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp000064400000007522147547540550016761 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_.hpp * Contains an implementation class for a binomial heap. */ /* * Binomial heap. * Vuillemin J is the mastah. * Modified from CLRS. */ #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ binomial_heap /** * Binomial heap. * * @ingroup heap-detail */ template class binomial_heap : public binomial_heap_base { private: typedef binomial_heap_base base_type; typedef typename base_type::node_pointer node_pointer; typedef typename base_type::node_const_pointer node_const_pointer; public: typedef Value_Type value_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::cmp_fn cmp_fn; typedef typename base_type::allocator_type allocator_type; binomial_heap(); binomial_heap(const Cmp_Fn&); binomial_heap(const binomial_heap&); ~binomial_heap(); protected: #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif }; #include #include #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp000064400000003754147547540550017232 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/trace_fn_imps.hpp * Contains implementations of lu_map_. */ #ifdef PB_DS_LU_MAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << m_p_l << std::endl << std::endl; const_entry_pointer p_l = m_p_l; while (p_l != 0) { std::cerr << PB_DS_V2F(p_l->m_value) << std::endl; p_l = p_l->m_p_next; } std::cerr << std::endl; } #endif 4.8.2/ext/pb_ds/detail/list_update_map_/lu_map_.hpp000064400000024231147547540550016026 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/lu_map_.hpp * Contains a list update map. */ #include #include #include #include #include #include #include #ifdef _GLIBCXX_DEBUG #include #endif #ifdef PB_DS_LU_MAP_TRACE_ #include #endif #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_LU_NAME lu_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_LU_NAME lu_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_LU_NAME #define PB_DS_LU_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base::other::const_reference> #endif /// list-based (with updates) associative container. /// Skip to the lu, my darling. template class PB_DS_LU_NAME : #ifdef _GLIBCXX_DEBUG protected PB_DS_DEBUG_MAP_BASE_C_DEC, #endif public PB_DS_LU_TRAITS_BASE { private: typedef PB_DS_LU_TRAITS_BASE traits_base; struct entry : public lu_map_entry_metadata_base { typename traits_base::value_type m_value; typename _Alloc::template rebind::other::pointer m_p_next; }; typedef typename _Alloc::template rebind::other entry_allocator; typedef typename entry_allocator::pointer entry_pointer; typedef typename entry_allocator::const_pointer const_entry_pointer; typedef typename entry_allocator::reference entry_reference; typedef typename entry_allocator::const_reference const_entry_reference; typedef typename _Alloc::template rebind::other entry_pointer_allocator; typedef typename entry_pointer_allocator::pointer entry_pointer_array; typedef typename traits_base::value_type value_type_; typedef typename traits_base::pointer pointer_; typedef typename traits_base::const_pointer const_pointer_; typedef typename traits_base::reference reference_; typedef typename traits_base::const_reference const_reference_; #define PB_DS_GEN_POS entry_pointer #include #include #include #include #undef PB_DS_GEN_POS #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif typedef cond_dealtor cond_dealtor_t; public: typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Eq_Fn eq_fn; typedef Update_Policy update_policy; typedef typename Update_Policy::metadata_type update_metadata; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef point_iterator_ point_iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef point_const_iterator_ point_iterator; #endif typedef point_const_iterator_ point_const_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef iterator_ iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_iterator_ iterator; #endif typedef const_iterator_ const_iterator; public: PB_DS_LU_NAME(); PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC&); virtual ~PB_DS_LU_NAME(); template PB_DS_LU_NAME(It, It); void swap(PB_DS_CLASS_C_DEC&); inline size_type size() const; inline size_type max_size() const; inline bool empty() const; inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return insert(std::make_pair(r_key, mapped_type())).first->second; #else insert(r_key); return traits_base::s_null_type; #endif } inline std::pair insert(const_reference); inline point_iterator find(key_const_reference r_key) { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) entry_pointer p_e = find_imp(r_key); return point_iterator(p_e == 0 ? 0: &p_e->m_value); } inline point_const_iterator find(key_const_reference r_key) const { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) entry_pointer p_e = find_imp(r_key); return point_const_iterator(p_e == 0 ? 0: &p_e->m_value); } inline bool erase(key_const_reference); template inline size_type erase_if(Pred); void clear(); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_LU_MAP_TRACE_ void trace() const; #endif protected: template void copy_from_range(It, It); private: #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; #endif friend class const_iterator_; inline entry_pointer allocate_new_entry(const_reference, false_type); inline entry_pointer allocate_new_entry(const_reference, true_type); template inline static void init_entry_metadata(entry_pointer, type_to_type); inline static void init_entry_metadata(entry_pointer, type_to_type); void deallocate_all(); void erase_next(entry_pointer); void actual_erase_entry(entry_pointer); void inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const { r_pos = r_pos->m_p_next; r_p_value = (r_pos == 0) ? 0 : &r_pos->m_value; } template inline static bool apply_update(entry_pointer, type_to_type); inline static bool apply_update(entry_pointer, type_to_type); inline entry_pointer find_imp(key_const_reference) const; static entry_allocator s_entry_allocator; static Eq_Fn s_eq_fn; static Update_Policy s_update_policy; static type_to_type s_metadata_type_indicator; static null_type s_null_type; mutable entry_pointer m_p_l; }; #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_LU_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC #undef PB_DS_LU_NAME } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp000064400000004105147547540550020403 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/entry_metadata_base.hpp * Contains an implementation for a list update map. */ #ifndef PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP #define PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP namespace __gnu_pbds { namespace detail { template struct lu_map_entry_metadata_base { Metadata m_update_metadata; }; template<> struct lu_map_entry_metadata_base { }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp000064400000004057147547540550017217 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/debug_fn_imps.hpp * Contains implementations of cc_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { size_type calc_size = 0; for (const_iterator it = begin(); it != end(); ++it) { debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); ++calc_size; } debug_base::check_size(calc_size, __file, __line); } #endif 4.8.2/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp000064400000006666147547540550017445 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/insert_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline std::pair< typename PB_DS_CLASS_C_DEC::point_iterator, bool> PB_DS_CLASS_C_DEC:: insert(const_reference r_val) { PB_DS_ASSERT_VALID((*this)) entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); if (p_l != 0) { PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) return std::make_pair(point_iterator(&p_l->m_value), false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator); p_l->m_p_next = m_p_l; m_p_l = p_l; PB_DS_ASSERT_VALID((*this)) return std::make_pair(point_iterator(&p_l->m_value), true); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: allocate_new_entry(const_reference r_val, false_type) { entry_pointer p_l = s_entry_allocator.allocate(1); cond_dealtor_t cond(p_l); new (const_cast(static_cast(&p_l->m_value))) value_type(r_val); cond.set_no_action(); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) init_entry_metadata(p_l, s_metadata_type_indicator); return p_l; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: allocate_new_entry(const_reference r_val, true_type) { entry_pointer p_l = s_entry_allocator.allocate(1); new (&p_l->m_value) value_type(r_val); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) init_entry_metadata(p_l, s_metadata_type_indicator); return p_l; } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: init_entry_metadata(entry_pointer p_l, type_to_type) { new (&p_l->m_update_metadata) Metadata(s_update_policy()); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: init_entry_metadata(entry_pointer, type_to_type) { } 4.8.2/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp000064400000004730147547540550020143 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/iterators_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { if (m_p_l == 0) { _GLIBCXX_DEBUG_ASSERT(empty()); return end(); } return iterator(&m_p_l->m_value, m_p_l, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { if (m_p_l == 0) { _GLIBCXX_DEBUG_ASSERT(empty()); return end(); } return iterator(&m_p_l->m_value, m_p_l, const_cast(this)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return iterator(0, 0, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return const_iterator(0, 0, const_cast(this)); } 4.8.2/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp000064400000006632147547540550017231 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/erase_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) if (m_p_l == 0) return false; if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) { entry_pointer p_next = m_p_l->m_p_next; actual_erase_entry(m_p_l); m_p_l = p_next; return true; } entry_pointer p_l = m_p_l; while (p_l->m_p_next != 0) if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value))) { erase_next(p_l); return true; } else p_l = p_l->m_p_next; return false; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { deallocate_all(); } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; while (m_p_l != 0 && pred(m_p_l->m_value)) { entry_pointer p_next = m_p_l->m_p_next; ++num_ersd; actual_erase_entry(m_p_l); m_p_l = p_next; } if (m_p_l == 0) return num_ersd; entry_pointer p_l = m_p_l; while (p_l->m_p_next != 0) { if (pred(p_l->m_p_next->m_value)) { ++num_ersd; erase_next(p_l); } else p_l = p_l->m_p_next; } PB_DS_ASSERT_VALID((*this)) return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_next(entry_pointer p_l) { _GLIBCXX_DEBUG_ASSERT(p_l != 0); _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0); entry_pointer p_next_l = p_l->m_p_next->m_p_next; actual_erase_entry(p_l->m_p_next); p_l->m_p_next = p_next_l; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: actual_erase_entry(entry_pointer p_l) { _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->m_value));) p_l->~entry(); s_entry_allocator.deallocate(p_l, 1); } 4.8.2/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp000064400000007000147547540550022763 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/constructor_destructor_fn_imps.hpp */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_allocator PB_DS_CLASS_C_DEC::s_entry_allocator; PB_DS_CLASS_T_DEC Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn; PB_DS_CLASS_T_DEC null_type PB_DS_CLASS_C_DEC::s_null_type; PB_DS_CLASS_T_DEC Update_Policy PB_DS_CLASS_C_DEC::s_update_policy; PB_DS_CLASS_T_DEC type_to_type< typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator; PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_LU_NAME() : m_p_l(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template PB_DS_CLASS_C_DEC:: PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0) { copy_from_range(first_it, last_it); PB_DS_ASSERT_VALID((*this)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) : m_p_l(0) { __try { for (const_iterator it = other.begin(); it != other.end(); ++it) { entry_pointer p_l = allocate_new_entry(*it, traits_base::m_no_throw_copies_indicator); p_l->m_p_next = m_p_l; m_p_l = p_l; } } __catch(...) { deallocate_all(); __throw_exception_again; } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_p_l, other.m_p_l); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: deallocate_all() { entry_pointer p_l = m_p_l; while (p_l != 0) { entry_pointer p_next_l = p_l->m_p_next; actual_erase_entry(p_l); p_l = p_next_l; } m_p_l = 0; } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_LU_NAME() { deallocate_all(); } 4.8.2/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp000064400000005455147547540550017054 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/find_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: find_imp(key_const_reference r_key) const { if (m_p_l == 0) return 0; if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) { apply_update(m_p_l, s_metadata_type_indicator); PB_DS_CHECK_KEY_EXISTS(r_key) return m_p_l; } entry_pointer p_l = m_p_l; while (p_l->m_p_next != 0) { entry_pointer p_next = p_l->m_p_next; if (s_eq_fn(r_key, PB_DS_V2F(p_next->m_value))) { if (apply_update(p_next, s_metadata_type_indicator)) { p_l->m_p_next = p_next->m_p_next; p_next->m_p_next = m_p_l; m_p_l = p_next; return m_p_l; } return p_next; } else p_l = p_next; } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return 0; } PB_DS_CLASS_T_DEC template inline bool PB_DS_CLASS_C_DEC:: apply_update(entry_pointer p_l, type_to_type) { return s_update_policy(p_l->m_update_metadata); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: apply_update(entry_pointer, type_to_type) { return s_update_policy(s_null_type); } 4.8.2/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp000064400000004032147547540550017055 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_map_/info_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return std::distance(begin(), end()); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_entry_allocator.max_size(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (m_p_l == 0); } 4.8.2/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp000064400000005231147547540550020635 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/sample_trie_access_traits.hpp * Contains a sample probe policy. */ #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP #define PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP namespace __gnu_pbds { /// A sample trie element access traits. struct sample_trie_access_traits { typedef std::size_t size_type; typedef std::string key_type; typedef typename _Alloc::template rebind __rebind_k; typedef typename __rebind_k::other::const_reference key_const_reference; typedef std::string::const_iterator const_iterator; /// Element type. typedef char e_type; enum { max_size = 4 }; /// Returns a const_iterator to the first element of r_key. inline static const_iterator begin(key_const_reference); /// Returns a const_iterator to the after-last element of r_key. inline static const_iterator end(key_const_reference); /// Maps an element to a position. inline static size_type e_pos(e_type); }; } #endif // #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP 4.8.2/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp000064400000013327147547540550016743 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/trie_policy_base.hpp * Contains an implementation of trie_policy_base. */ #ifndef PB_DS_TRIE_POLICY_BASE_HPP #define PB_DS_TRIE_POLICY_BASE_HPP #include namespace __gnu_pbds { namespace detail { /// Base class for trie policies. template class trie_policy_base : public branch_policy { typedef branch_policy base_type; public: typedef _ATraits access_traits; typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; typedef null_type metadata_type; typedef Node_CItr node_const_iterator; typedef Node_Itr node_iterator; typedef typename node_const_iterator::value_type const_iterator; typedef typename node_iterator::value_type iterator; typedef typename base_type::key_type key_type; typedef typename base_type::key_const_reference key_const_reference; protected: virtual const_iterator end() const = 0; virtual iterator end() = 0; virtual node_const_iterator node_begin() const = 0; virtual node_iterator node_begin() = 0; virtual node_const_iterator node_end() const = 0; virtual node_iterator node_end() = 0; virtual const access_traits& get_access_traits() const = 0; private: typedef typename access_traits::const_iterator e_const_iterator; typedef std::pair prefix_range_t; protected: static size_type common_prefix_len(node_iterator, e_const_iterator, e_const_iterator, const access_traits&); static iterator leftmost_it(node_iterator); static iterator rightmost_it(node_iterator); static bool less(e_const_iterator, e_const_iterator, e_const_iterator, e_const_iterator, const access_traits&); }; #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ trie_policy_base PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: common_prefix_len(node_iterator nd_it, e_const_iterator b_r, e_const_iterator e_r, const access_traits& r_traits) { prefix_range_t pref_range = nd_it.valid_prefix(); e_const_iterator b_l = pref_range.first; e_const_iterator e_l = pref_range.second; const size_type range_length_l = std::distance(b_l, e_l); const size_type range_length_r = std::distance(b_r, e_r); if (range_length_r < range_length_l) { std::swap(b_l, b_r); std::swap(e_l, e_r); } size_type ret = 0; while (b_l != e_l) { if (r_traits.e_pos(*b_l) != r_traits.e_pos(*b_r)) return ret; ++ret; ++b_l; ++b_r; } return ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: leftmost_it(node_iterator nd_it) { if (nd_it.num_children() == 0) return *nd_it; return leftmost_it(nd_it.get_child(0)); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: rightmost_it(node_iterator nd_it) { const size_type num_children = nd_it.num_children(); if (num_children == 0) return *nd_it; return rightmost_it(nd_it.get_child(num_children - 1)); } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: less(e_const_iterator b_l, e_const_iterator e_l, e_const_iterator b_r, e_const_iterator e_r, const access_traits& r_traits) { while (b_l != e_l) { if (b_r == e_r) return false; size_type l_pos = r_traits.e_pos(*b_l); size_type r_pos = r_traits.e_pos(*b_r); if (l_pos != r_pos) return (l_pos < r_pos); ++b_l; ++b_r; } return b_r != e_r; } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_TRIE_POLICY_BASE_HPP 4.8.2/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp000064400000006412147547540550020111 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/node_metadata_selector.hpp * Contains an implementation class for tries. */ #ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP #define PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP #include #include namespace __gnu_pbds { namespace detail { /** * @addtogroup traits Traits * @{ */ /// Trie metadata helper. template struct trie_metadata_helper; /// Specialization, false. template struct trie_metadata_helper { typedef typename Node_Update::metadata_type type; }; /// Specialization, true. template struct trie_metadata_helper { typedef null_type type; }; /// Trie node metadata dispatch. template class Node_Update, typename _Alloc> struct trie_node_metadata_dispatch { private: typedef dumnode_const_iterator __it_type; typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u; typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u; enum { null_update = is_same<__node_u, __nnode_u>::value }; public: typedef typename trie_metadata_helper<__node_u, null_update>::type type; }; //@} } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP 4.8.2/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp000064400000010637147547540550021466 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/prefix_search_node_update_imp.hpp * Contains an implementation of prefix_search_node_update. */ PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::const_iterator, typename PB_DS_CLASS_C_DEC::const_iterator> PB_DS_CLASS_C_DEC:: prefix_range(key_const_reference r_key) const { const access_traits& r_traits = get_access_traits(); return (prefix_range(r_traits.begin(r_key), r_traits.end(r_key))); } PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::iterator, typename PB_DS_CLASS_C_DEC::iterator> PB_DS_CLASS_C_DEC:: prefix_range(key_const_reference r_key) { return (prefix_range(get_access_traits().begin(r_key), get_access_traits().end(r_key))); } PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::const_iterator, typename PB_DS_CLASS_C_DEC::const_iterator> PB_DS_CLASS_C_DEC:: prefix_range(typename access_traits::const_iterator b, typename access_traits::const_iterator e) const { const std::pair non_const_ret = const_cast(this)->prefix_range(b, e); return (std::make_pair(const_iterator(non_const_ret.first), const_iterator(non_const_ret.second))); } PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::iterator, typename PB_DS_CLASS_C_DEC::iterator> PB_DS_CLASS_C_DEC:: prefix_range(typename access_traits::const_iterator b, typename access_traits::const_iterator e) { Node_Itr nd_it = node_begin(); Node_Itr end_nd_it = node_end(); const access_traits& r_traits = get_access_traits(); const size_type given_range_length = std::distance(b, e); while (true) { if (nd_it == end_nd_it) return (std::make_pair(end(), end())); const size_type common_range_length = base_type::common_prefix_len(nd_it, b, e, r_traits); if (common_range_length >= given_range_length) { iterator ret_b = this->leftmost_it(nd_it); iterator ret_e = this->rightmost_it(nd_it); return (std::make_pair(ret_b, ++ret_e)); } nd_it = next_child(nd_it, b, e, end_nd_it, r_traits); } } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: next_child(node_iterator nd_it, typename access_traits::const_iterator b, typename access_traits::const_iterator e, node_iterator end_nd_it, const access_traits& r_traits) { const size_type num_children = nd_it.num_children(); node_iterator ret = end_nd_it; size_type max_length = 0; for (size_type i = 0; i < num_children; ++i) { node_iterator pot = nd_it.get_child(i); const size_type common_range_length = base_type::common_prefix_len(pot, b, e, r_traits); if (common_range_length > max_length) { ret = pot; max_length = common_range_length; } } return (ret); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: operator()(node_iterator /*nd_it*/, node_const_iterator /*end_nd_it*/) const { } 4.8.2/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp000064400000011135147547540550017654 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/order_statistics_imp.hpp * Contains forward declarations for order_statistics_key */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: find_by_order(size_type order) { if (empty()) return end(); ++order; node_iterator nd_it = node_begin(); while (true) { if (order > nd_it.get_metadata()) return ++base_type::rightmost_it(nd_it); const size_type num_children = nd_it.num_children(); if (num_children == 0) return *nd_it; for (size_type i = 0; i < num_children; ++i) { node_iterator child_nd_it = nd_it.get_child(i); if (order <= child_nd_it.get_metadata()) { i = num_children; nd_it = child_nd_it; } else order -= child_nd_it.get_metadata(); } } } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: find_by_order(size_type order) const { return const_cast(this)->find_by_order(order); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: order_of_key(key_const_reference r_key) const { const _ATraits& r_traits = const_cast(this)->get_access_traits(); return order_of_prefix(r_traits.begin(r_key), r_traits.end(r_key)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: order_of_prefix(typename access_traits::const_iterator b, typename access_traits::const_iterator e) const { if (empty()) return 0; const _ATraits& r_traits = const_cast(this)->get_access_traits(); node_const_iterator nd_it = node_begin(); node_const_iterator end_nd_it = node_end(); size_type ord = 0; while (true) { const size_type num_children = nd_it.num_children(); if (num_children == 0) { key_const_reference r_key = base_type::extract_key(*(*nd_it)); typename access_traits::const_iterator key_b = r_traits.begin(r_key); typename access_traits::const_iterator key_e = r_traits.end(r_key); return (base_type::less(key_b, key_e, b, e, r_traits)) ? ord + 1 : ord; } node_const_iterator next_nd_it = end_nd_it; size_type i = num_children - 1; do { node_const_iterator child_nd_it = nd_it.get_child(i); if (next_nd_it != end_nd_it) ord += child_nd_it.get_metadata(); else if (!base_type::less(b, e, child_nd_it.valid_prefix().first, child_nd_it.valid_prefix().second, r_traits)) next_nd_it = child_nd_it; } while (i-- > 0); if (next_nd_it == end_nd_it) return ord; nd_it = next_nd_it; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: operator()(node_iterator nd_it, node_const_iterator /*end_nd_it*/) const { const size_type num_children = nd_it.num_children(); size_type children_rank = 0; for (size_type i = 0; i < num_children; ++i) children_rank += nd_it.get_child(i).get_metadata(); const size_type res = (num_children == 0) ? 1 : children_rank; const_cast(nd_it.get_metadata()) = res; } 4.8.2/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp000064400000004454147547540550020303 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/sample_trie_node_update.hpp * Contains a samle node update functor. */ #ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP #define PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP namespace __gnu_pbds { /// A sample node updator. template class sample_trie_node_update { public: typedef std::size_t metadata_type; protected: /// Default constructor. sample_trie_node_update(); /// Updates the rank of a node through a node_iterator node_it; /// end_nd_it is the end node iterator. inline void operator()(node_iterator, node_const_iterator) const; }; } #endif // #ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP 4.8.2/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp000064400000005753147547540550021540 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file trie_policy/trie_string_access_traits_imp.hpp * Contains a policy for extracting character positions from * a string for a vector-based PATRICIA tree */ PB_DS_CLASS_T_DEC detail::integral_constant PB_DS_CLASS_C_DEC::s_rev_ind; PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: e_pos(e_type e) { return (static_cast(e - min_e_val)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin(key_const_reference r_key) { return (begin_imp(r_key, s_rev_ind)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end(key_const_reference r_key) { return (end_imp(r_key, s_rev_ind)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin_imp(key_const_reference r_key, detail::false_type) { return (r_key.begin()); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin_imp(key_const_reference r_key, detail::true_type) { return (r_key.rbegin()); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end_imp(key_const_reference r_key, detail::false_type) { return (r_key.end()); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end_imp(key_const_reference r_key, detail::true_type) { return (r_key.rend()); } 4.8.2/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp000064400000005402147547540550016340 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/debug_fn_imps.hpp * Contains an implementation class for ov_tree_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { if (m_a_values == 0 || m_end_it == 0 || m_size == 0) PB_DS_DEBUG_VERIFY(m_a_values == 0 && m_end_it == 0 && m_size == 0); assert_iterators(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_iterators(const char* __file, int __line) const { debug_base::check_size(m_size, __file, __line); size_type iterated_num = 0; const_iterator prev_it = end(); PB_DS_DEBUG_VERIFY(m_end_it == m_a_values + m_size); for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; PB_DS_DEBUG_VERIFY(upper_bound_it == it); if (prev_it != end()) PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), PB_DS_V2F(*it))); prev_it = it; } PB_DS_DEBUG_VERIFY(iterated_num == m_size); } #endif 4.8.2/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp000064400000015325147547540550022305 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/constructors_destructor_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::value_allocator PB_DS_CLASS_C_DEC::s_value_alloc; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::metadata_allocator PB_DS_CLASS_C_DEC::s_metadata_alloc; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_NAME() : m_a_values(0), m_a_metadata(0), m_end_it(0), m_size(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn) : cmp_fn(r_cmp_fn), m_a_values(0), m_a_metadata(0), m_end_it(0), m_size(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_nodeu) : cmp_fn(r_cmp_fn), node_update(r_nodeu), m_a_values(0), m_a_metadata(0), m_end_it(0), m_size(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : #ifdef PB_DS_TREE_TRACE trace_base(other), #endif cmp_fn(other), node_update(other), m_a_values(0), m_a_metadata(0), m_end_it(0), m_size(0) { copy_from_ordered_range(other.begin(), other.end()); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { #ifdef PB_DS_DATA_TRUE_INDICATOR typedef std::map::other> map_type; #else typedef std::set::other> map_type; #endif map_type m(first_it, last_it); copy_from_ordered_range(m.begin(), m.end()); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_ordered_range(It first_it, It last_it) { const size_type len = std::distance(first_it, last_it); if (len == 0) return; value_vector a_values = s_value_alloc.allocate(len); iterator target_it = a_values; It source_it = first_it; It source_end_it = last_it; cond_dtor cd(a_values, target_it, len); while (source_it != source_end_it) { void* __v = const_cast(static_cast(target_it)); new (__v) value_type(*source_it++); ++target_it; } reallocate_metadata((node_update*)this, len); cd.set_no_action(); m_a_values = a_values; m_size = len; m_end_it = m_a_values + m_size; update(PB_DS_node_begin_imp(), (node_update*)this); #ifdef _GLIBCXX_DEBUG for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) debug_base::insert_new(PB_DS_V2F(*dbg_it)); #endif } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it) { clear(); const size_type len = std::distance(first_it, last_it) + std::distance(other_first_it, other_last_it); value_vector a_values = s_value_alloc.allocate(len); iterator target_it = a_values; It source_it = first_it; It source_end_it = last_it; cond_dtor cd(a_values, target_it, len); while (source_it != source_end_it) { new (const_cast(static_cast(target_it))) value_type(*source_it++); ++target_it; } source_it = other_first_it; source_end_it = other_last_it; while (source_it != source_end_it) { new (const_cast(static_cast(target_it))) value_type(*source_it++); ++target_it; } reallocate_metadata((node_update* )this, len); cd.set_no_action(); m_a_values = a_values; m_size = len; m_end_it = m_a_values + m_size; update(PB_DS_node_begin_imp(), (node_update* )this); #ifdef _GLIBCXX_DEBUG for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) debug_base::insert_new(PB_DS_V2F(*dbg_it)); #endif } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) value_swap(other); std::swap(static_cast(*this), static_cast(other)); std::swap(static_cast(*this), static_cast(other)); PB_DS_ASSERT_VALID(other) PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_a_values, other.m_a_values); std::swap(m_a_metadata, other.m_a_metadata); std::swap(m_size, other.m_size); std::swap(m_end_it, other.m_end_it); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_OV_TREE_NAME() { PB_DS_ASSERT_VALID((*this)) cond_dtor cd(m_a_values, m_end_it, m_size); reallocate_metadata((node_update*)this, 0); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update(node_iterator, null_node_update_pointer) { } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: update(node_iterator nd_it, Node_Update* p_update) { node_const_iterator end_it = PB_DS_node_end_imp(); if (nd_it != end_it) { update(nd_it.get_l_child(), p_update); update(nd_it.get_r_child(), p_update); node_update::operator()(nd_it, end_it); } } 4.8.2/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp000064400000004341147547540550016557 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/insert_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: reallocate_metadata(null_node_update_pointer, size_type) { } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: reallocate_metadata(Node_Update_* , size_type new_size) { metadata_pointer a_new_metadata_vec =(new_size == 0) ? 0 : s_metadata_alloc.allocate(new_size); if (m_a_metadata != 0) { for (size_type i = 0; i < m_size; ++i) m_a_metadata[i].~metadata_type(); s_metadata_alloc.deallocate(m_a_metadata, m_size); } std::swap(m_a_metadata, a_new_metadata_vec); } 4.8.2/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp000064400000007276147547540550017437 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/split_join_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (m_size == 0) { other.clear(); return; } if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin()))) { value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1)))) { return; } if (m_size == 1) { value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } iterator it = upper_bound(r_key); PB_DS_CLASS_C_DEC new_other(other, other); new_other.copy_from_ordered_range(it, end()); PB_DS_CLASS_C_DEC new_this(*this, *this); new_this.copy_from_ordered_range(begin(), it); // No exceptions from this point. other.update(other.node_begin(), (node_update*)(&other)); update(node_begin(), (node_update*)this); other.value_swap(new_other); value_swap(new_this); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return; if (m_size == 0) { value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } const bool greater = Cmp_Fn::operator()(PB_DS_V2F(*(end() - 1)), PB_DS_V2F(*other.begin())); const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)), PB_DS_V2F(*begin())); if (!greater && !lesser) __throw_join_error(); PB_DS_CLASS_C_DEC new_this(*this, *this); if (greater) new_this.copy_from_ordered_range(begin(), end(), other.begin(), other.end()); else new_this.copy_from_ordered_range(other.begin(), other.end(), begin(), end()); // No exceptions from this point. value_swap(new_this); other.clear(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp000064400000006441147547540550017272 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/iterators_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_begin() const { return PB_DS_node_begin_imp(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_end() const { return PB_DS_node_end_imp(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_begin() { return PB_DS_node_begin_imp(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_end() { return PB_DS_node_end_imp(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: PB_DS_node_begin_imp() const { return node_const_iterator(const_cast(mid_pointer(begin(), end())), const_cast(begin()), const_cast(end()),(m_a_metadata == 0)? 0 : mid_pointer(m_a_metadata, m_a_metadata + m_size)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: PB_DS_node_end_imp() const { return node_const_iterator(end(), end(), end(), (m_a_metadata == 0) ? 0 : m_a_metadata + m_size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: PB_DS_node_begin_imp() { return node_iterator(mid_pointer(begin(), end()), begin(), end(), (m_a_metadata == 0) ? 0 : mid_pointer(m_a_metadata, m_a_metadata + m_size)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: PB_DS_node_end_imp() { return node_iterator(end(), end(), end(),(m_a_metadata == 0) ? 0 : m_a_metadata + m_size); } 4.8.2/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp000064400000036006147547540550016202 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/ov_tree_map_.hpp * Contains an implementation class for ov_tree. */ #include #include #include #include #include #include #include #include #ifdef _GLIBCXX_DEBUG #include #endif #include #include #include #include #include #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_OV_TREE_NAME ov_tree_map #define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_OV_TREE_NAME ov_tree_set #define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_OV_TREE_NAME #define PB_DS_OV_TREE_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base, \ typename _Alloc::template rebind::other::const_reference> #endif #ifdef PB_DS_TREE_TRACE #define PB_DS_TREE_TRACE_BASE_C_DEC \ tree_trace_base #endif #ifndef PB_DS_CHECK_KEY_EXISTS # error Missing definition #endif /** * @brief Ordered-vector tree associative-container. * @ingroup branch-detail */ template class PB_DS_OV_TREE_NAME : #ifdef _GLIBCXX_DEBUG protected PB_DS_DEBUG_MAP_BASE_C_DEC, #endif #ifdef PB_DS_TREE_TRACE public PB_DS_TREE_TRACE_BASE_C_DEC, #endif public Cmp_Fn, public Node_And_It_Traits::node_update, public PB_DS_OV_TREE_TRAITS_BASE { private: typedef PB_DS_OV_TREE_TRAITS_BASE traits_base; typedef Node_And_It_Traits traits_type; typedef typename remove_const::type non_const_value_type; typedef typename _Alloc::template rebind::other value_allocator; typedef typename value_allocator::pointer value_vector; #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif #ifdef PB_DS_TREE_TRACE typedef PB_DS_TREE_TRACE_BASE_C_DEC trace_base; #endif typedef typename traits_base::pointer mapped_pointer_; typedef typename traits_base::const_pointer mapped_const_pointer_; typedef typename traits_type::metadata_type metadata_type; typedef typename _Alloc::template rebind::other metadata_allocator; typedef typename metadata_allocator::pointer metadata_pointer; typedef typename metadata_allocator::const_reference metadata_const_reference; typedef typename metadata_allocator::reference metadata_reference; typedef typename traits_type::null_node_update_pointer null_node_update_pointer; public: typedef ov_tree_tag container_category; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Cmp_Fn cmp_fn; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; typedef const_pointer point_const_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef pointer point_iterator; #else typedef point_const_iterator point_iterator; #endif typedef point_iterator iterator; typedef point_const_iterator const_iterator; /// Conditional destructor. template class cond_dtor { public: cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size) : m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size), m_no_action(false) { } ~cond_dtor() { if (m_no_action) return; iterator it = m_a_vec; while (it != m_r_last_it) { it->~value_type(); ++it; } if (m_max_size > 0) value_allocator().deallocate(m_a_vec, m_max_size); } inline void set_no_action() { m_no_action = true; } protected: value_vector m_a_vec; iterator& m_r_last_it; const Size_Type m_max_size; bool m_no_action; }; typedef typename traits_type::node_update node_update; typedef typename traits_type::node_iterator node_iterator; typedef typename traits_type::node_const_iterator node_const_iterator; PB_DS_OV_TREE_NAME(); PB_DS_OV_TREE_NAME(const Cmp_Fn&); PB_DS_OV_TREE_NAME(const Cmp_Fn&, const node_update&); PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC&); ~PB_DS_OV_TREE_NAME(); void swap(PB_DS_CLASS_C_DEC&); template void copy_from_range(It, It); inline size_type max_size() const; inline bool empty() const; inline size_type size() const; Cmp_Fn& get_cmp_fn(); const Cmp_Fn& get_cmp_fn() const; inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR PB_DS_ASSERT_VALID((*this)) point_iterator it = lower_bound(r_key); if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) { PB_DS_CHECK_KEY_EXISTS(r_key) PB_DS_ASSERT_VALID((*this)) return it->second; } return insert_new_val(it, std::make_pair(r_key, mapped_type()))->second; #else insert(r_key); return traits_base::s_null_type; #endif } inline std::pair insert(const_reference r_value) { PB_DS_ASSERT_VALID((*this)) key_const_reference r_key = PB_DS_V2F(r_value); point_iterator it = lower_bound(r_key); if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) { PB_DS_ASSERT_VALID((*this)) PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(it, false); } return std::make_pair(insert_new_val(it, r_value), true); } inline point_iterator lower_bound(key_const_reference r_key) { pointer it = m_a_values; pointer e_it = m_a_values + m_size; while (it != e_it) { pointer mid_it = it + ((e_it - it) >> 1); if (cmp_fn::operator()(PB_DS_V2F(*mid_it), r_key)) it = ++mid_it; else e_it = mid_it; } return it; } inline point_const_iterator lower_bound(key_const_reference r_key) const { return const_cast(*this).lower_bound(r_key); } inline point_iterator upper_bound(key_const_reference r_key) { iterator pot_it = lower_bound(r_key); if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { PB_DS_CHECK_KEY_EXISTS(r_key) return ++pot_it; } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return pot_it; } inline point_const_iterator upper_bound(key_const_reference r_key) const { return const_cast(*this).upper_bound(r_key); } inline point_iterator find(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) iterator pot_it = lower_bound(r_key); if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { PB_DS_CHECK_KEY_EXISTS(r_key) return pot_it; } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } inline point_const_iterator find(key_const_reference r_key) const { return (const_cast(*this).find(r_key)); } bool erase(key_const_reference); template inline size_type erase_if(Pred); inline iterator erase(iterator it) { return erase_imp(it); } void clear(); void join(PB_DS_CLASS_C_DEC&); void split(key_const_reference, PB_DS_CLASS_C_DEC&); inline iterator begin() { return m_a_values; } inline const_iterator begin() const { return m_a_values; } inline iterator end() { return m_end_it; } inline const_iterator end() const { return m_end_it; } /// Returns a const node_iterator corresponding to the node at the /// root of the tree. inline node_const_iterator node_begin() const; /// Returns a node_iterator corresponding to the node at the /// root of the tree. inline node_iterator node_begin(); /// Returns a const node_iterator corresponding to a node just /// after a leaf of the tree. inline node_const_iterator node_end() const; /// Returns a node_iterator corresponding to a node just /// after a leaf of the tree. inline node_iterator node_end(); private: inline void update(node_iterator, null_node_update_pointer); template void update(node_iterator, Node_Update*); void reallocate_metadata(null_node_update_pointer, size_type); template void reallocate_metadata(Node_Update_*, size_type); template void copy_from_ordered_range(It, It); void value_swap(PB_DS_CLASS_C_DEC&); template void copy_from_ordered_range(It, It, It, It); template inline static Ptr mid_pointer(Ptr p_begin, Ptr p_end) { _GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); return (p_begin + (p_end - p_begin) / 2); } inline iterator insert_new_val(iterator it, const_reference r_value) { #ifdef PB_DS_REGRESSION typename _Alloc::group_adjustor adjust(m_size); #endif PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) value_vector a_values = s_value_alloc.allocate(m_size + 1); iterator source_it = begin(); iterator source_end_it = end(); iterator target_it = a_values; iterator ret_it; cond_dtor cd(a_values, target_it, m_size + 1); while (source_it != it) { new (const_cast(static_cast(target_it))) value_type(*source_it++); ++target_it; } new (const_cast(static_cast(ret_it = target_it))) value_type(r_value); ++target_it; while (source_it != source_end_it) { new (const_cast(static_cast(target_it))) value_type(*source_it++); ++target_it; } reallocate_metadata((node_update*)this, m_size + 1); cd.set_no_action(); if (m_size != 0) { cond_dtor cd1(m_a_values, m_end_it, m_size); } ++m_size; m_a_values = a_values; m_end_it = m_a_values + m_size; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value))); update(node_begin(), (node_update* )this); PB_DS_ASSERT_VALID((*this)) return ret_it; } #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; void assert_iterators(const char*, int) const; #endif template It erase_imp(It); inline node_const_iterator PB_DS_node_begin_imp() const; inline node_const_iterator PB_DS_node_end_imp() const; inline node_iterator PB_DS_node_begin_imp(); inline node_iterator PB_DS_node_end_imp(); private: static value_allocator s_value_alloc; static metadata_allocator s_metadata_alloc; value_vector m_a_values; metadata_pointer m_a_metadata; iterator m_end_it; size_type m_size; }; #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_OV_TREE_NAME #undef PB_DS_OV_TREE_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC #ifdef PB_DS_TREE_TRACE #undef PB_DS_TREE_TRACE_BASE_C_DEC #endif #undef PB_DS_CONST_NODE_ITERATOR_NAME } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp000064400000011565147547540550016360 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/erase_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { PB_DS_ASSERT_VALID((*this)) if (m_size == 0) { return; } else { reallocate_metadata((node_update* )this, 0); cond_dtor cd(m_a_values, m_end_it, m_size); } _GLIBCXX_DEBUG_ONLY(debug_base::clear();) m_a_values = 0; m_size = 0; m_end_it = m_a_values; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) #ifdef PB_DS_REGRESSION typename _Alloc::group_adjustor adjust(m_size); #endif size_type new_size = 0; size_type num_val_ersd = 0; for (iterator source_it = begin(); source_it != m_end_it; ++source_it) if (!pred(*source_it)) ++new_size; else ++num_val_ersd; if (new_size == 0) { clear(); return num_val_ersd; } value_vector a_new_values = s_value_alloc.allocate(new_size); iterator target_it = a_new_values; cond_dtor cd(a_new_values, target_it, new_size); _GLIBCXX_DEBUG_ONLY(debug_base::clear()); for (iterator source_it = begin(); source_it != m_end_it; ++source_it) { if (!pred(*source_it)) { new (const_cast(static_cast(target_it))) value_type(*source_it); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(*source_it))); ++target_it; } } reallocate_metadata((node_update*)this, new_size); cd.set_no_action(); { cond_dtor cd1(m_a_values, m_end_it, m_size); } m_a_values = a_new_values; m_size = new_size; m_end_it = target_it; update(node_begin(), (node_update*)this); PB_DS_ASSERT_VALID((*this)) return num_val_ersd; } PB_DS_CLASS_T_DEC template It PB_DS_CLASS_C_DEC:: erase_imp(It it) { PB_DS_ASSERT_VALID((*this)) if (it == end()) return end(); PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it)) #ifdef PB_DS_REGRESSION typename _Alloc::group_adjustor adjust(m_size); #endif _GLIBCXX_DEBUG_ASSERT(m_size > 0); value_vector a_values = s_value_alloc.allocate(m_size - 1); iterator source_it = begin(); iterator source_end_it = end(); iterator target_it = a_values; iterator ret_it = end(); cond_dtor cd(a_values, target_it, m_size - 1); _GLIBCXX_DEBUG_ONLY(size_type cnt = 0;) while (source_it != source_end_it) { if (source_it != it) { _GLIBCXX_DEBUG_ONLY(++cnt;) _GLIBCXX_DEBUG_ASSERT(cnt != m_size); new (const_cast(static_cast(target_it))) value_type(*source_it); ++target_it; } else ret_it = target_it; ++source_it; } _GLIBCXX_DEBUG_ASSERT(m_size > 0); reallocate_metadata((node_update*)this, m_size - 1); cd.set_no_action(); _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(*it));) { cond_dtor cd1(m_a_values, m_end_it, m_size); } m_a_values = a_values; --m_size; m_end_it = m_a_values + m_size; update(node_begin(), (node_update*)this); PB_DS_ASSERT_VALID((*this)) return It(ret_it); } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { point_iterator it = find(r_key); if (it == end()) return false; erase(it); return true; } 4.8.2/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp000064400000003537147547540550020101 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/policy_access_fn_imps.hpp * Contains an implementation class for ov_tree. */ PB_DS_CLASS_T_DEC Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() { return *this; } PB_DS_CLASS_T_DEC const Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() const { return *this; } 4.8.2/ext/pb_ds/detail/ov_tree_map_/traits.hpp000064400000010722147547540550015046 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/traits.hpp * Contains an implementation class for ov_tree_. */ #ifndef PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP #define PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP #include namespace __gnu_pbds { namespace detail { /// Tree traits. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits< Key, Mapped, Cmp_Fn, Node_Update, ov_tree_tag, _Alloc> { private: typedef typename types_traits< Key, Mapped, _Alloc, false>::value_type value_type; public: typedef typename tree_node_metadata_dispatch< Key, Mapped, Cmp_Fn, Node_Update, _Alloc>::type metadata_type; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef ov_tree_node_const_it_< value_type, metadata_type, _Alloc> node_const_iterator; typedef ov_tree_node_it_< value_type, metadata_type, _Alloc> node_iterator; typedef Node_Update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc> node_update; typedef __gnu_pbds::null_node_update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc>* null_node_update_pointer; }; /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits< Key, null_type, Cmp_Fn, Node_Update, ov_tree_tag, _Alloc> { private: typedef typename types_traits< Key, null_type, _Alloc, false>::value_type value_type; public: typedef typename tree_node_metadata_dispatch< Key, null_type, Cmp_Fn, Node_Update, _Alloc>::type metadata_type; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef ov_tree_node_const_it_< value_type, metadata_type, _Alloc> node_const_iterator; typedef node_const_iterator node_iterator; typedef Node_Update< node_const_iterator, node_const_iterator, Cmp_Fn, _Alloc> node_update; typedef __gnu_pbds::null_node_update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc>* null_node_update_pointer; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP 4.8.2/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp000064400000021153147547540550016561 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/node_iterators.hpp * Contains an implementation class for ov_tree_. */ #ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP #define PB_DS_OV_TREE_NODE_ITERATORS_HPP #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \ ov_tree_node_const_it_ /// Const node reference. template class ov_tree_node_const_it_ { protected: typedef typename _Alloc::template rebind< Value_Type>::other::pointer pointer; typedef typename _Alloc::template rebind< Value_Type>::other::const_pointer const_pointer; typedef typename _Alloc::template rebind< Metadata_Type>::other::const_pointer const_metadata_pointer; typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC this_type; protected: template inline static Ptr mid_pointer(Ptr p_begin, Ptr p_end) { _GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); return (p_begin + (p_end - p_begin) / 2); } public: typedef trivial_iterator_tag iterator_category; typedef trivial_iterator_difference_type difference_type; typedef typename _Alloc::template rebind< Value_Type>::other::const_pointer value_type; typedef typename _Alloc::template rebind< typename remove_const< Value_Type>::type>::other::const_pointer reference; typedef typename _Alloc::template rebind< typename remove_const< Value_Type>::type>::other::const_pointer const_reference; typedef Metadata_Type metadata_type; typedef typename _Alloc::template rebind< metadata_type>::other::const_reference metadata_const_reference; public: inline ov_tree_node_const_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : m_p_value(const_cast(p_nd)), m_p_begin_value(const_cast(p_begin_nd)), m_p_end_value(const_cast(p_end_nd)), m_p_metadata(p_metadata) { } inline const_reference operator*() const { return m_p_value; } inline metadata_const_reference get_metadata() const { enum { has_metadata = !is_same::value }; PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata); _GLIBCXX_DEBUG_ASSERT(m_p_metadata != 0); return *m_p_metadata; } /// Returns the node iterator associated with the left node. inline this_type get_l_child() const { if (m_p_begin_value == m_p_value) return (this_type(m_p_begin_value, m_p_begin_value, m_p_begin_value)); const_metadata_pointer p_begin_metadata = m_p_metadata - (m_p_value - m_p_begin_value); return (this_type(mid_pointer(m_p_begin_value, m_p_value), m_p_begin_value, m_p_value, mid_pointer(p_begin_metadata, m_p_metadata))); } /// Returns the node iterator associated with the right node. inline this_type get_r_child() const { if (m_p_value == m_p_end_value) return (this_type(m_p_end_value, m_p_end_value, m_p_end_value)); const_metadata_pointer p_end_metadata = m_p_metadata + (m_p_end_value - m_p_value); return (this_type(mid_pointer(m_p_value + 1, m_p_end_value), m_p_value + 1, m_p_end_value,(m_p_metadata == 0) ? 0 : mid_pointer(m_p_metadata + 1, p_end_metadata))); } inline bool operator==(const this_type& other) const { const bool is_end = m_p_begin_value == m_p_end_value; const bool is_other_end = other.m_p_begin_value == other.m_p_end_value; if (is_end) return (is_other_end); if (is_other_end) return (is_end); return m_p_value == other.m_p_value; } inline bool operator!=(const this_type& other) const { return !operator==(other); } public: pointer m_p_value; pointer m_p_begin_value; pointer m_p_end_value; const_metadata_pointer m_p_metadata; }; #define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \ ov_tree_node_it_ /// Node reference. template class ov_tree_node_it_ : public PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC { private: typedef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC this_type; typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC base_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::const_metadata_pointer const_metadata_pointer; public: typedef trivial_iterator_tag iterator_category; typedef trivial_iterator_difference_type difference_type; typedef typename _Alloc::template rebind< Value_Type>::other::pointer value_type; typedef typename _Alloc::template rebind< typename remove_const< Value_Type>::type>::other::pointer reference; typedef typename _Alloc::template rebind< typename remove_const< Value_Type>::type>::other::pointer const_reference; inline ov_tree_node_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : base_type(p_nd, p_begin_nd, p_end_nd, p_metadata) { } /// Access. inline reference operator*() const { return reference(base_type::m_p_value); } /// Returns the node reference associated with the left node. inline ov_tree_node_it_ get_l_child() const { if (base_type::m_p_begin_value == base_type::m_p_value) return (this_type(base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value)); const_metadata_pointer p_begin_metadata = base_type::m_p_metadata - (base_type::m_p_value - base_type::m_p_begin_value); return (this_type(base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value), base_type::m_p_begin_value, base_type::m_p_value, base_type::mid_pointer(p_begin_metadata, base_type::m_p_metadata))); } /// Returns the node reference associated with the right node. inline ov_tree_node_it_ get_r_child() const { if (base_type::m_p_value == base_type::m_p_end_value) return this_type(base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value); const_metadata_pointer p_end_metadata = base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value); return (this_type(base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value), base_type::m_p_value + 1, base_type::m_p_end_value,(base_type::m_p_metadata == 0)? 0 : base_type::mid_pointer(base_type::m_p_metadata + 1, p_end_metadata))); } }; #undef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC #undef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp000064400000004044147547540550016206 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ov_tree_map_/info_fn_imps.hpp * Contains an implementation class for ov_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { PB_DS_ASSERT_VALID((*this)) return m_size; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_value_alloc.max_size(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return size() == 0; } 4.8.2/ext/pb_ds/detail/types_traits.hpp000064400000023416147547540550013637 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/types_traits.hpp * Contains a traits class of types used by containers. */ #ifndef PB_DS_TYPES_TRAITS_HPP #define PB_DS_TYPES_TRAITS_HPP #include #include #include #include #include namespace __gnu_pbds { namespace detail { /** * @addtogroup traits Traits * @{ */ /// Primary template. template struct no_throw_copies { static const bool __simple = is_simple::value && is_simple::value; typedef integral_constant indicator; }; /// Specialization. template struct no_throw_copies { typedef integral_constant::value> indicator; }; /// Stored value. template struct stored_value { typedef _Tv value_type; value_type m_value; }; /// Stored hash. template struct stored_hash { typedef _Th hash_type; hash_type m_hash; }; /// Primary template for representation of stored data. /// Two types of data can be stored: value and hash. template struct stored_data : public stored_value<_Tv>, public stored_hash<_Th> { }; /// Specialization for representation of stored data of just value type. template struct stored_data<_Tv, null_type> : public stored_value<_Tv> { }; /// Primary template. template struct type_base; /** * Specialization of type_base for the case where the hash value * is not stored alongside each value. */ template struct type_base { public: typedef typename _Alloc::size_type size_type; private: typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef std::pair __value_type; typedef typename _Alloc::template rebind<__value_type> __rebind_v; typedef typename __rebind_v::other __rebind_va; public: typedef typename __rebind_ma::value_type mapped_type; typedef typename __rebind_ma::pointer mapped_pointer; typedef typename __rebind_ma::const_pointer mapped_const_pointer; typedef typename __rebind_ma::reference mapped_reference; typedef typename __rebind_ma::const_reference mapped_const_reference; typedef typename __rebind_va::value_type value_type; typedef typename __rebind_va::pointer pointer; typedef typename __rebind_va::const_pointer const_pointer; typedef typename __rebind_va::reference reference; typedef typename __rebind_va::const_reference const_reference; typedef stored_data stored_data_type; }; /** * Specialization of type_base for the case where the hash value * is stored alongside each value. */ template struct type_base { public: typedef typename _Alloc::size_type size_type; private: typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef std::pair __value_type; typedef typename _Alloc::template rebind<__value_type> __rebind_v; typedef typename __rebind_v::other __rebind_va; public: typedef typename __rebind_ma::value_type mapped_type; typedef typename __rebind_ma::pointer mapped_pointer; typedef typename __rebind_ma::const_pointer mapped_const_pointer; typedef typename __rebind_ma::reference mapped_reference; typedef typename __rebind_ma::const_reference mapped_const_reference; typedef typename __rebind_va::value_type value_type; typedef typename __rebind_va::pointer pointer; typedef typename __rebind_va::const_pointer const_pointer; typedef typename __rebind_va::reference reference; typedef typename __rebind_va::const_reference const_reference; typedef stored_data stored_data_type; }; /** * Specialization of type_base for the case where the hash value * is not stored alongside each value. */ template struct type_base { public: typedef typename _Alloc::size_type size_type; typedef Key value_type; private: typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef typename _Alloc::template rebind __rebind_v; typedef typename __rebind_v::other __rebind_va; public: typedef typename __rebind_ma::value_type mapped_type; typedef typename __rebind_ma::pointer mapped_pointer; typedef typename __rebind_ma::const_pointer mapped_const_pointer; typedef typename __rebind_ma::reference mapped_reference; typedef typename __rebind_ma::const_reference mapped_const_reference; typedef typename __rebind_va::pointer pointer; typedef typename __rebind_va::const_pointer const_pointer; typedef typename __rebind_va::reference reference; typedef typename __rebind_va::const_reference const_reference; typedef stored_data stored_data_type; static null_type s_null_type; }; template null_type type_base::s_null_type; /** * Specialization of type_base for the case where the hash value * is stored alongside each value. */ template struct type_base { public: typedef typename _Alloc::size_type size_type; typedef Key value_type; private: typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef typename _Alloc::template rebind __rebind_v; typedef typename __rebind_v::other __rebind_va; public: typedef typename __rebind_ma::value_type mapped_type; typedef typename __rebind_ma::pointer mapped_pointer; typedef typename __rebind_ma::const_pointer mapped_const_pointer; typedef typename __rebind_ma::reference mapped_reference; typedef typename __rebind_ma::const_reference mapped_const_reference; typedef typename __rebind_va::pointer pointer; typedef typename __rebind_va::const_pointer const_pointer; typedef typename __rebind_va::reference reference; typedef typename __rebind_va::const_reference const_reference; typedef stored_data stored_data_type; static null_type s_null_type; }; template null_type type_base::s_null_type; /// Type base dispatch. template struct type_dispatch { typedef type_base type; }; /// Traits for abstract types. template struct types_traits : public type_dispatch::type { private: typedef no_throw_copies __nothrowcopy; typedef typename _Alloc::template rebind::other __rebind_a; public: typedef typename _Alloc::size_type size_type; typedef typename __rebind_a::value_type key_type; typedef typename __rebind_a::pointer key_pointer; typedef typename __rebind_a::const_pointer key_const_pointer; typedef typename __rebind_a::reference key_reference; typedef typename __rebind_a::const_reference key_const_reference; typedef std::pair comp_hash; typedef integral_constant store_extra; typedef typename __nothrowcopy::indicator no_throw_indicator; store_extra m_store_extra_indicator; no_throw_indicator m_no_throw_copies_indicator; }; //@} } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp000064400000004637147547540550016220 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/debug_fn_imps.hpp * Contains an implementation class for splay_tree_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { base_type::assert_valid(__file, __line); const node_pointer p_head = base_type::m_p_head; assert_special_imp(p_head, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_special_imp(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) return; if (p_nd == base_type::m_p_head) { PB_DS_DEBUG_VERIFY(p_nd->m_special); assert_special_imp(p_nd->m_p_parent, __file, __line); return; } PB_DS_DEBUG_VERIFY(!p_nd->m_special); assert_special_imp(p_nd->m_p_left, __file, __line); assert_special_imp(p_nd->m_p_right, __file, __line); } #endif 4.8.2/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp000064400000017561147547540550016262 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/splay_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: splay(node_pointer p_nd) { while (p_nd->m_p_parent != base_type::m_p_head) { #ifdef _GLIBCXX_DEBUG { node_pointer p_head = base_type::m_p_head; assert_special_imp(p_head, __FILE__, __LINE__); } #endif PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) { base_type::rotate_parent(p_nd); _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); } else { const node_pointer p_parent = p_nd->m_p_parent; const node_pointer p_grandparent = p_parent->m_p_parent; #ifdef _GLIBCXX_DEBUG const size_type total = base_type::recursive_count(p_grandparent); _GLIBCXX_DEBUG_ASSERT(total >= 3); #endif if (p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent) splay_zig_zag_left(p_nd, p_parent, p_grandparent); else if (p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zag_right(p_nd, p_parent, p_grandparent); else if (p_parent->m_p_left == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zig_left(p_nd, p_parent, p_grandparent); else splay_zig_zig_right(p_nd, p_parent, p_grandparent); _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); } PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_right; node_pointer p_c = p_nd->m_p_left; p_nd->m_p_right = p_parent; p_parent->m_p_parent = p_nd; p_nd->m_p_left = p_grandparent; p_grandparent->m_p_parent = p_nd; p_parent->m_p_left = p_b; if (p_b != 0) p_b->m_p_parent = p_parent; p_grandparent->m_p_right = p_c; if (p_c != 0) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_left; node_pointer p_c = p_nd->m_p_right; p_nd->m_p_left = p_parent; p_parent->m_p_parent = p_nd; p_nd->m_p_right = p_grandparent; p_grandparent->m_p_parent = p_nd; p_parent->m_p_right = p_b; if (p_b != 0) p_b->m_p_parent = p_parent; p_grandparent->m_p_left = p_c; if (p_c != 0) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_right; node_pointer p_c = p_parent->m_p_right; p_nd->m_p_right = p_parent; p_parent->m_p_parent = p_nd; p_parent->m_p_right = p_grandparent; p_grandparent->m_p_parent = p_parent; p_parent->m_p_left = p_b; if (p_b != 0) p_b->m_p_parent = p_parent; p_grandparent->m_p_left = p_c; if (p_c != 0) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_left; node_pointer p_c = p_parent->m_p_left; p_nd->m_p_left = p_parent; p_parent->m_p_parent = p_nd; p_parent->m_p_left = p_grandparent; p_grandparent->m_p_parent = p_parent; p_parent->m_p_right = p_b; if (p_b != 0) p_b->m_p_parent = p_parent; p_grandparent->m_p_right = p_c; if (p_c != 0) p_c->m_p_parent = p_grandparent; base_type::update_to_top(p_grandparent, (node_update*)this); splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zz_start(node_pointer p_nd, #ifdef _GLIBCXX_DEBUG node_pointer p_parent, #else node_pointer /*p_parent*/, #endif node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_parent != 0); _GLIBCXX_DEBUG_ASSERT(p_grandparent != 0); const bool grandparent_head = p_grandparent->m_p_parent == base_type::m_p_head; if (grandparent_head) { base_type::m_p_head->m_p_parent = base_type::m_p_head->m_p_parent; p_nd->m_p_parent = base_type::m_p_head; return; } node_pointer p_greatgrandparent = p_grandparent->m_p_parent; p_nd->m_p_parent = p_greatgrandparent; if (p_grandparent == p_greatgrandparent->m_p_left) p_greatgrandparent->m_p_left = p_nd; else p_greatgrandparent->m_p_right = p_nd; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zz_end(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { if (p_nd->m_p_parent == base_type::m_p_head) base_type::m_p_head->m_p_parent = p_nd; this->apply_update(p_grandparent, (node_update*)this); this->apply_update(p_parent, (node_update*)this); this->apply_update(p_nd, (node_update*)this); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) } 4.8.2/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp000064400000005437147547540550022157 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/constructors_destructor_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_S_TREE_NAME() { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : base_type(r_cmp_fn, r_node_update) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) base_type::swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { base_type::m_p_head->m_special = true; } 4.8.2/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp000064400000006431147547540550016430 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/insert_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { PB_DS_ASSERT_VALID((*this)) std::pair ins_pair = insert_leaf_imp(r_value); ins_pair.first.m_p_nd->m_special = false; PB_DS_ASSERT_VALID((*this)) splay(ins_pair.first.m_p_nd); PB_DS_ASSERT_VALID((*this)) return ins_pair; } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf_imp(const_reference r_value) { _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, __LINE__);) if (base_type::m_size == 0) return std::make_pair(base_type::insert_imp_empty(r_value), true); node_pointer p_nd = base_type::m_p_head->m_p_parent; node_pointer p_pot = base_type::m_p_head; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))) { if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value))) { return std::make_pair(point_iterator(p_nd), false); } p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; if (p_pot == base_type::m_p_head) return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true); PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) p_nd = p_pot->m_p_left; if (p_nd == 0) return (std::make_pair(base_type::insert_leaf_new(r_value, p_pot, true), true)); while (p_nd->m_p_right != 0) p_nd = p_nd->m_p_right; return std::make_pair(this->insert_leaf_new(r_value, p_nd, false), true); } 4.8.2/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp000064400000022133147547540550015714 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/splay_tree_.hpp * Contains an implementation class for splay trees. */ /* * This implementation uses an idea from the SGI STL (using a @a header node * which is needed for efficient iteration). Following is the SGI STL * copyright. * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * */ #include #include #include #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR # define PB_DS_S_TREE_NAME splay_tree_map # define PB_DS_S_TREE_BASE_NAME bin_search_tree_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR # define PB_DS_S_TREE_NAME splay_tree_set # define PB_DS_S_TREE_BASE_NAME bin_search_tree_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_S_TREE_NAME #define PB_DS_S_TREE_BASE \ PB_DS_S_TREE_BASE_NAME /** * @brief Splay tree. * @ingroup branch-detail */ template class PB_DS_S_TREE_NAME : public PB_DS_S_TREE_BASE { private: typedef PB_DS_S_TREE_BASE base_type; #ifdef _GLIBCXX_DEBUG typedef base_type debug_base; #endif typedef typename base_type::node_pointer node_pointer; public: typedef splay_tree_tag container_category; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Cmp_Fn cmp_fn; typedef typename base_type::key_type key_type; typedef typename base_type::key_pointer key_pointer; typedef typename base_type::key_const_pointer key_const_pointer; typedef typename base_type::key_reference key_reference; typedef typename base_type::key_const_reference key_const_reference; typedef typename base_type::mapped_type mapped_type; typedef typename base_type::mapped_pointer mapped_pointer; typedef typename base_type::mapped_const_pointer mapped_const_pointer; typedef typename base_type::mapped_reference mapped_reference; typedef typename base_type::mapped_const_reference mapped_const_reference; typedef typename base_type::value_type value_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator point_const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::reverse_iterator reverse_iterator; typedef typename base_type::const_reverse_iterator const_reverse_iterator; typedef typename base_type::node_update node_update; PB_DS_S_TREE_NAME(); PB_DS_S_TREE_NAME(const Cmp_Fn&); PB_DS_S_TREE_NAME(const Cmp_Fn&, const node_update&); PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); template void copy_from_range(It, It); void initialize(); inline std::pair insert(const_reference r_value); inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) std::pair ins_pair = insert_leaf_imp(value_type(r_key, mapped_type())); ins_pair.first.m_p_nd->m_special = false; _GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__)); splay(ins_pair.first.m_p_nd); _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return ins_pair.first.m_p_nd->m_value.second; #else insert(r_key); return base_type::s_null_type; #endif } inline point_iterator find(key_const_reference); inline point_const_iterator find(key_const_reference) const; inline bool erase(key_const_reference); inline iterator erase(iterator it); inline reverse_iterator erase(reverse_iterator); template inline size_type erase_if(Pred); void join(PB_DS_CLASS_C_DEC&); void split(key_const_reference, PB_DS_CLASS_C_DEC&); private: inline std::pair insert_leaf_imp(const_reference); inline node_pointer find_imp(key_const_reference); inline const node_pointer find_imp(key_const_reference) const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char* file, int line) const; void assert_special_imp(const node_pointer, const char* file, int line) const; #endif void splay(node_pointer); inline void splay_zig_zag_left(node_pointer, node_pointer, node_pointer); inline void splay_zig_zag_right(node_pointer, node_pointer, node_pointer); inline void splay_zig_zig_left(node_pointer, node_pointer, node_pointer); inline void splay_zig_zig_right(node_pointer, node_pointer, node_pointer); inline void splay_zz_start(node_pointer, node_pointer, node_pointer); inline void splay_zz_end(node_pointer, node_pointer, node_pointer); inline node_pointer leftmost(node_pointer); void erase_node(node_pointer); }; #define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \ __FILE__, __LINE__);) #include #include #include #include #include #include #include #undef PB_DS_ASSERT_BASE_NODE_CONSISTENT #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_S_TREE_NAME #undef PB_DS_S_TREE_BASE_NAME #undef PB_DS_S_TREE_BASE } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/splay_tree_/node.hpp000064400000007240147547540550014335 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/node.hpp * Contains an implementation struct for splay_tree_'s node. */ #ifndef PB_DS_SPLAY_TREE_NODE_HPP #define PB_DS_SPLAY_TREE_NODE_HPP namespace __gnu_pbds { namespace detail { /// Node for splay tree. template struct splay_tree_node_ { public: typedef Value_Type value_type; typedef Metadata metadata_type; typedef typename _Alloc::template rebind< splay_tree_node_ >::other::pointer node_pointer; typedef typename _Alloc::template rebind::other::reference metadata_reference; typedef typename _Alloc::template rebind::other::const_reference metadata_const_reference; #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value) << "(" << m_metadata << ")"; } #endif inline bool special() const { return m_special; } inline metadata_const_reference get_metadata() const { return m_metadata; } inline metadata_reference get_metadata() { return m_metadata; } value_type m_value; bool m_special; node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; metadata_type m_metadata; }; template struct splay_tree_node_ { public: typedef Value_Type value_type; typedef null_type metadata_type; typedef typename _Alloc::template rebind< splay_tree_node_ >::other::pointer node_pointer; inline bool special() const { return m_special; } #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value); } #endif node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; value_type m_value; bool m_special; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp000064400000007062147547540550017277 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/split_join_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (base_type::join_prep(other) == false) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } node_pointer p_target_r = other.leftmost(other.m_p_head); _GLIBCXX_DEBUG_ASSERT(p_target_r != 0); other.splay(p_target_r); _GLIBCXX_DEBUG_ASSERT(p_target_r == other.m_p_head->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left == 0); p_target_r->m_p_left = base_type::m_p_head->m_p_parent; _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left != 0); p_target_r->m_p_left->m_p_parent = p_target_r; base_type::m_p_head->m_p_parent = p_target_r; p_target_r->m_p_parent = base_type::m_p_head; this->apply_update(p_target_r, (node_update*)this); base_type::join_finish(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (base_type::split_prep(r_key, other) == false) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } node_pointer p_upper_bound = this->upper_bound(r_key).m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_upper_bound != 0); splay(p_upper_bound); _GLIBCXX_DEBUG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head); node_pointer p_new_root = p_upper_bound->m_p_left; _GLIBCXX_DEBUG_ASSERT(p_new_root != 0); base_type::m_p_head->m_p_parent = p_new_root; p_new_root->m_p_parent = base_type::m_p_head; other.m_p_head->m_p_parent = p_upper_bound; p_upper_bound->m_p_parent = other.m_p_head; p_upper_bound->m_p_left = 0; this->apply_update(p_upper_bound, (node_update*)this); base_type::split_finish(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp000064400000010255147547540550016222 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/erase_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { point_iterator it = find(r_key); if (it == base_type::end()) return false; erase(it); return true; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { PB_DS_ASSERT_VALID((*this)) if (it == base_type::end()) return it; iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) return ret_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == base_type::m_p_head) return (it); reverse_iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) return ret_it; } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; iterator it = base_type::begin(); while (it != base_type::end()) { if (pred(*it)) { ++num_ersd; it = erase(it); } else ++it; } PB_DS_ASSERT_VALID((*this)) return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_node(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); splay(p_nd); PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); node_pointer p_l = p_nd->m_p_left; node_pointer p_r = p_nd->m_p_right; base_type::update_min_max_for_erased_node(p_nd); base_type::actual_erase_node(p_nd); if (p_r == 0) { base_type::m_p_head->m_p_parent = p_l; if (p_l != 0) p_l->m_p_parent = base_type::m_p_head; PB_DS_ASSERT_VALID((*this)) return; } node_pointer p_target_r = leftmost(p_r); _GLIBCXX_DEBUG_ASSERT(p_target_r != 0); p_r->m_p_parent = base_type::m_p_head; base_type::m_p_head->m_p_parent = p_r; splay(p_target_r); _GLIBCXX_DEBUG_ONLY(p_target_r->m_p_left = 0); _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_parent == this->m_p_head); _GLIBCXX_DEBUG_ASSERT(this->m_p_head->m_p_parent == p_target_r); p_target_r->m_p_left = p_l; if (p_l != 0) p_l->m_p_parent = p_target_r; PB_DS_ASSERT_VALID((*this)) this->apply_update(p_target_r, (node_update*)this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: leftmost(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); while (p_nd->m_p_left != 0) p_nd = p_nd->m_p_left; return p_nd; } 4.8.2/ext/pb_ds/detail/splay_tree_/traits.hpp000064400000006427147547540550014724 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/traits.hpp * Contains an implementation for splay_tree_. */ #ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP #define PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP #include namespace __gnu_pbds { namespace detail { /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits : public bin_search_tree_traits::value_type, typename tree_node_metadata_dispatch::type, _Alloc>, _Alloc> { }; /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits : public bin_search_tree_traits::value_type, typename tree_node_metadata_dispatch::type, _Alloc>, _Alloc> { }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP 4.8.2/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp000064400000006367147547540550016054 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/find_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { node_pointer p_found = find_imp(r_key); if (p_found != base_type::m_p_head) splay(p_found); return point_iterator(p_found); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { const node_pointer p_found = find_imp(r_key); if (p_found != base_type::m_p_head) const_cast(this)->splay(p_found); return point_iterator(p_found); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(key_const_reference r_key) { _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, __LINE__);) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) return p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return base_type::m_p_head; } PB_DS_CLASS_T_DEC inline const typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(key_const_reference r_key) const { PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) return p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return base_type::m_p_head; } 4.8.2/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp000064400000003231147547540550016052 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file splay_tree_/info_fn_imps.hpp * Contains an implementation. */ 4.8.2/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp000064400000003714147547540550016472 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/debug_fn_imps.hpp * Contains an implementation class for a pairing heap. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0 || base_type::m_p_root->m_p_next_sibling == 0); base_type::assert_valid(__file, __line); } #endif 4.8.2/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp000064400000004712147547540550022431 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation class for a pairing heap. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) push(*(first_it++)); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap(const PB_DS_CLASS_C_DEC& other) : base_type(other) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) base_type::swap(other); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~pairing_heap() { } 4.8.2/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp000064400000005603147547540550016707 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/insert_fn_imps.hpp * Contains an implementation class for a pairing heap. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { PB_DS_ASSERT_VALID((*this)) node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); push_imp(p_new_nd); PB_DS_ASSERT_VALID((*this)) return point_iterator(p_new_nd); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: push_imp(node_pointer p_nd) { p_nd->m_p_l_child = 0; if (base_type::m_p_root == 0) { p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; base_type::m_p_root = p_nd; } else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value)) { p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; base_type::make_child_of(base_type::m_p_root, p_nd); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) base_type::m_p_root = p_nd; } else { base_type::make_child_of(p_nd, base_type::m_p_root); PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { PB_DS_ASSERT_VALID((*this)) remove_node(it.m_p_nd); it.m_p_nd->m_value = r_new_val; push_imp(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) } 4.8.2/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp000064400000012615147547540550016456 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/pairing_heap_.hpp * Contains an implementation class for a pairing heap. */ /* * Pairing heap: * Michael L. Fredman, Robert Sedgewick, Daniel Dominic Sleator, * and Robert Endre Tarjan, The Pairing Heap: * A New Form of Self-Adjusting Heap, Algorithmica, 1(1):111-129, 1986. */ #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ pairing_heap #ifdef _GLIBCXX_DEBUG #define PB_DS_P_HEAP_BASE \ left_child_next_sibling_heap #else #define PB_DS_P_HEAP_BASE \ left_child_next_sibling_heap #endif /** * Pairing heap. * * @ingroup heap-detail */ template class pairing_heap : public PB_DS_P_HEAP_BASE { private: typedef PB_DS_P_HEAP_BASE base_type; typedef typename base_type::node_pointer node_pointer; typedef typename _Alloc::template rebind::other __rebind_a; public: typedef Value_Type value_type; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename __rebind_a::pointer pointer; typedef typename __rebind_a::const_pointer const_pointer; typedef typename __rebind_a::reference reference; typedef typename __rebind_a::const_reference const_reference; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::iterator iterator; pairing_heap(); pairing_heap(const Cmp_Fn&); pairing_heap(const pairing_heap&); void swap(pairing_heap&); ~pairing_heap(); inline point_iterator push(const_reference); void modify(point_iterator, const_reference); inline const_reference top() const; void pop(); void erase(point_iterator); template size_type erase_if(Pred); template void split(Pred, pairing_heap&); void join(pairing_heap&); protected: template void copy_from_range(It, It); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif private: inline void push_imp(node_pointer); node_pointer join_node_children(node_pointer); node_pointer forward_join(node_pointer, node_pointer); node_pointer back_join(node_pointer, node_pointer); void remove_node(node_pointer); }; #define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \ __FILE__, __LINE__);) #include #include #include #include #include #include #undef PB_DS_ASSERT_NODE_CONSISTENT #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_P_HEAP_BASE } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp000064400000007172147547540550017560 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/split_join_fn_imps.hpp * Contains an implementation class for a pairing heap. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) other.clear(); if (base_type::empty()) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); while (p_out != 0) { _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; node_pointer p_next = p_out->m_p_next_sibling; p_out->m_p_l_child = p_out->m_p_next_sibling = p_out->m_p_prev_or_parent = 0; other.push_imp(p_out); p_out = p_next; } PB_DS_ASSERT_VALID(other) node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0; push_imp(p_cur); p_cur = p_next; } PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (other.m_p_root == 0) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } if (base_type::m_p_root == 0) base_type::m_p_root = other.m_p_root; else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value)) { base_type::make_child_of(base_type::m_p_root, other.m_p_root); PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false) base_type::m_p_root = other.m_p_root; } else { base_type::make_child_of(other.m_p_root, base_type::m_p_root); PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) } base_type::m_size += other.m_size; other.m_p_root = 0; other.m_size = 0; PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp000064400000016027147547540550016504 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/erase_fn_imps.hpp * Contains an implementation class for a pairing heap. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: pop() { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_root = join_node_children(base_type::m_p_root); PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false) if (p_new_root != 0) p_new_root->m_p_prev_or_parent = 0; base_type::actual_erase_node(base_type::m_p_root); base_type::m_p_root = p_new_root; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); remove_node(it.m_p_nd); base_type::actual_erase_node(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_node(node_pointer p_nd) { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_child = join_node_children(p_nd); PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false) if (p_nd == base_type::m_p_root) { if (p_new_child != 0) p_new_child->m_p_prev_or_parent = 0; base_type::m_p_root = p_new_child; PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) return; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != 0); if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd) { if (p_new_child != 0) { p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; if (p_new_child->m_p_next_sibling != 0) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child; PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } if (p_new_child != 0) { p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; if (p_new_child->m_p_next_sibling != 0) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child; PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: join_node_children(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); node_pointer p_ret = p_nd->m_p_l_child; if (p_ret == 0) return 0; while (p_ret->m_p_next_sibling != 0) p_ret = forward_join(p_ret, p_ret->m_p_next_sibling); while (p_ret->m_p_prev_or_parent != p_nd) p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret); PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false) return p_ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: forward_join(node_pointer p_nd, node_pointer p_next) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; base_type::make_child_of(p_nd, p_next); return p_next->m_p_next_sibling == 0 ? p_next : p_next->m_p_next_sibling; } if (p_next->m_p_next_sibling != 0) { p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd; p_nd->m_p_next_sibling = p_next->m_p_next_sibling; base_type::make_child_of(p_next, p_nd); return p_nd->m_p_next_sibling; } p_nd->m_p_next_sibling = 0; base_type::make_child_of(p_next, p_nd); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) return p_nd; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: back_join(node_pointer p_nd, node_pointer p_next) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; base_type::make_child_of(p_nd, p_next); PB_DS_ASSERT_NODE_CONSISTENT(p_next, false) return p_next; } p_nd->m_p_next_sibling = 0; base_type::make_child_of(p_next, p_nd); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) return p_nd; } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) if (base_type::empty()) { PB_DS_ASSERT_VALID((*this)) return 0; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); size_type ersd = 0; while (p_out != 0) { ++ersd; node_pointer p_next = p_out->m_p_next_sibling; base_type::actual_erase_node(p_out); p_out = p_next; } node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0; push_imp(p_cur); p_cur = p_next; } PB_DS_ASSERT_VALID((*this)) return ersd; } 4.8.2/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp000064400000003621147547540550016321 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pairing_heap_/find_fn_imps.hpp * Contains an implementation class for a pairing heap. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); return base_type::m_p_root->m_value; } 4.8.2/ext/pb_ds/detail/unordered_iterator/iterator.hpp000064400000007325147547540550016637 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file iterator.hpp * Contains an iterator_ class used for ranging over the elements of the * table. */ /// Range-type iterator. class iterator_ : public const_iterator_ { public: /// Category. typedef std::forward_iterator_tag iterator_category; /// Difference type. typedef typename _Alloc::difference_type difference_type; /// Iterator's value type. typedef value_type_ value_type; /// Iterator's pointer type. typedef pointer_ pointer; /// Iterator's const pointer type. typedef const_pointer_ const_pointer; /// Iterator's reference type. typedef reference_ reference; /// Iterator's const reference type. typedef const_reference_ const_reference; /// Default constructor. inline iterator_() : const_iterator_(0, PB_DS_GEN_POS(), 0) { } /// Conversion to a point-type iterator. inline operator point_iterator_() { return point_iterator_(const_cast(const_iterator_::m_p_value)); } /// Conversion to a point-type iterator. inline operator const point_iterator_() const { return point_iterator_(const_cast(const_iterator_::m_p_value)); } /// Access. pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0); return (const_cast(base_type::m_p_value)); } /// Access. reference operator*() const { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0); return (const_cast(*base_type::m_p_value)); } /// Increments. iterator_& operator++() { base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos); return *this; } /// Increments. iterator_ operator++(int) { iterator_ ret =* this; base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos); return ret; } protected: typedef const_iterator_ base_type; /** * Constructor used by the table to initiate the generalized * pointer and position (e.g., this is called from within a find() * of a table. * */ inline iterator_(pointer p_value, PB_DS_GEN_POS pos, PB_DS_CLASS_C_DEC* p_tbl) : const_iterator_(p_value, pos, p_tbl) { } friend class PB_DS_CLASS_C_DEC; }; 4.8.2/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp000064400000006766147547540550020060 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file point_iterator.hpp * Contains an iterator class returned by the tables' find and insert * methods. */ /// Find type iterator. class point_iterator_ { public: /// Category. typedef trivial_iterator_tag iterator_category; /// Difference type. typedef trivial_iterator_difference_type difference_type; /// Iterator's value type. typedef value_type_ value_type; /// Iterator's pointer type. typedef pointer_ pointer; /// Iterator's const pointer type. typedef const_pointer_ const_pointer; /// Iterator's reference type. typedef reference_ reference; /// Iterator's const reference type. typedef const_reference_ const_reference; /// Default constructor. inline point_iterator_() : m_p_value(0) { } /// Copy constructor. inline point_iterator_(const point_iterator_& other) : m_p_value(other.m_p_value) { } /// Access. pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_value != 0); return (m_p_value); } /// Access. reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_value != 0); return (*m_p_value); } /// Compares content to a different iterator object. bool operator==(const point_iterator_& other) const { return m_p_value == other.m_p_value; } /// Compares content to a different iterator object. bool operator==(const point_const_iterator_& other) const { return m_p_value == other.m_p_value; } /// Compares content to a different iterator object. bool operator!=(const point_iterator_& other) const { return m_p_value != other.m_p_value; } /// Compares content (negatively) to a different iterator object. bool operator!=(const point_const_iterator_& other) const { return m_p_value != other.m_p_value; } inline point_iterator_(pointer p_value) : m_p_value(p_value) { } protected: friend class point_const_iterator_; friend class PB_DS_CLASS_C_DEC; protected: pointer m_p_value; }; 4.8.2/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp000064400000006421147547540550020041 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file unordered_iterator/const_iterator.hpp * Contains an iterator class used for const ranging over the elements of the * table. */ /// Const range-type iterator. class const_iterator_ : public point_const_iterator_ { public: /// Category. typedef std::forward_iterator_tag iterator_category; /// Difference type. typedef typename _Alloc::difference_type difference_type; /// Iterator's value type. typedef value_type_ value_type; /// Iterator's pointer type. typedef pointer_ pointer; /// Iterator's const pointer type. typedef const_pointer_ const_pointer; /// Iterator's reference type. typedef reference_ reference; /// Iterator's const reference type. typedef const_reference_ const_reference; /// Default constructor. const_iterator_() : m_p_tbl(0) { } /// Increments. const_iterator_& operator++() { m_p_tbl->inc_it_state(base_type::m_p_value, m_pos); return *this; } /// Increments. const_iterator_ operator++(int) { const_iterator_ ret =* this; m_p_tbl->inc_it_state(base_type::m_p_value, m_pos); return ret; } protected: typedef point_const_iterator_ base_type; /** * Constructor used by the table to initiate the generalized * pointer and position (e.g., this is called from within a find() * of a table. * */ const_iterator_(const_pointer_ p_value, PB_DS_GEN_POS pos, const PB_DS_CLASS_C_DEC* p_tbl) : point_const_iterator_(p_value), m_p_tbl(p_tbl), m_pos(pos) { } /** * Pointer to the table object which created the iterator (used for * incrementing its position. * */ const PB_DS_CLASS_C_DEC* m_p_tbl; PB_DS_GEN_POS m_pos; friend class PB_DS_CLASS_C_DEC; }; 4.8.2/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp000064400000007336147547540550021260 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file unordered_iterator/point_const_iterator.hpp * Contains an iterator class returned by the tables' const find and insert * methods. */ class point_iterator_; /// Const point-type iterator. class point_const_iterator_ { public: /// Category. typedef trivial_iterator_tag iterator_category; /// Difference type. typedef trivial_iterator_difference_type difference_type; /// Iterator's value type. typedef value_type_ value_type; /// Iterator's pointer type. typedef pointer_ pointer; /// Iterator's const pointer type. typedef const_pointer_ const_pointer; /// Iterator's reference type. typedef reference_ reference; /// Iterator's const reference type. typedef const_reference_ const_reference; inline point_const_iterator_(const_pointer p_value) : m_p_value(p_value) { } /// Default constructor. inline point_const_iterator_() : m_p_value(0) { } /// Copy constructor. inline point_const_iterator_(const point_const_iterator_& other) : m_p_value(other.m_p_value) { } /// Copy constructor. inline point_const_iterator_(const point_iterator_& other) : m_p_value(other.m_p_value) { } /// Access. const_pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_value != 0); return m_p_value; } /// Access. const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_value != 0); return *m_p_value; } /// Compares content to a different iterator object. bool operator==(const point_iterator_& other) const { return m_p_value == other.m_p_value; } /// Compares content to a different iterator object. bool operator==(const point_const_iterator_& other) const { return m_p_value == other.m_p_value; } /// Compares content (negatively) to a different iterator object. bool operator!=(const point_iterator_& other) const { return m_p_value != other.m_p_value; } /// Compares content (negatively) to a different iterator object. bool operator!=(const point_const_iterator_& other) const { return m_p_value != other.m_p_value; } protected: const_pointer m_p_value; friend class point_iterator_; friend class PB_DS_CLASS_C_DEC; }; 4.8.2/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp000064400000003652147547540560016015 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/trace_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ #ifdef PB_DS_THIN_HEAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << std::endl; std::cerr << "m_p_max " << m_p_max << std::endl; base_type::trace(); } #endif // #ifdef PB_DS_THIN_HEAP_TRACE_ 4.8.2/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp000064400000020142147547540560015273 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/thin_heap_.hpp * Contains an implementation class for a thin heap. */ #ifndef PB_DS_THIN_HEAP_HPP #define PB_DS_THIN_HEAP_HPP #include #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ thin_heap #ifdef _GLIBCXX_DEBUG #define PB_DS_BASE_T_P \ #else #define PB_DS_BASE_T_P \ #endif /** * Thin heap. * * @ingroup heap-detail * * See Tarjan and Kaplan. */ template class thin_heap : public left_child_next_sibling_heap PB_DS_BASE_T_P { private: typedef typename _Alloc::template rebind::other __rebind_a; typedef left_child_next_sibling_heap PB_DS_BASE_T_P base_type; protected: typedef typename base_type::node node; typedef typename base_type::node_pointer node_pointer; typedef typename base_type::node_const_pointer node_const_pointer; public: typedef Value_Type value_type; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename __rebind_a::pointer pointer; typedef typename __rebind_a::const_pointer const_pointer; typedef typename __rebind_a::reference reference; typedef typename __rebind_a::const_reference const_reference; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; inline point_iterator push(const_reference); void modify(point_iterator, const_reference); inline const_reference top() const; void pop(); void erase(point_iterator); inline void clear(); template size_type erase_if(Pred); template void split(Pred, PB_DS_CLASS_C_DEC&); void join(PB_DS_CLASS_C_DEC&); protected: thin_heap(); thin_heap(const Cmp_Fn&); thin_heap(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); ~thin_heap(); template void copy_from_range(It, It); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; void assert_max(const char*, int) const; #endif #ifdef PB_DS_THIN_HEAP_TRACE_ void trace() const; #endif private: enum { max_rank = (sizeof(size_type) << 4) + 2 }; void initialize(); inline void update_max(node_pointer); inline void fix(node_pointer); inline void fix_root(node_pointer); inline void fix_sibling_rank_1_unmarked(node_pointer); inline void fix_sibling_rank_1_marked(node_pointer); inline void fix_sibling_general_unmarked(node_pointer); inline void fix_sibling_general_marked(node_pointer); inline void fix_child(node_pointer); inline static void make_root(node_pointer); inline void make_root_and_link(node_pointer); inline void remove_max_node(); void to_aux_except_max(); inline void add_to_aux(node_pointer); inline void make_from_aux(); inline size_type rank_bound(); inline void make_child_of(node_pointer, node_pointer); inline void remove_node(node_pointer); inline node_pointer join(node_pointer, node_pointer) const; #ifdef _GLIBCXX_DEBUG void assert_node_consistent(node_const_pointer, bool, const char*, int) const; void assert_aux_null(const char*, int) const; #endif node_pointer m_p_max; node_pointer m_a_aux[max_rank]; }; enum { num_distinct_rank_bounds = 48 }; // Taken from the SGI implementation; acknowledged in the docs. static const std::size_t g_a_rank_bounds[num_distinct_rank_bounds] = { /* Dealing cards... */ /* 0 */ 0ul, /* 1 */ 1ul, /* 2 */ 1ul, /* 3 */ 2ul, /* 4 */ 4ul, /* 5 */ 6ul, /* 6 */ 11ul, /* 7 */ 17ul, /* 8 */ 29ul, /* 9 */ 46ul, /* 10 */ 76ul, /* 11 */ 122ul, /* 12 */ 199ul, /* 13 */ 321ul, /* 14 */ 521ul, /* 15 */ 842ul, /* 16 */ 1364ul, /* 17 */ 2206ul, /* 18 */ 3571ul, /* 19 */ 5777ul, /* 20 */ 9349ul, /* 21 */ 15126ul, /* 22 */ 24476ul, /* 23 */ 39602ul, /* 24 */ 64079ul, /* 25 */ 103681ul, /* 26 */ 167761ul, /* 27 */ 271442ul, /* 28 */ 439204ul, /* 29 */ 710646ul, /* 30 */ 1149851ul, /* 31 */ 1860497ul, /* 32 */ 3010349ul, /* 33 */ 4870846ul, /* 34 */ 7881196ul, /* 35 */ 12752042ul, /* 36 */ 20633239ul, /* 37 */ 33385282ul, /* 38 */ 54018521ul, /* 39 */ 87403803ul, /* 40 */ 141422324ul, /* 41 */ 228826127ul, /* 42 */ 370248451ul, /* 43 */ 599074578ul, /* 44 */ 969323029ul, /* 45 */ 1568397607ul, /* 46 */ 2537720636ul, /* 47 */ 4106118243ul /* Pot's good, let's play */ }; #define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \ __FILE__, __LINE__);) #define PB_DS_ASSERT_AUX_NULL(X) \ _GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);) #include #include #include #include #include #include #include #undef PB_DS_ASSERT_AUX_NULL #undef PB_DS_ASSERT_NODE_CONSISTENT #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_T_P } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp000064400000007432147547540560016005 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/debug_fn_imps.hpp * Contains an implementation for thin_heap_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { base_type::assert_valid(__file, __line); assert_node_consistent(base_type::m_p_root, true, __file, __line); assert_max(__file, __line); assert_aux_null(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_aux_null(const char* __file, int __line) const { for (size_type i = 0; i < max_rank; ++i) PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_max(const char* __file, int __line) const { if (m_p_max == 0) { PB_DS_DEBUG_VERIFY(base_type::empty()); return; } PB_DS_DEBUG_VERIFY(!base_type::empty()); PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0); PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 0); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent(node_const_pointer p_nd, bool root, const char* __file, int __line) const { base_type::assert_node_consistent(p_nd, root, __file, __line); if (p_nd == 0) return; assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line); assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); if (!root) { if (p_nd->m_metadata == 0) PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0); else PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); } if (p_nd->m_p_l_child != 0) PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); const bool unmarked_valid = (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0) || (p_nd->m_p_l_child != 0 && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); const bool marked_valid = (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1) || (p_nd->m_p_l_child != 0 && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid); if (root) PB_DS_DEBUG_VERIFY(unmarked_valid); } #endif 4.8.2/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp000064400000005602147547540560021742 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation for thin_heap_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) push(*(first_it++)); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: thin_heap() : m_p_max(0) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: thin_heap(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn), m_p_max(0) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: thin_heap(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); m_p_max = base_type::m_p_root; for (node_pointer p_nd = base_type::m_p_root; p_nd != 0; p_nd = p_nd->m_p_next_sibling) if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) m_p_max = p_nd; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) base_type::swap(other); std::swap(m_p_max, other.m_p_max); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~thin_heap() { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { std::fill(m_a_aux, m_a_aux + max_rank, static_cast(0)); } 4.8.2/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp000064400000016473147547540560016230 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/insert_fn_imps.hpp * Contains an implementation for thin_heap_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); p_nd->m_metadata = 0; p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0; if (base_type::m_p_root == 0) { p_nd->m_p_next_sibling = 0; m_p_max = base_type::m_p_root = p_nd; PB_DS_ASSERT_VALID((*this)) return point_iterator(p_nd); } p_nd->m_p_next_sibling = base_type::m_p_root; base_type::m_p_root->m_p_prev_or_parent = 0; base_type::m_p_root = p_nd; update_max(p_nd); PB_DS_ASSERT_VALID((*this)) return point_iterator(p_nd); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: make_root(node_pointer p_nd) { p_nd->m_metadata = p_nd->m_p_l_child == 0 ? 0 : 1 + p_nd->m_p_l_child->m_metadata; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: make_root_and_link(node_pointer p_nd) { make_root(p_nd); p_nd->m_p_prev_or_parent = 0; p_nd->m_p_next_sibling = base_type::m_p_root; if (base_type::m_p_root != 0) base_type::m_p_root->m_p_prev_or_parent = 0; base_type::m_p_root = p_nd; update_max(p_nd); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix(node_pointer p_y) { while (true) { if (p_y->m_p_prev_or_parent == 0) { fix_root(p_y); return; } else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0) { if (p_y->m_p_l_child != 0) { fix_sibling_rank_1_unmarked(p_y); return; } fix_sibling_rank_1_marked(p_y); p_y = p_y->m_p_prev_or_parent; } else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0); if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2) { fix_sibling_general_unmarked(p_y); return; } fix_sibling_general_marked(p_y); p_y = p_y->m_p_prev_or_parent; } else if ((p_y->m_p_l_child == 0&& p_y->m_metadata == 2) ||(p_y->m_p_l_child != 0&& p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3)) { node_pointer p_z = p_y->m_p_prev_or_parent; fix_child(p_y); p_y = p_z; } else return; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_root(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0); make_root(p_y); PB_DS_ASSERT_NODE_CONSISTENT(p_y, true) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_sibling_rank_1_unmarked(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); _GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;) _GLIBCXX_DEBUG_ASSERT(p_w != 0); _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0); _GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0); p_y->m_p_next_sibling = p_y->m_p_l_child; p_y->m_p_next_sibling->m_p_prev_or_parent = p_y; p_y->m_p_l_child = 0; PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_sibling_rank_1_marked(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0); p_y->m_metadata = 0; PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_sibling_general_unmarked(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); node_pointer p_w = p_y->m_p_l_child; _GLIBCXX_DEBUG_ASSERT(p_w != 0); _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0); p_y->m_p_l_child = p_w->m_p_next_sibling; p_w->m_p_next_sibling->m_p_prev_or_parent = p_y; p_w->m_p_next_sibling = p_y->m_p_next_sibling; _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0); p_w->m_p_next_sibling->m_p_prev_or_parent = p_w; p_y->m_p_next_sibling = p_w; p_w->m_p_prev_or_parent = p_y; PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_sibling_general_marked(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); --p_y->m_metadata; PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: fix_child(node_pointer p_y) { _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); if (p_y->m_p_next_sibling != 0) p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent; if (p_y->m_p_prev_or_parent->m_p_l_child == p_y) p_y->m_p_prev_or_parent->m_p_l_child = p_y->m_p_next_sibling; else p_y->m_p_prev_or_parent->m_p_next_sibling = p_y->m_p_next_sibling; make_root_and_link(p_y); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = it.m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); const bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value); p_nd->m_value = r_new_val; if (smaller) { remove_node(p_nd); p_nd->m_p_l_child = 0; make_root_and_link(p_nd); PB_DS_ASSERT_VALID((*this)) return; } if (p_nd->m_p_prev_or_parent == 0) { update_max(p_nd); PB_DS_ASSERT_VALID((*this)) return; } node_pointer p_y = p_nd->m_p_prev_or_parent; _GLIBCXX_DEBUG_ASSERT(p_y != 0); if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y; if (p_y->m_p_l_child == p_nd) p_y->m_p_l_child = p_nd->m_p_next_sibling; else p_y->m_p_next_sibling = p_nd->m_p_next_sibling; fix(p_y); make_root_and_link(p_nd); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_max(node_pointer p_nd) { if (m_p_max == 0 || Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) m_p_max = p_nd; } 4.8.2/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp000064400000006123147547540560017065 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/split_join_fn_imps.hpp * Contains an implementation for thin_heap_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) other.clear(); if (base_type::empty()) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); while (p_out != 0) { _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; node_pointer p_next = p_out->m_p_next_sibling; other.make_root_and_link(p_out); p_out = p_next; } PB_DS_ASSERT_VALID(other) node_pointer p_cur = base_type::m_p_root; m_p_max = 0; base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; make_root_and_link(p_cur); p_cur = p_next; } PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) node_pointer p_other = other.m_p_root; while (p_other != 0) { node_pointer p_next = p_other->m_p_next_sibling; make_root_and_link(p_other); p_other = p_next; } base_type::m_size += other.m_size; other.m_p_root = 0; other.m_size = 0; other.m_p_max = 0; PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp000064400000013647147547540560016023 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/erase_fn_imps.hpp * Contains an implementation for thin_heap_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: pop() { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); node_pointer p_nd = m_p_max; remove_max_node(); base_type::actual_erase_node(p_nd); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: remove_max_node() { to_aux_except_max(); make_from_aux(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: to_aux_except_max() { node_pointer p_add = base_type::m_p_root; while (p_add != m_p_max) { node_pointer p_next_add = p_add->m_p_next_sibling; add_to_aux(p_add); p_add = p_next_add; } p_add = m_p_max->m_p_l_child; while (p_add != 0) { node_pointer p_next_add = p_add->m_p_next_sibling; p_add->m_metadata = p_add->m_p_l_child == 0 ? 0 : p_add->m_p_l_child->m_metadata + 1; add_to_aux(p_add); p_add = p_next_add; } p_add = m_p_max->m_p_next_sibling; while (p_add != 0) { node_pointer p_next_add = p_add->m_p_next_sibling; add_to_aux(p_add); p_add = p_next_add; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: add_to_aux(node_pointer p_nd) { size_type r = p_nd->m_metadata; while (m_a_aux[r] != 0) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); if (Cmp_Fn::operator()(m_a_aux[r]->m_value, p_nd->m_value)) make_child_of(m_a_aux[r], p_nd); else { make_child_of(p_nd, m_a_aux[r]); p_nd = m_a_aux[r]; } m_a_aux[r] = 0; ++r; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); m_a_aux[r] = p_nd; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: make_child_of(node_pointer p_nd, node_pointer p_new_parent) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_new_parent->m_metadata); _GLIBCXX_DEBUG_ASSERT(m_a_aux[p_nd->m_metadata] == p_nd || m_a_aux[p_nd->m_metadata] == p_new_parent); ++p_new_parent->m_metadata; base_type::make_child_of(p_nd, p_new_parent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: make_from_aux() { base_type::m_p_root = m_p_max = 0; const size_type rnk_bnd = rank_bound(); size_type i = 0; while (i < rnk_bnd) { if (m_a_aux[i] != 0) { make_root_and_link(m_a_aux[i]); m_a_aux[i] = 0; } ++i; } PB_DS_ASSERT_AUX_NULL((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: remove_node(node_pointer p_nd) { node_pointer p_parent = p_nd; while (base_type::parent(p_parent) != 0) p_parent = base_type::parent(p_parent); base_type::bubble_to_top(p_nd); m_p_max = p_nd; node_pointer p_fix = base_type::m_p_root; while (p_fix != 0&& p_fix->m_p_next_sibling != p_parent) p_fix = p_fix->m_p_next_sibling; if (p_fix != 0) p_fix->m_p_next_sibling = p_nd; remove_max_node(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: clear() { base_type::clear(); m_p_max = 0; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_nd = it.m_p_nd; remove_node(p_nd); base_type::actual_erase_node(p_nd); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) if (base_type::empty()) { PB_DS_ASSERT_VALID((*this)) return 0; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); size_type ersd = 0; while (p_out != 0) { ++ersd; node_pointer p_next = p_out->m_p_next_sibling; base_type::actual_erase_node(p_out); p_out = p_next; } node_pointer p_cur = base_type::m_p_root; m_p_max = base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; make_root_and_link(p_cur); p_cur = p_next; } PB_DS_ASSERT_VALID((*this)) return ersd; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: rank_bound() { using namespace std; const size_t* const p_upper = std::upper_bound(g_a_rank_bounds, g_a_rank_bounds + num_distinct_rank_bounds, base_type::m_size); if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds) return max_rank; return (p_upper - g_a_rank_bounds); } 4.8.2/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp000064400000003640147547540560015634 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file thin_heap_/find_fn_imps.hpp * Contains an implementation for thin_heap_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); return m_p_max->m_value; } 4.8.2/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp000064400000004667147547540560016661 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_range_hashing.hpp * Contains a range hashing policy. */ #ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP #define PB_DS_SAMPLE_RANGE_HASHING_HPP namespace __gnu_pbds { /// A sample range-hashing functor. class sample_range_hashing { public: /// Size type. typedef std::size_t size_type; /// Default constructor. sample_range_hashing(); /// Copy constructor. sample_range_hashing(const sample_range_hashing& other); /// Swaps content. inline void swap(sample_range_hashing& other); protected: /// Notifies the policy object that the container's size has /// changed to argument's size. void notify_resized(size_type); /// Transforms the __hash value hash into a ranged-hash value. inline size_type operator()(size_type ) const; }; } #endif // #ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP 4.8.2/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp000064400000024573147547540560015447 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ranged_hash_fn.hpp * Contains a unified ranged hash functor, allowing the hash tables * to deal with a single class for ranged hashing. */ #ifndef PB_DS_RANGED_HASH_FN_HPP #define PB_DS_RANGED_HASH_FN_HPP #include #include namespace __gnu_pbds { namespace detail { /// Primary template. template class ranged_hash_fn; #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_hash_fn /** * Specialization 1 * The client supplies a hash function and a ranged hash function, * and requests that hash values not be stored. **/ template class ranged_hash_fn< Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false> : public Hash_Fn, public Comb_Hash_Fn { protected: typedef typename _Alloc::size_type size_type; typedef Hash_Fn hash_fn_base; typedef Comb_Hash_Fn comb_hash_fn_base; typedef typename _Alloc::template rebind< Key>::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; ranged_hash_fn(size_type); ranged_hash_fn(size_type, const Hash_Fn&); ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&); void swap(PB_DS_CLASS_C_DEC&); void notify_resized(size_type); inline size_type operator()(key_const_reference) const; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : Hash_Fn(r_hash_fn) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn) { comb_hash_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_hash_fn_base::swap(other); std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type size) { comb_hash_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(key_const_reference r_key) const { return (comb_hash_fn_base::operator()(hash_fn_base::operator()(r_key)));} #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_hash_fn /** * Specialization 2 * The client supplies a hash function and a ranged hash function, * and requests that hash values be stored. **/ template class ranged_hash_fn : public Hash_Fn, public Comb_Hash_Fn { protected: typedef typename _Alloc::size_type size_type; typedef std::pair comp_hash; typedef Hash_Fn hash_fn_base; typedef Comb_Hash_Fn comb_hash_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; ranged_hash_fn(size_type); ranged_hash_fn(size_type, const Hash_Fn&); ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&); void swap(PB_DS_CLASS_C_DEC&); void notify_resized(size_type); inline comp_hash operator()(key_const_reference) const; inline comp_hash operator()(key_const_reference, size_type) const; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : Hash_Fn(r_hash_fn) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn) { comb_hash_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_hash_fn_base::swap(other); std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type size) { comb_hash_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: operator()(key_const_reference r_key) const { const size_type hash = hash_fn_base::operator()(r_key); return std::make_pair(comb_hash_fn_base::operator()(hash), hash); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: operator() #ifdef _GLIBCXX_DEBUG (key_const_reference r_key, size_type hash) const #else (key_const_reference /*r_key*/, size_type hash) const #endif { _GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key)); return std::make_pair(comb_hash_fn_base::operator()(hash), hash); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_hash_fn /** * Specialization 3 * The client does not supply a hash function (by specifying * null_type as the Hash_Fn parameter), and requests that hash * values not be stored. **/ template class ranged_hash_fn : public Comb_Hash_Fn { protected: typedef typename _Alloc::size_type size_type; typedef Comb_Hash_Fn comb_hash_fn_base; ranged_hash_fn(size_type); ranged_hash_fn(size_type, const Comb_Hash_Fn&); ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&); void swap(PB_DS_CLASS_C_DEC&); }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) : Comb_Hash_Fn(r_comb_hash_fn) { } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const null_type& r_null_type, const Comb_Hash_Fn& r_comb_hash_fn) : Comb_Hash_Fn(r_comb_hash_fn) { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_hash_fn_base::swap(other); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_hash_fn /** * Specialization 4 * The client does not supply a hash function (by specifying * null_type as the Hash_Fn parameter), and requests that hash * values be stored. **/ template class ranged_hash_fn : public Comb_Hash_Fn { protected: typedef typename _Alloc::size_type size_type; typedef Comb_Hash_Fn comb_hash_fn_base; ranged_hash_fn(size_type); ranged_hash_fn(size_type, const Comb_Hash_Fn&); ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&); void swap(PB_DS_CLASS_C_DEC&); }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size) { Comb_Hash_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) : Comb_Hash_Fn(r_comb_hash_fn) { } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_hash_fn(size_type size, const null_type& r_null_type, const Comb_Hash_Fn& r_comb_hash_fn) : Comb_Hash_Fn(r_comb_hash_fn) { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_hash_fn_base::swap(other); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp000064400000004527147547540560017310 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file mod_based_range_hashing.hpp * Contains a range hashing policy base. */ #ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP #define PB_DS_MOD_BASED_RANGE_HASHING_HPP namespace __gnu_pbds { namespace detail { /// Mod based range hashing. template class mod_based_range_hashing { protected: typedef Size_Type size_type; void swap(mod_based_range_hashing& other) { std::swap(m_size, other.m_size); } void notify_resized(size_type s) { m_size = s; } inline size_type range_hash(size_type s) const { return s % m_size; } private: size_type m_size; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP 4.8.2/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp000064400000003571147547540560016505 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file linear_probe_fn_imp.hpp * Contains a probe policy implementation */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(size_type i) const { return (i); } 4.8.2/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp000064400000003600147547540560017201 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file quadratic_probe_fn_imp.hpp * Contains a probe policy implementation */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(size_type i) const { return (i* i); } 4.8.2/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp000064400000004056147547540560020346 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file direct_mod_range_hashing_imp.hpp * Contains a range-hashing policy implementation */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { mod_based_base::swap(other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type n) { mod_based_base::notify_resized(n); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(size_type hash) const { return mod_based_base::range_hash(hash); } 4.8.2/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp000064400000006332147547540560017460 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file mask_based_range_hashing.hpp * Contains a range hashing policy base. */ #ifndef PB_DS_MASK_BASED_RANGE_HASHING_HPP #define PB_DS_MASK_BASED_RANGE_HASHING_HPP namespace __gnu_pbds { namespace detail { /// Range hashing policy. template class mask_based_range_hashing { protected: typedef Size_Type size_type; void swap(mask_based_range_hashing& other) { std::swap(m_mask, other.m_mask); } void notify_resized(size_type size); inline size_type range_hash(size_type hash) const { return size_type(hash & m_mask); } private: size_type m_mask; const static size_type s_num_bits_in_size_type; const static size_type s_highest_bit_1; }; template const typename mask_based_range_hashing::size_type mask_based_range_hashing::s_num_bits_in_size_type = sizeof(typename mask_based_range_hashing::size_type) << 3; template const typename mask_based_range_hashing::size_type mask_based_range_hashing::s_highest_bit_1 = static_cast::size_type>(1) << (s_num_bits_in_size_type - 1); template void mask_based_range_hashing:: notify_resized(size_type size) { size_type i = 0; while (size ^ s_highest_bit_1) { size <<= 1; ++i; } m_mask = 1; i += 2; while (i++ < s_num_bits_in_size_type) m_mask = (m_mask << 1) ^ 1; } } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp000064400000024304147547540560015623 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file ranged_probe_fn.hpp * Contains a unified ranged probe functor, allowing the probe tables to deal with * a single class for ranged probeing. */ #ifndef PB_DS_RANGED_PROBE_FN_HPP #define PB_DS_RANGED_PROBE_FN_HPP #include #include namespace __gnu_pbds { namespace detail { /// Primary template. template class ranged_probe_fn; #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_probe_fn /** * Specialization 1 * The client supplies a probe function and a ranged probe * function, and requests that hash values not be stored. **/ template class ranged_probe_fn : public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn { protected: typedef typename _Alloc::size_type size_type; typedef Comb_Probe_Fn comb_probe_fn_base; typedef Hash_Fn hash_fn_base; typedef Probe_Fn probe_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; ranged_probe_fn(size_type); ranged_probe_fn(size_type, const Hash_Fn&); ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&); ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&, const Probe_Fn&); void swap(PB_DS_CLASS_C_DEC&); void notify_resized(size_type); inline size_type operator()(key_const_reference) const; inline size_type operator()(key_const_reference, size_type, size_type) const; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size) { Comb_Probe_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) : Hash_Fn(r_hash_fn) { Comb_Probe_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn) : Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn) : Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_probe_fn_base::swap(other); std::swap((Hash_Fn& )(*this), (Hash_Fn&)other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type size) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(key_const_reference r_key) const { return comb_probe_fn_base::operator()(hash_fn_base::operator()(r_key)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(key_const_reference, size_type hash, size_type i) const { return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i)); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ ranged_probe_fn /** * Specialization 2- The client supplies a probe function and a ranged * probe function, and requests that hash values not be stored. **/ template class ranged_probe_fn : public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn { protected: typedef typename _Alloc::size_type size_type; typedef std::pair comp_hash; typedef Comb_Probe_Fn comb_probe_fn_base; typedef Hash_Fn hash_fn_base; typedef Probe_Fn probe_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; ranged_probe_fn(size_type); ranged_probe_fn(size_type, const Hash_Fn&); ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&); ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&, const Probe_Fn&); void swap(PB_DS_CLASS_C_DEC&); void notify_resized(size_type); inline comp_hash operator()(key_const_reference) const; inline size_type operator()(key_const_reference, size_type, size_type) const; inline size_type operator()(key_const_reference, size_type) const; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size) { Comb_Probe_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) : Hash_Fn(r_hash_fn) { Comb_Probe_Fn::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn) : Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn) : Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { comb_probe_fn_base::swap(other); std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type size) { comb_probe_fn_base::notify_resized(size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: operator()(key_const_reference r_key) const { const size_type hash = hash_fn_base::operator()(r_key); return std::make_pair(comb_probe_fn_base::operator()(hash), hash); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(key_const_reference, size_type hash, size_type i) const { return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator() #ifdef _GLIBCXX_DEBUG (key_const_reference r_key, size_type hash) const #else (key_const_reference /*r_key*/, size_type hash) const #endif { _GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key)); return hash; } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC /** * Specialization 3 and 4 * The client does not supply a hash function or probe function, * and requests that hash values not be stored. **/ template class ranged_probe_fn : public Comb_Probe_Fn { protected: typedef typename _Alloc::size_type size_type; typedef Comb_Probe_Fn comb_probe_fn_base; typedef typename _Alloc::template rebind::other key_allocator; typedef typename key_allocator::const_reference key_const_reference; ranged_probe_fn(size_type size) { Comb_Probe_Fn::notify_resized(size); } ranged_probe_fn(size_type, const Comb_Probe_Fn& r_comb_probe_fn) : Comb_Probe_Fn(r_comb_probe_fn) { } ranged_probe_fn(size_type, const null_type&, const Comb_Probe_Fn& r_comb_probe_fn, const null_type&) : Comb_Probe_Fn(r_comb_probe_fn) { } void swap(ranged_probe_fn& other) { comb_probe_fn_base::swap(other); } }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp000064400000004363147547540560015647 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_probe_fn.hpp * Contains a sample probe policy. */ #ifndef PB_DS_SAMPLE_PROBE_FN_HPP #define PB_DS_SAMPLE_PROBE_FN_HPP namespace __gnu_pbds { /// A sample probe policy. class sample_probe_fn { public: typedef std::size_t size_type; /// Default constructor. sample_probe_fn(); /// Copy constructor. sample_probe_fn(const sample_probe_fn&); /// Swaps content. inline void swap(sample_probe_fn&); protected: /// Returns the i-th offset from the hash value of some key r_key. inline size_type operator()(key_const_reference r_key, size_type i) const; }; } #endif // #ifndef PB_DS_SAMPLE_PROBE_FN_HPP 4.8.2/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp000064400000003731147547540560015276 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file probe_fn_base.hpp * Contains a probe policy base. */ #ifndef PB_DS_PROBE_FN_BASE_HPP #define PB_DS_PROBE_FN_BASE_HPP #include namespace __gnu_pbds { namespace detail { /// Probe functor base. template class probe_fn_base { protected: ~probe_fn_base() { } }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp000064400000005046147547540560017166 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_ranged_probe_fn.hpp * Contains a ranged probe policy. */ #ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP #define PB_DS_SAMPLE_RANGED_PROBE_FN_HPP namespace __gnu_pbds { /// A sample ranged-probe functor. class sample_ranged_probe_fn { public: typedef std::size_t size_type; // Default constructor. sample_ranged_probe_fn(); // Copy constructor. sample_ranged_probe_fn(const sample_ranged_probe_fn&); // Swaps content. inline void swap(sample_ranged_probe_fn&); protected: // Notifies the policy object that the container's __size has // changed to size. void notify_resized(size_type); // Transforms the const key reference r_key into the i-th position // within the table. This method is called for each collision within // the probe sequence. inline size_type operator()(key_const_reference, std::size_t, size_type) const; }; } #endif // #ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP 4.8.2/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp000064400000004645147547540560017006 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_ranged_hash_fn.hpp * Contains a ranged hash policy. */ #ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP #define PB_DS_SAMPLE_RANGED_HASH_FN_HPP namespace __gnu_pbds { /// A sample ranged-hash functor. class sample_ranged_hash_fn { public: typedef std::size_t size_type; /// Default constructor. sample_ranged_hash_fn(); /// Copy constructor. sample_ranged_hash_fn(const sample_ranged_hash_fn&); /// Swaps content. inline void swap(sample_ranged_hash_fn&); protected: /// Notifies the policy object that the container's __size has /// changed to size. void notify_resized(size_type); /// Transforms key_const_reference into a position within the table. inline size_type operator()(key_const_reference) const; }; } #endif // #ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP 4.8.2/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp000064400000004070147547540560020516 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file direct_mask_range_hashing_imp.hpp * Contains a range-hashing policy implementation */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { mask_based_base::swap(other); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type size) { mask_based_base::notify_resized(size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: operator()(size_type hash) const { return mask_based_base::range_hash(hash); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp000064400000030203147547540560017624 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/bin_search_tree_.hpp * Contains an implementation class for binary search tree. */ #include #include #include #include #include #include #include #ifdef _GLIBCXX_DEBUG #include #endif #include #include #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_BIN_TREE_NAME bin_search_tree_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_BIN_TREE_NAME bin_search_tree_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_BIN_TREE_NAME #define PB_DS_BIN_TREE_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base, \ typename _Alloc::template rebind::other::const_reference> #endif #ifdef PB_DS_TREE_TRACE #define PB_DS_TREE_TRACE_BASE_C_DEC \ tree_trace_base #endif /* * @brief Binary search tree (BST). * * This implementation uses an idea from the SGI STL (using a @a * header node which is needed for efficient iteration). */ template class PB_DS_BIN_TREE_NAME : #ifdef _GLIBCXX_DEBUG public PB_DS_DEBUG_MAP_BASE_C_DEC, #endif #ifdef PB_DS_TREE_TRACE public PB_DS_TREE_TRACE_BASE_C_DEC, #endif public Cmp_Fn, public PB_DS_BIN_TREE_TRAITS_BASE, public Node_And_It_Traits::node_update { typedef Node_And_It_Traits traits_type; protected: typedef PB_DS_BIN_TREE_TRAITS_BASE traits_base; typedef typename _Alloc::template rebind::other node_allocator; typedef typename node_allocator::value_type node; typedef typename node_allocator::pointer node_pointer; typedef typename traits_type::null_node_update_pointer null_node_update_pointer; private: typedef cond_dealtor cond_dealtor_t; #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif public: typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; #endif typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; typedef typename traits_type::point_const_iterator point_const_iterator; typedef point_const_iterator const_iterator; typedef typename traits_type::point_iterator point_iterator; typedef point_iterator iterator; typedef typename traits_type::const_reverse_iterator const_reverse_iterator; typedef typename traits_type::reverse_iterator reverse_iterator; typedef typename traits_type::node_const_iterator node_const_iterator; typedef typename traits_type::node_iterator node_iterator; typedef typename traits_type::node_update node_update; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; PB_DS_BIN_TREE_NAME(); PB_DS_BIN_TREE_NAME(const Cmp_Fn&); PB_DS_BIN_TREE_NAME(const Cmp_Fn&, const node_update&); PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); ~PB_DS_BIN_TREE_NAME(); inline bool empty() const; inline size_type size() const; inline size_type max_size() const; Cmp_Fn& get_cmp_fn(); const Cmp_Fn& get_cmp_fn() const; inline point_iterator lower_bound(key_const_reference); inline point_const_iterator lower_bound(key_const_reference) const; inline point_iterator upper_bound(key_const_reference); inline point_const_iterator upper_bound(key_const_reference) const; inline point_iterator find(key_const_reference); inline point_const_iterator find(key_const_reference) const; inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; inline reverse_iterator rbegin(); inline const_reverse_iterator rbegin() const; inline reverse_iterator rend(); inline const_reverse_iterator rend() const; /// Returns a const node_iterator corresponding to the node at the /// root of the tree. inline node_const_iterator node_begin() const; /// Returns a node_iterator corresponding to the node at the /// root of the tree. inline node_iterator node_begin(); /// Returns a const node_iterator corresponding to a node just /// after a leaf of the tree. inline node_const_iterator node_end() const; /// Returns a node_iterator corresponding to a node just /// after a leaf of the tree. inline node_iterator node_end(); void clear(); protected: void value_swap(PB_DS_CLASS_C_DEC&); void initialize_min_max(); inline iterator insert_imp_empty(const_reference); inline iterator insert_leaf_new(const_reference, node_pointer, bool); inline node_pointer get_new_node_for_leaf_insert(const_reference, false_type); inline node_pointer get_new_node_for_leaf_insert(const_reference, true_type); inline void actual_erase_node(node_pointer); inline std::pair erase(node_pointer); inline void update_min_max_for_erased_node(node_pointer); static void clear_imp(node_pointer); inline std::pair insert_leaf(const_reference); inline void rotate_left(node_pointer); inline void rotate_right(node_pointer); inline void rotate_parent(node_pointer); inline void apply_update(node_pointer, null_node_update_pointer); template inline void apply_update(node_pointer, Node_Update_*); inline void update_to_top(node_pointer, null_node_update_pointer); template inline void update_to_top(node_pointer, Node_Update_*); bool join_prep(PB_DS_CLASS_C_DEC&); void join_finish(PB_DS_CLASS_C_DEC&); bool split_prep(key_const_reference, PB_DS_CLASS_C_DEC&); void split_finish(PB_DS_CLASS_C_DEC&); size_type recursive_count(node_pointer) const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; void structure_only_assert_valid(const char*, int) const; void assert_node_consistent(const node_pointer, const char*, int) const; #endif private: #ifdef _GLIBCXX_DEBUG void assert_iterators(const char*, int) const; void assert_consistent_with_debug_base(const char*, int) const; void assert_node_consistent_with_left(const node_pointer, const char*, int) const; void assert_node_consistent_with_right(const node_pointer, const char*, int) const; void assert_consistent_with_debug_base(const node_pointer, const char*, int) const; void assert_min(const char*, int) const; void assert_min_imp(const node_pointer, const char*, int) const; void assert_max(const char*, int) const; void assert_max_imp(const node_pointer, const char*, int) const; void assert_size(const char*, int) const; typedef std::pair node_consistent_t; node_consistent_t assert_node_consistent_(const node_pointer, const char*, int) const; #endif void initialize(); node_pointer recursive_copy_node(const node_pointer); protected: node_pointer m_p_head; size_type m_size; static node_allocator s_node_allocator; }; #define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);) #define PB_DS_ASSERT_NODE_CONSISTENT(_Node) \ _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, __FILE__, __LINE__);) #include #include #include #include #include #include #include #include #include #include #undef PB_DS_ASSERT_NODE_CONSISTENT #undef PB_DS_STRUCT_ONLY_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BIN_TREE_NAME #undef PB_DS_BIN_TREE_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC #ifdef PB_DS_TREE_TRACE #undef PB_DS_TREE_TRACE_BASE_C_DEC #endif } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp000064400000017607147547540560017167 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/debug_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { structure_only_assert_valid(__file, __line); assert_consistent_with_debug_base(__file, __line); assert_size(__file, __line); assert_iterators(__file, __line); if (m_p_head->m_p_parent == 0) { PB_DS_DEBUG_VERIFY(m_size == 0); } else { PB_DS_DEBUG_VERIFY(m_size > 0); } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: structure_only_assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(m_p_head != 0); if (m_p_head->m_p_parent == 0) { PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head); } else { PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head); } if (m_p_head->m_p_parent != 0) assert_node_consistent(m_p_head->m_p_parent, __file, __line); assert_min(__file, __line); assert_max(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent(const node_pointer p_nd, const char* __file, int __line) const { assert_node_consistent_(p_nd, __file, __line); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_consistent_t PB_DS_CLASS_C_DEC:: assert_node_consistent_(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) return (std::make_pair((const_pointer)0,(const_pointer)0)); assert_node_consistent_with_left(p_nd, __file, __line); assert_node_consistent_with_right(p_nd, __file, __line); const std::pair l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line); if (l_range.second != 0) PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second), PB_DS_V2F(p_nd->m_value))); const std::pair r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line); if (r_range.first != 0) PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(*r_range.first))); return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value, (r_range.second != 0)? r_range.second : &p_nd->m_value); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent_with_left(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd->m_p_left == 0) return; PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd); PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(p_nd->m_p_left->m_value))); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent_with_right(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd->m_p_right == 0) return; PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd); PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value), PB_DS_V2F(p_nd->m_value))); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_min(const char* __file, int __line) const { assert_min_imp(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) { PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head); return; } if (p_nd->m_p_left == 0) { PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left); return; } assert_min_imp(p_nd->m_p_left, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_max(const char* __file, int __line) const { assert_max_imp(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_max_imp(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) { PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head); return; } if (p_nd->m_p_right == 0) { PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right); return; } assert_max_imp(p_nd->m_p_right, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_iterators(const char* __file, int __line) const { size_type iterated_num = 0; const_iterator prev_it = end(); for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd); if (prev_it != end()) PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), PB_DS_V2F(*it))); prev_it = it; } PB_DS_DEBUG_VERIFY(iterated_num == m_size); size_type reverse_iterated_num = 0; const_reverse_iterator reverse_prev_it = rend(); for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); ++reverse_it) { ++reverse_iterated_num; PB_DS_DEBUG_VERIFY(lower_bound( PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it)); --upper_bound_it; PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd); if (reverse_prev_it != rend()) PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it), PB_DS_V2F(*reverse_it))); reverse_prev_it = reverse_it; } PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_consistent_with_debug_base(const char* __file, int __line) const { debug_base::check_size(m_size, __file, __line); assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_consistent_with_debug_base(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) return; debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line); assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line); assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_size(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); } #endif 4.8.2/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp000064400000012603147547540560023116 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/constructors_destructor_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_allocator PB_DS_CLASS_C_DEC::s_node_allocator; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_BIN_TREE_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn) : Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : Cmp_Fn(r_cmp_fn), node_update(r_node_update), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : #ifdef _GLIBCXX_DEBUG debug_base(other), #endif #ifdef PB_DS_TREE_TRACE PB_DS_TREE_TRACE_BASE_C_DEC(other), #endif Cmp_Fn(other), node_update(other), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); m_size = other.m_size; PB_DS_STRUCT_ONLY_ASSERT_VALID(other) __try { m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent); if (m_p_head->m_p_parent != 0) m_p_head->m_p_parent->m_p_parent = m_p_head; m_size = other.m_size; initialize_min_max(); } __catch(...) { _GLIBCXX_DEBUG_ONLY(debug_base::clear();) s_node_allocator.deallocate(m_p_head, 1); __throw_exception_again; } PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_STRUCT_ONLY_ASSERT_VALID(other) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_STRUCT_ONLY_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_p_head, other.m_p_head); std::swap(m_size, other.m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_BIN_TREE_NAME() { clear(); s_node_allocator.deallocate(m_p_head, 1); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { m_p_head->m_p_parent = 0; m_p_head->m_p_left = m_p_head; m_p_head->m_p_right = m_p_head; m_size = 0; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: recursive_copy_node(const node_pointer p_nd) { if (p_nd == 0) return (0); node_pointer p_ret = s_node_allocator.allocate(1); __try { new (p_ret) node(*p_nd); } __catch(...) { s_node_allocator.deallocate(p_ret, 1); __throw_exception_again; } p_ret->m_p_left = p_ret->m_p_right = 0; __try { p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left); p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right); } __catch(...) { clear_imp(p_ret); __throw_exception_again; } if (p_ret->m_p_left != 0) p_ret->m_p_left->m_p_parent = p_ret; if (p_ret->m_p_right != 0) p_ret->m_p_right->m_p_parent = p_ret; PB_DS_ASSERT_NODE_CONSISTENT(p_ret) return p_ret; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize_min_max() { if (m_p_head->m_p_parent == 0) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; return; } { node_pointer p_min = m_p_head->m_p_parent; while (p_min->m_p_left != 0) p_min = p_min->m_p_left; m_p_head->m_p_left = p_min; } { node_pointer p_max = m_p_head->m_p_parent; while (p_max->m_p_right != 0) p_max = p_max->m_p_right; m_p_head->m_p_right = p_max; } } 4.8.2/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp000064400000012551147547540560017376 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/insert_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf(const_reference r_value) { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) if (m_size == 0) return std::make_pair(insert_imp_empty(r_value), true); node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_pot = m_p_head; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))) { p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; if (p_pot == m_p_head) return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false), true); if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_pot->m_value))) { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value)) return std::make_pair(p_pot, false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) p_nd = p_pot->m_p_left; if (p_nd == 0) return std::make_pair(insert_leaf_new(r_value, p_pot, true), true); while (p_nd->m_p_right != 0) p_nd = p_nd->m_p_right; return std::make_pair(insert_leaf_new(r_value, p_nd, false), true); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) { node_pointer p_new_nd = get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator); if (left_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0); _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value))); p_nd->m_p_left = p_new_nd; if (m_p_head->m_p_left == p_nd) m_p_head->m_p_left = p_new_nd; } else { _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0); _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))); p_nd->m_p_right = p_new_nd; if (m_p_head->m_p_right == p_nd) m_p_head->m_p_right = p_new_nd; } p_new_nd->m_p_parent = p_nd; p_new_nd->m_p_left = p_new_nd->m_p_right = 0; PB_DS_ASSERT_NODE_CONSISTENT(p_nd) update_to_top(p_new_nd, (node_update* )this); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));) return iterator(p_new_nd); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: insert_imp_empty(const_reference r_value) { node_pointer p_new_node = get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator); m_p_head->m_p_left = m_p_head->m_p_right = m_p_head->m_p_parent = p_new_node; p_new_node->m_p_parent = m_p_head; p_new_node->m_p_left = p_new_node->m_p_right = 0; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));) update_to_top(m_p_head->m_p_parent, (node_update*)this); return iterator(p_new_node); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_new_node_for_leaf_insert(const_reference r_val, false_type) { node_pointer p_new_nd = s_node_allocator.allocate(1); cond_dealtor_t cond(p_new_nd); new (const_cast(static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); cond.set_no_action(); p_new_nd->m_p_left = p_new_nd->m_p_right = 0; ++m_size; return p_new_nd; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_new_node_for_leaf_insert(const_reference r_val, true_type) { node_pointer p_new_nd = s_node_allocator.allocate(1); new (const_cast(static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); p_new_nd->m_p_left = p_new_nd->m_p_right = 0; ++m_size; return p_new_nd; } 4.8.2/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp000064400000007647147547540560020256 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/split_join_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return false; if (m_size == 0) { value_swap(other); return false; } const bool greater = Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value), PB_DS_V2F(other.m_p_head->m_p_left->m_value)); const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value), PB_DS_V2F(m_p_head->m_p_left->m_value)); if (!greater && !lesser) __throw_join_error(); if (lesser) value_swap(other); m_size += other.m_size; _GLIBCXX_DEBUG_ONLY(debug_base::join(other);) return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join_finish(PB_DS_CLASS_C_DEC& other) { initialize_min_max(); other.initialize(); } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) other.clear(); if (m_size == 0) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return false; } if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value))) { value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return false; } if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value))) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return false; } if (m_size == 1) { value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return false; } _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(Cmp_Fn& )(*this), other);) return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split_finish(PB_DS_CLASS_C_DEC& other) { other.initialize_min_max(); other.m_size = std::distance(other.begin(), other.end()); m_size -= other.m_size; initialize_min_max(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: recursive_count(node_pointer p) const { if (p == 0) return 0; return 1 + recursive_count(p->m_p_left) + recursive_count(p->m_p_right); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp000064400000021401147547540560017576 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/point_iterators.hpp * Contains an implementation class for bin_search_tree_. */ #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP #define PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_TREE_CONST_IT_C_DEC \ bin_search_tree_const_it_< \ Node_Pointer, \ Value_Type, \ Pointer, \ Const_Pointer, \ Reference, \ Const_Reference, \ Is_Forward_Iterator, \ _Alloc> #define PB_DS_TREE_CONST_ODIR_IT_C_DEC \ bin_search_tree_const_it_< \ Node_Pointer, \ Value_Type, \ Pointer, \ Const_Pointer, \ Reference, \ Const_Reference, \ !Is_Forward_Iterator, \ _Alloc> #define PB_DS_TREE_IT_C_DEC \ bin_search_tree_it_< \ Node_Pointer, \ Value_Type, \ Pointer, \ Const_Pointer, \ Reference, \ Const_Reference, \ Is_Forward_Iterator, \ _Alloc> #define PB_DS_TREE_ODIR_IT_C_DEC \ bin_search_tree_it_< \ Node_Pointer, \ Value_Type, \ Pointer, \ Const_Pointer, \ Reference, \ Const_Reference, \ !Is_Forward_Iterator, \ _Alloc> /// Const iterator. template class bin_search_tree_const_it_ { public: typedef std::bidirectional_iterator_tag iterator_category; typedef typename _Alloc::difference_type difference_type; typedef Value_Type value_type; typedef Pointer pointer; typedef Const_Pointer const_pointer; typedef Reference reference; typedef Const_Reference const_reference; inline bin_search_tree_const_it_(const Node_Pointer p_nd = 0) : m_p_nd(const_cast(p_nd)) { } inline bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) : m_p_nd(other.m_p_nd) { } inline PB_DS_TREE_CONST_IT_C_DEC& operator=(const PB_DS_TREE_CONST_IT_C_DEC& other) { m_p_nd = other.m_p_nd; return *this; } inline PB_DS_TREE_CONST_IT_C_DEC& operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) { m_p_nd = other.m_p_nd; return *this; } inline const_pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); return &m_p_nd->m_value; } inline const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); return m_p_nd->m_value; } inline bool operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const { return m_p_nd == other.m_p_nd; } inline bool operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const { return m_p_nd == other.m_p_nd; } inline bool operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const { return m_p_nd != other.m_p_nd; } inline bool operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const { return m_p_nd != other.m_p_nd; } inline PB_DS_TREE_CONST_IT_C_DEC& operator++() { _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); inc(integral_constant()); return *this; } inline PB_DS_TREE_CONST_IT_C_DEC operator++(int) { PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd); operator++(); return ret_it; } inline PB_DS_TREE_CONST_IT_C_DEC& operator--() { dec(integral_constant()); return *this; } inline PB_DS_TREE_CONST_IT_C_DEC operator--(int) { PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd); operator--(); return ret_it; } protected: inline void inc(false_type) { dec(true_type()); } void inc(true_type) { if (m_p_nd->special()&& m_p_nd->m_p_parent->m_p_parent == m_p_nd) { m_p_nd = m_p_nd->m_p_left; return; } if (m_p_nd->m_p_right != 0) { m_p_nd = m_p_nd->m_p_right; while (m_p_nd->m_p_left != 0) m_p_nd = m_p_nd->m_p_left; return; } Node_Pointer p_y = m_p_nd->m_p_parent; while (m_p_nd == p_y->m_p_right) { m_p_nd = p_y; p_y = p_y->m_p_parent; } if (m_p_nd->m_p_right != p_y) m_p_nd = p_y; } inline void dec(false_type) { inc(true_type()); } void dec(true_type) { if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd) { m_p_nd = m_p_nd->m_p_right; return; } if (m_p_nd->m_p_left != 0) { Node_Pointer p_y = m_p_nd->m_p_left; while (p_y->m_p_right != 0) p_y = p_y->m_p_right; m_p_nd = p_y; return; } Node_Pointer p_y = m_p_nd->m_p_parent; while (m_p_nd == p_y->m_p_left) { m_p_nd = p_y; p_y = p_y->m_p_parent; } if (m_p_nd->m_p_left != p_y) m_p_nd = p_y; } public: Node_Pointer m_p_nd; }; /// Iterator. template class bin_search_tree_it_ : public PB_DS_TREE_CONST_IT_C_DEC { public: inline bin_search_tree_it_(const Node_Pointer p_nd = 0) : PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd) { } inline bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other) : PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd) { } inline PB_DS_TREE_IT_C_DEC& operator=(const PB_DS_TREE_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; return *this; } inline PB_DS_TREE_IT_C_DEC& operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; return *this; } inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0); return &base_it_type::m_p_nd->m_value; } inline typename PB_DS_TREE_CONST_IT_C_DEC::reference operator*() const { _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0); return base_it_type::m_p_nd->m_value; } inline PB_DS_TREE_IT_C_DEC& operator++() { PB_DS_TREE_CONST_IT_C_DEC:: operator++(); return *this; } inline PB_DS_TREE_IT_C_DEC operator++(int) { PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd); operator++(); return ret_it; } inline PB_DS_TREE_IT_C_DEC& operator--() { PB_DS_TREE_CONST_IT_C_DEC:: operator--(); return *this; } inline PB_DS_TREE_IT_C_DEC operator--(int) { PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd); operator--(); return ret_it; } protected: typedef PB_DS_TREE_CONST_IT_C_DEC base_it_type; }; #undef PB_DS_TREE_CONST_IT_C_DEC #undef PB_DS_TREE_CONST_ODIR_IT_C_DEC #undef PB_DS_TREE_IT_C_DEC #undef PB_DS_TREE_ODIR_IT_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp000064400000010136147547540560017365 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/rotate_fn_imps.hpp * Contains imps for rotating nodes. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_left(node_pointer p_x) { node_pointer p_y = p_x->m_p_right; p_x->m_p_right = p_y->m_p_left; if (p_y->m_p_left != 0) p_y->m_p_left->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_left) p_x->m_p_parent->m_p_left = p_y; else p_x->m_p_parent->m_p_right = p_y; p_y->m_p_left = p_x; p_x->m_p_parent = p_y; PB_DS_ASSERT_NODE_CONSISTENT(p_x) PB_DS_ASSERT_NODE_CONSISTENT(p_y) apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_right(node_pointer p_x) { node_pointer p_y = p_x->m_p_left; p_x->m_p_left = p_y->m_p_right; if (p_y->m_p_right != 0) p_y->m_p_right->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_right) p_x->m_p_parent->m_p_right = p_y; else p_x->m_p_parent->m_p_left = p_y; p_y->m_p_right = p_x; p_x->m_p_parent = p_y; PB_DS_ASSERT_NODE_CONSISTENT(p_x) PB_DS_ASSERT_NODE_CONSISTENT(p_y) apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_parent(node_pointer p_nd) { node_pointer p_parent = p_nd->m_p_parent; if (p_nd == p_parent->m_p_left) rotate_right(p_parent); else rotate_left(p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/) { } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer p_nd, Node_Update_* /*p_update*/) { node_update::operator()(node_iterator(p_nd), node_const_iterator(static_cast(0))); } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: update_to_top(node_pointer p_nd, Node_Update_* p_update) { while (p_nd != m_p_head) { apply_update(p_nd, p_update); p_nd = p_nd->m_p_parent; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_to_top(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/) { } 4.8.2/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp000064400000006673147547540560020116 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/iterators_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { return (iterator(m_p_head->m_p_left)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { return (const_iterator(m_p_head->m_p_left)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return (iterator(m_p_head)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return (const_iterator(m_p_head)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: rbegin() const { return (const_reverse_iterator(m_p_head->m_p_right)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: rbegin() { return (reverse_iterator(m_p_head->m_p_right)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: rend() { return (reverse_iterator(m_p_head)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: rend() const { return (const_reverse_iterator(m_p_head)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_begin() const { return (node_const_iterator(m_p_head->m_p_parent)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_begin() { return (node_iterator(m_p_head->m_p_parent)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_end() const { return (node_const_iterator(0)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_end() { return (node_iterator(0)); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp000064400000005547147547540560017200 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/erase_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value));) p_z->~node(); s_node_allocator.deallocate(p_z, 1); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_min_max_for_erased_node(node_pointer p_z) { if (m_size == 1) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; return; } if (m_p_head->m_p_left == p_z) { iterator it(p_z); ++it; m_p_head->m_p_left = it.m_p_nd; } else if (m_p_head->m_p_right == p_z) { iterator it(p_z); --it; m_p_head->m_p_right = it.m_p_nd; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) clear_imp(m_p_head->m_p_parent); m_size = 0; initialize(); _GLIBCXX_DEBUG_ONLY(debug_base::clear();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear_imp(node_pointer p_nd) { if (p_nd == 0) return; clear_imp(p_nd->m_p_left); clear_imp(p_nd->m_p_right); p_nd->~node(); s_node_allocator.deallocate(p_nd, 1); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp000064400000005535147547540560017516 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/r_erase_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));) p_z->~node(); s_node_allocator.deallocate(p_z, 1); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_min_max_for_erased_node(node_pointer p_z) { if (m_size == 1) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; return; } if (m_p_head->m_p_left == p_z) { iterator it(p_z); ++it; m_p_head->m_p_left = it.m_p_nd; } else if (m_p_head->m_p_right == p_z) { iterator it(p_z); --it; m_p_head->m_p_right = it.m_p_nd; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) clear_imp(m_p_head->m_p_parent); m_size = 0; initialize(); _GLIBCXX_DEBUG_ONLY(debug_base::clear();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear_imp(node_pointer p_nd) { if (p_nd == 0) return; clear_imp(p_nd->m_p_left); clear_imp(p_nd->m_p_right); p_nd->~Node(); s_node_allocator.deallocate(p_nd, 1); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp000064400000003561147547540560020713 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/policy_access_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() { return (*this); } PB_DS_CLASS_T_DEC const Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() const { return (*this); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/traits.hpp000064400000014411147547540560015662 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/traits.hpp * Contains an implementation for bin_search_tree_. */ #ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP #define PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP #include #include namespace __gnu_pbds { namespace detail { /// Binary search tree traits, primary template /// @ingroup traits template class Node_Update, class Node, typename _Alloc> struct bin_search_tree_traits { private: typedef types_traits type_traits; public: typedef Node node; typedef bin_search_tree_const_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, true, _Alloc> point_const_iterator; typedef bin_search_tree_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, true, _Alloc> point_iterator; typedef bin_search_tree_const_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, false, _Alloc> const_reverse_iterator; typedef bin_search_tree_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, false, _Alloc> reverse_iterator; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef bin_search_tree_const_node_it_< Node, point_const_iterator, point_iterator, _Alloc> node_const_iterator; typedef bin_search_tree_node_it_< Node, point_const_iterator, point_iterator, _Alloc> node_iterator; typedef Node_Update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc> node_update; typedef __gnu_pbds::null_node_update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc>* null_node_update_pointer; }; /// Specialization. /// @ingroup traits template class Node_Update, class Node, typename _Alloc> struct bin_search_tree_traits< Key, null_type, Cmp_Fn, Node_Update, Node, _Alloc> { private: typedef types_traits type_traits; public: typedef Node node; typedef bin_search_tree_const_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, true, _Alloc> point_const_iterator; typedef point_const_iterator point_iterator; typedef bin_search_tree_const_it_< typename _Alloc::template rebind< node>::other::pointer, typename type_traits::value_type, typename type_traits::pointer, typename type_traits::const_pointer, typename type_traits::reference, typename type_traits::const_reference, false, _Alloc> const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef bin_search_tree_const_node_it_< Node, point_const_iterator, point_iterator, _Alloc> node_const_iterator; typedef node_const_iterator node_iterator; typedef Node_Update node_update; typedef __gnu_pbds::null_node_update< node_const_iterator, node_iterator, Cmp_Fn, _Alloc>* null_node_update_pointer; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP 4.8.2/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp000064400000013555147547540560017405 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/node_iterators.hpp * Contains an implementation class for bin_search_tree_. */ #ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP #define PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP #include namespace __gnu_pbds { namespace detail { #define PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC \ bin_search_tree_const_node_it_ /// Const node iterator. template class bin_search_tree_const_node_it_ { private: typedef typename _Alloc::template rebind< Node>::other::pointer node_pointer; public: /// Category. typedef trivial_iterator_tag iterator_category; /// Difference type. typedef trivial_iterator_difference_type difference_type; /// Iterator's value type. typedef Const_Iterator value_type; /// Iterator's reference type. typedef Const_Iterator reference; /// Iterator's __const reference type. typedef Const_Iterator const_reference; /// Metadata type. typedef typename Node::metadata_type metadata_type; /// Const metadata reference type. typedef typename _Alloc::template rebind::other::const_reference metadata_const_reference; bin_search_tree_const_node_it_(const node_pointer p_nd = 0) : m_p_nd(const_cast(p_nd)) { } /// Access. const_reference operator*() const { return Const_Iterator(m_p_nd); } /// Metadata access. metadata_const_reference get_metadata() const { return m_p_nd->get_metadata(); } /// Returns the __const node iterator associated with the left node. PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC get_l_child() const { return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_left); } /// Returns the __const node iterator associated with the right node. PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC get_r_child() const { return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_right); } /// Compares to a different iterator object. bool operator==(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const { return m_p_nd == other.m_p_nd; } /// Compares (negatively) to a different iterator object. bool operator!=(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const { return m_p_nd != other.m_p_nd; } node_pointer m_p_nd; }; #define PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC \ bin_search_tree_node_it_ /// Node iterator. template class bin_search_tree_node_it_ : public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC { private: typedef typename _Alloc::template rebind< Node>::other::pointer node_pointer; public: /// Iterator's value type. typedef Iterator value_type; /// Iterator's reference type. typedef Iterator reference; /// Iterator's __const reference type. typedef Iterator const_reference; inline bin_search_tree_node_it_(const node_pointer p_nd = 0) : PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(const_cast(p_nd)) { } /// Access. Iterator operator*() const { return Iterator(PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd); } /// Returns the node iterator associated with the left node. PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC get_l_child() const { return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC( PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_left); } /// Returns the node iterator associated with the right node. PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC get_r_child() const { return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC( PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_right); } }; #undef PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC #undef PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP 4.8.2/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp000064400000011107147547540560017006 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/find_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: lower_bound(key_const_reference r_key) const { node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) p_nd = p_nd->m_p_right; else { p_pot = p_nd; p_nd = p_nd->m_p_left; } return iterator(p_pot); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: lower_bound(key_const_reference r_key) { node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) p_nd = p_nd->m_p_right; else { p_pot = p_nd; p_nd = p_nd->m_p_left; } return iterator(p_pot); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: upper_bound(key_const_reference r_key) const { node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) { p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return const_iterator(p_pot); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: upper_bound(key_const_reference r_key) { node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) { p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return point_iterator(p_pot); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; node_pointer ret = p_pot; if (p_pot != m_p_head) { const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value)); if (__cmp) ret = m_p_head; } return point_iterator(ret); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; node_pointer ret = p_pot; if (p_pot != m_p_head) { const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value)); if (__cmp) ret = m_p_head; } return point_const_iterator(ret); } 4.8.2/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp000064400000004040147547540560017017 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file bin_search_tree_/info_fn_imps.hpp * Contains an implementation class for bin_search_tree_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (m_size == 0); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return (m_size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return (s_node_allocator.max_size()); } 4.8.2/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp000064400000040745147547540560015026 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/pat_trie_.hpp * Contains an implementation class for a patricia tree. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _GLIBCXX_DEBUG #include #endif #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_PAT_TRIE_NAME pat_trie_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_PAT_TRIE_NAME pat_trie_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_PAT_TRIE_NAME #define PB_DS_PAT_TRIE_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base >, \ typename _Alloc::template rebind::other::const_reference> #endif /** * @brief PATRICIA trie. * @ingroup branch-detail * * This implementation loosely borrows ideas from: * 1) Fast Mergeable Integer Maps, Okasaki, Gill 1998 * 2) Ptset: Sets of integers implemented as Patricia trees, * Jean-Christophe Filliatr, 2000 */ template class PB_DS_PAT_TRIE_NAME : #ifdef _GLIBCXX_DEBUG public PB_DS_DEBUG_MAP_BASE_C_DEC, #endif public Node_And_It_Traits::synth_access_traits, public Node_And_It_Traits::node_update, public PB_DS_PAT_TRIE_TRAITS_BASE, public pat_trie_base { private: typedef pat_trie_base base_type; typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base; typedef Node_And_It_Traits traits_type; typedef typename traits_type::synth_access_traits synth_access_traits; typedef typename synth_access_traits::const_iterator a_const_iterator; typedef typename traits_type::node node; typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::const_pointer node_const_pointer; typedef typename __rebind_n::other::pointer node_pointer; typedef typename traits_type::head head; typedef typename _Alloc::template rebind __rebind_h; typedef typename __rebind_h::other head_allocator; typedef typename head_allocator::pointer head_pointer; typedef typename traits_type::leaf leaf; typedef typename _Alloc::template rebind __rebind_l; typedef typename __rebind_l::other leaf_allocator; typedef typename leaf_allocator::pointer leaf_pointer; typedef typename leaf_allocator::const_pointer leaf_const_pointer; typedef typename traits_type::inode inode; typedef typename inode::iterator inode_iterator; typedef typename _Alloc::template rebind __rebind_in; typedef typename __rebind_in::other __rebind_ina; typedef typename __rebind_in::other inode_allocator; typedef typename __rebind_ina::pointer inode_pointer; typedef typename __rebind_ina::const_pointer inode_const_pointer; /// Conditional deallocator. class cond_dealtor { protected: leaf_pointer m_p_nd; bool m_no_action_dtor; bool m_call_destructor; public: cond_dealtor(leaf_pointer p_nd) : m_p_nd(p_nd), m_no_action_dtor(false), m_call_destructor(false) { } void set_no_action_dtor() { m_no_action_dtor = true; } void set_call_destructor() { m_call_destructor = true; } ~cond_dealtor() { if (m_no_action_dtor) return; if (m_call_destructor) m_p_nd->~leaf(); s_leaf_allocator.deallocate(m_p_nd, 1); } }; /// Branch bag, for split-join. class branch_bag { private: typedef inode_pointer __inp; typedef typename _Alloc::template rebind<__inp>::other __rebind_inp; #ifdef _GLIBCXX_DEBUG typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type; #else typedef std::list<__inp, __rebind_inp> bag_type; #endif bag_type m_bag; public: void add_branch() { inode_pointer p_nd = s_inode_allocator.allocate(1); __try { m_bag.push_back(p_nd); } __catch(...) { s_inode_allocator.deallocate(p_nd, 1); __throw_exception_again; } } inode_pointer get_branch() { _GLIBCXX_DEBUG_ASSERT(!m_bag.empty()); inode_pointer p_nd = *m_bag.begin(); m_bag.pop_front(); return p_nd; } ~branch_bag() { while (!m_bag.empty()) { inode_pointer p_nd = *m_bag.begin(); s_inode_allocator.deallocate(p_nd, 1); m_bag.pop_front(); } } inline bool empty() const { return m_bag.empty(); } }; #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif typedef typename traits_type::null_node_update_pointer null_node_update_pointer; public: typedef pat_trie_tag container_category; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; typedef typename traits_type::access_traits access_traits; typedef typename traits_type::const_iterator point_const_iterator; typedef typename traits_type::iterator point_iterator; typedef point_const_iterator const_iterator; typedef point_iterator iterator; typedef typename traits_type::reverse_iterator reverse_iterator; typedef typename traits_type::const_reverse_iterator const_reverse_iterator; typedef typename traits_type::node_const_iterator node_const_iterator; typedef typename traits_type::node_iterator node_iterator; typedef typename traits_type::node_update node_update; PB_DS_PAT_TRIE_NAME(); PB_DS_PAT_TRIE_NAME(const access_traits&); PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); ~PB_DS_PAT_TRIE_NAME(); inline bool empty() const; inline size_type size() const; inline size_type max_size() const; access_traits& get_access_traits(); const access_traits& get_access_traits() const; node_update& get_node_update(); const node_update& get_node_update() const; inline std::pair insert(const_reference); inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR return insert(std::make_pair(r_key, mapped_type())).first->second; #else insert(r_key); return traits_base::s_null_type; #endif } inline point_iterator find(key_const_reference); inline point_const_iterator find(key_const_reference) const; inline point_iterator lower_bound(key_const_reference); inline point_const_iterator lower_bound(key_const_reference) const; inline point_iterator upper_bound(key_const_reference); inline point_const_iterator upper_bound(key_const_reference) const; void clear(); inline bool erase(key_const_reference); inline const_iterator erase(const_iterator); #ifdef PB_DS_DATA_TRUE_INDICATOR inline iterator erase(iterator); #endif inline const_reverse_iterator erase(const_reverse_iterator); #ifdef PB_DS_DATA_TRUE_INDICATOR inline reverse_iterator erase(reverse_iterator); #endif template inline size_type erase_if(Pred); void join(PB_DS_CLASS_C_DEC&); void split(key_const_reference, PB_DS_CLASS_C_DEC&); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; inline reverse_iterator rbegin(); inline const_reverse_iterator rbegin() const; inline reverse_iterator rend(); inline const_reverse_iterator rend() const; /// Returns a const node_iterator corresponding to the node at the /// root of the tree. inline node_const_iterator node_begin() const; /// Returns a node_iterator corresponding to the node at the /// root of the tree. inline node_iterator node_begin(); /// Returns a const node_iterator corresponding to a node just /// after a leaf of the tree. inline node_const_iterator node_end() const; /// Returns a node_iterator corresponding to a node just /// after a leaf of the tree. inline node_iterator node_end(); #ifdef PB_DS_PAT_TRIE_TRACE_ void trace() const; #endif protected: template void copy_from_range(It, It); void value_swap(PB_DS_CLASS_C_DEC&); node_pointer recursive_copy_node(node_const_pointer); private: void initialize(); inline void apply_update(node_pointer, null_node_update_pointer); template inline void apply_update(node_pointer, Node_Update_*); bool join_prep(PB_DS_CLASS_C_DEC&, branch_bag&); void rec_join_prep(node_const_pointer, node_const_pointer, branch_bag&); void rec_join_prep(leaf_const_pointer, leaf_const_pointer, branch_bag&); void rec_join_prep(leaf_const_pointer, inode_const_pointer, branch_bag&); void rec_join_prep(inode_const_pointer, leaf_const_pointer, branch_bag&); void rec_join_prep(inode_const_pointer, inode_const_pointer, branch_bag&); node_pointer rec_join(node_pointer, node_pointer, size_type, branch_bag&); node_pointer rec_join(leaf_pointer, leaf_pointer, branch_bag&); node_pointer rec_join(leaf_pointer, inode_pointer, size_type, branch_bag&); node_pointer rec_join(inode_pointer, leaf_pointer, size_type, branch_bag&); node_pointer rec_join(inode_pointer, inode_pointer, branch_bag&); size_type keys_diff_ind(typename access_traits::const_iterator, typename access_traits::const_iterator, typename access_traits::const_iterator, typename access_traits::const_iterator); inode_pointer insert_branch(node_pointer, node_pointer, branch_bag&); void update_min_max_for_inserted_leaf(leaf_pointer); void erase_leaf(leaf_pointer); inline void actual_erase_leaf(leaf_pointer); void clear_imp(node_pointer); void erase_fixup(inode_pointer); void update_min_max_for_erased_leaf(leaf_pointer); static inline a_const_iterator pref_begin(node_const_pointer); static inline a_const_iterator pref_end(node_const_pointer); inline node_pointer find_imp(key_const_reference); inline node_pointer lower_bound_imp(key_const_reference); inline node_pointer upper_bound_imp(key_const_reference); inline static leaf_const_pointer leftmost_descendant(node_const_pointer); inline static leaf_pointer leftmost_descendant(node_pointer); inline static leaf_const_pointer rightmost_descendant(node_const_pointer); inline static leaf_pointer rightmost_descendant(node_pointer); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; void assert_iterators(const char*, int) const; void assert_reverse_iterators(const char*, int) const; static size_type recursive_count_leafs(node_const_pointer, const char*, int); #endif #ifdef PB_DS_PAT_TRIE_TRACE_ static void trace_node(node_const_pointer, size_type); template static void trace_node_metadata(node_const_pointer, type_to_type); static void trace_node_metadata(node_const_pointer, type_to_type); #endif leaf_pointer split_prep(key_const_reference, PB_DS_CLASS_C_DEC&, branch_bag&); node_pointer rec_split(node_pointer, a_const_iterator, a_const_iterator, PB_DS_CLASS_C_DEC&, branch_bag&); void split_insert_branch(size_type, a_const_iterator, inode_iterator, size_type, branch_bag&); static head_allocator s_head_allocator; static inode_allocator s_inode_allocator; static leaf_allocator s_leaf_allocator; head_pointer m_p_head; size_type m_size; }; #define PB_DS_ASSERT_NODE_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);) #define PB_DS_RECURSIVE_COUNT_LEAFS(X) \ recursive_count_leafs(X, __FILE__, __LINE__) #include #include #include #include #include #include #include #include #include #include #include #undef PB_DS_RECURSIVE_COUNT_LEAFS #undef PB_DS_ASSERT_NODE_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_PAT_TRIE_NAME #undef PB_DS_PAT_TRIE_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp000064400000111401147547540560015645 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/pat_trie_base.hpp * Contains the base class for a patricia tree. */ #ifndef PB_DS_PAT_TRIE_BASE #define PB_DS_PAT_TRIE_BASE #include namespace __gnu_pbds { namespace detail { /// Base type for PATRICIA trees. struct pat_trie_base { /** * @brief Three types of nodes. * * i_node is used by _Inode, leaf_node by _Leaf, and head_node by _Head. */ enum node_type { i_node, leaf_node, head_node }; /// Metadata base primary template. template struct _Metadata { typedef Metadata metadata_type; typedef _Alloc allocator_type; typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other::const_reference const_reference; const_reference get_metadata() const { return m_metadata; } metadata_type m_metadata; }; /// Specialization for null metadata. template struct _Metadata { typedef null_type metadata_type; typedef _Alloc allocator_type; }; /// Node base. template struct _Node_base : public Metadata { private: typedef typename Metadata::allocator_type _Alloc; public: typedef _Alloc allocator_type; typedef _ATraits access_traits; typedef typename _ATraits::type_traits type_traits; typedef typename _Alloc::template rebind<_Node_base> __rebind_n; typedef typename __rebind_n::other::pointer node_pointer; node_pointer m_p_parent; const node_type m_type; _Node_base(node_type type) : m_type(type) { } typedef typename _Alloc::template rebind<_ATraits> __rebind_at; typedef typename __rebind_at::other::const_pointer a_const_pointer; typedef typename _ATraits::const_iterator a_const_iterator; #ifdef _GLIBCXX_DEBUG typedef std::pair node_debug_info; void assert_valid(a_const_pointer p_traits, const char* __file, int __line) const { assert_valid_imp(p_traits, __file, __line); } virtual node_debug_info assert_valid_imp(a_const_pointer, const char*, int) const = 0; #endif }; /// Head node for PATRICIA tree. template struct _Head : public _Node_base<_ATraits, Metadata> { typedef _Node_base<_ATraits, Metadata> base_type; typedef typename base_type::type_traits type_traits; typedef typename base_type::node_pointer node_pointer; node_pointer m_p_min; node_pointer m_p_max; _Head() : base_type(head_node) { } #ifdef _GLIBCXX_DEBUG typedef typename base_type::node_debug_info node_debug_info; typedef typename base_type::a_const_pointer a_const_pointer; virtual node_debug_info assert_valid_imp(a_const_pointer, const char* __file, int __line) const { _GLIBCXX_DEBUG_VERIFY_AT(false, _M_message("Assertion from %1;:%2;") ._M_string(__FILE__)._M_integer(__LINE__), __file, __line); return node_debug_info(); } #endif }; /// Leaf node for PATRICIA tree. template struct _Leaf : public _Node_base<_ATraits, Metadata> { typedef _Node_base<_ATraits, Metadata> base_type; typedef typename base_type::type_traits type_traits; typedef typename type_traits::value_type value_type; typedef typename type_traits::reference reference; typedef typename type_traits::const_reference const_reference; private: value_type m_value; _Leaf(const _Leaf&); public: _Leaf(const_reference other) : base_type(leaf_node), m_value(other) { } reference value() { return m_value; } const_reference value() const { return m_value; } #ifdef _GLIBCXX_DEBUG typedef typename base_type::node_debug_info node_debug_info; typedef typename base_type::a_const_pointer a_const_pointer; virtual node_debug_info assert_valid_imp(a_const_pointer p_traits, const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(base_type::m_type == leaf_node); node_debug_info ret; const_reference r_val = value(); return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)), p_traits->end(p_traits->extract_key(r_val))); } virtual ~_Leaf() { } #endif }; /// Internal node type, PATRICIA tree. template struct _Inode : public _Node_base<_ATraits, Metadata> { typedef _Node_base<_ATraits, Metadata> base_type; typedef typename base_type::type_traits type_traits; typedef typename base_type::access_traits access_traits; typedef typename type_traits::value_type value_type; typedef typename base_type::allocator_type _Alloc; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; private: typedef typename base_type::a_const_pointer a_const_pointer; typedef typename base_type::a_const_iterator a_const_iterator; typedef typename base_type::node_pointer node_pointer; typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::const_pointer node_const_pointer; typedef _Leaf<_ATraits, Metadata> leaf; typedef typename _Alloc::template rebind::other __rebind_l; typedef typename __rebind_l::pointer leaf_pointer; typedef typename __rebind_l::const_pointer leaf_const_pointer; typedef typename _Alloc::template rebind<_Inode>::other __rebind_in; typedef typename __rebind_in::pointer inode_pointer; typedef typename __rebind_in::const_pointer inode_const_pointer; inline size_type get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer) const; public: typedef typename _Alloc::template rebind::other __rebind_np; typedef typename __rebind_np::pointer node_pointer_pointer; typedef typename __rebind_np::reference node_pointer_reference; enum { arr_size = _ATraits::max_size + 1 }; PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2); /// Constant child iterator. struct const_iterator { node_pointer_pointer m_p_p_cur; node_pointer_pointer m_p_p_end; typedef std::forward_iterator_tag iterator_category; typedef typename _Alloc::difference_type difference_type; typedef node_pointer value_type; typedef node_pointer_pointer pointer; typedef node_pointer_reference reference; const_iterator(node_pointer_pointer p_p_cur = 0, node_pointer_pointer p_p_end = 0) : m_p_p_cur(p_p_cur), m_p_p_end(p_p_end) { } bool operator==(const const_iterator& other) const { return m_p_p_cur == other.m_p_p_cur; } bool operator!=(const const_iterator& other) const { return m_p_p_cur != other.m_p_p_cur; } const_iterator& operator++() { do ++m_p_p_cur; while (m_p_p_cur != m_p_p_end && *m_p_p_cur == 0); return *this; } const_iterator operator++(int) { const_iterator ret_it(*this); operator++(); return ret_it; } const node_pointer_pointer operator->() const { _GLIBCXX_DEBUG_ONLY(assert_referencible();) return m_p_p_cur; } node_const_pointer operator*() const { _GLIBCXX_DEBUG_ONLY(assert_referencible();) return *m_p_p_cur; } protected: #ifdef _GLIBCXX_DEBUG void assert_referencible() const { _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end && *m_p_p_cur != 0); } #endif }; /// Child iterator. struct iterator : public const_iterator { public: typedef std::forward_iterator_tag iterator_category; typedef typename _Alloc::difference_type difference_type; typedef node_pointer value_type; typedef node_pointer_pointer pointer; typedef node_pointer_reference reference; inline iterator(node_pointer_pointer p_p_cur = 0, node_pointer_pointer p_p_end = 0) : const_iterator(p_p_cur, p_p_end) { } bool operator==(const iterator& other) const { return const_iterator::m_p_p_cur == other.m_p_p_cur; } bool operator!=(const iterator& other) const { return const_iterator::m_p_p_cur != other.m_p_p_cur; } iterator& operator++() { const_iterator::operator++(); return *this; } iterator operator++(int) { iterator ret_it(*this); operator++(); return ret_it; } node_pointer_pointer operator->() { _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) return const_iterator::m_p_p_cur; } node_pointer operator*() { _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) return *const_iterator::m_p_p_cur; } }; _Inode(size_type, const a_const_iterator); void update_prefixes(a_const_pointer); const_iterator begin() const; iterator begin(); const_iterator end() const; iterator end(); inline node_pointer get_child_node(a_const_iterator, a_const_iterator, a_const_pointer); inline node_const_pointer get_child_node(a_const_iterator, a_const_iterator, a_const_pointer) const; inline iterator get_child_it(a_const_iterator, a_const_iterator, a_const_pointer); inline node_pointer get_lower_bound_child_node(a_const_iterator, a_const_iterator, size_type, a_const_pointer); inline node_pointer add_child(node_pointer, a_const_iterator, a_const_iterator, a_const_pointer); inline node_const_pointer get_join_child(node_const_pointer, a_const_pointer) const; inline node_pointer get_join_child(node_pointer, a_const_pointer); void remove_child(node_pointer); void remove_child(iterator); void replace_child(node_pointer, a_const_iterator, a_const_iterator, a_const_pointer); inline a_const_iterator pref_b_it() const; inline a_const_iterator pref_e_it() const; bool should_be_mine(a_const_iterator, a_const_iterator, size_type, a_const_pointer) const; leaf_pointer leftmost_descendant(); leaf_const_pointer leftmost_descendant() const; leaf_pointer rightmost_descendant(); leaf_const_pointer rightmost_descendant() const; #ifdef _GLIBCXX_DEBUG typedef typename base_type::node_debug_info node_debug_info; virtual node_debug_info assert_valid_imp(a_const_pointer, const char*, int) const; #endif size_type get_e_ind() const { return m_e_ind; } private: _Inode(const _Inode&); size_type get_begin_pos() const; static __rebind_l s_leaf_alloc; static __rebind_in s_inode_alloc; const size_type m_e_ind; a_const_iterator m_pref_b_it; a_const_iterator m_pref_e_it; node_pointer m_a_p_children[arr_size]; }; #define PB_DS_CONST_IT_C_DEC \ _CIter #define PB_DS_CONST_ODIR_IT_C_DEC \ _CIter #define PB_DS_IT_C_DEC \ _Iter #define PB_DS_ODIR_IT_C_DEC \ _Iter /// Const iterator. template class _CIter { public: // These types are all the same for the first four template arguments. typedef typename Node::allocator_type allocator_type; typedef typename Node::type_traits type_traits; typedef std::bidirectional_iterator_tag iterator_category; typedef typename allocator_type::difference_type difference_type; typedef typename type_traits::value_type value_type; typedef typename type_traits::pointer pointer; typedef typename type_traits::reference reference; typedef typename type_traits::const_pointer const_pointer; typedef typename type_traits::const_reference const_reference; typedef allocator_type _Alloc; typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::pointer node_pointer; typedef typename _Alloc::template rebind __rebind_l; typedef typename __rebind_l::other::pointer leaf_pointer; typedef typename __rebind_l::other::const_pointer leaf_const_pointer; typedef typename _Alloc::template rebind __rebind_h; typedef typename __rebind_h::other::pointer head_pointer; typedef typename _Alloc::template rebind __rebind_in; typedef typename __rebind_in::other::pointer inode_pointer; typedef typename Inode::iterator inode_iterator; node_pointer m_p_nd; _CIter(node_pointer p_nd = 0) : m_p_nd(p_nd) { } _CIter(const PB_DS_CONST_ODIR_IT_C_DEC& other) : m_p_nd(other.m_p_nd) { } _CIter& operator=(const _CIter& other) { m_p_nd = other.m_p_nd; return *this; } _CIter& operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other) { m_p_nd = other.m_p_nd; return *this; } const_pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node); return &static_cast(m_p_nd)->value(); } const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node); return static_cast(m_p_nd)->value(); } bool operator==(const _CIter& other) const { return m_p_nd == other.m_p_nd; } bool operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const { return m_p_nd == other.m_p_nd; } bool operator!=(const _CIter& other) const { return m_p_nd != other.m_p_nd; } bool operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const { return m_p_nd != other.m_p_nd; } _CIter& operator++() { inc(integral_constant()); return *this; } _CIter operator++(int) { _CIter ret_it(m_p_nd); operator++(); return ret_it; } _CIter& operator--() { dec(integral_constant()); return *this; } _CIter operator--(int) { _CIter ret_it(m_p_nd); operator--(); return ret_it; } protected: void inc(false_type) { dec(true_type()); } void inc(true_type) { if (m_p_nd->m_type == head_node) { m_p_nd = static_cast(m_p_nd)->m_p_min; return; } node_pointer p_y = m_p_nd->m_p_parent; while (p_y->m_type != head_node && get_larger_sibling(m_p_nd) == 0) { m_p_nd = p_y; p_y = p_y->m_p_parent; } if (p_y->m_type == head_node) { m_p_nd = p_y; return; } m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd)); } void dec(false_type) { inc(true_type()); } void dec(true_type) { if (m_p_nd->m_type == head_node) { m_p_nd = static_cast(m_p_nd)->m_p_max; return; } node_pointer p_y = m_p_nd->m_p_parent; while (p_y->m_type != head_node && get_smaller_sibling(m_p_nd) == 0) { m_p_nd = p_y; p_y = p_y->m_p_parent; } if (p_y->m_type == head_node) { m_p_nd = p_y; return; } m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd)); } static node_pointer get_larger_sibling(node_pointer p_nd) { inode_pointer p_parent = static_cast(p_nd->m_p_parent); inode_iterator it = p_parent->begin(); while (*it != p_nd) ++it; inode_iterator next_it = it; ++next_it; return (next_it == p_parent->end())? 0 : *next_it; } static node_pointer get_smaller_sibling(node_pointer p_nd) { inode_pointer p_parent = static_cast(p_nd->m_p_parent); inode_iterator it = p_parent->begin(); if (*it == p_nd) return 0; inode_iterator prev_it; do { prev_it = it; ++it; if (*it == p_nd) return *prev_it; } while (true); _GLIBCXX_DEBUG_ASSERT(false); return 0; } static leaf_pointer leftmost_descendant(node_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->leftmost_descendant(); } static leaf_pointer rightmost_descendant(node_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->rightmost_descendant(); } }; /// Iterator. template class _Iter : public _CIter { public: typedef _CIter base_type; typedef typename base_type::allocator_type allocator_type; typedef typename base_type::type_traits type_traits; typedef typename type_traits::value_type value_type; typedef typename type_traits::pointer pointer; typedef typename type_traits::reference reference; typedef typename base_type::node_pointer node_pointer; typedef typename base_type::leaf_pointer leaf_pointer; typedef typename base_type::leaf_const_pointer leaf_const_pointer; typedef typename base_type::head_pointer head_pointer; typedef typename base_type::inode_pointer inode_pointer; _Iter(node_pointer p_nd = 0) : base_type(p_nd) { } _Iter(const PB_DS_ODIR_IT_C_DEC& other) : base_type(other.m_p_nd) { } _Iter& operator=(const _Iter& other) { base_type::m_p_nd = other.m_p_nd; return *this; } _Iter& operator=(const PB_DS_ODIR_IT_C_DEC& other) { base_type::m_p_nd = other.m_p_nd; return *this; } pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node); return &static_cast(base_type::m_p_nd)->value(); } reference operator*() const { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node); return static_cast(base_type::m_p_nd)->value(); } _Iter& operator++() { base_type::operator++(); return *this; } _Iter operator++(int) { _Iter ret(base_type::m_p_nd); operator++(); return ret; } _Iter& operator--() { base_type::operator--(); return *this; } _Iter operator--(int) { _Iter ret(base_type::m_p_nd); operator--(); return ret; } }; #undef PB_DS_CONST_ODIR_IT_C_DEC #undef PB_DS_ODIR_IT_C_DEC #define PB_DS_PAT_TRIE_NODE_CONST_ITERATOR_C_DEC \ _Node_citer #define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \ _Node_iter /// Node const iterator. template class _Node_citer { protected: typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::pointer node_pointer; typedef typename _Alloc::template rebind __rebind_l; typedef typename __rebind_l::other::pointer leaf_pointer; typedef typename __rebind_l::other::const_pointer leaf_const_pointer; typedef typename _Alloc::template rebind __rebind_in; typedef typename __rebind_in::other::pointer inode_pointer; typedef typename __rebind_in::other::const_pointer inode_const_pointer; typedef typename Node::a_const_pointer a_const_pointer; typedef typename Node::a_const_iterator a_const_iterator; private: a_const_iterator pref_begin() const { if (m_p_nd->m_type == leaf_node) { leaf_const_pointer lcp = static_cast(m_p_nd); return m_p_traits->begin(m_p_traits->extract_key(lcp->value())); } _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); return static_cast(m_p_nd)->pref_b_it(); } a_const_iterator pref_end() const { if (m_p_nd->m_type == leaf_node) { leaf_const_pointer lcp = static_cast(m_p_nd); return m_p_traits->end(m_p_traits->extract_key(lcp->value())); } _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); return static_cast(m_p_nd)->pref_e_it(); } public: typedef trivial_iterator_tag iterator_category; typedef trivial_iterator_difference_type difference_type; typedef typename _Alloc::size_type size_type; typedef _CIterator value_type; typedef value_type reference; typedef value_type const_reference; /// Metadata type. typedef typename Node::metadata_type metadata_type; /// Const metadata reference type. typedef typename _Alloc::template rebind __rebind_m; typedef typename __rebind_m::other __rebind_ma; typedef typename __rebind_ma::const_reference metadata_const_reference; inline _Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0) : m_p_nd(const_cast(p_nd)), m_p_traits(p_traits) { } /// Subtree valid prefix. std::pair valid_prefix() const { return std::make_pair(pref_begin(), pref_end()); } /// Const access; returns the __const iterator* associated with /// the current leaf. const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(num_children() == 0); return _CIterator(m_p_nd); } /// Metadata access. metadata_const_reference get_metadata() const { return m_p_nd->get_metadata(); } /// Returns the number of children in the corresponding node. size_type num_children() const { if (m_p_nd->m_type == leaf_node) return 0; _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); inode_pointer inp = static_cast(m_p_nd); return std::distance(inp->begin(), inp->end()); } /// Returns a __const node __iterator to the corresponding node's /// i-th child. _Node_citer get_child(size_type i) const { _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); inode_pointer inp = static_cast(m_p_nd); typename Inode::iterator it = inp->begin(); std::advance(it, i); return _Node_citer(*it, m_p_traits); } /// Compares content to a different iterator object. bool operator==(const _Node_citer& other) const { return m_p_nd == other.m_p_nd; } /// Compares content (negatively) to a different iterator object. bool operator!=(const _Node_citer& other) const { return m_p_nd != other.m_p_nd; } node_pointer m_p_nd; a_const_pointer m_p_traits; }; /// Node iterator. template class _Node_iter : public _Node_citer { private: typedef _Node_citer base_type; typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::pointer node_pointer; typedef typename base_type::inode_pointer inode_pointer; typedef typename base_type::a_const_pointer a_const_pointer; typedef Iterator iterator; public: typedef typename base_type::size_type size_type; typedef Iterator value_type; typedef value_type reference; typedef value_type const_reference; _Node_iter(node_pointer p_nd = 0, a_const_pointer p_traits = 0) : base_type(p_nd, p_traits) { } /// Access; returns the iterator* associated with the current leaf. reference operator*() const { _GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0); return iterator(base_type::m_p_nd); } /// Returns a node __iterator to the corresponding node's i-th child. _Node_iter get_child(size_type i) const { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == i_node); typename Inode::iterator it = static_cast(base_type::m_p_nd)->begin(); std::advance(it, i); return _Node_iter(*it, base_type::m_p_traits); } }; }; #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ pat_trie_base::_Inode<_ATraits, Metadata> PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::__rebind_l PB_DS_CLASS_C_DEC::s_leaf_alloc; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::__rebind_in PB_DS_CLASS_C_DEC::s_inode_alloc; PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_pref_pos(a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) const { if (static_cast(std::distance(b_it, e_it)) <= m_e_ind) return 0; std::advance(b_it, m_e_ind); return 1 + p_traits->e_pos(*b_it); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: _Inode(size_type len, const a_const_iterator it) : base_type(i_node), m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it) { std::advance(m_pref_e_it, m_e_ind); std::fill(m_a_p_children, m_a_p_children + arr_size, static_cast(0)); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: update_prefixes(a_const_pointer p_traits) { node_pointer p_first = *begin(); if (p_first->m_type == leaf_node) { leaf_const_pointer p = static_cast(p_first); m_pref_b_it = p_traits->begin(access_traits::extract_key(p->value())); } else { inode_pointer p = static_cast(p_first); _GLIBCXX_DEBUG_ASSERT(p_first->m_type == i_node); m_pref_b_it = p->pref_b_it(); } m_pref_e_it = m_pref_b_it; std::advance(m_pref_e_it, m_e_ind); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { typedef node_pointer_pointer pointer_type; pointer_type p = const_cast(m_a_p_children); return const_iterator(p + get_begin_pos(), p + arr_size); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { return iterator(m_a_p_children + get_begin_pos(), m_a_p_children + arr_size); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { typedef node_pointer_pointer pointer_type; pointer_type p = const_cast(m_a_p_children) + arr_size; return const_iterator(p, p); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_child_node(a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); return m_a_p_children[i]; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: get_child_it(a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0); return iterator(m_a_p_children + i, m_a_p_children + i); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_pointer PB_DS_CLASS_C_DEC:: get_child_node(a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) const { return const_cast(get_child_node(b_it, e_it, p_traits)); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_lower_bound_child_node(a_const_iterator b_it, a_const_iterator e_it, size_type checked_ind, a_const_pointer p_traits) { if (!should_be_mine(b_it, e_it, checked_ind, p_traits)) { if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it, m_pref_e_it, true)) return leftmost_descendant(); return rightmost_descendant(); } size_type i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); if (m_a_p_children[i] != 0) return m_a_p_children[i]; while (++i < arr_size) if (m_a_p_children[i] != 0) { const node_type& __nt = m_a_p_children[i]->m_type; node_pointer ret = m_a_p_children[i]; if (__nt == leaf_node) return ret; _GLIBCXX_DEBUG_ASSERT(__nt == i_node); inode_pointer inp = static_cast(ret); return inp->leftmost_descendant(); } return rightmost_descendant(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: add_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); if (m_a_p_children[i] == 0) { m_a_p_children[i] = p_nd; p_nd->m_p_parent = this; return p_nd; } return m_a_p_children[i]; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_const_pointer PB_DS_CLASS_C_DEC:: get_join_child(node_const_pointer p_nd, a_const_pointer p_tr) const { node_pointer p = const_cast(p_nd); return const_cast(this)->get_join_child(p, p_tr); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_join_child(node_pointer p_nd, a_const_pointer p_traits) { size_type i; a_const_iterator b_it; a_const_iterator e_it; if (p_nd->m_type == leaf_node) { leaf_const_pointer p = static_cast(p_nd); typedef typename type_traits::key_const_reference kcr; kcr r_key = access_traits::extract_key(p->value()); b_it = p_traits->begin(r_key); e_it = p_traits->end(r_key); } else { b_it = static_cast(p_nd)->pref_b_it(); e_it = static_cast(p_nd)->pref_e_it(); } i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); return m_a_p_children[i]; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_child(node_pointer p_nd) { size_type i = 0; for (; i < arr_size; ++i) if (m_a_p_children[i] == p_nd) { m_a_p_children[i] = 0; return; } _GLIBCXX_DEBUG_ASSERT(i != arr_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_child(iterator it) { *it.m_p_p_cur = 0; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: replace_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it, a_const_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); _GLIBCXX_DEBUG_ASSERT(i < arr_size); m_a_p_children[i] = p_nd; p_nd->m_p_parent = this; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::a_const_iterator PB_DS_CLASS_C_DEC:: pref_b_it() const { return m_pref_b_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::a_const_iterator PB_DS_CLASS_C_DEC:: pref_e_it() const { return m_pref_e_it; } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: should_be_mine(a_const_iterator b_it, a_const_iterator e_it, size_type checked_ind, a_const_pointer p_traits) const { if (m_e_ind == 0) return true; const size_type num_es = std::distance(b_it, e_it); if (num_es < m_e_ind) return false; a_const_iterator key_b_it = b_it; std::advance(key_b_it, checked_ind); a_const_iterator key_e_it = b_it; std::advance(key_e_it, m_e_ind); a_const_iterator value_b_it = m_pref_b_it; std::advance(value_b_it, checked_ind); a_const_iterator value_e_it = m_pref_b_it; std::advance(value_e_it, m_e_ind); return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it, value_e_it); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: leftmost_descendant() { node_pointer p_pot = *begin(); if (p_pot->m_type == leaf_node) return (static_cast(p_pot)); _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node); return static_cast(p_pot)->leftmost_descendant(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_const_pointer PB_DS_CLASS_C_DEC:: leftmost_descendant() const { return const_cast(this)->leftmost_descendant(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: rightmost_descendant() { const size_type num_children = std::distance(begin(), end()); _GLIBCXX_DEBUG_ASSERT(num_children >= 2); iterator it = begin(); std::advance(it, num_children - 1); node_pointer p_pot =* it; if (p_pot->m_type == leaf_node) return static_cast(p_pot); _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node); return static_cast(p_pot)->rightmost_descendant(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_const_pointer PB_DS_CLASS_C_DEC:: rightmost_descendant() const { return const_cast(this)->rightmost_descendant(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_begin_pos() const { size_type i = 0; for (; i < arr_size && m_a_p_children[i] == 0; ++i) ; return i; } #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_debug_info PB_DS_CLASS_C_DEC:: assert_valid_imp(a_const_pointer p_traits, const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(base_type::m_type == i_node); PB_DS_DEBUG_VERIFY(static_cast(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2); for (typename _Inode::const_iterator it = begin(); it != end(); ++it) { node_const_pointer p_nd = *it; PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this); node_debug_info child_ret = p_nd->assert_valid_imp(p_traits, __file, __line); PB_DS_DEBUG_VERIFY(static_cast(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast(it.m_p_p_cur - m_a_p_children)); } return std::make_pair(pref_b_it(), pref_e_it()); } #endif #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp000064400000003772147547540560016054 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/update_fn_imps.hpp * Contains an implementation class for pat_trie_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer, null_node_update_pointer) { } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer p_nd, Node_Update_*) { Node_Update_::operator()(node_iterator(p_nd, this), node_const_iterator(0, this)); } 4.8.2/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp000064400000006511147547540560015662 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/trace_fn_imps.hpp * Contains an implementation class for pat_trie_. */ #ifdef PB_DS_PAT_TRIE_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << std::endl; if (m_p_head->m_p_parent == 0) return; trace_node(m_p_head->m_p_parent, 0); std::cerr << std::endl; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_node(node_const_pointer p_nd, size_type level) { for (size_type i = 0; i < level; ++i) std::cerr << ' '; std::cerr << p_nd << " "; std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i "); trace_node_metadata(p_nd, type_to_type()); typename access_traits::const_iterator el_it = pref_begin(p_nd); while (el_it != pref_end(p_nd)) { std::cerr <<* el_it; ++el_it; } if (p_nd->m_type == pat_trie_leaf_node_type) { std::cerr << std::endl; return; } inode_const_pointer p_internal = static_cast(p_nd); std::cerr << " " << static_cast(p_internal->get_e_ind()) << std::endl; const size_type num_children = std::distance(p_internal->begin(), p_internal->end()); for (size_type child_i = 0; child_i < num_children; ++child_i) { typename inode::const_iterator child_it = p_internal->begin(); std::advance(child_it, num_children - child_i - 1); trace_node(*child_it, level + 1); } } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: trace_node_metadata(node_const_pointer p_nd, type_to_type) { std::cerr << "(" << static_cast(p_nd->get_metadata()) << ") "; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_node_metadata(node_const_pointer, type_to_type) { } #endif 4.8.2/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp000064400000034213147547540560017107 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/insert_join_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) branch_bag bag; if (!join_prep(other, bag)) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, other.m_p_head->m_p_parent, 0, bag); m_p_head->m_p_parent->m_p_parent = m_p_head; m_size += other.m_size; other.initialize(); PB_DS_ASSERT_VALID(other) m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other, branch_bag& r_bag) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return false; if (m_size == 0) { value_swap(other); return false; } const bool greater = synth_access_traits::cmp_keys(PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()), PB_DS_V2F(static_cast(other.m_p_head->m_p_min)->value())); const bool lesser = synth_access_traits::cmp_keys(PB_DS_V2F(static_cast(other.m_p_head->m_p_max)->value()), PB_DS_V2F(static_cast(m_p_head->m_p_min)->value())); if (!greater && !lesser) __throw_join_error(); rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);) return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: rec_join_prep(node_const_pointer p_l, node_const_pointer p_r, branch_bag& r_bag) { if (p_l->m_type == leaf_node) { if (p_r->m_type == leaf_node) { rec_join_prep(static_cast(p_l), static_cast(p_r), r_bag); return; } _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); rec_join_prep(static_cast(p_l), static_cast(p_r), r_bag); return; } _GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node); if (p_r->m_type == leaf_node) { rec_join_prep(static_cast(p_l), static_cast(p_r), r_bag); return; } _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); rec_join_prep(static_cast(p_l), static_cast(p_r), r_bag); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: rec_join_prep(leaf_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/, branch_bag& r_bag) { r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: rec_join_prep(leaf_const_pointer /*p_l*/, inode_const_pointer /*p_r*/, branch_bag& r_bag) { r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: rec_join_prep(inode_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/, branch_bag& r_bag) { r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: rec_join_prep(inode_const_pointer p_l, inode_const_pointer p_r, branch_bag& r_bag) { if (p_l->get_e_ind() == p_r->get_e_ind() && synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), p_r->pref_b_it(), p_r->pref_e_it())) { for (typename inode::const_iterator it = p_r->begin(); it != p_r->end(); ++ it) { node_const_pointer p_l_join_child = p_l->get_join_child(*it, this); if (p_l_join_child != 0) rec_join_prep(p_l_join_child, * it, r_bag); } return; } if (p_r->get_e_ind() < p_l->get_e_ind() && p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this); if (p_r_join_child != 0) rec_join_prep(p_r_join_child, p_l, r_bag); return; } if (p_r->get_e_ind() < p_l->get_e_ind() && p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this); if (p_r_join_child != 0) rec_join_prep(p_r_join_child, p_l, r_bag); return; } r_bag.add_branch(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind, branch_bag& r_bag) { _GLIBCXX_DEBUG_ASSERT(p_r != 0); if (p_l == 0) { apply_update(p_r, (node_update*)this); return (p_r); } if (p_l->m_type == leaf_node) { if (p_r->m_type == leaf_node) { node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), r_bag); apply_update(p_ret, (node_update*)this); return p_ret; } _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), checked_ind, r_bag); apply_update(p_ret, (node_update*)this); return p_ret; } _GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node); if (p_r->m_type == leaf_node) { node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), checked_ind, r_bag); apply_update(p_ret, (node_update*)this); return p_ret; } _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), r_bag); apply_update(p_ret, (node_update*)this); return p_ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(leaf_pointer p_l, leaf_pointer p_r, branch_bag& r_bag) { _GLIBCXX_DEBUG_ASSERT(p_r != 0); if (p_l == 0) return (p_r); node_pointer p_ret = insert_branch(p_l, p_r, r_bag); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2); return p_ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(leaf_pointer p_l, inode_pointer p_r, size_type checked_ind, branch_bag& r_bag) { #ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif _GLIBCXX_DEBUG_ASSERT(p_r != 0); node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(inode_pointer p_l, leaf_pointer p_r, size_type checked_ind, branch_bag& r_bag) { _GLIBCXX_DEBUG_ASSERT(p_l != 0); _GLIBCXX_DEBUG_ASSERT(p_r != 0); #ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this)) { node_pointer p_ret = insert_branch(p_l, p_r, r_bag); PB_DS_ASSERT_NODE_VALID(p_ret) _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } node_pointer p_pot_child = p_l->add_child(p_r, pref_begin(p_r), pref_end(p_r), this); if (p_pot_child != p_r) { node_pointer p_new_child = rec_join(p_pot_child, p_r, p_l->get_e_ind(), r_bag); p_l->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); } PB_DS_ASSERT_NODE_VALID(p_l) _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); return p_l; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(inode_pointer p_l, inode_pointer p_r, branch_bag& r_bag) { _GLIBCXX_DEBUG_ASSERT(p_l != 0); _GLIBCXX_DEBUG_ASSERT(p_r != 0); #ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif if (p_l->get_e_ind() == p_r->get_e_ind() && synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), p_r->pref_b_it(), p_r->pref_e_it())) { for (typename inode::iterator it = p_r->begin(); it != p_r->end(); ++ it) { node_pointer p_new_child = rec_join(p_l->get_join_child(*it, this), * it, 0, r_bag); p_l->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); } p_r->~inode(); s_inode_allocator.deallocate(p_r, 1); PB_DS_ASSERT_NODE_VALID(p_l) _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); return p_l; } if (p_l->get_e_ind() < p_r->get_e_ind() && p_l->should_be_mine(p_r->pref_b_it(), p_r->pref_e_it(), 0, this)) { node_pointer p_new_child = rec_join(p_l->get_join_child(p_r, this), p_r, 0, r_bag); p_l->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); PB_DS_ASSERT_NODE_VALID(p_l) return p_l; } if (p_r->get_e_ind() < p_l->get_e_ind() && p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { node_pointer p_new_child = rec_join(p_r->get_join_child(p_l, this), p_l, 0, r_bag); p_r->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); PB_DS_ASSERT_NODE_VALID(p_r) _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs); return p_r; } node_pointer p_ret = insert_branch(p_l, p_r, r_bag); PB_DS_ASSERT_NODE_VALID(p_ret) _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_val) { node_pointer p_lf = find_imp(PB_DS_V2F(r_val)); if (p_lf != 0 && p_lf->m_type == leaf_node && synth_access_traits::equal_keys(PB_DS_V2F(static_cast(p_lf)->value()), PB_DS_V2F(r_val))) { PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) PB_DS_ASSERT_VALID((*this)) return std::make_pair(iterator(p_lf), false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); cond_dealtor cond(p_new_lf); new (p_new_lf) leaf(r_val); apply_update(p_new_lf, (node_update*)this); cond.set_call_destructor(); branch_bag bag; bag.add_branch(); m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag); m_p_head->m_p_parent->m_p_parent = m_p_head; cond.set_no_action_dtor(); ++m_size; update_min_max_for_inserted_leaf(p_new_lf); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) PB_DS_ASSERT_VALID((*this)) return std::make_pair(point_iterator(p_new_lf), true); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: keys_diff_ind(typename access_traits::const_iterator b_l, typename access_traits::const_iterator e_l, typename access_traits::const_iterator b_r, typename access_traits::const_iterator e_r) { size_type diff_pos = 0; while (b_l != e_l) { if (b_r == e_r) return (diff_pos); if (access_traits::e_pos(*b_l) != access_traits::e_pos(*b_r)) return (diff_pos); ++b_l; ++b_r; ++diff_pos; } _GLIBCXX_DEBUG_ASSERT(b_r != e_r); return diff_pos; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::inode_pointer PB_DS_CLASS_C_DEC:: insert_branch(node_pointer p_l, node_pointer p_r, branch_bag& r_bag) { typename synth_access_traits::const_iterator left_b_it = pref_begin(p_l); typename synth_access_traits::const_iterator left_e_it = pref_end(p_l); typename synth_access_traits::const_iterator right_b_it = pref_begin(p_r); typename synth_access_traits::const_iterator right_e_it = pref_end(p_r); const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it, right_b_it, right_e_it); inode_pointer p_new_nd = r_bag.get_branch(); new (p_new_nd) inode(diff_ind, left_b_it); p_new_nd->add_child(p_l, left_b_it, left_e_it, this); p_new_nd->add_child(p_r, right_b_it, right_e_it, this); p_l->m_p_parent = p_new_nd; p_r->m_p_parent = p_new_nd; PB_DS_ASSERT_NODE_VALID(p_new_nd) return (p_new_nd); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: update_min_max_for_inserted_leaf(leaf_pointer p_new_lf) { if (m_p_head->m_p_min == m_p_head || synth_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()), PB_DS_V2F(static_cast(m_p_head->m_p_min)->value()))) m_p_head->m_p_min = p_new_lf; if (m_p_head->m_p_max == m_p_head || synth_access_traits::cmp_keys(PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value()))) m_p_head->m_p_max = p_new_lf; } 4.8.2/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp000064400000007317147547540560015657 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/debug_fn_imps.hpp * Contains an implementation class for pat_trie_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { if (m_p_head->m_p_parent != 0) m_p_head->m_p_parent->assert_valid(this, __file, __line); assert_iterators(__file, __line); assert_reverse_iterators(__file, __line); if (m_p_head->m_p_parent == 0) { PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head); PB_DS_DEBUG_VERIFY(empty()); return; } PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == leaf_node); PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == leaf_node); PB_DS_DEBUG_VERIFY(!empty()); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_iterators(const char* __file, int __line) const { size_type calc_size = 0; for (const_iterator it = begin(); it != end(); ++it) { ++calc_size; debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it); } PB_DS_DEBUG_VERIFY(calc_size == m_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_reverse_iterators(const char* __file, int __line) const { size_type calc_size = 0; for (const_reverse_iterator it = rbegin(); it != rend(); ++it) { ++calc_size; node_const_pointer p_nd = const_cast(this)->find_imp(PB_DS_V2F(*it)); PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd); } PB_DS_DEBUG_VERIFY(calc_size == m_size); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: recursive_count_leafs(node_const_pointer p_nd, const char* __file, int __line) { if (p_nd == 0) return (0); if (p_nd->m_type == leaf_node) return (1); PB_DS_DEBUG_VERIFY(p_nd->m_type == i_node); size_type ret = 0; for (typename inode::const_iterator it = static_cast(p_nd)->begin(); it != static_cast(p_nd)->end(); ++it) ret += recursive_count_leafs(*it, __file, __line); return ret; } #endif 4.8.2/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp000064400000017055147547540560015724 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/split_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) branch_bag bag; leaf_pointer p_split_lf = split_prep(r_key, other, bag); if (p_split_lf == 0) { _GLIBCXX_DEBUG_ASSERT(bag.empty()); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } _GLIBCXX_DEBUG_ASSERT(!bag.empty()); other.clear(); m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf), pref_end(p_split_lf), other, bag); m_p_head->m_p_parent->m_p_parent = m_p_head; head_pointer __ohead = other.m_p_head; __ohead->m_p_max = m_p_head->m_p_max; m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); __ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent); other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(), other.PB_DS_CLASS_C_DEC::end()); m_size -= other.m_size; PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other, branch_bag& r_bag) { _GLIBCXX_DEBUG_ASSERT(r_bag.empty()); if (m_size == 0) { other.clear(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return 0; } if (synth_access_traits::cmp_keys(r_key, PB_DS_V2F(static_cast(m_p_head->m_p_min)->value()))) { other.clear(); value_swap(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return 0; } if (!synth_access_traits::cmp_keys(r_key, PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()))) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return 0; } iterator it = lower_bound(r_key); if (!synth_access_traits::equal_keys(PB_DS_V2F(*it), r_key)) --it; node_pointer p_nd = it.m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); leaf_pointer p_ret_l = static_cast(p_nd); while (p_nd->m_type != head_node) { r_bag.add_branch(); p_nd = p_nd->m_p_parent; } _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_access_traits&)(*this), other);) return p_ret_l; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it, PB_DS_CLASS_C_DEC& other, branch_bag& r_bag) { if (p_nd->m_type == leaf_node) { _GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == 0); return p_nd; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); inode_pointer p_ind = static_cast(p_nd); node_pointer pfirst = p_ind->get_child_node(b_it, e_it, this); node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag); PB_DS_ASSERT_NODE_VALID(p_child_ret) p_ind->replace_child(p_child_ret, b_it, e_it, this); apply_update(p_ind, (node_update*)this); inode_iterator child_it = p_ind->get_child_it(b_it, e_it, this); const size_type lhs_dist = std::distance(p_ind->begin(), child_it); const size_type lhs_num_children = lhs_dist + 1; _GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0); const size_type rhs_dist = std::distance(p_ind->begin(), p_ind->end()); size_type rhs_num_children = rhs_dist - lhs_num_children; if (rhs_num_children == 0) { apply_update(p_ind, (node_update*)this); return p_ind; } other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it, rhs_num_children, r_bag); child_it = p_ind->get_child_it(b_it, e_it, this); while (rhs_num_children != 0) { ++child_it; p_ind->remove_child(child_it); --rhs_num_children; } apply_update(p_ind, (node_update*)this); const size_type int_dist = std::distance(p_ind->begin(), p_ind->end()); _GLIBCXX_DEBUG_ASSERT(int_dist >= 1); if (int_dist > 1) { p_ind->update_prefixes(this); PB_DS_ASSERT_NODE_VALID(p_ind) apply_update(p_ind, (node_update*)this); return p_ind; } node_pointer p_ret = *p_ind->begin(); p_ind->~inode(); s_inode_allocator.deallocate(p_ind, 1); apply_update(p_ret, (node_update*)this); return p_ret; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split_insert_branch(size_type e_ind, a_const_iterator b_it, inode_iterator child_b_it, size_type num_children, branch_bag& r_bag) { #ifdef _GLIBCXX_DEBUG if (m_p_head->m_p_parent != 0) PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) #endif const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1; const size_type total_num_children = start + num_children; if (total_num_children == 0) { _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0); return; } if (total_num_children == 1) { if (m_p_head->m_p_parent != 0) { PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) return; } _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0); ++child_b_it; m_p_head->m_p_parent = *child_b_it; m_p_head->m_p_parent->m_p_parent = m_p_head; apply_update(m_p_head->m_p_parent, (node_update*)this); PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) return; } _GLIBCXX_DEBUG_ASSERT(total_num_children > 1); inode_pointer p_new_root = r_bag.get_branch(); new (p_new_root) inode(e_ind, b_it); size_type num_inserted = 0; while (num_inserted++ < num_children) { ++child_b_it; PB_DS_ASSERT_NODE_VALID((*child_b_it)) p_new_root->add_child(*child_b_it, pref_begin(*child_b_it), pref_end(*child_b_it), this); } if (m_p_head->m_p_parent != 0) p_new_root->add_child(m_p_head->m_p_parent, pref_begin(m_p_head->m_p_parent), pref_end(m_p_head->m_p_parent), this); m_p_head->m_p_parent = p_new_root; p_new_root->m_p_parent = m_p_head; apply_update(m_p_head->m_p_parent, (node_update*)this); PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) } 4.8.2/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp000064400000013120147547540560021604 0ustar00 // -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/constructors_destructor_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::head_allocator PB_DS_CLASS_C_DEC::s_head_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::inode_allocator PB_DS_CLASS_C_DEC::s_inode_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::leaf_allocator PB_DS_CLASS_C_DEC::s_leaf_allocator; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_PAT_TRIE_NAME() : m_p_head(s_head_allocator.allocate(1)), m_size(0) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_PAT_TRIE_NAME(const access_traits& r_access_traits) : synth_access_traits(r_access_traits), m_p_head(s_head_allocator.allocate(1)), m_size(0) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC& other) : #ifdef _GLIBCXX_DEBUG debug_base(other), #endif synth_access_traits(other), node_update(other), m_p_head(s_head_allocator.allocate(1)), m_size(0) { initialize(); m_size = other.m_size; PB_DS_ASSERT_VALID(other) if (other.m_p_head->m_p_parent == 0) { PB_DS_ASSERT_VALID((*this)) return; } __try { m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent); } __catch(...) { s_head_allocator.deallocate(m_p_head, 1); __throw_exception_again; } m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_parent->m_p_parent = m_p_head; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) value_swap(other); std::swap((access_traits& )(*this), (access_traits& )other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_p_head, other.m_p_head); std::swap(m_size, other.m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_PAT_TRIE_NAME() { clear(); s_head_allocator.deallocate(m_p_head, 1); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { new (m_p_head) head(); m_p_head->m_p_parent = 0; m_p_head->m_p_min = m_p_head; m_p_head->m_p_max = m_p_head; m_size = 0; } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: recursive_copy_node(node_const_pointer p_ncp) { _GLIBCXX_DEBUG_ASSERT(p_ncp != 0); if (p_ncp->m_type == leaf_node) { leaf_const_pointer p_other_lf = static_cast(p_ncp); leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); cond_dealtor cond(p_new_lf); new (p_new_lf) leaf(p_other_lf->value()); apply_update(p_new_lf, (node_update*)this); cond.set_no_action_dtor(); return (p_new_lf); } _GLIBCXX_DEBUG_ASSERT(p_ncp->m_type == i_node); node_pointer a_p_children[inode::arr_size]; size_type child_i = 0; inode_const_pointer p_icp = static_cast(p_ncp); typename inode::const_iterator child_it = p_icp->begin(); inode_pointer p_ret; __try { while (child_it != p_icp->end()) { a_p_children[child_i] = recursive_copy_node(*(child_it)); child_i++; child_it++; } p_ret = s_inode_allocator.allocate(1); } __catch(...) { while (child_i-- > 0) clear_imp(a_p_children[child_i]); __throw_exception_again; } new (p_ret) inode(p_icp->get_e_ind(), pref_begin(a_p_children[0])); --child_i; _GLIBCXX_DEBUG_ASSERT(child_i >= 1); do p_ret->add_child(a_p_children[child_i], pref_begin(a_p_children[child_i]), pref_end(a_p_children[child_i]), this); while (child_i-- > 0); apply_update(p_ret, (node_update*)this); return p_ret; } 4.8.2/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp000064400000010352147547540560016060 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/rotate_fn_imps.hpp * Contains imps for rotating nodes. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_left(node_pointer p_x) { node_pointer p_y = p_x->m_p_right; p_x->m_p_right = p_y->m_p_left; if (p_y->m_p_left != 0) p_y->m_p_left->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_left) p_x->m_p_parent->m_p_left = p_y; else p_x->m_p_parent->m_p_right = p_y; p_y->m_p_left = p_x; p_x->m_p_parent = p_y; _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) apply_update(p_x, (Node_Update*)this); apply_update(p_x->m_p_parent, (Node_Update*)this); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_right(node_pointer p_x) { node_pointer p_y = p_x->m_p_left; p_x->m_p_left = p_y->m_p_right; if (p_y->m_p_right != 0) p_y->m_p_right->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_right) p_x->m_p_parent->m_p_right = p_y; else p_x->m_p_parent->m_p_left = p_y; p_y->m_p_right = p_x; p_x->m_p_parent = p_y; _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) apply_update(p_x, (Node_Update*)this); apply_update(p_x->m_p_parent, (Node_Update*)this); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: rotate_parent(node_pointer p_nd) { node_pointer p_parent = p_nd->m_p_parent; if (p_nd == p_parent->m_p_left) rotate_right(p_parent); else rotate_left(p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer /*p_nd*/, __gnu_pbds::null_node_update* /*p_update*/) { } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer p_nd, Node_Update_* p_update) { p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == 0) ? 0 : & PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == 0) ? 0 : & PB_DS_V2F(p_nd->m_p_right->m_value)); } PB_DS_CLASS_T_DEC template inline void PB_DS_CLASS_C_DEC:: update_to_top(node_pointer p_nd, Node_Update_* p_update) { while (p_nd != m_p_head) { apply_update(p_nd, p_update); p_nd = p_nd->m_p_parent; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_to_top(node_pointer /*p_nd*/, __gnu_pbds::null_node_update* /*p_update*/) { } 4.8.2/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp000064400000006630147547540560016602 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/iterators_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { return iterator(m_p_head->m_p_min); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { return const_iterator(m_p_head->m_p_min); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return iterator(m_p_head); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return const_iterator(m_p_head); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: rbegin() const { if (empty()) return rend(); return --end(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: rbegin() { if (empty()) return rend(); return --end(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: rend() { return reverse_iterator(m_p_head); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: rend() const { return const_reverse_iterator(m_p_head); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_begin() const { return node_const_iterator(m_p_head->m_p_parent, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_begin() { return node_iterator(m_p_head->m_p_parent, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_const_iterator PB_DS_CLASS_C_DEC:: node_end() const { return node_const_iterator(0, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_iterator PB_DS_CLASS_C_DEC:: node_end() { return node_iterator(0, this); } 4.8.2/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp000064400000017411147547540560015664 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/erase_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { node_pointer p_nd = find_imp(r_key); if (p_nd == 0 || p_nd->m_type == i_node) { PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); if (!synth_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast(p_nd)->value()), r_key)) { PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } PB_DS_CHECK_KEY_EXISTS(r_key) erase_leaf(static_cast(p_nd)); PB_DS_ASSERT_VALID((*this)) return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_fixup(inode_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1); if (std::distance(p_nd->begin(), p_nd->end()) == 1) { node_pointer p_parent = p_nd->m_p_parent; if (p_parent == m_p_head) m_p_head->m_p_parent = *p_nd->begin(); else { _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node); node_pointer p_new_child = *p_nd->begin(); typedef inode_pointer inode_ptr; inode_ptr p_internal = static_cast(p_parent); p_internal->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); } (*p_nd->begin())->m_p_parent = p_nd->m_p_parent; p_nd->~inode(); s_inode_allocator.deallocate(p_nd, 1); if (p_parent == m_p_head) return; _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node); p_nd = static_cast(p_parent); } while (true) { _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); p_nd->update_prefixes(this); apply_update(p_nd, (node_update*)this); PB_DS_ASSERT_NODE_VALID(p_nd) if (p_nd->m_p_parent->m_type == head_node) return; _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == i_node); p_nd = static_cast(p_nd->m_p_parent); } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: actual_erase_leaf(leaf_pointer p_l) { _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->value()))); p_l->~leaf(); s_leaf_allocator.deallocate(p_l, 1); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { if (!empty()) { clear_imp(m_p_head->m_p_parent); m_size = 0; initialize(); _GLIBCXX_DEBUG_ONLY(debug_base::clear();) PB_DS_ASSERT_VALID((*this)) } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear_imp(node_pointer p_nd) { if (p_nd->m_type == i_node) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); for (typename inode::iterator it = static_cast(p_nd)->begin(); it != static_cast(p_nd)->end(); ++it) { node_pointer p_child =* it; clear_imp(p_child); } s_inode_allocator.deallocate(static_cast(p_nd), 1); return; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); static_cast(p_nd)->~leaf(); s_leaf_allocator.deallocate(static_cast(p_nd), 1); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: erase(const_iterator it) { PB_DS_ASSERT_VALID((*this)) if (it == end()) return it; const_iterator ret_it = it; ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); erase_leaf(static_cast(it.m_p_nd)); PB_DS_ASSERT_VALID((*this)) return ret_it; } #ifdef PB_DS_DATA_TRUE_INDICATOR PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { PB_DS_ASSERT_VALID((*this)) if (it == end()) return it; iterator ret_it = it; ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); erase_leaf(static_cast(it.m_p_nd)); PB_DS_ASSERT_VALID((*this)) return ret_it; } #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: erase(const_reverse_iterator it) { PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == m_p_head) return it; const_reverse_iterator ret_it = it; ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); erase_leaf(static_cast(it.m_p_nd)); PB_DS_ASSERT_VALID((*this)) return ret_it; } #ifdef PB_DS_DATA_TRUE_INDICATOR PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == m_p_head) return it; reverse_iterator ret_it = it; ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); erase_leaf(static_cast(it.m_p_nd)); PB_DS_ASSERT_VALID((*this)) return ret_it; } #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { size_type num_ersd = 0; PB_DS_ASSERT_VALID((*this)) iterator it = begin(); while (it != end()) { PB_DS_ASSERT_VALID((*this)) if (pred(*it)) { ++num_ersd; it = erase(it); } else ++it; } PB_DS_ASSERT_VALID((*this)) return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_leaf(leaf_pointer p_l) { update_min_max_for_erased_leaf(p_l); if (p_l->m_p_parent->m_type == head_node) { _GLIBCXX_DEBUG_ASSERT(size() == 1); clear(); return; } _GLIBCXX_DEBUG_ASSERT(size() > 1); _GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == i_node); inode_pointer p_parent = static_cast(p_l->m_p_parent); p_parent->remove_child(p_l); erase_fixup(p_parent); actual_erase_leaf(p_l); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: update_min_max_for_erased_leaf(leaf_pointer p_l) { if (m_size == 1) { m_p_head->m_p_min = m_p_head; m_p_head->m_p_max = m_p_head; return; } if (p_l == static_cast(m_p_head->m_p_min)) { iterator it(p_l); ++it; m_p_head->m_p_min = it.m_p_nd; return; } if (p_l == static_cast(m_p_head->m_p_max)) { iterator it(p_l); --it; m_p_head->m_p_max = it.m_p_nd; } } 4.8.2/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp000064400000005550147547540560016206 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/r_erase_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value))); p_z->~node(); s_node_allocator.deallocate(p_z, 1); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: update_min_max_for_erased_node(node_pointer p_z) { if (m_size == 1) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; return; } if (m_p_head->m_p_left == p_z) { iterator it(p_z); ++it; m_p_head->m_p_left = it.m_p_nd; } else if (m_p_head->m_p_right == p_z) { iterator it(p_z); --it; m_p_head->m_p_right = it.m_p_nd; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { _GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) clear_imp(m_p_head->m_p_parent); m_size = 0; initialize(); _GLIBCXX_DEBUG_ONLY(debug_base::clear();) _GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear_imp(node_pointer p_nd) { if (p_nd == 0) return; clear_imp(p_nd->m_p_left); clear_imp(p_nd->m_p_right); p_nd->~Node(); s_node_allocator.deallocate(p_nd, 1); } 4.8.2/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp000064400000004247147547540560017410 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/policy_access_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::access_traits& PB_DS_CLASS_C_DEC:: get_access_traits() { return *this; } PB_DS_CLASS_T_DEC const typename PB_DS_CLASS_C_DEC::access_traits& PB_DS_CLASS_C_DEC:: get_access_traits() const { return *this; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_update& PB_DS_CLASS_C_DEC:: get_node_update() { return *this; } PB_DS_CLASS_T_DEC const typename PB_DS_CLASS_C_DEC::node_update& PB_DS_CLASS_C_DEC:: get_node_update() const { return *this; } 4.8.2/ext/pb_ds/detail/pat_trie_/traits.hpp000064400000014241147547540560014356 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/traits.hpp * Contains an implementation class for pat_trie_. */ #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP #define PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP #include #include namespace __gnu_pbds { namespace detail { /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct trie_traits { private: typedef pat_trie_base base_type; typedef types_traits type_traits; public: typedef typename trie_node_metadata_dispatch::type metadata_type; typedef base_type::_Metadata metadata; typedef _ATraits access_traits; /// Type for synthesized traits. typedef __gnu_pbds::detail::synth_access_traits synth_access_traits; typedef base_type::_Node_base node; typedef base_type::_Head head; typedef base_type::_Leaf leaf; typedef base_type::_Inode inode; typedef base_type::_Iter iterator; typedef base_type::_CIter const_iterator; typedef base_type::_Iter reverse_iterator; typedef base_type::_CIter const_reverse_iterator; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef base_type::_Node_citer node_const_iterator; typedef base_type::_Node_iter node_iterator; /// Type for node update. typedef Node_Update node_update; typedef null_node_update* null_node_update_pointer; }; /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct trie_traits { private: typedef pat_trie_base base_type; typedef types_traits type_traits; public: typedef typename trie_node_metadata_dispatch::type metadata_type; typedef base_type::_Metadata metadata; typedef _ATraits access_traits; /// Type for synthesized traits. typedef __gnu_pbds::detail::synth_access_traits synth_access_traits; typedef base_type::_Node_base node; typedef base_type::_Head head; typedef base_type::_Leaf leaf; typedef base_type::_Inode inode; typedef base_type::_CIter const_iterator; typedef const_iterator iterator; typedef base_type::_CIter const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; /// This is an iterator to an iterator: it iterates over nodes, /// and de-referencing it returns one of the tree's iterators. typedef base_type::_Node_citer node_const_iterator; typedef node_const_iterator node_iterator; /// Type for node update. typedef Node_Update node_update; typedef null_node_update* null_node_update_pointer; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP 4.8.2/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp000064400000017303147547540560015505 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/find_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = find_imp(r_key); if (p_nd == 0 || p_nd->m_type != leaf_node) { PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { PB_DS_CHECK_KEY_EXISTS(r_key) return iterator(p_nd); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { PB_DS_ASSERT_VALID((*this)) node_const_pointer p_nd = const_cast(this)->find_imp(r_key); if (p_nd == 0 || p_nd->m_type != leaf_node) { PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { PB_DS_CHECK_KEY_EXISTS(r_key) return const_iterator(const_cast(p_nd)); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(key_const_reference r_key) { if (empty()) return 0; typename synth_access_traits::const_iterator b_it = synth_access_traits::begin(r_key); typename synth_access_traits::const_iterator e_it = synth_access_traits::end(r_key); node_pointer p_nd = m_p_head->m_p_parent; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); while (p_nd->m_type != leaf_node) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); node_pointer p_next_nd = static_cast(p_nd)->get_child_node(b_it, e_it, this); if (p_next_nd == 0) return p_nd; p_nd = p_next_nd; } return p_nd; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: lower_bound_imp(key_const_reference r_key) { if (empty()) return (m_p_head); node_pointer p_nd = m_p_head->m_p_parent; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); typename PB_DS_CLASS_C_DEC::a_const_iterator b_it = synth_access_traits::begin(r_key); typename PB_DS_CLASS_C_DEC::a_const_iterator e_it = synth_access_traits::end(r_key); size_type checked_ind = 0; while (true) { if (p_nd->m_type == leaf_node) { if (!synth_access_traits::cmp_keys(PB_DS_V2F(static_cast(p_nd)->value()), r_key)) return p_nd; iterator it(p_nd); ++it; return it.m_p_nd; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); const size_type new_checked_ind = static_cast(p_nd)->get_e_ind(); p_nd = static_cast(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this); checked_ind = new_checked_ind; } } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: lower_bound(key_const_reference r_key) { return point_iterator(lower_bound_imp(r_key)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: lower_bound(key_const_reference r_key) const { return point_const_iterator(const_cast(this)->lower_bound_imp(r_key)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: upper_bound(key_const_reference r_key) { point_iterator l_bound_it = lower_bound(r_key); _GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || !synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it), r_key)); if (l_bound_it == end() || synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it))) return l_bound_it; return ++l_bound_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: upper_bound(key_const_reference r_key) const { point_const_iterator l_bound_it = lower_bound(r_key); _GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || !synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it), r_key)); if (l_bound_it == end() || synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it))) return l_bound_it; return ++l_bound_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::a_const_iterator PB_DS_CLASS_C_DEC:: pref_begin(node_const_pointer p_nd) { if (p_nd->m_type == leaf_node) return (synth_access_traits::begin(PB_DS_V2F(static_cast(p_nd)->value()))); _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); return static_cast(p_nd)->pref_b_it(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::a_const_iterator PB_DS_CLASS_C_DEC:: pref_end(node_const_pointer p_nd) { if (p_nd->m_type == leaf_node) return (synth_access_traits::end(PB_DS_V2F(static_cast(p_nd)->value()))); _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); return static_cast(p_nd)->pref_e_it(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer PB_DS_CLASS_C_DEC:: leftmost_descendant(node_const_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->leftmost_descendant(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: leftmost_descendant(node_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->leftmost_descendant(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer PB_DS_CLASS_C_DEC:: rightmost_descendant(node_const_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->rightmost_descendant(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: rightmost_descendant(node_pointer p_nd) { if (p_nd->m_type == leaf_node) return static_cast(p_nd); return static_cast(p_nd)->rightmost_descendant(); } 4.8.2/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp000064400000004010147547540560015507 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/info_fn_imps.hpp * Contains an implementation class for pat_trie. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (m_size == 0); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return m_size; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_inode_allocator.max_size(); } 4.8.2/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp000064400000015076147547540560017133 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file pat_trie_/synth_access_traits.hpp * Contains an implementation class for a patricia tree. */ #ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP #define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP #include namespace __gnu_pbds { namespace detail { #define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \ template #define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \ synth_access_traits /// Synthetic element access traits. template struct synth_access_traits : public _ATraits { typedef _ATraits base_type; typedef typename base_type::const_iterator const_iterator; typedef Type_Traits type_traits; typedef typename type_traits::const_reference const_reference; typedef typename type_traits::key_const_reference key_const_reference; synth_access_traits(); synth_access_traits(const base_type&); inline bool equal_prefixes(const_iterator, const_iterator, const_iterator, const_iterator, bool compare_after = true) const; bool equal_keys(key_const_reference, key_const_reference) const; bool cmp_prefixes(const_iterator, const_iterator, const_iterator, const_iterator, bool compare_after = false) const; bool cmp_keys(key_const_reference, key_const_reference) const; inline static key_const_reference extract_key(const_reference); #ifdef _GLIBCXX_DEBUG bool operator()(key_const_reference, key_const_reference); #endif private: inline static key_const_reference extract_key(const_reference, true_type); inline static key_const_reference extract_key(const_reference, false_type); static integral_constant s_set_ind; }; PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC integral_constant PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind; PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: synth_access_traits() { } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: synth_access_traits(const _ATraits& r_traits) : _ATraits(r_traits) { } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC inline bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: equal_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r, const_iterator e_r, bool compare_after /*= false */) const { while (b_l != e_l) { if (b_r == e_r) return false; if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r)) return false; ++b_l; ++b_r; } return (!compare_after || b_r == e_r); } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: equal_keys(key_const_reference r_lhs_key, key_const_reference r_rhs_key) const { return equal_prefixes(base_type::begin(r_lhs_key), base_type::end(r_lhs_key), base_type::begin(r_rhs_key), base_type::end(r_rhs_key), true); } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: cmp_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r, const_iterator e_r, bool compare_after /* = false*/) const { while (b_l != e_l) { if (b_r == e_r) return false; const typename base_type::size_type l_pos = base_type::e_pos(*b_l); const typename base_type::size_type r_pos = base_type::e_pos(*b_r); if (l_pos != r_pos) return l_pos < r_pos; ++b_l; ++b_r; } if (!compare_after) return false; return b_r != e_r; } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: cmp_keys(key_const_reference r_lhs_key, key_const_reference r_rhs_key) const { return cmp_prefixes(base_type::begin(r_lhs_key), base_type::end(r_lhs_key), base_type::begin(r_rhs_key), base_type::end(r_rhs_key), true); } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: extract_key(const_reference r_val) { return extract_key(r_val, s_set_ind); } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: extract_key(const_reference r_val, true_type) { return r_val; } PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: extract_key(const_reference r_val, false_type) { return r_val.first; } #ifdef _GLIBCXX_DEBUG PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: operator()(key_const_reference r_lhs, key_const_reference r_rhs) { return cmp_keys(r_lhs, r_rhs); } #endif #undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC #undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp000064400000004570147547540560017473 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/trace_fn_imps.hpp * Contains implementations of gp_ht_map_'s trace-mode functions. */ #ifdef PB_DS_HT_MAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << static_cast(m_num_e) << " " << static_cast(m_num_used_e) << std::endl; for (size_type i = 0; i < m_num_e; ++i) { std::cerr << static_cast(i) << " "; switch(m_entries[i].m_stat) { case empty_entry_status: std::cerr << ""; break; case erased_entry_status: std::cerr << ""; break; case valid_entry_status: std::cerr << PB_DS_V2F(m_entries[i].m_value); break; default: _GLIBCXX_DEBUG_ASSERT(0); }; std::cerr << std::endl; } } #endif // #ifdef PB_DS_HT_MAP_TRACE_ 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp000064400000005547147547540560021720 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/erase_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s erase related functions, * when the hash value is stored. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase_imp(key_const_reference r_key, true_type) { const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); size_type i; resize_base::notify_erase_search_start(); for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); entry* const p_e = m_entries + pos; switch(p_e->m_stat) { case empty_entry_status: { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_erase_search_end(); erase_entry(p_e); do_resize_if_needed_no_throw(); return true; } break; case erased_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_erase_search_collision(); } resize_base::notify_erase_search_end(); return false; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp000064400000005133147547540560022111 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/resize_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s resize related functions, when the * hash value is stored. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, true_type) { key_const_reference r_key = PB_DS_V2F(p_e->m_value); size_type hash = ranged_probe_fn_base::operator()(r_key, p_e->m_hash); size_type i; for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); entry_pointer p_new_e = a_entries_resized + pos; switch(p_new_e->m_stat) { case empty_entry_status: new (&p_new_e->m_value) value_type(p_e->m_value); p_new_e->m_hash = hash; p_new_e->m_stat = valid_entry_status; return; case erased_entry_status: _GLIBCXX_DEBUG_ASSERT(0); break; case valid_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; } __throw_insert_error(); } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp000064400000004176147547540560017465 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/debug_fn_imps.hpp * Contains implementations of gp_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { debug_base::check_size(m_num_used_e, __file, __line); assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator, __file, __line); } #include #include #endif 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp000064400000004711147547540560022373 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_entry_array_valid(const entry_array a_entries, false_type, const char* __file, int __line) const { size_type iterated_num_used_e = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { const_entry_pointer p_e = &a_entries[pos]; switch(p_e->m_stat) { case empty_entry_status: case erased_entry_status: break; case valid_entry_status: { key_const_reference r_key = PB_DS_V2F(p_e->m_value); debug_base::check_key_exists(r_key, __file, __line); ++iterated_num_used_e; break; } default: PB_DS_DEBUG_VERIFY(0); }; } PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #endif 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp000064400000003550147547540560017676 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/insert_fn_imps.hpp * Contains implementations of gp_ht_map_'s insert related functions. */ #include #include 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp000064400000004335147547540560025456 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(mapped_const_reference r_val, size_type pos, true_type) { _GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); entry* const p_e = m_entries + pos; new (&p_e->m_value) mapped_value_type(r_val); p_e->m_hash = ranged_probe_fn_base::operator()(PB_DS_V2F(r_val)).second; p_e->m_stat = valid_entry_status; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);) } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp000064400000007765147547540560022131 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/insert_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s find related functions, * when the hash value is stored. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: find_ins_pos(key_const_reference r_key, true_type) { PB_DS_ASSERT_VALID((*this)) comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); size_type i; /* The insertion position is initted to a non-legal value to indicate * that it has not been initted yet. */ size_type ins_pos = m_num_e; resize_base::notify_insert_search_start(); for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); entry* const p_e = m_entries + pos; switch(p_e->m_stat) { case empty_entry_status: { resize_base::notify_insert_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return ((ins_pos == m_num_e) ? std::make_pair(pos, pos_hash_pair.second) : std::make_pair(ins_pos, pos_hash_pair.second)); } break; case erased_entry_status: if (ins_pos == m_num_e) ins_pos = pos; break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_insert_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(pos, pos_hash_pair.second); } break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_insert_search_collision(); } resize_base::notify_insert_search_end(); if (ins_pos == m_num_e) __throw_insert_error(); return std::make_pair(ins_pos, pos_hash_pair.second); } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, true_type) { key_const_reference r_key = PB_DS_V2F(r_val); comp_hash pos_hash_pair = find_ins_pos(r_key, traits_base::m_store_extra_indicator); _GLIBCXX_DEBUG_ASSERT(pos_hash_pair.first < m_num_e); entry_pointer p_e =& m_entries[pos_hash_pair.first]; if (p_e->m_stat == valid_entry_status) { PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&p_e->m_value, false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp000064400000003364147547540560021534 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/find_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s insert related functions, * when the hash value is stored. */ 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp000064400000006204147547540560017470 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/erase_fn_imps.hpp * Contains implementations of gp_ht_map_'s erase related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: erase_entry(entry_pointer p_e) { _GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status); _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_e->m_value));) p_e->m_value.~value_type(); p_e->m_stat = erased_entry_status; _GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0); resize_base::notify_erased(--m_num_used_e); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { for (size_type pos = 0; pos < m_num_e; ++pos) { entry_pointer p_e = &m_entries[pos]; if (p_e->m_stat == valid_entry_status) erase_entry(p_e); } do_resize_if_needed_no_throw(); resize_base::notify_cleared(); } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { entry_pointer p_e = &m_entries[pos]; if (p_e->m_stat == valid_entry_status) if (pred(p_e->m_value)) { ++num_ersd; erase_entry(p_e); } } do_resize_if_needed_no_throw(); PB_DS_ASSERT_VALID((*this)) return num_ersd; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { return erase_imp(r_key, traits_base::m_store_extra_indicator); } #include #include 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp000064400000005144147547540560021213 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/policy_access_fn_imps.hpp * Contains implementations of gp_ht_map_'s policy agpess * functions. */ PB_DS_CLASS_T_DEC Hash_Fn& PB_DS_CLASS_C_DEC:: get_hash_fn() { return *this; } PB_DS_CLASS_T_DEC const Hash_Fn& PB_DS_CLASS_C_DEC:: get_hash_fn() const { return *this; } PB_DS_CLASS_T_DEC Eq_Fn& PB_DS_CLASS_C_DEC:: get_eq_fn() { return *this; } PB_DS_CLASS_T_DEC const Eq_Fn& PB_DS_CLASS_C_DEC:: get_eq_fn() const { return *this; } PB_DS_CLASS_T_DEC Probe_Fn& PB_DS_CLASS_C_DEC:: get_probe_fn() { return *this; } PB_DS_CLASS_T_DEC const Probe_Fn& PB_DS_CLASS_C_DEC:: get_probe_fn() const { return *this; } PB_DS_CLASS_T_DEC Comb_Probe_Fn& PB_DS_CLASS_C_DEC:: get_comb_probe_fn() { return *this; } PB_DS_CLASS_T_DEC const Comb_Probe_Fn& PB_DS_CLASS_C_DEC:: get_comb_probe_fn() const { return *this; } PB_DS_CLASS_T_DEC Resize_Policy& PB_DS_CLASS_C_DEC:: get_resize_policy() { return *this; } PB_DS_CLASS_T_DEC const Resize_Policy& PB_DS_CLASS_C_DEC:: get_resize_policy() const { return *this; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp000064400000010075147547540560017673 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/resize_fn_imps.hpp * Contains implementations of gp_ht_map_'s resize related functions. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: do_resize_if_needed() { if (!resize_base::is_resize_needed()) return false; resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e)); return true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: do_resize(size_type n) { resize_imp(resize_base::get_nearest_larger_size(n)); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: do_resize_if_needed_no_throw() { if (!resize_base::is_resize_needed()) return; __try { resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e)); } __catch(...) { } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: resize_imp(size_type new_size) { #ifdef PB_DS_REGRESSION typename _Alloc::group_adjustor adjust(m_num_e); #endif if (new_size == m_num_e) return; PB_DS_ASSERT_VALID((*this)) const size_type old_size = m_num_e; entry_array a_entries_resized = 0; // Following line might throw an exception. a_entries_resized = s_entry_allocator.allocate(new_size); ranged_probe_fn_base::notify_resized(new_size); m_num_e = new_size; for (size_type i = 0; i < m_num_e; ++i) a_entries_resized[i].m_stat = empty_entry_status; __try { resize_imp(a_entries_resized, old_size); } __catch(...) { erase_all_valid_entries(a_entries_resized, new_size); m_num_e = old_size; s_entry_allocator.deallocate(a_entries_resized, new_size); ranged_probe_fn_base::notify_resized(old_size); __throw_exception_again; } // At this point no exceptions can be thrown. _GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator, __FILE__, __LINE__);) Resize_Policy::notify_resized(new_size); erase_all_valid_entries(m_entries, old_size); s_entry_allocator.deallocate(m_entries, old_size); m_entries = a_entries_resized; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: resize_imp(entry_array a_entries_resized, size_type old_size) { for (size_type pos = 0; pos < old_size; ++pos) if (m_entries[pos].m_stat == valid_entry_status) resize_imp_reassign(m_entries + pos, a_entries_resized, traits_base::m_store_extra_indicator); } #include #include 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp000064400000014716147547540560023243 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/constructor_destructor_fn_imps.hpp * Contains implementations of gp_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_allocator PB_DS_CLASS_C_DEC::s_entry_allocator; PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME() : ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn) : ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) : hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober) : hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, comb_hash_fn, prober), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober, const Resize_Policy& r_resize_policy) : hash_eq_fn_base(r_eq_fn), resize_base(r_resize_policy), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, comb_hash_fn, prober), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC& other) : #ifdef _GLIBCXX_DEBUG debug_base(other), #endif hash_eq_fn_base(other), resize_base(other), ranged_probe_fn_base(other), m_num_e(other.m_num_e), m_num_used_e(other.m_num_used_e), m_entries(s_entry_allocator.allocate(m_num_e)) { for (size_type i = 0; i < m_num_e; ++i) m_entries[i].m_stat = (entry_status)empty_entry_status; __try { for (size_type i = 0; i < m_num_e; ++i) { m_entries[i].m_stat = other.m_entries[i].m_stat; if (m_entries[i].m_stat == valid_entry_status) new (m_entries + i) entry(other.m_entries[i]); } } __catch(...) { deallocate_all(); __throw_exception_again; } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_GP_HASH_NAME() { deallocate_all(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) std::swap(m_num_e, other.m_num_e); std::swap(m_num_used_e, other.m_num_used_e); std::swap(m_entries, other.m_entries); ranged_probe_fn_base::swap(other); hash_eq_fn_base::swap(other); resize_base::swap(other); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: deallocate_all() { clear(); erase_all_valid_entries(m_entries, m_num_e); s_entry_allocator.deallocate(m_entries, m_num_e); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_all_valid_entries(entry_array a_entries_resized, size_type len) { for (size_type pos = 0; pos < len; ++pos) { entry_pointer p_e = &a_entries_resized[pos]; if (p_e->m_stat == valid_entry_status) p_e->m_value.~value_type(); } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { Resize_Policy::notify_resized(m_num_e); Resize_Policy::notify_cleared(); ranged_probe_fn_base::notify_resized(m_num_e); for (size_type i = 0; i < m_num_e; ++i) m_entries[i].m_stat = empty_entry_status; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp000064400000003604147547540560022225 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/find_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s find related functions, * when the hash value is not stored. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::pointer PB_DS_CLASS_C_DEC:: find_key_pointer(key_const_reference r_key, false_type) 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp000064400000007301147547540560022607 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s insert related functions, * when the hash value is not stored. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: find_ins_pos(key_const_reference r_key, false_type) { size_type hash = ranged_probe_fn_base::operator()(r_key); size_type i; /* The insertion position is initted to a non-legal value to indicate * that it has not been initted yet. */ size_type ins_pos = m_num_e; resize_base::notify_insert_search_start(); for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); _GLIBCXX_DEBUG_ASSERT(pos < m_num_e); entry* const p_e = m_entries + pos; switch(p_e->m_stat) { case empty_entry_status: { resize_base::notify_insert_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return (ins_pos == m_num_e) ? pos : ins_pos; } break; case erased_entry_status: if (ins_pos == m_num_e) ins_pos = pos; break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_insert_search_end(); PB_DS_CHECK_KEY_EXISTS(r_key) return pos; } break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_insert_search_collision(); } resize_base::notify_insert_search_end(); if (ins_pos == m_num_e) __throw_insert_error(); return ins_pos; } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, false_type) { key_const_reference r_key = PB_DS_V2F(r_val); const size_type pos = find_ins_pos(r_key, traits_base::m_store_extra_indicator); if (m_entries[pos].m_stat == valid_entry_status) { PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&(m_entries + pos)->m_value, false); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos), true); } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp000064400000005072147547540560022607 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s resize related functions, when the * hash value is not stored. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, false_type) { key_const_reference r_key = PB_DS_V2F(p_e->m_value); size_type hash = ranged_probe_fn_base::operator()(r_key); size_type i; for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); entry_pointer p_new_e = a_entries_resized + pos; switch(p_new_e->m_stat) { case empty_entry_status: new (&p_new_e->m_value) value_type(p_e->m_value); p_new_e->m_stat = valid_entry_status; return; case erased_entry_status: _GLIBCXX_DEBUG_ASSERT(0); break; case valid_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; } __throw_insert_error(); } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp000064400000005073147547540560020225 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/iterator_fn_imps.hpp * Contains implementations of gp_ht_map_'s iterators related functions, e.g., * begin(). */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC::s_end_it; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC::s_const_end_it; PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { pointer_ p_value; size_type pos; get_start_it_state(p_value, pos); return iterator(p_value, pos, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return s_end_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { const_pointer_ p_value; size_type pos; get_start_it_state(p_value, pos); return const_iterator(p_value, pos, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return s_const_end_it; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp000064400000004656147547540560017322 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/find_fn_imps.hpp * Contains implementations of gp_ht_map_'s find related functions. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) { PB_DS_ASSERT_VALID((*this)) return find_key_pointer(r_key, traits_base::m_store_extra_indicator); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find(key_const_reference r_key) const { PB_DS_ASSERT_VALID((*this)) return const_cast(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find_end() { return 0; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_const_iterator PB_DS_CLASS_C_DEC:: find_end() const { return 0; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp000064400000004074147547540560017327 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/info_fn_imps.hpp * Contains implementations of gp_ht_map_'s entire container info related * functions. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return m_num_used_e; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_entry_allocator.max_size(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (size() == 0); } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp000064400000047652147547540560016767 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/gp_ht_map_.hpp * Contains an implementation class for general probing hash. */ #include #include #include #include #include #include #ifdef PB_DS_HT_MAP_TRACE_ #include #endif #ifdef _GLIBCXX_DEBUG #include #endif #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_GP_HASH_NAME gp_ht_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_GP_HASH_NAME gp_ht_set #endif #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ PB_DS_GP_HASH_NAME #define PB_DS_HASH_EQ_FN_C_DEC \ hash_eq_fn #define PB_DS_RANGED_PROBE_FN_C_DEC \ ranged_probe_fn #define PB_DS_GP_HASH_TRAITS_BASE \ types_traits #ifdef _GLIBCXX_DEBUG #define PB_DS_DEBUG_MAP_BASE_C_DEC \ debug_map_base::other::const_reference> #endif /** * A general-probing hash-based container. * * * @ingroup hash-detail * * @tparam Key Key type. * * @tparam Mapped Map type. * * @tparam Hash_Fn Hashing functor. * Default is __gnu_cxx::hash. * * @tparam Eq_Fn Equal functor. * Default std::equal_to * * @tparam _Alloc Allocator type. * * @tparam Store_Hash If key type stores extra metadata. * Defaults to false. * * @tparam Comb_Probe_Fn Combining probe functor. * If Hash_Fn is not null_type, then this * is the ranged-probe functor; otherwise, * this is the range-hashing functor. * XXX See Design::Hash-Based Containers::Hash Policies. * Default direct_mask_range_hashing. * * @tparam Probe_Fn Probe functor. * Defaults to linear_probe_fn, * also quadratic_probe_fn. * * @tparam Resize_Policy Resizes hash. * Defaults to hash_standard_resize_policy, * using hash_exponential_size_policy and * hash_load_check_resize_trigger. * * * Bases are: detail::hash_eq_fn, Resize_Policy, detail::ranged_probe_fn, * detail::types_traits. (Optional: detail::debug_map_base.) */ template class PB_DS_GP_HASH_NAME : #ifdef _GLIBCXX_DEBUG protected PB_DS_DEBUG_MAP_BASE_C_DEC, #endif public PB_DS_HASH_EQ_FN_C_DEC, public Resize_Policy, public PB_DS_RANGED_PROBE_FN_C_DEC, public PB_DS_GP_HASH_TRAITS_BASE { private: typedef PB_DS_GP_HASH_TRAITS_BASE traits_base; typedef typename traits_base::value_type value_type_; typedef typename traits_base::pointer pointer_; typedef typename traits_base::const_pointer const_pointer_; typedef typename traits_base::reference reference_; typedef typename traits_base::const_reference const_reference_; typedef typename traits_base::comp_hash comp_hash; enum entry_status { empty_entry_status, valid_entry_status, erased_entry_status } __attribute__ ((packed)); struct entry : public traits_base::stored_data_type { entry_status m_stat; }; typedef typename _Alloc::template rebind::other entry_allocator; typedef typename entry_allocator::pointer entry_pointer; typedef typename entry_allocator::const_pointer const_entry_pointer; typedef typename entry_allocator::reference entry_reference; typedef typename entry_allocator::const_reference const_entry_reference; typedef typename entry_allocator::pointer entry_array; typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base; #ifdef _GLIBCXX_DEBUG typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; #endif typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base; typedef Resize_Policy resize_base; #define PB_DS_GEN_POS typename _Alloc::size_type #include #include #include #include #undef PB_DS_GEN_POS public: typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Hash_Fn hash_fn; typedef Eq_Fn eq_fn; typedef Probe_Fn probe_fn; typedef Comb_Probe_Fn comb_probe_fn; typedef Resize_Policy resize_policy; /// Value stores hash, true or false. enum { store_hash = Store_Hash }; typedef typename traits_base::key_type key_type; typedef typename traits_base::key_pointer key_pointer; typedef typename traits_base::key_const_pointer key_const_pointer; typedef typename traits_base::key_reference key_reference; typedef typename traits_base::key_const_reference key_const_reference; typedef typename traits_base::mapped_type mapped_type; typedef typename traits_base::mapped_pointer mapped_pointer; typedef typename traits_base::mapped_const_pointer mapped_const_pointer; typedef typename traits_base::mapped_reference mapped_reference; typedef typename traits_base::mapped_const_reference mapped_const_reference; typedef typename traits_base::value_type value_type; typedef typename traits_base::pointer pointer; typedef typename traits_base::const_pointer const_pointer; typedef typename traits_base::reference reference; typedef typename traits_base::const_reference const_reference; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef point_iterator_ point_iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef point_const_iterator_ point_iterator; #endif typedef point_const_iterator_ point_const_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef iterator_ iterator; #endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_iterator_ iterator; #endif typedef const_iterator_ const_iterator; PB_DS_GP_HASH_NAME(); PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC&); PB_DS_GP_HASH_NAME(const Hash_Fn&); PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&); PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&); PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&, const Probe_Fn&); PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&, const Probe_Fn&, const Resize_Policy&); template void copy_from_range(It, It); virtual ~PB_DS_GP_HASH_NAME(); void swap(PB_DS_CLASS_C_DEC&); inline size_type size() const; inline size_type max_size() const; /// True if size() == 0. inline bool empty() const; /// Return current hash_fn. Hash_Fn& get_hash_fn(); /// Return current const hash_fn. const Hash_Fn& get_hash_fn() const; /// Return current eq_fn. Eq_Fn& get_eq_fn(); /// Return current const eq_fn. const Eq_Fn& get_eq_fn() const; /// Return current probe_fn. Probe_Fn& get_probe_fn(); /// Return current const probe_fn. const Probe_Fn& get_probe_fn() const; /// Return current comb_probe_fn. Comb_Probe_Fn& get_comb_probe_fn(); /// Return current const comb_probe_fn. const Comb_Probe_Fn& get_comb_probe_fn() const; /// Return current resize_policy. Resize_Policy& get_resize_policy(); /// Return current const resize_policy. const Resize_Policy& get_resize_policy() const; inline std::pair insert(const_reference r_val) { _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);) return insert_imp(r_val, traits_base::m_store_extra_indicator); } inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR return subscript_imp(r_key, traits_base::m_store_extra_indicator); #else insert(r_key); return traits_base::s_null_type; #endif } inline point_iterator find(key_const_reference); inline point_const_iterator find(key_const_reference) const; inline point_iterator find_end(); inline point_const_iterator find_end() const; inline bool erase(key_const_reference); template inline size_type erase_if(Pred); void clear(); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_HT_MAP_TRACE_ void trace() const; #endif private: #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; #endif friend class const_iterator_; void deallocate_all(); void initialize(); void erase_all_valid_entries(entry_array, size_type); inline bool do_resize_if_needed(); inline void do_resize_if_needed_no_throw(); void resize_imp(size_type); virtual void do_resize(size_type); void resize_imp(entry_array, size_type); inline void resize_imp_reassign(entry_pointer, entry_array, false_type); inline void resize_imp_reassign(entry_pointer, entry_array, true_type); inline size_type find_ins_pos(key_const_reference, false_type); inline comp_hash find_ins_pos(key_const_reference, true_type); inline std::pair insert_imp(const_reference, false_type); inline std::pair insert_imp(const_reference, true_type); inline pointer insert_new_imp(const_reference r_val, size_type pos) { _GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); if (do_resize_if_needed()) pos = find_ins_pos(PB_DS_V2F(r_val), traits_base::m_store_extra_indicator); _GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); entry* const p_e = m_entries + pos; new (&p_e->m_value) value_type(r_val); p_e->m_stat = valid_entry_status; resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } inline pointer insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) { _GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat != valid_entry_status); if (do_resize_if_needed()) r_pos_hash_pair = find_ins_pos(PB_DS_V2F(r_val), traits_base::m_store_extra_indicator); _GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat != valid_entry_status); entry* const p_e = m_entries + r_pos_hash_pair.first; new (&p_e->m_value) value_type(r_val); p_e->m_hash = r_pos_hash_pair.second; p_e->m_stat = valid_entry_status; resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } #ifdef PB_DS_DATA_TRUE_INDICATOR inline mapped_reference subscript_imp(key_const_reference key, false_type) { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) const size_type pos = find_ins_pos(key, traits_base::m_store_extra_indicator); entry_pointer p_e = &m_entries[pos]; if (p_e->m_stat != valid_entry_status) return insert_new_imp(value_type(key, mapped_type()), pos)->second; PB_DS_CHECK_KEY_EXISTS(key) return p_e->m_value.second; } inline mapped_reference subscript_imp(key_const_reference key, true_type) { _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) comp_hash pos_hash_pair = find_ins_pos(key, traits_base::m_store_extra_indicator); if (m_entries[pos_hash_pair.first].m_stat != valid_entry_status) return insert_new_imp(value_type(key, mapped_type()), pos_hash_pair)->second; PB_DS_CHECK_KEY_EXISTS(key) return (m_entries + pos_hash_pair.first)->m_value.second; } #endif inline pointer find_key_pointer(key_const_reference key, false_type) { const size_type hash = ranged_probe_fn_base::operator()(key); resize_base::notify_find_search_start(); // Loop until entry is found or until all possible entries accessed. for (size_type i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(key, hash, i); entry* const p_e = m_entries + pos; switch (p_e->m_stat) { case empty_entry_status: { resize_base::notify_find_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) return 0; } break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key)) { resize_base::notify_find_search_end(); PB_DS_CHECK_KEY_EXISTS(key) return pointer(&p_e->m_value); } break; case erased_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_find_search_collision(); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) resize_base::notify_find_search_end(); return 0; } inline pointer find_key_pointer(key_const_reference key, true_type) { comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(key); resize_base::notify_find_search_start(); // Loop until entry is found or until all possible entries accessed. for (size_type i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(key, pos_hash_pair.second, i); entry* const p_e = m_entries + pos; switch(p_e->m_stat) { case empty_entry_status: { resize_base::notify_find_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) return 0; } break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, key, pos_hash_pair.second)) { resize_base::notify_find_search_end(); PB_DS_CHECK_KEY_EXISTS(key) return pointer(&p_e->m_value); } break; case erased_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_find_search_collision(); } PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) resize_base::notify_find_search_end(); return 0; } inline bool erase_imp(key_const_reference, true_type); inline bool erase_imp(key_const_reference, false_type); inline void erase_entry(entry_pointer); #ifdef PB_DS_DATA_TRUE_INDICATOR void inc_it_state(pointer& r_p_value, size_type& r_pos) const { inc_it_state((mapped_const_pointer& )r_p_value, r_pos); } #endif void inc_it_state(const_pointer& r_p_value, size_type& r_pos) const { _GLIBCXX_DEBUG_ASSERT(r_p_value != 0); for (++r_pos; r_pos < m_num_e; ++r_pos) { const_entry_pointer p_e =& m_entries[r_pos]; if (p_e->m_stat == valid_entry_status) { r_p_value =& p_e->m_value; return; } } r_p_value = 0; } void get_start_it_state(const_pointer& r_p_value, size_type& r_pos) const { for (r_pos = 0; r_pos < m_num_e; ++r_pos) { const_entry_pointer p_e = &m_entries[r_pos]; if (p_e->m_stat == valid_entry_status) { r_p_value = &p_e->m_value; return; } } r_p_value = 0; } void get_start_it_state(pointer& r_p_value, size_type& r_pos) { for (r_pos = 0; r_pos < m_num_e; ++r_pos) { entry_pointer p_e = &m_entries[r_pos]; if (p_e->m_stat == valid_entry_status) { r_p_value = &p_e->m_value; return; } } r_p_value = 0; } #ifdef _GLIBCXX_DEBUG void assert_entry_array_valid(const entry_array, false_type, const char*, int) const; void assert_entry_array_valid(const entry_array, true_type, const char*, int) const; #endif static entry_allocator s_entry_allocator; static iterator s_end_it; static const_iterator s_const_end_it; size_type m_num_e; size_type m_num_used_e; entry_pointer m_entries; enum { store_hash_ok = !Store_Hash || !is_same::value }; PB_DS_STATIC_ASSERT(sth, store_hash_ok); }; #include #include #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC #undef PB_DS_RANGED_PROBE_FN_C_DEC #undef PB_DS_GP_HASH_TRAITS_BASE #undef PB_DS_DEBUG_MAP_BASE_C_DEC #undef PB_DS_GP_HASH_NAME } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp000064400000004232147547540560026146 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s constructors, destructor, * and related functions. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(mapped_const_reference r_val, size_type pos, false_type) { _GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status)k; entry* const p_e = m_entries + pos; new (&p_e->m_value) mapped_value_type(r_val); p_e->m_stat = valid_entry_status; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);) } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp000064400000005505147547540560022406 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s erase related functions, * when the hash value is not stored. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase_imp(key_const_reference r_key, false_type) { PB_DS_ASSERT_VALID((*this)) size_type hash = ranged_probe_fn_base::operator()(r_key); size_type i; resize_base::notify_erase_search_start(); for (i = 0; i < m_num_e; ++i) { const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); entry* const p_e = m_entries + pos; switch(p_e->m_stat) { case empty_entry_status: { resize_base::notify_erase_search_end(); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_erase_search_end(); erase_entry(p_e); do_resize_if_needed_no_throw(); return true; } break; case erased_entry_status: break; default: _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_erase_search_collision(); } resize_base::notify_erase_search_end(); return false; } 4.8.2/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp000064400000005125147547540560021677 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file gp_hash_table_map_/debug_store_hash_fn_imps.hpp * Contains implementations of gp_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_entry_array_valid(const entry_array a_entries, true_type, const char* __file, int __line) const { size_type iterated_num_used_e = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { const_entry_pointer p_e =& a_entries[pos]; switch(p_e->m_stat) { case empty_entry_status: case erased_entry_status: break; case valid_entry_status: { key_const_reference r_key = PB_DS_V2F(p_e->m_value); debug_base::check_key_exists(r_key, __file, __line); const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second); ++iterated_num_used_e; break; } default: PB_DS_DEBUG_VERIFY(0); }; } PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #endif 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp000064400000005377147547540560021723 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/trace_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ #ifdef PB_DS_LC_NS_HEAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << std::endl; trace_node(m_p_root, 0); std::cerr << std::endl; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_node(node_const_pointer p_nd, size_type level) { while (p_nd != 0) { for (size_type i = 0; i < level; ++i) std::cerr << ' '; std::cerr << p_nd << " prev = " << p_nd->m_p_prev_or_parent << " next " << p_nd->m_p_next_sibling << " left = " << p_nd->m_p_l_child << " "; trace_node_metadata(p_nd, type_to_type()); std::cerr << p_nd->m_value << std::endl; trace_node(p_nd->m_p_l_child, level + 1); p_nd = p_nd->m_p_next_sibling; } } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: trace_node_metadata(node_const_pointer p_nd, type_to_type) { std::cerr << "(" << p_nd->m_metadata << ") "; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_node_metadata(node_const_pointer, type_to_type) { } #endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp000064400000017757147547540560025115 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp * Contains an implementation class for a basic heap. */ #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP /* * Based on CLRS. */ #include #include #include #include #include #include #ifdef PB_DS_LC_NS_HEAP_TRACE_ #include #endif #include namespace __gnu_pbds { namespace detail { #ifdef _GLIBCXX_DEBUG #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap #else #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap #endif /// Base class for a basic heap. template #else > #endif class left_child_next_sibling_heap : public Cmp_Fn { protected: typedef typename _Alloc::template rebind< left_child_next_sibling_heap_node_ >::other node_allocator; typedef typename node_allocator::value_type node; typedef typename node_allocator::pointer node_pointer; typedef typename node_allocator::const_pointer node_const_pointer; typedef Node_Metadata node_metadata; typedef std::pair< node_pointer, node_pointer> node_pointer_pair; private: typedef cond_dealtor< node, _Alloc> cond_dealtor_t; enum { simple_value = is_simple::value }; typedef integral_constant no_throw_copies_t; typedef typename _Alloc::template rebind __rebind_v; public: typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef Value_Type value_type; typedef typename __rebind_v::other::pointer pointer; typedef typename __rebind_v::other::const_pointer const_pointer; typedef typename __rebind_v::other::reference reference; typedef typename __rebind_v::other::const_reference const_reference; typedef left_child_next_sibling_heap_node_point_const_iterator_ point_const_iterator; typedef point_const_iterator point_iterator; typedef left_child_next_sibling_heap_const_iterator_ const_iterator; typedef const_iterator iterator; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; left_child_next_sibling_heap(); left_child_next_sibling_heap(const Cmp_Fn&); left_child_next_sibling_heap(const left_child_next_sibling_heap&); void swap(PB_DS_CLASS_C_DEC&); ~left_child_next_sibling_heap(); inline bool empty() const; inline size_type size() const; inline size_type max_size() const; Cmp_Fn& get_cmp_fn(); const Cmp_Fn& get_cmp_fn() const; inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; void clear(); #ifdef PB_DS_LC_NS_HEAP_TRACE_ void trace() const; #endif protected: inline node_pointer get_new_node_for_insert(const_reference); inline static void make_child_of(node_pointer, node_pointer); void value_swap(left_child_next_sibling_heap&); inline static node_pointer parent(node_pointer); inline void swap_with_parent(node_pointer, node_pointer); void bubble_to_top(node_pointer); inline void actual_erase_node(node_pointer); void clear_imp(node_pointer); void to_linked_list(); template node_pointer prune(Pred); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; void assert_node_consistent(node_const_pointer, bool, const char*, int) const; static size_type size_under_node(node_const_pointer); static size_type degree(node_const_pointer); #endif #ifdef PB_DS_LC_NS_HEAP_TRACE_ static void trace_node(node_const_pointer, size_type); #endif private: #ifdef _GLIBCXX_DEBUG void assert_iterators(const char*, int) const; void assert_size(const char*, int) const; static size_type size_from_node(node_const_pointer); #endif node_pointer recursive_copy_node(node_const_pointer); inline node_pointer get_new_node_for_insert(const_reference, false_type); inline node_pointer get_new_node_for_insert(const_reference, true_type); #ifdef PB_DS_LC_NS_HEAP_TRACE_ template static void trace_node_metadata(node_const_pointer, type_to_type); static void trace_node_metadata(node_const_pointer, type_to_type); #endif static node_allocator s_node_allocator; static no_throw_copies_t s_no_throw_copies_ind; protected: node_pointer m_p_root; size_type m_size; }; #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp000064400000007753147547540560021713 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/debug_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0); if (m_p_root != 0) assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line); assert_size(__file, __line); assert_iterators(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent(node_const_pointer p_nd, bool single_link, const char* __file, int __line) const { if (p_nd == 0) return; assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line); if (single_link) PB_DS_DEBUG_VERIFY(p_nd->m_p_prev_or_parent == 0); else if (p_nd->m_p_next_sibling != 0) PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); if (p_nd->m_p_l_child == 0) return; node_const_pointer p_child = p_nd->m_p_l_child; while (p_child != 0) { node_const_pointer p_next_child = p_child->m_p_next_sibling; PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); p_child = p_next_child; } PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_iterators(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size()); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_size(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size_under_node(node_const_pointer p_nd) { return 1 + size_from_node(p_nd->m_p_l_child); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size_from_node(node_const_pointer p_nd) { size_type ret = 0; while (p_nd != 0) { ret += 1 + size_from_node(p_nd->m_p_l_child); p_nd = p_nd->m_p_next_sibling; } return ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: degree(node_const_pointer p_nd) { size_type ret = 0; node_const_pointer p_child = p_nd->m_p_l_child; while (p_child != 0) { ++ret; p_child = p_child->m_p_next_sibling; } return ret; } #endif 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp000064400000007727147547540560025654 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_allocator PB_DS_CLASS_C_DEC::s_node_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::no_throw_copies_t PB_DS_CLASS_C_DEC::s_no_throw_copies_ind; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: left_child_next_sibling_heap() : m_p_root(0), m_size(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: left_child_next_sibling_heap(const Cmp_Fn& r_cmp_fn) : Cmp_Fn(r_cmp_fn), m_p_root(0), m_size(0) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: left_child_next_sibling_heap(const PB_DS_CLASS_C_DEC& other) : Cmp_Fn(other), m_p_root(0), m_size(0) { m_size = other.m_size; PB_DS_ASSERT_VALID(other) m_p_root = recursive_copy_node(other.m_p_root); m_size = other.m_size; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_p_root, other.m_p_root); std::swap(m_size, other.m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~left_child_next_sibling_heap() { clear(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: recursive_copy_node(node_const_pointer p_nd) { if (p_nd == 0) return (0); node_pointer p_ret = s_node_allocator.allocate(1); __try { new (p_ret) node(*p_nd); } __catch(...) { s_node_allocator.deallocate(p_ret, 1); __throw_exception_again; } p_ret->m_p_l_child = p_ret->m_p_next_sibling = p_ret->m_p_prev_or_parent = 0; __try { p_ret->m_p_l_child = recursive_copy_node(p_nd->m_p_l_child); p_ret->m_p_next_sibling = recursive_copy_node(p_nd->m_p_next_sibling); } __catch(...) { clear_imp(p_ret); __throw_exception_again; } if (p_ret->m_p_l_child != 0) p_ret->m_p_l_child->m_p_prev_or_parent = p_ret; if (p_ret->m_p_next_sibling != 0) p_ret->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd ? p_ret : 0; return p_ret; } 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp000064400000012121147547540560022112 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/insert_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_new_node_for_insert(const_reference r_val) { return get_new_node_for_insert(r_val, s_no_throw_copies_ind); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_new_node_for_insert(const_reference r_val, false_type) { node_pointer p_new_nd = s_node_allocator.allocate(1); cond_dealtor_t cond(p_new_nd); new (const_cast( static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); cond.set_no_action(); ++m_size; return (p_new_nd); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: get_new_node_for_insert(const_reference r_val, true_type) { node_pointer p_new_nd = s_node_allocator.allocate(1); new (const_cast( static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); ++m_size; return (p_new_nd); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: make_child_of(node_pointer p_nd, node_pointer p_new_parent) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_new_parent != 0); p_nd->m_p_next_sibling = p_new_parent->m_p_l_child; if (p_new_parent->m_p_l_child != 0) p_new_parent->m_p_l_child->m_p_prev_or_parent = p_nd; p_nd->m_p_prev_or_parent = p_new_parent; p_new_parent->m_p_l_child = p_nd; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: parent(node_pointer p_nd) { while (true) { node_pointer p_pot = p_nd->m_p_prev_or_parent; if (p_pot == 0 || p_pot->m_p_l_child == p_nd) return p_pot; p_nd = p_pot; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap_with_parent(node_pointer p_nd, node_pointer p_parent) { if (p_parent == m_p_root) m_p_root = p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_parent != 0); _GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent); const bool nd_direct_child = p_parent->m_p_l_child == p_nd; const bool parent_root = p_parent->m_p_prev_or_parent == 0; const bool parent_direct_child = !parent_root&& p_parent->m_p_prev_or_parent->m_p_l_child == p_parent; std::swap(p_parent->m_p_prev_or_parent, p_nd->m_p_prev_or_parent); std::swap(p_parent->m_p_next_sibling, p_nd->m_p_next_sibling); std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child); std::swap(p_parent->m_metadata, p_nd->m_metadata); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != 0); _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != 0); if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd; if (p_parent->m_p_next_sibling != 0) p_parent->m_p_next_sibling->m_p_prev_or_parent = p_parent; if (p_parent->m_p_l_child != 0) p_parent->m_p_l_child->m_p_prev_or_parent = p_parent; if (parent_direct_child) p_nd->m_p_prev_or_parent->m_p_l_child = p_nd; else if (!parent_root) p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd; if (!nd_direct_child) { p_nd->m_p_l_child->m_p_prev_or_parent = p_nd; p_parent->m_p_prev_or_parent->m_p_next_sibling = p_parent; } else { _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd); _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent); p_nd->m_p_l_child = p_parent; p_parent->m_p_prev_or_parent = p_nd; } _GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd); } 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp000064400000006214147547540560020026 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/node.hpp * Contains an implementation struct for this type of heap's node. */ #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP namespace __gnu_pbds { namespace detail { /// Node. template struct left_child_next_sibling_heap_node_ { private: typedef left_child_next_sibling_heap_node_<_Value, _Metadata, _Alloc> this_type; public: typedef _Value value_type; typedef typename _Alloc::size_type size_type; typedef _Metadata metadata_type; typedef typename _Alloc::template rebind::other::pointer node_pointer; value_type m_value; metadata_type m_metadata; node_pointer m_p_l_child; node_pointer m_p_next_sibling; node_pointer m_p_prev_or_parent; }; template struct left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> { private: typedef left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> this_type; public: typedef _Value value_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::template rebind::other::pointer node_pointer; value_type m_value; node_pointer m_p_l_child; node_pointer m_p_next_sibling; node_pointer m_p_prev_or_parent; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp000064400000011474147547540560022144 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/const_iterator.hpp * Contains an iterator class returned by the table's const find and insert * methods. */ #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap_const_iterator_ #define PB_DS_BASIC_HEAP_CIT_BASE \ left_child_next_sibling_heap_node_point_const_iterator_ /// Const point-type iterator. template class left_child_next_sibling_heap_const_iterator_ : public PB_DS_BASIC_HEAP_CIT_BASE { private: typedef PB_DS_BASIC_HEAP_CIT_BASE base_type; typedef typename base_type::node_pointer node_pointer; public: /// Category. typedef std::forward_iterator_tag iterator_category; /// Difference type. typedef typename _Alloc::difference_type difference_type; /// Iterator's value type. typedef typename base_type::value_type value_type; /// Iterator's pointer type. typedef typename base_type::pointer pointer; /// Iterator's const pointer type. typedef typename base_type::const_pointer const_pointer; /// Iterator's reference type. typedef typename base_type::reference reference; /// Iterator's const reference type. typedef typename base_type::const_reference const_reference; inline left_child_next_sibling_heap_const_iterator_(node_pointer p_nd) : base_type(p_nd) { } /// Default constructor. inline left_child_next_sibling_heap_const_iterator_() { } /// Copy constructor. inline left_child_next_sibling_heap_const_iterator_(const PB_DS_CLASS_C_DEC& other) : base_type(other) { } /// Compares content to a different iterator object. bool operator==(const PB_DS_CLASS_C_DEC& other) const { return (base_type::m_p_nd == other.m_p_nd); } /// Compares content (negatively) to a different iterator object. bool operator!=(const PB_DS_CLASS_C_DEC& other) const { return (base_type::m_p_nd != other.m_p_nd); } PB_DS_CLASS_C_DEC& operator++() { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != 0); inc(); return (*this); } PB_DS_CLASS_C_DEC operator++(int) { PB_DS_CLASS_C_DEC ret_it(base_type::m_p_nd); operator++(); return (ret_it); } private: void inc() { if (base_type::m_p_nd->m_p_next_sibling != 0) { base_type::m_p_nd = base_type::m_p_nd->m_p_next_sibling; while (base_type::m_p_nd->m_p_l_child != 0) base_type::m_p_nd = base_type::m_p_nd->m_p_l_child; return; } while (true) { node_pointer p_next = base_type::m_p_nd; base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent; if (base_type::m_p_nd == 0 || base_type::m_p_nd->m_p_l_child == p_next) return; } } }; #undef PB_DS_CLASS_C_DEC #undef PB_DS_BASIC_HEAP_CIT_BASE } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp000064400000004773147547540560022640 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/iterators_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { node_pointer p_nd = m_p_root; if (p_nd == 0) return (iterator(0)); while (p_nd->m_p_l_child != 0) p_nd = p_nd->m_p_l_child; return (iterator(p_nd)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { node_pointer p_nd = m_p_root; if (p_nd == 0) return (const_iterator(0)); while (p_nd->m_p_l_child != 0) p_nd = p_nd->m_p_l_child; return (const_iterator(p_nd)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return (iterator(0)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return (const_iterator(0)); } 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp000064400000007567147547540560021727 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/erase_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { clear_imp(m_p_root); _GLIBCXX_DEBUG_ASSERT(m_size == 0); m_p_root = 0; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; p_nd->~node(); s_node_allocator.deallocate(p_nd, 1); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear_imp(node_pointer p_nd) { while (p_nd != 0) { clear_imp(p_nd->m_p_l_child); node_pointer p_next = p_nd->m_p_next_sibling; actual_erase_node(p_nd); p_nd = p_next; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: to_linked_list() { PB_DS_ASSERT_VALID((*this)) node_pointer p_cur = m_p_root; while (p_cur != 0) if (p_cur->m_p_l_child != 0) { node_pointer p_child_next = p_cur->m_p_l_child->m_p_next_sibling; p_cur->m_p_l_child->m_p_next_sibling = p_cur->m_p_next_sibling; p_cur->m_p_next_sibling = p_cur->m_p_l_child; p_cur->m_p_l_child = p_child_next; } else p_cur = p_cur->m_p_next_sibling; #ifdef _GLIBCXX_DEBUG node_const_pointer p_counter = m_p_root; size_type count = 0; while (p_counter != 0) { ++count; _GLIBCXX_DEBUG_ASSERT(p_counter->m_p_l_child == 0); p_counter = p_counter->m_p_next_sibling; } _GLIBCXX_DEBUG_ASSERT(count == m_size); #endif } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: prune(Pred pred) { node_pointer p_cur = m_p_root; m_p_root = 0; node_pointer p_out = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; if (pred(p_cur->m_value)) { p_cur->m_p_next_sibling = p_out; if (p_out != 0) p_out->m_p_prev_or_parent = p_cur; p_out = p_cur; } else { p_cur->m_p_next_sibling = m_p_root; if (m_p_root != 0) m_p_root->m_p_prev_or_parent = p_cur; m_p_root = p_cur; } p_cur = p_next; } return p_out; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: bubble_to_top(node_pointer p_nd) { node_pointer p_parent = parent(p_nd); while (p_parent != 0) { swap_with_parent(p_nd, p_parent); p_parent = parent(p_nd); } } 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp000064400000003607147547540560023437 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/policy_access_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() { return *this; } PB_DS_CLASS_T_DEC const Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() const { return *this; } 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp000064400000010620147547540560023345 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/point_const_iterator.hpp * Contains an iterator class returned by the table's const find and insert * methods. */ #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap_node_point_const_iterator_ /// Const point-type iterator. template class left_child_next_sibling_heap_node_point_const_iterator_ { protected: typedef typename _Alloc::template rebind::other::pointer node_pointer; public: /// Category. typedef trivial_iterator_tag iterator_category; /// Difference type. typedef trivial_iterator_difference_type difference_type; /// Iterator's value type. typedef typename Node::value_type value_type; /// Iterator's pointer type. typedef typename _Alloc::template rebind< value_type>::other::pointer pointer; /// Iterator's const pointer type. typedef typename _Alloc::template rebind< value_type>::other::const_pointer const_pointer; /// Iterator's reference type. typedef typename _Alloc::template rebind< value_type>::other::reference reference; /// Iterator's const reference type. typedef typename _Alloc::template rebind< value_type>::other::const_reference const_reference; inline left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd) { } /// Default constructor. inline left_child_next_sibling_heap_node_point_const_iterator_() : m_p_nd(0) { } /// Copy constructor. inline left_child_next_sibling_heap_node_point_const_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd) { } /// Access. const_pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); return &m_p_nd->m_value; } /// Access. const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); return m_p_nd->m_value; } /// Compares content to a different iterator object. bool operator==(const PB_DS_CLASS_C_DEC& other) const { return m_p_nd == other.m_p_nd; } /// Compares content (negatively) to a different iterator object. bool operator!=(const PB_DS_CLASS_C_DEC& other) const { return m_p_nd != other.m_p_nd; } node_pointer m_p_nd; }; #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp000064400000004072147547540560021547 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file left_child_next_sibling_heap_/info_fn_imps.hpp * Contains an implementation class for left_child_next_sibling_heap_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (m_size == 0); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return (m_size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return (s_node_allocator.max_size()); } 4.8.2/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp000064400000014072147547540560020744 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/binomial_heap_base_.hpp * Contains an implementation class for a base of binomial heaps. */ #ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP #define PB_DS_BINOMIAL_HEAP_BASE_HPP /* * Binomial heap base. * Vuillemin J is the mastah. * Modified from CLRS. */ #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ binomial_heap_base #ifdef _GLIBCXX_DEBUG #define PB_DS_B_HEAP_BASE \ left_child_next_sibling_heap #else #define PB_DS_B_HEAP_BASE \ left_child_next_sibling_heap #endif /// Base class for binomial heap. template class binomial_heap_base : public PB_DS_B_HEAP_BASE { private: typedef typename _Alloc::template rebind::other __rebind_v; typedef PB_DS_B_HEAP_BASE base_type; protected: typedef typename base_type::node node; typedef typename base_type::node_pointer node_pointer; typedef typename base_type::node_const_pointer node_const_pointer; public: typedef Value_Type value_type; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename __rebind_v::pointer pointer; typedef typename __rebind_v::const_pointer const_pointer; typedef typename __rebind_v::reference reference; typedef typename __rebind_v::const_reference const_reference; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::iterator iterator; public: inline point_iterator push(const_reference); void modify(point_iterator, const_reference); inline const_reference top() const; void pop(); void erase(point_iterator); inline void clear(); template size_type erase_if(Pred); template void split(Pred, PB_DS_CLASS_C_DEC&); void join(PB_DS_CLASS_C_DEC&); protected: binomial_heap_base(); binomial_heap_base(const Cmp_Fn&); binomial_heap_base(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); ~binomial_heap_base(); template void copy_from_range(It, It); inline void find_max(); #ifdef _GLIBCXX_DEBUG void assert_valid(bool, const char*, int) const; void assert_max(const char*, int) const; #endif private: inline node_pointer fix(node_pointer) const; inline void insert_node(node_pointer); inline void remove_parentless_node(node_pointer); inline node_pointer join(node_pointer, node_pointer) const; #ifdef _GLIBCXX_DEBUG void assert_node_consistent(node_const_pointer, bool, bool, const char*, int) const; #endif protected: node_pointer m_p_max; }; #define PB_DS_ASSERT_VALID_COND(X, _StrictlyBinomial) \ _GLIBCXX_DEBUG_ONLY(X.assert_valid(_StrictlyBinomial,__FILE__, __LINE__);) #define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node, _Bool) \ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \ __FILE__, __LINE__);) #include #include #include #include #include #include #undef PB_DS_ASSERT_BASE_NODE_CONSISTENT #undef PB_DS_ASSERT_VALID_COND #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_B_HEAP_BASE } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp000064400000006614147547540560017630 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/debug_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(bool strictly_binomial, const char* __file, int __line) const { base_type::assert_valid(__file, __line); assert_node_consistent(base_type::m_p_root, strictly_binomial, true, __file, __line); assert_max(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_max(const char* __file, int __line) const { if (m_p_max == 0) return; PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent(node_const_pointer p_nd, bool strictly_binomial, bool increasing, const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(increasing || strictly_binomial); base_type::assert_node_consistent(p_nd, false, __file, __line); if (p_nd == 0) return; PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd)); PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) == static_cast(1 << p_nd->m_metadata)); assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing, __file, __line); assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line); if (p_nd->m_p_next_sibling != 0) { if (increasing) { if (strictly_binomial) PB_DS_DEBUG_VERIFY(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata); else PB_DS_DEBUG_VERIFY(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata); } else PB_DS_DEBUG_VERIFY(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata); } } #endif 4.8.2/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp000064400000005200147547540560023556 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/constructors_destructor_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) push(*(first_it++)); PB_DS_ASSERT_VALID_COND((*this),false) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_base() : m_p_max(0) { PB_DS_ASSERT_VALID_COND((*this),false) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_base(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn), m_p_max(0) { PB_DS_ASSERT_VALID_COND((*this),false) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_base(const PB_DS_CLASS_C_DEC& other) : base_type(other), m_p_max(0) { PB_DS_ASSERT_VALID_COND((*this),false) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID_COND((*this),false) base_type::swap(other); std::swap(m_p_max, other.m_p_max); PB_DS_ASSERT_VALID_COND((*this),false) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~binomial_heap_base() { } 4.8.2/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp000064400000012227147547540560020043 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/insert_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { PB_DS_ASSERT_VALID_COND((*this),true) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); insert_node(p_nd); m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) return point_iterator(p_nd); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_node(node_pointer p_nd) { if (base_type::m_p_root == 0) { p_nd->m_p_next_sibling = 0; p_nd->m_p_prev_or_parent = 0; p_nd->m_p_l_child = 0; p_nd->m_metadata = 0; base_type::m_p_root = p_nd; return; } if (base_type::m_p_root->m_metadata > 0) { p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0; p_nd->m_p_next_sibling = base_type::m_p_root; base_type::m_p_root->m_p_prev_or_parent = p_nd; base_type::m_p_root = p_nd; p_nd->m_metadata = 0; return; } if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value)) { p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling; p_nd->m_p_prev_or_parent = 0; p_nd->m_metadata = 1; p_nd->m_p_l_child = base_type::m_p_root; base_type::m_p_root->m_p_prev_or_parent = p_nd; base_type::m_p_root->m_p_next_sibling = 0; base_type::m_p_root = p_nd; } else { p_nd->m_p_next_sibling = 0; p_nd->m_p_l_child = 0; p_nd->m_p_prev_or_parent = base_type::m_p_root; p_nd->m_metadata = 0; _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0); base_type::m_p_root->m_p_l_child = p_nd; base_type::m_p_root->m_metadata = 1; } base_type::m_p_root = fix(base_type::m_p_root); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: fix(node_pointer p_nd) const { while (p_nd->m_p_next_sibling != 0 && p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata) { node_pointer p_next = p_nd->m_p_next_sibling; if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; if (p_nd->m_p_prev_or_parent != 0) p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next; base_type::make_child_of(p_nd, p_next); ++p_next->m_metadata; p_nd = p_next; } else { p_nd->m_p_next_sibling = p_next->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_next->m_p_next_sibling = 0; base_type::make_child_of(p_next, p_nd); ++p_nd->m_metadata; } } if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd; return p_nd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { PB_DS_ASSERT_VALID_COND((*this),true) node_pointer p_nd = it.m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false) const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val); p_nd->m_value = r_new_val; if (bubble_up) { node_pointer p_parent = base_type::parent(p_nd); while (p_parent != 0 && Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value)) { base_type::swap_with_parent(p_nd, p_parent); p_parent = base_type::parent(p_nd); } if (p_nd->m_p_prev_or_parent == 0) base_type::m_p_root = p_nd; m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) return; } base_type::bubble_to_top(p_nd); remove_parentless_node(p_nd); insert_node(p_nd); m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) } 4.8.2/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp000064400000012365147547540560020714 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/split_join_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID_COND((*this),true) PB_DS_ASSERT_VALID_COND(other,true) other.clear(); if (base_type::empty()) { PB_DS_ASSERT_VALID_COND((*this),true) PB_DS_ASSERT_VALID_COND(other,true) return; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); while (p_out != 0) { _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; node_pointer p_next = p_out->m_p_next_sibling; p_out->m_p_l_child = p_out->m_p_prev_or_parent = 0; p_out->m_metadata = 0; p_out->m_p_next_sibling = other.m_p_root; if (other.m_p_root != 0) other.m_p_root->m_p_prev_or_parent = p_out; other.m_p_root = p_out; other.m_p_root = other.fix(other.m_p_root); p_out = p_next; } PB_DS_ASSERT_VALID_COND(other,true) node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0; p_cur->m_metadata = 0; p_cur->m_p_next_sibling = base_type::m_p_root; if (base_type::m_p_root != 0) base_type::m_p_root->m_p_prev_or_parent = p_cur; base_type::m_p_root = p_cur; base_type::m_p_root = fix(base_type::m_p_root); p_cur = p_next; } m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) PB_DS_ASSERT_VALID_COND(other,true) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID_COND((*this),true) PB_DS_ASSERT_VALID_COND(other,true) node_pointer p_other = other.m_p_root; if (p_other != 0) do { node_pointer p_next = p_other->m_p_next_sibling; std::swap(p_other->m_p_next_sibling, p_other->m_p_prev_or_parent); p_other = p_next; } while (p_other != 0); base_type::m_p_root = join(base_type::m_p_root, other.m_p_root); base_type::m_size += other.m_size; m_p_max = 0; other.m_p_root = 0; other.m_size = 0; other.m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) PB_DS_ASSERT_VALID_COND(other,true) } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: join(node_pointer p_lhs, node_pointer p_rhs) const { node_pointer p_ret = 0; node_pointer p_cur = 0; while (p_lhs != 0 || p_rhs != 0) { if (p_rhs == 0) { if (p_cur == 0) p_ret = p_cur = p_lhs; else { p_cur->m_p_next_sibling = p_lhs; p_lhs->m_p_prev_or_parent = p_cur; } p_cur = p_lhs = 0; } else if (p_lhs == 0 || p_rhs->m_metadata < p_lhs->m_metadata) { if (p_cur == 0) { p_ret = p_cur = p_rhs; p_rhs = p_rhs->m_p_prev_or_parent; } else { p_cur->m_p_next_sibling = p_rhs; p_rhs = p_rhs->m_p_prev_or_parent; p_cur->m_p_next_sibling->m_p_prev_or_parent = p_cur; p_cur = p_cur->m_p_next_sibling; } } else if (p_lhs->m_metadata < p_rhs->m_metadata) { if (p_cur == 0) p_ret = p_cur = p_lhs; else { p_cur->m_p_next_sibling = p_lhs; p_lhs->m_p_prev_or_parent = p_cur; p_cur = p_cur->m_p_next_sibling; } p_lhs = p_cur->m_p_next_sibling; } else { node_pointer p_next_rhs = p_rhs->m_p_prev_or_parent; p_rhs->m_p_next_sibling = p_lhs; p_lhs = fix(p_rhs); p_rhs = p_next_rhs; } } if (p_cur != 0) p_cur->m_p_next_sibling = 0; if (p_ret != 0) p_ret->m_p_prev_or_parent = 0; return p_ret; } 4.8.2/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp000064400000010602147547540560017631 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/erase_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: pop() { PB_DS_ASSERT_VALID_COND((*this),true) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == 0) find_max(); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); node_pointer p_nd = m_p_max; remove_parentless_node(m_p_max); base_type::actual_erase_node(p_nd); m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_parentless_node(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == 0); node_pointer p_cur_root = p_nd == base_type::m_p_root? p_nd->m_p_next_sibling : base_type::m_p_root; if (p_cur_root != 0) p_cur_root->m_p_prev_or_parent = 0; if (p_nd->m_p_prev_or_parent != 0) p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; node_pointer p_child = p_nd->m_p_l_child; if (p_child != 0) { p_child->m_p_prev_or_parent = 0; while (p_child->m_p_next_sibling != 0) p_child = p_child->m_p_next_sibling; } m_p_max = 0; base_type::m_p_root = join(p_cur_root, p_child); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: clear() { base_type::clear(); m_p_max = 0; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { PB_DS_ASSERT_VALID_COND((*this),true) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); base_type::bubble_to_top(it.m_p_nd); remove_parentless_node(it.m_p_nd); base_type::actual_erase_node(it.m_p_nd); m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID_COND((*this),true) if (base_type::empty()) { PB_DS_ASSERT_VALID_COND((*this),true) return 0; } base_type::to_linked_list(); node_pointer p_out = base_type::prune(pred); size_type ersd = 0; while (p_out != 0) { ++ersd; node_pointer p_next = p_out->m_p_next_sibling; base_type::actual_erase_node(p_out); p_out = p_next; } node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; while (p_cur != 0) { node_pointer p_next = p_cur->m_p_next_sibling; p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0; p_cur->m_metadata = 0; p_cur->m_p_next_sibling = base_type::m_p_root; if (base_type::m_p_root != 0) base_type::m_p_root->m_p_prev_or_parent = p_cur; base_type::m_p_root = p_cur; base_type::m_p_root = fix(base_type::m_p_root); p_cur = p_next; } m_p_max = 0; PB_DS_ASSERT_VALID_COND((*this),true) return ersd; } 4.8.2/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp000064400000004451147547540560017457 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binomial_heap_base_/find_fn_imps.hpp * Contains an implementation class for a base of binomial heaps. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { PB_DS_ASSERT_VALID_COND((*this),false) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == 0) const_cast(this)->find_max(); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); return m_p_max->m_value; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: find_max() { node_pointer p_cur = base_type::m_p_root; m_p_max = p_cur; while (p_cur != 0) { if (Cmp_Fn::operator()(m_p_max->m_value, p_cur->m_value)) m_p_max = p_cur; p_cur = p_cur->m_p_next_sibling; } } 4.8.2/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp000064400000006412147547540560020106 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file tree_policy/node_metadata_selector.hpp * Contains an implementation class for trees. */ #ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP #define PB_DS_TREE_NODE_METADATA_DISPATCH_HPP #include #include namespace __gnu_pbds { namespace detail { /** * @addtogroup traits Traits * @{ */ /// Tree metadata helper. template struct tree_metadata_helper; /// Specialization, false. template struct tree_metadata_helper { typedef typename Node_Update::metadata_type type; }; /// Specialization, true. template struct tree_metadata_helper { typedef null_type type; }; /// Tree node metadata dispatch. template class Node_Update, typename _Alloc> struct tree_node_metadata_dispatch { private: typedef dumnode_const_iterator __it_type; typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u; typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u; enum { null_update = is_same<__node_u, __nnode_u>::value }; public: typedef typename tree_metadata_helper<__node_u, null_update>::type type; }; //@} } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP 4.8.2/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp000064400000007213147547540560017653 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file tree_policy/order_statistics_imp.hpp * Contains forward declarations for order_statistics_key */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: find_by_order(size_type order) { node_iterator it = node_begin(); node_iterator end_it = node_end(); while (it != end_it) { node_iterator l_it = it.get_l_child(); const size_type o = (l_it == end_it)? 0 : l_it.get_metadata(); if (order == o) return *it; else if (order < o) it = l_it; else { order -= o + 1; it = it.get_r_child(); } } return base_type::end_iterator(); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: find_by_order(size_type order) const { return const_cast(this)->find_by_order(order); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: order_of_key(key_const_reference r_key) const { node_const_iterator it = node_begin(); node_const_iterator end_it = node_end(); const cmp_fn& r_cmp_fn = const_cast(this)->get_cmp_fn(); size_type ord = 0; while (it != end_it) { node_const_iterator l_it = it.get_l_child(); if (r_cmp_fn(r_key, this->extract_key(*(*it)))) it = l_it; else if (r_cmp_fn(this->extract_key(*(*it)), r_key)) { ord += (l_it == end_it)? 1 : 1 + l_it.get_metadata(); it = it.get_r_child(); } else { ord += (l_it == end_it)? 0 : l_it.get_metadata(); it = end_it; } } return ord; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: operator()(node_iterator node_it, node_const_iterator end_nd_it) const { node_iterator l_it = node_it.get_l_child(); const size_type l_rank = (l_it == end_nd_it) ? 0 : l_it.get_metadata(); node_iterator r_it = node_it.get_r_child(); const size_type r_rank = (r_it == end_nd_it) ? 0 : r_it.get_metadata(); const_cast(node_it.get_metadata())= 1 + l_rank + r_rank; } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~tree_order_statistics_node_update() { } 4.8.2/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp000064400000004452147547540560020272 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file tree_policy/sample_tree_node_update.hpp * Contains a samle node update functor. */ #ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP #define PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP namespace __gnu_pbds { /// A sample node updator. template class sample_tree_node_update { typedef std::size_t metadata_type; /// Default constructor. sample_tree_node_update(); /// Updates the rank of a node through a node_iterator node_it; /// end_nd_it is the end node iterator. inline void operator()(node_iterator node_it, node_const_iterator end_nd_it) const; }; } #endif // #ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp000064400000003560147547540560017327 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/trace_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { base_type::trace(); m_rc.trace(); } #endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp000064400000006722147547540560017322 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/debug_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { base_type::assert_valid(false, __file, __line); if (!base_type::empty()) { PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0); base_type::assert_max(__file, __line); } m_rc.assert_valid(__file, __line); if (m_rc.empty()) { base_type::assert_valid(true, __file, __line); PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0); return; } node_const_pointer p_nd = next_2_pointer(base_type::m_p_root); typename rc_t::const_iterator it = m_rc.end(); --it; while (p_nd != 0) { PB_DS_DEBUG_VERIFY(*it == p_nd); node_const_pointer p_next = p_nd->m_p_next_sibling; PB_DS_DEBUG_VERIFY(p_next != 0); PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata); PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 || p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); --it; p_nd = next_2_pointer(next_after_0_pointer(p_nd)); } PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin()); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_const_pointer PB_DS_CLASS_C_DEC:: next_2_pointer(node_const_pointer p_nd) { if (p_nd == 0) return 0; node_pointer p_next = p_nd->m_p_next_sibling; if (p_next == 0) return 0; if (p_nd->m_metadata == p_next->m_metadata) return p_nd; return next_2_pointer(p_next); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_const_pointer PB_DS_CLASS_C_DEC:: next_after_0_pointer(node_const_pointer p_nd) { if (p_nd == 0) return 0; node_pointer p_next = p_nd->m_p_next_sibling; if (p_next == 0) return 0; if (p_nd->m_metadata < p_next->m_metadata) return p_next; return next_after_0_pointer(p_next); } #endif 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp000064400000012267147547540560020134 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/rc_binomial_heap_.hpp * Contains an implementation for redundant-counter binomial heap. */ #include #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ rc_binomial_heap #define PB_DS_RC_C_DEC \ rc::node, _Alloc> /** * Redundant-counter binomial heap. * * @ingroup heap-detail */ template class rc_binomial_heap : public binomial_heap_base { private: typedef binomial_heap_base base_type; typedef typename base_type::node_pointer node_pointer; typedef typename base_type::node_const_pointer node_const_pointer; typedef PB_DS_RC_C_DEC rc_t; public: typedef Value_Type value_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::cmp_fn cmp_fn; typedef typename base_type::allocator_type allocator_type; rc_binomial_heap(); rc_binomial_heap(const Cmp_Fn&); rc_binomial_heap(const PB_DS_CLASS_C_DEC&); ~rc_binomial_heap(); void swap(PB_DS_CLASS_C_DEC&); inline point_iterator push(const_reference); void modify(point_iterator, const_reference); inline void pop(); void erase(point_iterator); inline void clear(); template size_type erase_if(Pred); template void split(Pred, PB_DS_CLASS_C_DEC&); void join(PB_DS_CLASS_C_DEC&); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ void trace() const; #endif private: inline node_pointer link_with_next_sibling(node_pointer); void make_0_exposed(); void make_binomial_heap(); #ifdef _GLIBCXX_DEBUG static node_const_pointer next_2_pointer(node_const_pointer); static node_const_pointer next_after_0_pointer(node_const_pointer); #endif rc_t m_rc; }; #include #include #include #include #include #include #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_RC_C_DEC } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp000064400000004643147547540560023262 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap(const PB_DS_CLASS_C_DEC& other) : base_type(other) { make_binomial_heap(); base_type::find_max(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~rc_binomial_heap() { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) base_type::swap(other); m_rc.swap(other.m_rc); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp000064400000010215147547540560017530 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/insert_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { PB_DS_ASSERT_VALID((*this)) make_0_exposed(); PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); p_nd->m_p_l_child = p_nd->m_p_prev_or_parent = 0; p_nd->m_metadata = 0; if (base_type::m_p_max == 0 || Cmp_Fn::operator()(base_type::m_p_max->m_value, r_val)) base_type::m_p_max = p_nd; p_nd->m_p_next_sibling = base_type::m_p_root; if (base_type::m_p_root != 0) base_type::m_p_root->m_p_prev_or_parent = p_nd; base_type::m_p_root = p_nd; if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0) m_rc.push(p_nd); PB_DS_ASSERT_VALID((*this)) return point_iterator(p_nd); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { PB_DS_ASSERT_VALID((*this)) make_binomial_heap(); base_type::modify(it, r_new_val); base_type::find_max(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: link_with_next_sibling(node_pointer p_nd) { node_pointer p_next = p_nd->m_p_next_sibling; _GLIBCXX_DEBUG_ASSERT(p_next != 0); _GLIBCXX_DEBUG_ASSERT(p_next->m_p_prev_or_parent == p_nd); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; if (p_next->m_p_prev_or_parent == 0) base_type::m_p_root = p_next; else p_next->m_p_prev_or_parent->m_p_next_sibling = p_next; if (base_type::m_p_max == p_nd) base_type::m_p_max = p_next; base_type::make_child_of(p_nd, p_next); ++p_next->m_metadata; return p_next; } p_nd->m_p_next_sibling = p_next->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd; if (base_type::m_p_max == p_next) base_type::m_p_max = p_nd; base_type::make_child_of(p_next, p_nd); ++p_nd->m_metadata; return p_nd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: make_0_exposed() { if (m_rc.empty()) return; node_pointer p_nd = m_rc.top(); m_rc.pop(); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling != 0); _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata); node_pointer p_res = link_with_next_sibling(p_nd); if (p_res->m_p_next_sibling != 0&& p_res->m_metadata == p_res->m_p_next_sibling->m_metadata) m_rc.push(p_res); } 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp000064400000004562147547540560020406 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/split_join_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) make_binomial_heap(); other.make_binomial_heap(); base_type::split(pred, other); base_type::find_max(); other.find_max(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) make_binomial_heap(); other.make_binomial_heap(); base_type::join(other); base_type::find_max(); other.find_max(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp000064400000005511147547540560017326 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/erase_fn_imps.hpp * Contains an implementation for rc_binomial_heap_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: pop() { make_binomial_heap(); _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); base_type::pop(); base_type::find_max(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { base_type::clear(); m_rc.clear(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: make_binomial_heap() { node_pointer p_nd = base_type::m_p_root; while (p_nd != 0) { node_pointer p_next = p_nd->m_p_next_sibling; if (p_next == 0) p_nd = p_next; else if (p_nd->m_metadata == p_next->m_metadata) p_nd = link_with_next_sibling(p_nd); else if (p_nd->m_metadata < p_next->m_metadata) p_nd = p_next; #ifdef _GLIBCXX_DEBUG else _GLIBCXX_DEBUG_ASSERT(0); #endif } m_rc.clear(); } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { make_binomial_heap(); const size_type ersd = base_type::erase_if(pred); base_type::find_max(); PB_DS_ASSERT_VALID((*this)) return ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { make_binomial_heap(); base_type::erase(it); base_type::find_max(); } 4.8.2/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp000064400000014171147547540560015122 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rc_binomial_heap_/rc.hpp * Contains a redundant (binary counter). */ #ifndef PB_DS_RC_HPP #define PB_DS_RC_HPP namespace __gnu_pbds { namespace detail { /// Redundant binary counter. template class rc { private: typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; typedef _Node node; typedef typename _Alloc::template rebind __rebind_n; typedef typename __rebind_n::other::pointer node_pointer; typedef typename _Alloc::template rebind __rebind_np; typedef typename __rebind_np::other::pointer entry_pointer; typedef typename __rebind_np::other::const_pointer entry_const_pointer; enum { max_entries = sizeof(size_type) << 3 }; public: typedef node_pointer entry; typedef entry_const_pointer const_iterator; rc(); rc(const rc&); inline void swap(rc&); inline void push(entry); inline node_pointer top() const; inline void pop(); inline bool empty() const; inline size_type size() const; void clear(); const const_iterator begin() const; const const_iterator end() const; #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ void trace() const; #endif private: node_pointer m_a_entries[max_entries]; size_type m_over_top; }; template rc<_Node, _Alloc>:: rc() : m_over_top(0) { PB_DS_ASSERT_VALID((*this)) } template rc<_Node, _Alloc>:: rc(const rc<_Node, _Alloc>& other) : m_over_top(0) { PB_DS_ASSERT_VALID((*this)) } template inline void rc<_Node, _Alloc>:: swap(rc<_Node, _Alloc>& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) const size_type over_top = std::max(m_over_top, other.m_over_top); for (size_type i = 0; i < over_top; ++i) std::swap(m_a_entries[i], other.m_a_entries[i]); std::swap(m_over_top, other.m_over_top); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } template inline void rc<_Node, _Alloc>:: push(entry p_nd) { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); m_a_entries[m_over_top++] = p_nd; PB_DS_ASSERT_VALID((*this)) } template inline void rc<_Node, _Alloc>:: pop() { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); --m_over_top; PB_DS_ASSERT_VALID((*this)) } template inline typename rc<_Node, _Alloc>::node_pointer rc<_Node, _Alloc>:: top() const { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); return *(m_a_entries + m_over_top - 1); } template inline bool rc<_Node, _Alloc>:: empty() const { PB_DS_ASSERT_VALID((*this)) return m_over_top == 0; } template inline typename rc<_Node, _Alloc>::size_type rc<_Node, _Alloc>:: size() const { return m_over_top; } template void rc<_Node, _Alloc>:: clear() { PB_DS_ASSERT_VALID((*this)) m_over_top = 0; PB_DS_ASSERT_VALID((*this)) } template const typename rc<_Node, _Alloc>::const_iterator rc<_Node, _Alloc>:: begin() const { return& m_a_entries[0]; } template const typename rc<_Node, _Alloc>::const_iterator rc<_Node, _Alloc>:: end() const { return& m_a_entries[m_over_top]; } #ifdef _GLIBCXX_DEBUG template void rc<_Node, _Alloc>:: assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(m_over_top < max_entries); } #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ template void rc<_Node, _Alloc>:: trace() const { std::cout << "rc" << std::endl; for (size_type i = 0; i < m_over_top; ++i) std::cerr << m_a_entries[i] << std::endl; std::cout << std::endl; } #endif } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp000064400000005311147547540560016317 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/debug_fn_imps.hpp * Contains an implementation for rb_tree_. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: assert_node_consistent(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) return 1; const size_type l_height = assert_node_consistent(p_nd->m_p_left, __file, __line); const size_type r_height = assert_node_consistent(p_nd->m_p_right, __file, __line); if (p_nd->m_red) { PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left)); PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right)); } PB_DS_DEBUG_VERIFY(l_height == r_height); return (p_nd->m_red ? 0 : 1) + l_height; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { base_type::assert_valid(__file, __line); const node_pointer p_head = base_type::m_p_head; PB_DS_DEBUG_VERIFY(p_head->m_red); if (p_head->m_p_parent != 0) { PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red); assert_node_consistent(p_head->m_p_parent, __file, __line); } } #endif 4.8.2/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp000064400000005337147547540560022267 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/constructors_destructor_fn_imps.hpp * Contains an implementation for rb_tree_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_RB_TREE_NAME() { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : base_type(r_cmp_fn, r_node_update) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) base_type::swap(other); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() { base_type::m_p_head->m_red = true; } 4.8.2/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp000064400000007433147547540560016544 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/insert_fn_imps.hpp * Contains an implementation for rb_tree_. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { PB_DS_ASSERT_VALID((*this)) std::pair ins_pair = base_type::insert_leaf(r_value); if (ins_pair.second == true) { ins_pair.first.m_p_nd->m_red = true; PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) insert_fixup(ins_pair.first.m_p_nd); } PB_DS_ASSERT_VALID((*this)) return ins_pair; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_fixup(node_pointer p_nd) { _GLIBCXX_DEBUG_ASSERT(p_nd->m_red == true); while (p_nd != base_type::m_p_head->m_p_parent && p_nd->m_p_parent->m_red) { if (p_nd->m_p_parent == p_nd->m_p_parent->m_p_parent->m_p_left) { node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_right; if (p_y != 0 && p_y->m_red) { p_nd->m_p_parent->m_red = false; p_y->m_red = false; p_nd->m_p_parent->m_p_parent->m_red = true; p_nd = p_nd->m_p_parent->m_p_parent; } else { if (p_nd == p_nd->m_p_parent->m_p_right) { p_nd = p_nd->m_p_parent; base_type::rotate_left(p_nd); } p_nd->m_p_parent->m_red = false; p_nd->m_p_parent->m_p_parent->m_red = true; base_type::rotate_right(p_nd->m_p_parent->m_p_parent); } } else { node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_left; if (p_y != 0 && p_y->m_red) { p_nd->m_p_parent->m_red = false; p_y->m_red = false; p_nd->m_p_parent->m_p_parent->m_red = true; p_nd = p_nd->m_p_parent->m_p_parent; } else { if (p_nd == p_nd->m_p_parent->m_p_left) { p_nd = p_nd->m_p_parent; base_type::rotate_right(p_nd); } p_nd->m_p_parent->m_red = false; p_nd->m_p_parent->m_p_parent->m_red = true; base_type::rotate_left(p_nd->m_p_parent->m_p_parent); } } } base_type::update_to_top(p_nd, (node_update* )this); base_type::m_p_head->m_p_parent->m_red = false; } 4.8.2/ext/pb_ds/detail/rb_tree_map_/node.hpp000064400000007436147547540560014455 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/node.hpp * Contains an implementation for rb_tree_. */ #ifndef PB_DS_RB_TREE_NODE_HPP #define PB_DS_RB_TREE_NODE_HPP #include namespace __gnu_pbds { namespace detail { /// Node for Red-Black trees. template struct rb_tree_node_ { public: typedef Value_Type value_type; typedef Metadata metadata_type; typedef typename _Alloc::template rebind< rb_tree_node_< Value_Type, Metadata, _Alloc> >::other::pointer node_pointer; typedef typename _Alloc::template rebind< metadata_type>::other::reference metadata_reference; typedef typename _Alloc::template rebind< metadata_type>::other::const_reference metadata_const_reference; bool special() const { return m_red; } metadata_const_reference get_metadata() const { return m_metadata; } metadata_reference get_metadata() { return m_metadata; } #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value) <<(m_red? " " : " ") << "(" << m_metadata << ")"; } #endif node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; value_type m_value; bool m_red; metadata_type m_metadata; }; template struct rb_tree_node_ { public: typedef Value_Type value_type; typedef null_type metadata_type; typedef typename _Alloc::template rebind< rb_tree_node_< Value_Type, null_type, _Alloc> >::other::pointer node_pointer; bool special() const { return m_red; } #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value) <<(m_red? " " : " "); } #endif node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; value_type m_value; bool m_red; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp000064400000017265147547540560017416 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/split_join_fn_imps.hpp * Contains an implementation for rb_tree_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (base_type::join_prep(other) == false) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } const node_pointer p_x = other.split_min(); join_imp(p_x, other.m_p_head->m_p_parent); base_type::join_finish(other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join_imp(node_pointer p_x, node_pointer p_r) { _GLIBCXX_DEBUG_ASSERT(p_x != 0); if (p_r != 0) p_r->m_red = false; const size_type h = black_height(base_type::m_p_head->m_p_parent); const size_type other_h = black_height(p_r); node_pointer p_x_l; node_pointer p_x_r; std::pair join_pos; const bool right_join = h >= other_h; if (right_join) { join_pos = find_join_pos_right(base_type::m_p_head->m_p_parent, h, other_h); p_x_l = join_pos.first; p_x_r = p_r; } else { p_x_l = base_type::m_p_head->m_p_parent; base_type::m_p_head->m_p_parent = p_r; if (p_r != 0) p_r->m_p_parent = base_type::m_p_head; join_pos = find_join_pos_left(base_type::m_p_head->m_p_parent, h, other_h); p_x_r = join_pos.first; } node_pointer p_parent = join_pos.second; if (p_parent == base_type::m_p_head) { base_type::m_p_head->m_p_parent = p_x; p_x->m_p_parent = base_type::m_p_head; } else { p_x->m_p_parent = p_parent; if (right_join) p_x->m_p_parent->m_p_right = p_x; else p_x->m_p_parent->m_p_left = p_x; } p_x->m_p_left = p_x_l; if (p_x_l != 0) p_x_l->m_p_parent = p_x; p_x->m_p_right = p_x_r; if (p_x_r != 0) p_x_r->m_p_parent = p_x; p_x->m_red = true; base_type::initialize_min_max(); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) base_type::update_to_top(p_x, (node_update* )this); insert_fixup(p_x); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: split_min() { node_pointer p_min = base_type::m_p_head->m_p_left; #ifdef _GLIBCXX_DEBUG const node_pointer p_head = base_type::m_p_head; _GLIBCXX_DEBUG_ASSERT(p_min != p_head); #endif remove_node(p_min); return p_min; } PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::node_pointer, typename PB_DS_CLASS_C_DEC::node_pointer> PB_DS_CLASS_C_DEC:: find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r) { _GLIBCXX_DEBUG_ASSERT(h_l >= h_r); if (base_type::m_p_head->m_p_parent == 0) return (std::make_pair((node_pointer)0, base_type::m_p_head)); node_pointer p_l_parent = base_type::m_p_head; while (h_l > h_r) { if (p_l->m_red == false) { _GLIBCXX_DEBUG_ASSERT(h_l > 0); --h_l; } p_l_parent = p_l; p_l = p_l->m_p_right; } if (!is_effectively_black(p_l)) { p_l_parent = p_l; p_l = p_l->m_p_right; } _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_l)); _GLIBCXX_DEBUG_ASSERT(black_height(p_l) == h_r); _GLIBCXX_DEBUG_ASSERT(p_l == 0 || p_l->m_p_parent == p_l_parent); return std::make_pair(p_l, p_l_parent); } PB_DS_CLASS_T_DEC std::pair< typename PB_DS_CLASS_C_DEC::node_pointer, typename PB_DS_CLASS_C_DEC::node_pointer> PB_DS_CLASS_C_DEC:: find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r) { _GLIBCXX_DEBUG_ASSERT(h_r > h_l); if (base_type::m_p_head->m_p_parent == 0) return (std::make_pair((node_pointer)0, base_type::m_p_head)); node_pointer p_r_parent = base_type::m_p_head; while (h_r > h_l) { if (p_r->m_red == false) { _GLIBCXX_DEBUG_ASSERT(h_r > 0); --h_r; } p_r_parent = p_r; p_r = p_r->m_p_left; } if (!is_effectively_black(p_r)) { p_r_parent = p_r; p_r = p_r->m_p_left; } _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_r)); _GLIBCXX_DEBUG_ASSERT(black_height(p_r) == h_l); _GLIBCXX_DEBUG_ASSERT(p_r == 0 || p_r->m_p_parent == p_r_parent); return std::make_pair(p_r, p_r_parent); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: black_height(node_pointer p_nd) { size_type h = 1; while (p_nd != 0) { if (p_nd->m_red == false) ++h; p_nd = p_nd->m_p_left; } return h; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) if (base_type::split_prep(r_key, other) == false) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) return; } PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_STRUCT_ONLY_ASSERT_VALID(other) node_pointer p_nd = this->upper_bound(r_key).m_p_nd; do { node_pointer p_next_nd = p_nd->m_p_parent; if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) split_at_node(p_nd, other); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_STRUCT_ONLY_ASSERT_VALID(other) p_nd = p_next_nd; } while (p_nd != base_type::m_p_head); base_type::split_finish(other); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ASSERT(p_nd != 0); node_pointer p_l = p_nd->m_p_left; node_pointer p_r = p_nd->m_p_right; node_pointer p_parent = p_nd->m_p_parent; if (p_parent == base_type::m_p_head) { base_type::m_p_head->m_p_parent = p_l; if (p_l != 0) { p_l->m_p_parent = base_type::m_p_head; p_l->m_red = false; } } else { if (p_parent->m_p_left == p_nd) p_parent->m_p_left = p_l; else p_parent->m_p_right = p_l; if (p_l != 0) p_l->m_p_parent = p_parent; this->update_to_top(p_parent, (node_update* )this); if (!p_nd->m_red) remove_fixup(p_l, p_parent); } base_type::initialize_min_max(); other.join_imp(p_nd, p_r); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) PB_DS_STRUCT_ONLY_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp000064400000015613147547540560016336 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/erase_fn_imps.hpp * Contains an implementation for rb_tree_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(key_const_reference r_key) { point_iterator it = this->find(r_key); if (it == base_type::end()) return false; erase(it); return true; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { PB_DS_ASSERT_VALID((*this)) if (it == base_type::end()) return it; iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) return ret_it; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == base_type::m_p_head) return it; reverse_iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); PB_DS_ASSERT_VALID((*this)) return ret_it; } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; iterator it = base_type::begin(); while (it != base_type::end()) { if (pred(*it)) { ++num_ersd; it = erase(it); } else ++it; } PB_DS_ASSERT_VALID((*this)) return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_node(node_pointer p_nd) { remove_node(p_nd); base_type::actual_erase_node(p_nd); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_node(node_pointer p_z) { this->update_min_max_for_erased_node(p_z); node_pointer p_y = p_z; node_pointer p_x = 0; node_pointer p_new_x_parent = 0; if (p_y->m_p_left == 0) p_x = p_y->m_p_right; else if (p_y->m_p_right == 0) p_x = p_y->m_p_left; else { p_y = p_y->m_p_right; while (p_y->m_p_left != 0) p_y = p_y->m_p_left; p_x = p_y->m_p_right; } if (p_y == p_z) { p_new_x_parent = p_y->m_p_parent; if (p_x != 0) p_x->m_p_parent = p_y->m_p_parent; if (base_type::m_p_head->m_p_parent == p_z) base_type::m_p_head->m_p_parent = p_x; else if (p_z->m_p_parent->m_p_left == p_z) { p_y->m_p_left = p_z->m_p_parent; p_z->m_p_parent->m_p_left = p_x; } else { p_y->m_p_left = 0; p_z->m_p_parent->m_p_right = p_x; } } else { p_z->m_p_left->m_p_parent = p_y; p_y->m_p_left = p_z->m_p_left; if (p_y != p_z->m_p_right) { p_new_x_parent = p_y->m_p_parent; if (p_x != 0) p_x->m_p_parent = p_y->m_p_parent; p_y->m_p_parent->m_p_left = p_x; p_y->m_p_right = p_z->m_p_right; p_z->m_p_right->m_p_parent = p_y; } else p_new_x_parent = p_y; if (base_type::m_p_head->m_p_parent == p_z) base_type::m_p_head->m_p_parent = p_y; else if (p_z->m_p_parent->m_p_left == p_z) p_z->m_p_parent->m_p_left = p_y; else p_z->m_p_parent->m_p_right = p_y; p_y->m_p_parent = p_z->m_p_parent; std::swap(p_y->m_red, p_z->m_red); p_y = p_z; } this->update_to_top(p_new_x_parent, (node_update* )this); if (p_y->m_red) return; remove_fixup(p_x, p_new_x_parent); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_fixup(node_pointer p_x, node_pointer p_new_x_parent) { _GLIBCXX_DEBUG_ASSERT(p_x == 0 || p_x->m_p_parent == p_new_x_parent); while (p_x != base_type::m_p_head->m_p_parent && is_effectively_black(p_x)) if (p_x == p_new_x_parent->m_p_left) { node_pointer p_w = p_new_x_parent->m_p_right; if (p_w->m_red) { p_w->m_red = false; p_new_x_parent->m_red = true; base_type::rotate_left(p_new_x_parent); p_w = p_new_x_parent->m_p_right; } if (is_effectively_black(p_w->m_p_left) && is_effectively_black(p_w->m_p_right)) { p_w->m_red = true; p_x = p_new_x_parent; p_new_x_parent = p_new_x_parent->m_p_parent; } else { if (is_effectively_black(p_w->m_p_right)) { if (p_w->m_p_left != 0) p_w->m_p_left->m_red = false; p_w->m_red = true; base_type::rotate_right(p_w); p_w = p_new_x_parent->m_p_right; } p_w->m_red = p_new_x_parent->m_red; p_new_x_parent->m_red = false; if (p_w->m_p_right != 0) p_w->m_p_right->m_red = false; base_type::rotate_left(p_new_x_parent); this->update_to_top(p_new_x_parent, (node_update* )this); break; } } else { node_pointer p_w = p_new_x_parent->m_p_left; if (p_w->m_red == true) { p_w->m_red = false; p_new_x_parent->m_red = true; base_type::rotate_right(p_new_x_parent); p_w = p_new_x_parent->m_p_left; } if (is_effectively_black(p_w->m_p_right) && is_effectively_black(p_w->m_p_left)) { p_w->m_red = true; p_x = p_new_x_parent; p_new_x_parent = p_new_x_parent->m_p_parent; } else { if (is_effectively_black(p_w->m_p_left)) { if (p_w->m_p_right != 0) p_w->m_p_right->m_red = false; p_w->m_red = true; base_type::rotate_left(p_w); p_w = p_new_x_parent->m_p_left; } p_w->m_red = p_new_x_parent->m_red; p_new_x_parent->m_red = false; if (p_w->m_p_left != 0) p_w->m_p_left->m_red = false; base_type::rotate_right(p_new_x_parent); this->update_to_top(p_new_x_parent, (node_update* )this); break; } } if (p_x != 0) p_x->m_red = false; } 4.8.2/ext/pb_ds/detail/rb_tree_map_/traits.hpp000064400000006323147547540560015030 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/traits.hpp * Contains an implementation for rb_tree_. */ #ifndef PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP #define PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP #include namespace __gnu_pbds { namespace detail { /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits : public bin_search_tree_traits< Key, Mapped, Cmp_Fn, Node_Update, rb_tree_node_< typename types_traits::value_type, typename tree_node_metadata_dispatch::type, _Alloc>, _Alloc> { }; /// Specialization. /// @ingroup traits template class Node_Update, typename _Alloc> struct tree_traits : public bin_search_tree_traits< Key, null_type, Cmp_Fn, Node_Update, rb_tree_node_< typename types_traits::value_type, typename tree_node_metadata_dispatch::type, _Alloc>, _Alloc> { }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp000064400000017432147547540560015306 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/rb_tree_.hpp * Contains an implementation for Red Black trees. */ #include #include #include #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #ifdef PB_DS_DATA_TRUE_INDICATOR # define PB_DS_RB_TREE_NAME rb_tree_map # define PB_DS_RB_TREE_BASE_NAME bin_search_tree_map #endif #ifdef PB_DS_DATA_FALSE_INDICATOR # define PB_DS_RB_TREE_NAME rb_tree_set # define PB_DS_RB_TREE_BASE_NAME bin_search_tree_set #endif #define PB_DS_CLASS_C_DEC \ PB_DS_RB_TREE_NAME #define PB_DS_RB_TREE_BASE \ PB_DS_RB_TREE_BASE_NAME /** * @brief Red-Black tree. * @ingroup branch-detail * * This implementation uses an idea from the SGI STL (using a * @a header node which is needed for efficient iteration). */ template class PB_DS_RB_TREE_NAME : public PB_DS_RB_TREE_BASE { private: typedef PB_DS_RB_TREE_BASE base_type; typedef typename base_type::node_pointer node_pointer; public: typedef rb_tree_tag container_category; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename base_type::key_type key_type; typedef typename base_type::key_pointer key_pointer; typedef typename base_type::key_const_pointer key_const_pointer; typedef typename base_type::key_reference key_reference; typedef typename base_type::key_const_reference key_const_reference; typedef typename base_type::mapped_type mapped_type; typedef typename base_type::mapped_pointer mapped_pointer; typedef typename base_type::mapped_const_pointer mapped_const_pointer; typedef typename base_type::mapped_reference mapped_reference; typedef typename base_type::mapped_const_reference mapped_const_reference; typedef typename base_type::value_type value_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::const_iterator point_const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::reverse_iterator reverse_iterator; typedef typename base_type::const_reverse_iterator const_reverse_iterator; typedef typename base_type::node_update node_update; PB_DS_RB_TREE_NAME(); PB_DS_RB_TREE_NAME(const Cmp_Fn&); PB_DS_RB_TREE_NAME(const Cmp_Fn&, const node_update&); PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC&); void swap(PB_DS_CLASS_C_DEC&); template void copy_from_range(It, It); inline std::pair insert(const_reference); inline mapped_reference operator[](key_const_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) std::pair ins_pair = base_type::insert_leaf(value_type(r_key, mapped_type())); if (ins_pair.second == true) { ins_pair.first.m_p_nd->m_red = true; _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);) insert_fixup(ins_pair.first.m_p_nd); } _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return ins_pair.first.m_p_nd->m_value.second; #else insert(r_key); return base_type::s_null_type; #endif } inline bool erase(key_const_reference); inline iterator erase(iterator); inline reverse_iterator erase(reverse_iterator); template inline size_type erase_if(Pred); void join(PB_DS_CLASS_C_DEC&); void split(key_const_reference, PB_DS_CLASS_C_DEC&); private: #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; size_type assert_node_consistent(const node_pointer, const char*, int) const; #endif inline static bool is_effectively_black(const node_pointer); void initialize(); void insert_fixup(node_pointer); void erase_node(node_pointer); void remove_node(node_pointer); void remove_fixup(node_pointer, node_pointer); void split_imp(node_pointer, PB_DS_CLASS_C_DEC&); inline node_pointer split_min(); std::pair split_min_imp(); void join_imp(node_pointer, node_pointer); std::pair find_join_pos_right(node_pointer, size_type, size_type); std::pair find_join_pos_left(node_pointer, size_type, size_type); inline size_type black_height(node_pointer); void split_at_node(node_pointer, PB_DS_CLASS_C_DEC&); }; #define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);) #include #include #include #include #include #include #undef PB_DS_STRUCT_ONLY_ASSERT_VALID #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_RB_TREE_NAME #undef PB_DS_RB_TREE_BASE_NAME #undef PB_DS_RB_TREE_BASE } // namespace detail } // namespace __gnu_pbds 4.8.2/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp000064400000003247147547540560016157 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/find_fn_imps.hpp * Contains an implementation for rb_tree_. */ 4.8.2/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp000064400000003461147547540560016170 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file rb_tree_map_/info_fn_imps.hpp * Contains an implementation for rb_tree_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_effectively_black(const node_pointer p_nd) { return (p_nd == 0 || !p_nd->m_red); } 4.8.2/ext/pb_ds/detail/branch_policy/branch_policy.hpp000064400000007677147547540560016551 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file branch_policy/branch_policy.hpp * Contains a base class for branch policies. */ #ifndef PB_DS_BRANCH_POLICY_BASE_HPP #define PB_DS_BRANCH_POLICY_BASE_HPP #include namespace __gnu_pbds { namespace detail { /// Primary template, base class for branch structure policies. template struct branch_policy { protected: typedef typename Node_Itr::value_type it_type; typedef typename std::iterator_traits::value_type value_type; typedef typename value_type::first_type key_type; typedef typename remove_const::type rcvalue_type; typedef typename remove_const::type rckey_type; typedef typename _Alloc::template rebind::other rebind_v; typedef typename _Alloc::template rebind::other rebind_k; typedef typename rebind_v::reference reference; typedef typename rebind_v::const_reference const_reference; typedef typename rebind_v::const_pointer const_pointer; typedef typename rebind_k::const_reference key_const_reference; static inline key_const_reference extract_key(const_reference r_val) { return r_val.first; } virtual it_type end() = 0; it_type end_iterator() const { return const_cast(this)->end(); } virtual ~branch_policy() { } }; /// Specialization for const iterators. template struct branch_policy { protected: typedef typename Node_CItr::value_type it_type; typedef typename std::iterator_traits::value_type value_type; typedef typename remove_const::type rcvalue_type; typedef typename _Alloc::template rebind::other rebind_v; typedef typename rebind_v::reference reference; typedef typename rebind_v::const_reference const_reference; typedef typename rebind_v::const_pointer const_pointer; typedef value_type key_type; typedef typename rebind_v::const_reference key_const_reference; static inline key_const_reference extract_key(const_reference r_val) { return r_val; } virtual it_type end() const = 0; it_type end_iterator() const { return end(); } virtual ~branch_policy() { } }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_BRANCH_POLICY_BASE_HPP 4.8.2/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp000064400000004513147547540560017536 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file branch_policy/null_node_metadata.hpp * Contains an implementation class for tree-like classes. */ #ifndef PB_DS_0_NODE_METADATA_HPP #define PB_DS_0_NODE_METADATA_HPP #include namespace __gnu_pbds { namespace detail { /// Constant node iterator. template struct dumnode_const_iterator { private: typedef types_traits __traits_type; typedef typename __traits_type::pointer const_iterator; public: typedef const_iterator value_type; typedef const_iterator const_reference; typedef const_reference reference; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/branch_policy/traits.hpp000064400000006266147547540560015234 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file branch_policy/traits.hpp * Contains an implementation class for tree-like classes. */ #ifndef PB_DS_NODE_AND_IT_TRAITS_HPP #define PB_DS_NODE_AND_IT_TRAITS_HPP #include #include #include #include #define PB_DS_DEBUG_VERIFY(_Cond) \ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ _M_message(#_Cond" assertion from %1;:%2;") \ ._M_string(__FILE__)._M_integer(__LINE__) \ ,__file,__line) namespace __gnu_pbds { namespace detail { /// Tree traits class, primary template. template class Node_Update, typename Tag, typename _Alloc> struct tree_traits; /// Trie traits class, primary template. template class Node_Update, typename Tag, typename _Alloc> struct trie_traits; } // namespace detail } // namespace __gnu_pbds #include #include #include #include #undef PB_DS_DEBUG_VERIFY #endif // #ifndef PB_DS_NODE_AND_IT_TRAITS_HPP 4.8.2/ext/pb_ds/detail/container_base_dispatch.hpp000064400000031500147547540560015732 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file container_base_dispatch.hpp * Contains associative container dispatching. */ #ifndef PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP #define PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP #include #define PB_DS_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) #define PB_DS_DEBUG_VERIFY(_Cond) \ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ _M_message(#_Cond" assertion from %1;:%2;") \ ._M_string(__FILE__)._M_integer(__LINE__) \ ,__file,__line) #define PB_DS_CHECK_KEY_EXISTS(_Key) \ _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) #define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ __FILE__, __LINE__);) #define PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) #include #include #include #include #include #include #include #include #undef PB_DS_DATA_TRUE_INDICATOR #undef PB_DS_V2F #undef PB_DS_V2S #undef PB_DS_EP2VP #define PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) #include #include #include #include #include #include #include #include #undef PB_DS_DATA_FALSE_INDICATOR #undef PB_DS_V2F #undef PB_DS_V2S #undef PB_DS_EP2VP #undef PB_DS_CHECK_KEY_DOES_NOT_EXIST #undef PB_DS_CHECK_KEY_EXISTS #undef PB_DS_DEBUG_VERIFY #undef PB_DS_ASSERT_VALID namespace __gnu_pbds { namespace detail { /// Specialization for list-update map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef lu_map type; }; /// Specialization for list-update set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef lu_set type; }; /// Specialization for PATRICIA trie map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: typedef pat_trie_map type; }; /// Specialization for PATRICIA trie set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef pat_trie_set type; }; /// Specialization for R-B tree map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef rb_tree_map type; }; /// Specialization for R-B tree set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: typedef rb_tree_set type; }; /// Specialization splay tree map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef splay_tree_map type; }; /// Specialization splay tree set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef splay_tree_set type; }; /// Specialization ordered-vector tree map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef ov_tree_map type; }; /// Specialization ordered-vector tree set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; public: /// Dispatched type. typedef ov_tree_set type; }; /// Specialization colision-chaining hash map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; typedef __gnu_cxx::typelist::at_index at2; typedef typename at2::type at2t; typedef __gnu_cxx::typelist::at_index at3; typedef typename at3::type at3t; typedef __gnu_cxx::typelist::at_index at4; typedef typename at4::type at4t; public: /// Dispatched type. typedef cc_ht_map type; }; /// Specialization colision-chaining hash set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; typedef __gnu_cxx::typelist::at_index at2; typedef typename at2::type at2t; typedef __gnu_cxx::typelist::at_index at3; typedef typename at3::type at3t; typedef __gnu_cxx::typelist::at_index at4; typedef typename at4::type at4t; public: /// Dispatched type. typedef cc_ht_set type; }; /// Specialization general-probe hash map. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; typedef __gnu_cxx::typelist::at_index at2; typedef typename at2::type at2t; typedef __gnu_cxx::typelist::at_index at3; typedef typename at3::type at3t; typedef __gnu_cxx::typelist::at_index at4; typedef typename at4::type at4t; typedef __gnu_cxx::typelist::at_index at5; typedef typename at5::type at5t; public: /// Dispatched type. typedef gp_ht_map type; }; /// Specialization general-probe hash set. template struct container_base_dispatch { private: typedef __gnu_cxx::typelist::at_index at0; typedef typename at0::type at0t; typedef __gnu_cxx::typelist::at_index at1; typedef typename at1::type at1t; typedef __gnu_cxx::typelist::at_index at2; typedef typename at2::type at2t; typedef __gnu_cxx::typelist::at_index at3; typedef typename at3::type at3t; typedef __gnu_cxx::typelist::at_index at4; typedef typename at4::type at4t; typedef __gnu_cxx::typelist::at_index at5; typedef typename at5::type at5t; public: /// Dispatched type. typedef gp_ht_set type; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/type_utils.hpp000064400000010337147547540560013305 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/type_utils.hpp * Contains utilities for handnling types. All of these classes are based on * Modern C++ by Andrei Alxandrescu. */ #ifndef PB_DS_TYPE_UTILS_HPP #define PB_DS_TYPE_UTILS_HPP #include #include #include #include #include namespace __gnu_pbds { namespace detail { using std::tr1::is_same; using std::tr1::is_const; using std::tr1::is_pointer; using std::tr1::is_reference; using std::tr1::is_fundamental; using std::tr1::is_member_object_pointer; using std::tr1::is_member_pointer; using std::tr1::is_base_of; using std::tr1::remove_const; using std::tr1::remove_reference; // Need integral_const <-> integral_const, so // because of this use the following typedefs instead of importing // std::tr1's. using std::tr1::integral_constant; typedef std::tr1::integral_constant true_type; typedef std::tr1::integral_constant false_type; using __gnu_cxx::__conditional_type; using __gnu_cxx::__numeric_traits; template struct is_const_pointer { enum { value = is_const::value && is_pointer::value }; }; template struct is_const_reference { enum { value = is_const::value && is_reference::value }; }; template struct is_simple { enum { value = is_fundamental::type>::value || is_pointer::type>::value || is_member_pointer::value }; }; template class is_pair { private: template struct is_pair_imp { enum { value = 0 }; }; template struct is_pair_imp > { enum { value = 1 }; }; public: enum { value = is_pair_imp::value }; }; // Use C++0x's static_assert if possible. #if __cplusplus >= 201103L #define PB_DS_STATIC_ASSERT(UNIQUE, E) static_assert(E, #UNIQUE) #else template struct __static_assert; template<> struct __static_assert { }; template struct __static_assert_dumclass { enum { v = 1 }; }; #define PB_DS_STATIC_ASSERT(UNIQUE, E) \ typedef __gnu_pbds::detail::__static_assert_dumclass)> UNIQUE##__static_assert_type #endif template struct type_to_type { typedef Type type; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp000064400000005632147547540560024175 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_load_check_resize_trigger_size_base.hpp * Contains an base holding size for some resize policies. */ #ifndef PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP #define PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP namespace __gnu_pbds { namespace detail { /// Primary template. template class hash_load_check_resize_trigger_size_base; /// Specializations. template class hash_load_check_resize_trigger_size_base { protected: typedef Size_Type size_type; hash_load_check_resize_trigger_size_base(): m_size(0) { } inline void swap(hash_load_check_resize_trigger_size_base& other) { std::swap(m_size, other.m_size); } inline void set_size(size_type size) { m_size = size; } inline size_type get_size() const { return m_size; } private: size_type m_size; }; template class hash_load_check_resize_trigger_size_base { protected: typedef Size_Type size_type; protected: inline void swap(hash_load_check_resize_trigger_size_base& other) { } inline void set_size(size_type size) { } }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp000064400000017110147547540560023010 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_load_check_resize_trigger_imp.hpp * Contains a resize trigger implementation. */ #define PB_DS_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_load_check_resize_trigger(float load_min, float load_max) : m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0), m_next_grow_size(0), m_resize_needed(false) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_start() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_collision() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_end() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_start() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_collision() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_end() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_start() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_collision() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_end() { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_inserted(size_type num_entries) { m_resize_needed = (num_entries >= m_next_grow_size); size_base::set_size(num_entries); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erased(size_type num_entries) { size_base::set_size(num_entries); m_resize_needed = num_entries <= m_next_shrink_size; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_resize_needed() const { PB_DS_ASSERT_VALID((*this)) return m_resize_needed; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_grow_needed(size_type /*size*/, size_type num_entries) const { _GLIBCXX_DEBUG_ASSERT(m_resize_needed); return num_entries >= m_next_grow_size; } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~hash_load_check_resize_trigger() { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type new_size) { m_resize_needed = false; m_next_grow_size = size_type(m_load_max * new_size - 1); m_next_shrink_size = size_type(m_load_min * new_size); #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ std::cerr << "hlcrt::notify_resized " << std::endl << "1 " << new_size << std::endl << "2 " << m_load_min << std::endl << "3 " << m_load_max << std::endl << "4 " << m_next_shrink_size << std::endl << "5 " << m_next_grow_size << std::endl; #endif PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_externally_resized(size_type new_size) { m_resize_needed = false; size_type new_grow_size = size_type(m_load_max * new_size - 1); size_type new_shrink_size = size_type(m_load_min * new_size); #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ std::cerr << "hlcrt::notify_externally_resized " << std::endl << "1 " << new_size << std::endl << "2 " << m_load_min << std::endl << "3 " << m_load_max << std::endl << "4 " << m_next_shrink_size << std::endl << "5 " << m_next_grow_size << std::endl << "6 " << new_shrink_size << std::endl << "7 " << new_grow_size << std::endl; #endif if (new_grow_size >= m_next_grow_size) { _GLIBCXX_DEBUG_ASSERT(new_shrink_size >= m_next_shrink_size); m_next_grow_size = new_grow_size; } else { _GLIBCXX_DEBUG_ASSERT(new_shrink_size <= m_next_shrink_size); m_next_shrink_size = new_shrink_size; } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_cleared() { PB_DS_ASSERT_VALID((*this)) size_base::set_size(0); m_resize_needed = (0 < m_next_shrink_size); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) size_base::swap(other); std::swap(m_load_min, other.m_load_min); std::swap(m_load_max, other.m_load_max); std::swap(m_resize_needed, other.m_resize_needed); std::swap(m_next_grow_size, other.m_next_grow_size); std::swap(m_next_shrink_size, other.m_next_shrink_size); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: get_loads() const { PB_DS_STATIC_ASSERT(access, external_load_access); return std::make_pair(m_load_min, m_load_max); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: set_loads(std::pair load_pair) { PB_DS_STATIC_ASSERT(access, external_load_access); const float old_load_min = m_load_min; const float old_load_max = m_load_max; const size_type old_next_shrink_size = m_next_shrink_size; const size_type old_next_grow_size = m_next_grow_size; const bool old_resize_needed = m_resize_needed; __try { m_load_min = load_pair.first; m_load_max = load_pair.second; do_resize(static_cast(size_base::get_size() / ((m_load_min + m_load_max) / 2))); } __catch(...) { m_load_min = old_load_min; m_load_max = old_load_max; m_next_shrink_size = old_next_shrink_size; m_next_grow_size = old_next_grow_size; m_resize_needed = old_resize_needed; __throw_exception_again; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: do_resize(size_type) { std::abort(); } #ifdef _GLIBCXX_DEBUG # define PB_DS_DEBUG_VERIFY(_Cond) \ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ _M_message(#_Cond" assertion from %1;:%2;") \ ._M_string(__FILE__)._M_integer(__LINE__) \ ,__file,__line) PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(m_load_max > m_load_min); PB_DS_DEBUG_VERIFY(m_next_grow_size >= m_next_shrink_size); } # undef PB_DS_DEBUG_VERIFY #endif #undef PB_DS_ASSERT_VALID 4.8.2/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp000064400000014213147547540560022371 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_standard_resize_policy_imp.hpp * Contains a resize policy implementation. */ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_standard_resize_policy() : m_size(Size_Policy::get_nearest_larger_size(1)) { trigger_policy_base::notify_externally_resized(m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_standard_resize_policy(const Size_Policy& r_size_policy) : Size_Policy(r_size_policy), m_size(Size_Policy::get_nearest_larger_size(1)) { trigger_policy_base::notify_externally_resized(m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_standard_resize_policy(const Size_Policy& r_size_policy, const Trigger_Policy& r_trigger_policy) : Size_Policy(r_size_policy), Trigger_Policy(r_trigger_policy), m_size(Size_Policy::get_nearest_larger_size(1)) { trigger_policy_base::notify_externally_resized(m_size); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~hash_standard_resize_policy() { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { trigger_policy_base::swap(other); size_policy_base::swap(other); std::swap(m_size, other.m_size); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_start() { trigger_policy_base::notify_find_search_start(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_collision() { trigger_policy_base::notify_find_search_collision(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_end() { trigger_policy_base::notify_find_search_end(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_start() { trigger_policy_base::notify_insert_search_start(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_collision() { trigger_policy_base::notify_insert_search_collision(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_end() { trigger_policy_base::notify_insert_search_end(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_start() { trigger_policy_base::notify_erase_search_start(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_collision() { trigger_policy_base::notify_erase_search_collision(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_end() { trigger_policy_base::notify_erase_search_end(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_inserted(size_type num_e) { trigger_policy_base::notify_inserted(num_e); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erased(size_type num_e) { trigger_policy_base::notify_erased(num_e); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_cleared() { trigger_policy_base::notify_cleared(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_resize_needed() const { return trigger_policy_base::is_resize_needed(); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_new_size(size_type size, size_type num_used_e) const { if (trigger_policy_base::is_grow_needed(size, num_used_e)) return size_policy_base::get_nearest_larger_size(size); return size_policy_base::get_nearest_smaller_size(size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type new_size) { trigger_policy_base::notify_resized(new_size); m_size = new_size; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_actual_size() const { PB_DS_STATIC_ASSERT(access, external_size_access); return m_size; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: resize(size_type new_size) { PB_DS_STATIC_ASSERT(access, external_size_access); size_type actual_size = size_policy_base::get_nearest_larger_size(1); while (actual_size < new_size) { const size_type pot = size_policy_base::get_nearest_larger_size(actual_size); if (pot == actual_size && pot < new_size) __throw_resize_error(); actual_size = pot; } if (actual_size > 0) --actual_size; const size_type old_size = m_size; __try { do_resize(actual_size - 1); } __catch(insert_error& ) { m_size = old_size; __throw_resize_error(); } __catch(...) { m_size = old_size; __throw_exception_again; } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: do_resize(size_type) { // Do nothing } PB_DS_CLASS_T_DEC Trigger_Policy& PB_DS_CLASS_C_DEC:: get_trigger_policy() { return *this; } PB_DS_CLASS_T_DEC const Trigger_Policy& PB_DS_CLASS_C_DEC:: get_trigger_policy() const { return *this; } PB_DS_CLASS_T_DEC Size_Policy& PB_DS_CLASS_C_DEC:: get_size_policy() { return *this; } PB_DS_CLASS_T_DEC const Size_Policy& PB_DS_CLASS_C_DEC:: get_size_policy() const { return *this; } 4.8.2/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp000064400000013773147547540560021370 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_prime_size_policy_imp.hpp * Contains a resize size policy implementation. */ #pragma GCC system_header namespace detail { enum { num_distinct_sizes_32_bit = 30, num_distinct_sizes_64_bit = 62, num_distinct_sizes = sizeof(std::size_t) != 8 ? num_distinct_sizes_32_bit : num_distinct_sizes_64_bit, }; // Originally taken from the SGI implementation; acknowledged in the docs. // Further modified (for 64 bits) from tr1's hashtable. static const std::size_t g_a_sizes[num_distinct_sizes_64_bit] = { /* 0 */ 5ul, /* 1 */ 11ul, /* 2 */ 23ul, /* 3 */ 47ul, /* 4 */ 97ul, /* 5 */ 199ul, /* 6 */ 409ul, /* 7 */ 823ul, /* 8 */ 1741ul, /* 9 */ 3469ul, /* 10 */ 6949ul, /* 11 */ 14033ul, /* 12 */ 28411ul, /* 13 */ 57557ul, /* 14 */ 116731ul, /* 15 */ 236897ul, /* 16 */ 480881ul, /* 17 */ 976369ul, /* 18 */ 1982627ul, /* 19 */ 4026031ul, /* 20 */ 8175383ul, /* 21 */ 16601593ul, /* 22 */ 33712729ul, /* 23 */ 68460391ul, /* 24 */ 139022417ul, /* 25 */ 282312799ul, /* 26 */ 573292817ul, /* 27 */ 1164186217ul, /* 28 */ 2364114217ul, /* 29 */ 4294967291ul, /* 30 */ (std::size_t)8589934583ull, /* 31 */ (std::size_t)17179869143ull, /* 32 */ (std::size_t)34359738337ull, /* 33 */ (std::size_t)68719476731ull, /* 34 */ (std::size_t)137438953447ull, /* 35 */ (std::size_t)274877906899ull, /* 36 */ (std::size_t)549755813881ull, /* 37 */ (std::size_t)1099511627689ull, /* 38 */ (std::size_t)2199023255531ull, /* 39 */ (std::size_t)4398046511093ull, /* 40 */ (std::size_t)8796093022151ull, /* 41 */ (std::size_t)17592186044399ull, /* 42 */ (std::size_t)35184372088777ull, /* 43 */ (std::size_t)70368744177643ull, /* 44 */ (std::size_t)140737488355213ull, /* 45 */ (std::size_t)281474976710597ull, /* 46 */ (std::size_t)562949953421231ull, /* 47 */ (std::size_t)1125899906842597ull, /* 48 */ (std::size_t)2251799813685119ull, /* 49 */ (std::size_t)4503599627370449ull, /* 50 */ (std::size_t)9007199254740881ull, /* 51 */ (std::size_t)18014398509481951ull, /* 52 */ (std::size_t)36028797018963913ull, /* 53 */ (std::size_t)72057594037927931ull, /* 54 */ (std::size_t)144115188075855859ull, /* 55 */ (std::size_t)288230376151711717ull, /* 56 */ (std::size_t)576460752303423433ull, /* 57 */ (std::size_t)1152921504606846883ull, /* 58 */ (std::size_t)2305843009213693951ull, /* 59 */ (std::size_t)4611686018427387847ull, /* 60 */ (std::size_t)9223372036854775783ull, /* 61 */ (std::size_t)18446744073709551557ull, }; } // namespace detail PB_DS_CLASS_T_DEC inline PB_DS_CLASS_C_DEC:: hash_prime_size_policy(size_type n) : m_start_size(n) { m_start_size = get_nearest_larger_size(n); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_start_size, other.m_start_size); } PB_DS_CLASS_T_DEC inline PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_nearest_larger_size(size_type n) const { const std::size_t* const p_upper = std::upper_bound(detail::g_a_sizes, detail::g_a_sizes + detail::num_distinct_sizes, n); if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes) __throw_resize_error(); return *p_upper; } PB_DS_CLASS_T_DEC inline PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_nearest_smaller_size(size_type n) const { const std::size_t* p_lower = std::lower_bound(detail::g_a_sizes, detail::g_a_sizes + detail::num_distinct_sizes, n); if (*p_lower >= n && p_lower != detail::g_a_sizes) --p_lower; if (*p_lower < m_start_size) return m_start_size; return *p_lower; } 4.8.2/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp000064400000005324147547540560022573 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_exponential_size_policy_imp.hpp * Contains a resize size policy implementation. */ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_exponential_size_policy(size_type start_size, size_type grow_factor) : m_start_size(start_size), m_grow_factor(grow_factor) { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_start_size, other.m_start_size); std::swap(m_grow_factor, other.m_grow_factor); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_nearest_larger_size(size_type size) const { size_type ret = m_start_size; while (ret <= size) { const size_type next_ret = ret* m_grow_factor; if (next_ret < ret) __throw_insert_error(); ret = next_ret; } return ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_nearest_smaller_size(size_type size) const { size_type ret = m_start_size; while (true) { const size_type next_ret = ret* m_grow_factor; if (next_ret < ret) __throw_resize_error(); if (next_ret >= size) return (ret); ret = next_ret; } return ret; } 4.8.2/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp000064400000006772147547540560020215 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_resize_policy.hpp * Contains a sample resize policy for hash tables. */ #ifndef PB_DS_SAMPLE_RESIZE_POLICY_HPP #define PB_DS_SAMPLE_RESIZE_POLICY_HPP namespace __gnu_pbds { /// A sample resize policy. class sample_resize_policy { public: /// Size type. typedef std::size_t size_type; /// Default constructor. sample_resize_policy(); /// Copy constructor. sample_range_hashing(const sample_resize_policy& other); /// Swaps content. inline void swap(sample_resize_policy& other); protected: /// Notifies a search started. inline void notify_insert_search_start(); /// Notifies a search encountered a collision. inline void notify_insert_search_collision(); /// Notifies a search ended. inline void notify_insert_search_end(); /// Notifies a search started. inline void notify_find_search_start(); /// Notifies a search encountered a collision. inline void notify_find_search_collision(); /// Notifies a search ended. inline void notify_find_search_end(); /// Notifies a search started. inline void notify_erase_search_start(); /// Notifies a search encountered a collision. inline void notify_erase_search_collision(); /// Notifies a search ended. inline void notify_erase_search_end(); /// Notifies an element was inserted. inline void notify_inserted(size_type num_e); /// Notifies an element was erased. inline void notify_erased(size_type num_e); /// Notifies the table was cleared. void notify_cleared(); /// Notifies the table was resized to new_size. void notify_resized(size_type new_size); /// Queries whether a resize is needed. inline bool is_resize_needed() const; /// Queries what the new size should be. size_type get_new_size(size_type size, size_type num_used_e) const; }; } #endif 4.8.2/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp000064400000011443147547540560025401 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file cc_hash_max_collision_check_resize_trigger_imp.hpp * Contains a resize trigger implementation. */ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: cc_hash_max_collision_check_resize_trigger(float load) : m_load(load), m_size(0), m_num_col(0), m_max_col(0), m_resize_needed(false) { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_start() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_collision() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_end() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_start() { m_num_col = 0; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_collision() { ++m_num_col; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_end() { calc_resize_needed(); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_start() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_collision() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_end() { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_inserted(size_type) { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erased(size_type) { m_resize_needed = true; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_cleared() { m_resize_needed = false; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_resize_needed() const { return m_resize_needed; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: is_grow_needed(size_type /*size*/, size_type /*num_used_e*/) const { return m_num_col >= m_max_col; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_resized(size_type new_size) { m_size = new_size; #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ std::cerr << "chmccrt::notify_resized " << static_cast(new_size) << std::endl; #endif calc_max_num_coll(); calc_resize_needed(); m_num_col = 0; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: calc_max_num_coll() { // max_col <-- \sqrt{2 load \ln( 2 m \ln( m ) ) } const double ln_arg = 2 * m_size * std::log(double(m_size)); m_max_col = size_type(std::ceil(std::sqrt(2 * m_load * std::log(ln_arg)))); #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ std::cerr << "chmccrt::calc_max_num_coll " << static_cast(m_size) << " " << static_cast(m_max_col) << std::endl; #endif } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: notify_externally_resized(size_type new_size) { notify_resized(new_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_load, other.m_load); std::swap(m_size, other.m_size); std::swap(m_num_col, other.m_num_col); std::swap(m_max_col, other.m_max_col); std::swap(m_resize_needed, other.m_resize_needed); } PB_DS_CLASS_T_DEC inline float PB_DS_CLASS_C_DEC:: get_load() const { PB_DS_STATIC_ASSERT(access, external_load_access); return m_load; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: calc_resize_needed() { m_resize_needed = m_resize_needed || m_num_col >= m_max_col; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: set_load(float load) { PB_DS_STATIC_ASSERT(access, external_load_access); m_load = load; calc_max_num_coll(); calc_resize_needed(); } 4.8.2/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp000064400000007512147547540560020352 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_resize_trigger.hpp * Contains a sample resize trigger policy class. */ #ifndef PB_DS_SAMPLE_RESIZE_TRIGGER_HPP #define PB_DS_SAMPLE_RESIZE_TRIGGER_HPP namespace __gnu_pbds { /// A sample resize trigger policy. class sample_resize_trigger { public: /// Size type. typedef std::size_t size_type; /// Default constructor. sample_resize_trigger(); /// Copy constructor. sample_range_hashing(const sample_resize_trigger&); /// Swaps content. inline void swap(sample_resize_trigger&); protected: /// Notifies a search started. inline void notify_insert_search_start(); /// Notifies a search encountered a collision. inline void notify_insert_search_collision(); /// Notifies a search ended. inline void notify_insert_search_end(); /// Notifies a search started. inline void notify_find_search_start(); /// Notifies a search encountered a collision. inline void notify_find_search_collision(); /// Notifies a search ended. inline void notify_find_search_end(); /// Notifies a search started. inline void notify_erase_search_start(); /// Notifies a search encountered a collision. inline void notify_erase_search_collision(); /// Notifies a search ended. inline void notify_erase_search_end(); /// Notifies an element was inserted. the total number of entries in /// the table is num_entries. inline void notify_inserted(size_type num_entries); /// Notifies an element was erased. inline void notify_erased(size_type num_entries); /// Notifies the table was cleared. void notify_cleared(); /// Notifies the table was resized as a result of this object's /// signifying that a resize is needed. void notify_resized(size_type new_size); /// Notifies the table was resized externally. void notify_externally_resized(size_type new_size); /// Queries whether a resize is needed. inline bool is_resize_needed() const; /// Queries whether a grow is needed. inline bool is_grow_needed(size_type size, size_type num_entries) const; private: /// Resizes to new_size. virtual void do_resize(size_type); }; } #endif 4.8.2/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp000064400000004573147547540560017663 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file sample_size_policy.hpp * Contains a sample size resize-policy. */ #ifndef PB_DS_SAMPLE_SIZE_POLICY_HPP #define PB_DS_SAMPLE_SIZE_POLICY_HPP namespace __gnu_pbds { /// A sample size policy. class sample_size_policy { public: /// Size type. typedef std::size_t size_type; /// Default constructor. sample_size_policy(); /// Copy constructor. sample_range_hashing(const sample_size_policy&); /// Swaps content. inline void swap(sample_size_policy& other); protected: /// Given a __size size, returns a __size that is larger. inline size_type get_nearest_larger_size(size_type size) const; /// Given a __size size, returns a __size that is smaller. inline size_type get_nearest_smaller_size(size_type size) const; }; } #endif 4.8.2/ext/pb_ds/detail/priority_queue_base_dispatch.hpp000064400000010054147547540560017036 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/priority_queue_base_dispatch.hpp * Contains an pqiative container dispatching base. */ #ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP #define PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP #define PB_DS_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) #define PB_DS_DEBUG_VERIFY(_Cond) \ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ _M_message(#_Cond" assertion from %1;:%2;") \ ._M_string(__FILE__)._M_integer(__LINE__) \ ,__file,__line) #include #include #include #include #include #undef PB_DS_DEBUG_VERIFY #undef PB_DS_ASSERT_VALID namespace __gnu_pbds { namespace detail { /// Specialization for pairing_heap. template struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, pairing_heap_tag, null_type> { /// Dispatched type. typedef pairing_heap<_VTp, Cmp_Fn, _Alloc> type; }; /// Specialization for binomial_heap. template struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binomial_heap_tag, null_type> { /// Dispatched type. typedef binomial_heap<_VTp, Cmp_Fn, _Alloc> type; }; /// Specialization for rc_binary_heap. template struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, rc_binomial_heap_tag, null_type> { /// Dispatched type. typedef rc_binomial_heap<_VTp, Cmp_Fn, _Alloc> type; }; /// Specialization for binary_heap. template struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binary_heap_tag, null_type> { /// Dispatched type. typedef binary_heap<_VTp, Cmp_Fn, _Alloc> type; }; /// Specialization for thin_heap. template struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, thin_heap_tag, null_type> { /// Dispatched type. typedef thin_heap<_VTp, Cmp_Fn, _Alloc> type; }; //@} group pbds } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP 4.8.2/ext/pb_ds/detail/tree_trace_base.hpp000064400000012016147547540560014207 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file detail/tree_trace_base.hpp * Contains tree-related policies. */ #ifndef PB_DS_TREE_TRACE_BASE_HPP #define PB_DS_TREE_TRACE_BASE_HPP #ifdef PB_DS_TREE_TRACE #include #include namespace __gnu_pbds { namespace detail { #ifdef PB_DS_TREE_TRACE #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ tree_trace_base #define PB_DS_TRACE_BASE \ branch_policy /// Tracing base class. template class tree_trace_base : private PB_DS_TRACE_BASE { public: void trace() const; private: typedef PB_DS_TRACE_BASE base_type; typedef Node_CItr node_const_iterator; typedef typename _Alloc::size_type size_type; void trace_node(node_const_iterator, size_type) const; virtual bool empty() const = 0; virtual node_const_iterator node_begin() const = 0; virtual node_const_iterator node_end() const = 0; static void print_node_pointer(Node_CItr, integral_constant); static void print_node_pointer(Node_CItr, integral_constant); template static void trace_it_metadata(Node_CItr, type_to_type); static void trace_it_metadata(Node_CItr, type_to_type); }; PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { if (empty()) return; trace_node(node_begin(), 0); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_node(node_const_iterator nd_it, size_type level) const { if (nd_it.get_r_child() != node_end()) trace_node(nd_it.get_r_child(), level + 1); for (size_type i = 0; i < level; ++i) std::cerr << ' '; print_node_pointer(nd_it, integral_constant()); std::cerr << base_type::extract_key(*(*nd_it)); typedef type_to_type m_type_ind_t; trace_it_metadata(nd_it, m_type_ind_t()); std::cerr << std::endl; if (nd_it.get_l_child() != node_end()) trace_node(nd_it.get_l_child(), level + 1); } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: trace_it_metadata(Node_CItr nd_it, type_to_type) { const unsigned long ul = static_cast(nd_it.get_metadata()); std::cerr << " (" << ul << ") "; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_it_metadata(Node_CItr, type_to_type) { } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: print_node_pointer(Node_CItr nd_it, integral_constant) { std::cerr << nd_it.m_p_nd << " "; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: print_node_pointer(Node_CItr nd_it, integral_constant) { std::cerr << *nd_it << " "; } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_TRACE_BASE #endif // #ifdef PB_DS_TREE_TRACE } // namespace detail } // namespace __gnu_pbds #endif // #ifdef PB_DS_TREE_TRACE #endif // #ifndef PB_DS_TREE_TRACE_BASE_HPP 4.8.2/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp000064400000004617147547540560016341 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/trace_fn_imps.hpp * Contains an implementation class for a binary_heap. */ #ifdef PB_DS_BINARY_HEAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << this << std::endl; std::cerr << m_a_entries << std::endl; for (size_type i = 0; i < m_size; ++i) trace_entry(m_a_entries[i], s_no_throw_copies_ind); std::cerr << std::endl; std::cerr << "size = " << m_size << " " << "actual_size = " << m_actual_size << std::endl; resize_policy::trace(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_entry(const entry& r_e, false_type) const { std::cout << r_e << " " <<* r_e << std::endl; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace_entry(const entry& r_e, true_type) const { std::cout << r_e << std::endl; } #endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ 4.8.2/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp000064400000004755147547540560016334 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/debug_fn_imps.hpp * Contains an implementation class for a binary_heap. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const char* __file, int __line) const { #ifdef PB_DS_REGRESSION s_entry_allocator.check_allocated(m_a_entries, m_actual_size); #endif resize_policy::assert_valid(__file, __line); PB_DS_DEBUG_VERIFY(m_size <= m_actual_size); for (size_type i = 0; i < m_size; ++i) { #ifdef PB_DS_REGRESSION s_value_allocator.check_allocated(m_a_entries[i], 1); #endif if (left_child(i) < m_size) PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i); if (right_child(i) < m_size) PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i); } } #endif 4.8.2/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp000064400000010135147547540560022261 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/constructors_destructor_fn_imps.hpp * Contains an implementation class for binary_heap_. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_allocator PB_DS_CLASS_C_DEC::s_entry_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::value_allocator PB_DS_CLASS_C_DEC::s_value_allocator; PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::no_throw_copies_t PB_DS_CLASS_C_DEC::s_no_throw_copies_ind; PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) { insert_value(*first_it, s_no_throw_copies_ind); ++first_it; } make_heap(); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binary_heap() : m_size(0), m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binary_heap(const Cmp_Fn& r_cmp_fn) : entry_cmp(r_cmp_fn), m_size(0), m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binary_heap(const PB_DS_CLASS_C_DEC& other) : entry_cmp(other), resize_policy(other), m_size(0), m_actual_size(other.m_actual_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { PB_DS_ASSERT_VALID(other) _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); __try { copy_from_range(other.begin(), other.end()); } __catch(...) { for (size_type i = 0; i < m_size; ++i) erase_at(m_a_entries, i, s_no_throw_copies_ind); s_entry_allocator.deallocate(m_a_entries, m_actual_size); __throw_exception_again; } PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); value_swap(other); std::swap((entry_cmp&)(*this), (entry_cmp&)other); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_a_entries, other.m_a_entries); std::swap(m_size, other.m_size); std::swap(m_actual_size, other.m_actual_size); static_cast(this)->swap(other); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~binary_heap() { for (size_type i = 0; i < m_size; ++i) erase_at(m_a_entries, i, s_no_throw_copies_ind); s_entry_allocator.deallocate(m_a_entries, m_actual_size); } 4.8.2/ext/pb_ds/detail/binary_heap_/resize_policy.hpp000064400000013765147547540560016414 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/resize_policy.hpp * Contains an implementation class for a binary_heap. */ #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #include namespace __gnu_pbds { namespace detail { /// Resize policy for binary heap. template class resize_policy { private: enum { ratio = 8, factor = 2 }; /// Next shrink size. _Tp m_shrink_size; /// Next grow size. _Tp m_grow_size; public: typedef _Tp size_type; static const _Tp min_size = 16; resize_policy() : m_shrink_size(0), m_grow_size(min_size) { PB_DS_ASSERT_VALID((*this)) } resize_policy(const resize_policy& other) : m_shrink_size(other.m_shrink_size), m_grow_size(other.m_grow_size) { PB_DS_ASSERT_VALID((*this)) } inline void swap(resize_policy<_Tp>&); inline bool resize_needed_for_grow(size_type) const; inline bool resize_needed_for_shrink(size_type) const; inline bool grow_needed(size_type) const; inline bool shrink_needed(size_type) const; inline size_type get_new_size_for_grow() const; inline size_type get_new_size_for_shrink() const; inline size_type get_new_size_for_arbitrary(size_type) const; inline void notify_grow_resize(); inline void notify_shrink_resize(); void notify_arbitrary(size_type); #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_BINARY_HEAP_TRACE_ void trace() const; #endif }; template const _Tp resize_policy<_Tp>::min_size; template inline void resize_policy<_Tp>:: swap(resize_policy<_Tp>& other) { std::swap(m_shrink_size, other.m_shrink_size); std::swap(m_grow_size, other.m_grow_size); } template inline bool resize_policy<_Tp>:: resize_needed_for_grow(size_type size) const { _GLIBCXX_DEBUG_ASSERT(size <= m_grow_size); return size == m_grow_size; } template inline bool resize_policy<_Tp>:: resize_needed_for_shrink(size_type size) const { _GLIBCXX_DEBUG_ASSERT(size <= m_grow_size); return size == m_shrink_size; } template inline typename resize_policy<_Tp>::size_type resize_policy<_Tp>:: get_new_size_for_grow() const { return m_grow_size * factor; } template inline typename resize_policy<_Tp>::size_type resize_policy<_Tp>:: get_new_size_for_shrink() const { const size_type half_size = m_grow_size / factor; return std::max(min_size, half_size); } template inline typename resize_policy<_Tp>::size_type resize_policy<_Tp>:: get_new_size_for_arbitrary(size_type size) const { size_type ret = min_size; while (ret < size) ret *= factor; return ret; } template inline void resize_policy<_Tp>:: notify_grow_resize() { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(m_grow_size >= min_size); m_grow_size *= factor; m_shrink_size = m_grow_size / ratio; PB_DS_ASSERT_VALID((*this)) } template inline void resize_policy<_Tp>:: notify_shrink_resize() { PB_DS_ASSERT_VALID((*this)) m_shrink_size /= factor; if (m_shrink_size == 1) m_shrink_size = 0; m_grow_size = std::max(m_grow_size / factor, min_size); PB_DS_ASSERT_VALID((*this)) } template inline void resize_policy<_Tp>:: notify_arbitrary(size_type actual_size) { m_grow_size = actual_size; m_shrink_size = m_grow_size / ratio; PB_DS_ASSERT_VALID((*this)) } #ifdef _GLIBCXX_DEBUG template void resize_policy<_Tp>:: assert_valid(const char* __file, int __line) const { PB_DS_DEBUG_VERIFY(m_shrink_size == 0 || m_shrink_size * ratio == m_grow_size); PB_DS_DEBUG_VERIFY(m_grow_size >= min_size); } #endif #ifdef PB_DS_BINARY_HEAP_TRACE_ template void resize_policy<_Tp>:: trace() const { std::cerr << "shrink = " << m_shrink_size << " grow = " << m_grow_size << std::endl; } #endif } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp000064400000011626147547540560016545 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/insert_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { PB_DS_ASSERT_VALID((*this)) insert_value(r_val, s_no_throw_copies_ind); push_heap(); PB_DS_ASSERT_VALID((*this)) return point_iterator(m_a_entries); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_value(value_type val, true_type) { resize_for_insert_if_needed(); m_a_entries[m_size++] = val; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_value(const_reference r_val, false_type) { resize_for_insert_if_needed(); pointer p_new = s_value_allocator.allocate(1); cond_dealtor_t cond(p_new); new (p_new) value_type(r_val); cond.set_no_action(); m_a_entries[m_size++] = p_new; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: resize_for_insert_if_needed() { if (!resize_policy::resize_needed_for_grow(m_size)) { _GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size); return; } const size_type new_size = resize_policy::get_new_size_for_grow(); entry_pointer new_entries = s_entry_allocator.allocate(new_size); resize_policy::notify_grow_resize(); std::copy(m_a_entries, m_a_entries + m_size, new_entries); s_entry_allocator.deallocate(m_a_entries, m_actual_size); m_actual_size = new_size; m_a_entries = new_entries; make_heap(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { PB_DS_ASSERT_VALID((*this)) swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); fix(it.m_p_e); PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(is_heap()); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: fix(entry_pointer p_e) { size_type i = p_e - m_a_entries; if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i])) { size_type parent_i = parent(i); while (i > 0 && entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i])) { std::swap(m_a_entries[i], m_a_entries[parent_i]); i = parent_i; parent_i = parent(i); } PB_DS_ASSERT_VALID((*this)) return; } while (i < m_size) { const size_type lchild_i = left_child(i); const size_type rchild_i = right_child(i); _GLIBCXX_DEBUG_ASSERT(rchild_i > lchild_i); const bool smaller_than_lchild = lchild_i < m_size && entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]); const bool smaller_than_rchild = rchild_i < m_size && entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]); const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i])); const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild; if (swap_with_lchild) { std::swap(m_a_entries[i], m_a_entries[lchild_i]); i = lchild_i; } else if (swap_with_rchild) { std::swap(m_a_entries[i], m_a_entries[rchild_i]); i = rchild_i; } else i = m_size; } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap_value_imp(entry_pointer p_e, value_type new_val, true_type) { *p_e = new_val; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap_value_imp(entry_pointer p_e, const_reference r_new_val, false_type) { value_type tmp(r_new_val); (*p_e)->swap(tmp); } 4.8.2/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp000064400000011473147547540560017413 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/split_join_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) typedef typename entry_pred::type pred_t; const size_type left = partition(pred_t(pred)); _GLIBCXX_DEBUG_ASSERT(m_size >= left); const size_type ersd = m_size - left; _GLIBCXX_DEBUG_ASSERT(m_size >= ersd); const size_type new_size = resize_policy::get_new_size_for_arbitrary(left); const size_type other_actual_size = other.get_new_size_for_arbitrary(ersd); entry_pointer a_entries = 0; entry_pointer a_other_entries = 0; __try { a_entries = s_entry_allocator.allocate(new_size); a_other_entries = s_entry_allocator.allocate(other_actual_size); } __catch(...) { if (a_entries != 0) s_entry_allocator.deallocate(a_entries, new_size); if (a_other_entries != 0) s_entry_allocator.deallocate(a_other_entries, other_actual_size); __throw_exception_again; }; for (size_type i = 0; i < other.m_size; ++i) erase_at(other.m_a_entries, i, s_no_throw_copies_ind); _GLIBCXX_DEBUG_ASSERT(new_size >= left); std::copy(m_a_entries, m_a_entries + left, a_entries); std::copy(m_a_entries + left, m_a_entries + m_size, a_other_entries); s_entry_allocator.deallocate(m_a_entries, m_actual_size); s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size); m_actual_size = new_size; other.m_actual_size = other_actual_size; m_size = left; other.m_size = ersd; m_a_entries = a_entries; other.m_a_entries = a_other_entries; make_heap(); other.make_heap(); resize_policy::notify_arbitrary(m_actual_size); other.notify_arbitrary(other.m_actual_size); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) const size_type len = m_size + other.m_size; const size_type new_size = resize_policy::get_new_size_for_arbitrary(len); entry_pointer a_entries = 0; entry_pointer a_other_entries = 0; __try { a_entries = s_entry_allocator.allocate(new_size); a_other_entries = s_entry_allocator.allocate(resize_policy::min_size); } __catch(...) { if (a_entries != 0) s_entry_allocator.deallocate(a_entries, new_size); if (a_other_entries != 0) s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size); __throw_exception_again; } std::copy(m_a_entries, m_a_entries + m_size, a_entries); std::copy(other.m_a_entries, other.m_a_entries + other.m_size, a_entries + m_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size); m_a_entries = a_entries; m_size = len; m_actual_size = new_size; resize_policy::notify_arbitrary(new_size); make_heap(); s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size); other.m_a_entries = a_other_entries; other.m_size = 0; other.m_actual_size = resize_policy::min_size; other.notify_arbitrary(resize_policy::min_size); other.make_heap(); PB_DS_ASSERT_VALID((*this)) PB_DS_ASSERT_VALID(other) } 4.8.2/ext/pb_ds/detail/binary_heap_/const_iterator.hpp000064400000010362147547540560016561 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/const_iterator.hpp * Contains an iterator class returned by the table's const find and insert * methods. */ #ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP #define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_BIN_HEAP_CIT_BASE \ binary_heap_point_const_iterator_ /// Const point-type iterator. template class binary_heap_const_iterator_ : public PB_DS_BIN_HEAP_CIT_BASE { private: typedef PB_DS_BIN_HEAP_CIT_BASE base_type; typedef typename base_type::entry_pointer entry_pointer; public: /// Category. typedef std::forward_iterator_tag iterator_category; /// Difference type. typedef typename _Alloc::difference_type difference_type; /// Iterator's value type. typedef typename base_type::value_type value_type; /// Iterator's pointer type. typedef typename base_type::pointer pointer; /// Iterator's const pointer type. typedef typename base_type::const_pointer const_pointer; /// Iterator's reference type. typedef typename base_type::reference reference; /// Iterator's const reference type. typedef typename base_type::const_reference const_reference; inline binary_heap_const_iterator_(entry_pointer p_e) : base_type(p_e) { } /// Default constructor. inline binary_heap_const_iterator_() { } /// Copy constructor. inline binary_heap_const_iterator_(const binary_heap_const_iterator_& other) : base_type(other) { } /// Compares content to a different iterator object. inline bool operator==(const binary_heap_const_iterator_& other) const { return base_type::m_p_e == other.m_p_e; } /// Compares content (negatively) to a different iterator object. inline bool operator!=(const binary_heap_const_iterator_& other) const { return base_type::m_p_e != other.m_p_e; } inline binary_heap_const_iterator_& operator++() { _GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != 0); inc(); return *this; } inline binary_heap_const_iterator_ operator++(int) { binary_heap_const_iterator_ ret_it(base_type::m_p_e); operator++(); return ret_it; } private: void inc() { ++base_type::m_p_e; } }; #undef PB_DS_BIN_HEAP_CIT_BASE } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp000064400000004336147547540560017255 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/iterators_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { return iterator(m_a_entries); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { return const_iterator(m_a_entries); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return iterator(m_a_entries + m_size); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return const_iterator(m_a_entries + m_size); } 4.8.2/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp000064400000012600147547540560016331 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/erase_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { for (size_type i = 0; i < m_size; ++i) erase_at(m_a_entries, i, s_no_throw_copies_ind); __try { const size_type new_size = resize_policy::get_new_size_for_arbitrary(0); entry_pointer new_entries = s_entry_allocator.allocate(new_size); resize_policy::notify_arbitrary(new_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size); m_actual_size = new_size; m_a_entries = new_entries; } __catch(...) { } m_size = 0; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_at(entry_pointer a_entries, size_type i, false_type) { a_entries[i]->~value_type(); s_value_allocator.deallocate(a_entries[i], 1); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_at(entry_pointer, size_type, true_type) { } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: pop() { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); pop_heap(); erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind); resize_for_erase_if_needed(); _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { PB_DS_ASSERT_VALID((*this)) typedef typename entry_pred::type pred_t; const size_type left = partition(pred_t(pred)); _GLIBCXX_DEBUG_ASSERT(m_size >= left); const size_type ersd = m_size - left; for (size_type i = left; i < m_size; ++i) erase_at(m_a_entries, i, s_no_throw_copies_ind); __try { const size_type new_size = resize_policy::get_new_size_for_arbitrary(left); entry_pointer new_entries = s_entry_allocator.allocate(new_size); std::copy(m_a_entries, m_a_entries + left, new_entries); s_entry_allocator.deallocate(m_a_entries, m_actual_size); m_actual_size = new_size; resize_policy::notify_arbitrary(m_actual_size); } __catch(...) { }; m_size = left; make_heap(); PB_DS_ASSERT_VALID((*this)) return ersd; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); const size_type fix_pos = it.m_p_e - m_a_entries; std::swap(*it.m_p_e, m_a_entries[m_size - 1]); erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind); resize_for_erase_if_needed(); _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; _GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size); if (fix_pos != m_size) fix(m_a_entries + fix_pos); PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: resize_for_erase_if_needed() { if (!resize_policy::resize_needed_for_shrink(m_size)) return; __try { const size_type new_size = resize_policy::get_new_size_for_shrink(); entry_pointer new_entries = s_entry_allocator.allocate(new_size); resize_policy::notify_shrink_resize(); _GLIBCXX_DEBUG_ASSERT(m_size > 0); std::copy(m_a_entries, m_a_entries + m_size - 1, new_entries); s_entry_allocator.deallocate(m_a_entries, m_actual_size); m_actual_size = new_size; m_a_entries = new_entries; } __catch(...) { } } PB_DS_CLASS_T_DEC template typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: partition(Pred pred) { size_type left = 0; size_type right = m_size - 1; while (right + 1 != left) { _GLIBCXX_DEBUG_ASSERT(left <= m_size); if (!pred(m_a_entries[left])) ++left; else if (pred(m_a_entries[right])) --right; else { _GLIBCXX_DEBUG_ASSERT(left < right); std::swap(m_a_entries[left], m_a_entries[right]); ++left; --right; } } return left; } 4.8.2/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp000064400000003556147547540560020064 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/policy_access_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() { return (*this); } PB_DS_CLASS_T_DEC const Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() const { return (*this); } 4.8.2/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp000064400000022141147547540560016140 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/binary_heap_.hpp * Contains an implementation class for a binary heap. */ #ifndef PB_DS_BINARY_HEAP_HPP #define PB_DS_BINARY_HEAP_HPP #include #include #include #include #include #include #include #include #include #include #ifdef PB_DS_BINARY_HEAP_TRACE_ #include #endif #include #include namespace __gnu_pbds { namespace detail { #define PB_DS_CLASS_T_DEC \ template #define PB_DS_CLASS_C_DEC \ binary_heap #define PB_DS_ENTRY_CMP_DEC \ entry_cmp::value>::type #define PB_DS_RESIZE_POLICY_DEC \ __gnu_pbds::detail::resize_policy /** * Binary heaps composed of resize and compare policies. * * @ingroup heap-detail * * Based on CLRS. */ template class binary_heap : public PB_DS_ENTRY_CMP_DEC, public PB_DS_RESIZE_POLICY_DEC { public: typedef Value_Type value_type; typedef Cmp_Fn cmp_fn; typedef _Alloc allocator_type; typedef typename _Alloc::size_type size_type; typedef typename _Alloc::difference_type difference_type; typedef typename PB_DS_ENTRY_CMP_DEC entry_cmp; typedef PB_DS_RESIZE_POLICY_DEC resize_policy; typedef cond_dealtor cond_dealtor_t; private: enum { simple_value = is_simple::value }; typedef integral_constant no_throw_copies_t; typedef typename _Alloc::template rebind __rebind_v; typedef typename __rebind_v::other value_allocator; public: typedef typename value_allocator::pointer pointer; typedef typename value_allocator::const_pointer const_pointer; typedef typename value_allocator::reference reference; typedef typename value_allocator::const_reference const_reference; typedef typename __conditional_type::__type entry; typedef typename _Alloc::template rebind::other entry_allocator; typedef typename entry_allocator::pointer entry_pointer; typedef binary_heap_point_const_iterator_ point_const_iterator; typedef point_const_iterator point_iterator; typedef binary_heap_const_iterator_ const_iterator; typedef const_iterator iterator; binary_heap(); binary_heap(const cmp_fn&); binary_heap(const binary_heap&); void swap(binary_heap&); ~binary_heap(); inline bool empty() const; inline size_type size() const; inline size_type max_size() const; Cmp_Fn& get_cmp_fn(); const Cmp_Fn& get_cmp_fn() const; inline point_iterator push(const_reference); void modify(point_iterator, const_reference); inline const_reference top() const; inline void pop(); inline void erase(point_iterator); template size_type erase_if(Pred); inline void erase_at(entry_pointer, size_type, false_type); inline void erase_at(entry_pointer, size_type, true_type); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; void clear(); template void split(Pred, binary_heap&); void join(binary_heap&); #ifdef PB_DS_BINARY_HEAP_TRACE_ void trace() const; #endif protected: template void copy_from_range(It, It); private: void value_swap(binary_heap&); inline void insert_value(const_reference, false_type); inline void insert_value(value_type, true_type); inline void resize_for_insert_if_needed(); inline void swap_value_imp(entry_pointer, value_type, true_type); inline void swap_value_imp(entry_pointer, const_reference, false_type); void fix(entry_pointer); inline const_reference top_imp(true_type) const; inline const_reference top_imp(false_type) const; inline static size_type left_child(size_type); inline static size_type right_child(size_type); inline static size_type parent(size_type); inline void resize_for_erase_if_needed(); template size_type partition(Pred); void make_heap() { const entry_cmp& m_cmp = static_cast(*this); entry_pointer end = m_a_entries + m_size; std::make_heap(m_a_entries, end, m_cmp); _GLIBCXX_DEBUG_ASSERT(is_heap()); } void push_heap() { if (!is_heap()) make_heap(); else { const entry_cmp& m_cmp = static_cast(*this); entry_pointer end = m_a_entries + m_size; std::push_heap(m_a_entries, end, m_cmp); } } void pop_heap() { const entry_cmp& m_cmp = static_cast(*this); entry_pointer end = m_a_entries + m_size; std::pop_heap(m_a_entries, end, m_cmp); } bool is_heap() { const entry_cmp& m_cmp = static_cast(*this); entry_pointer end = m_a_entries + m_size; bool p = std::__is_heap(m_a_entries, end, m_cmp); return p; } #ifdef _GLIBCXX_DEBUG void assert_valid(const char*, int) const; #endif #ifdef PB_DS_BINARY_HEAP_TRACE_ void trace_entry(const entry&, false_type) const; void trace_entry(const entry&, true_type) const; #endif static entry_allocator s_entry_allocator; static value_allocator s_value_allocator; static no_throw_copies_t s_no_throw_copies_ind; size_type m_size; size_type m_actual_size; entry_pointer m_a_entries; }; #define PB_DS_ASSERT_VALID(X) \ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) #define PB_DS_DEBUG_VERIFY(_Cond) \ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ _M_message(#_Cond" assertion from %1;:%2;") \ ._M_string(__FILE__)._M_integer(__LINE__) \ ,__file,__line) #include #include #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_ENTRY_CMP_DEC #undef PB_DS_RESIZE_POLICY_DEC } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp000064400000005404147547540560015523 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/entry_cmp.hpp * Contains an implementation class for a binary_heap. */ #ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP #define PB_DS_BINARY_HEAP_ENTRY_CMP_HPP namespace __gnu_pbds { namespace detail { /// Entry compare, primary template. template struct entry_cmp; /// Specialization, true. template struct entry_cmp<_VTp, Cmp_Fn, _Alloc, true> { /// Compare. typedef Cmp_Fn type; }; /// Specialization, false. template struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false> { private: typedef typename _Alloc::template rebind<_VTp> __rebind_v; public: typedef typename __rebind_v::other::const_pointer entry; /// Compare plus entry. struct type : public Cmp_Fn { type() { } type(const Cmp_Fn& other) : Cmp_Fn(other) { } bool operator()(entry lhs, entry rhs) const { return Cmp_Fn::operator()(*lhs, *rhs); } }; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP 4.8.2/ext/pb_ds/detail/binary_heap_/entry_pred.hpp000064400000005341147547540560015676 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/entry_pred.hpp * Contains an implementation class for a binary_heap. */ #ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP #define PB_DS_BINARY_HEAP_ENTRY_PRED_HPP namespace __gnu_pbds { namespace detail { /// Entry predicate primary class template. template struct entry_pred; /// Specialization, true. template struct entry_pred<_VTp, Pred, _Alloc, true> { typedef Pred type; }; /// Specialization, false. template struct entry_pred<_VTp, Pred, _Alloc, false> { private: typedef typename _Alloc::template rebind<_VTp> __rebind_v; public: typedef typename __rebind_v::other::const_pointer entry; struct type : public Pred { inline type() { } inline type(const Pred& other) : Pred(other) { } inline bool operator()(entry p_v) const { return Pred::operator()(*p_v); } }; }; } // namespace detail } // namespace __gnu_pbds #endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP 4.8.2/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp000064400000010537147547540560017776 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/point_const_iterator.hpp * Contains an iterator class returned by the table's const find and insert * methods. */ #ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP #define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP #include #include namespace __gnu_pbds { namespace detail { /// Const point-type iterator. template class binary_heap_point_const_iterator_ { protected: typedef typename _Alloc::template rebind::other::pointer entry_pointer; public: /// Category. typedef trivial_iterator_tag iterator_category; /// Difference type. typedef trivial_iterator_difference_type difference_type; /// Iterator's value type. typedef Value_Type value_type; /// Iterator's pointer type. typedef typename _Alloc::template rebind::other::pointer pointer; /// Iterator's const pointer type. typedef typename _Alloc::template rebind::other::const_pointer const_pointer; /// Iterator's reference type. typedef typename _Alloc::template rebind::other::reference reference; /// Iterator's const reference type. typedef typename _Alloc::template rebind::other::const_reference const_reference; inline binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e) { } /// Default constructor. inline binary_heap_point_const_iterator_() : m_p_e(0) { } /// Copy constructor. inline binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other) : m_p_e(other.m_p_e) { } /// Access. inline const_pointer operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_e != 0); return to_ptr(integral_constant()); } /// Access. inline const_reference operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_e != 0); return *to_ptr(integral_constant()); } /// Compares content to a different iterator object. inline bool operator==(const binary_heap_point_const_iterator_& other) const { return m_p_e == other.m_p_e; } /// Compares content (negatively) to a different iterator object. inline bool operator!=(const binary_heap_point_const_iterator_& other) const { return m_p_e != other.m_p_e; } private: inline const_pointer to_ptr(true_type) const { return m_p_e; } inline const_pointer to_ptr(false_type) const { return *m_p_e; } public: entry_pointer m_p_e; }; } // namespace detail } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp000064400000005045147547540560016157 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/find_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); return top_imp(s_no_throw_copies_ind); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top_imp(true_type) const { return *m_a_entries; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top_imp(false_type) const { return **m_a_entries; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: left_child(size_type i) { return i * 2 + 1; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: right_child(size_type i) { return i * 2 + 2; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: parent(size_type i) { return (i - 1) / 2; } 4.8.2/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp000064400000004016147547540560016167 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file binary_heap_/info_fn_imps.hpp * Contains an implementation class for a binary_heap. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return m_size == 0; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return m_size; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_entry_allocator.max_size(); } 4.8.2/ext/pb_ds/hash_policy.hpp000064400000040657147547540560012154 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file hash_policy.hpp * Contains hash-related policies. */ #ifndef PB_DS_HASH_POLICY_HPP #define PB_DS_HASH_POLICY_HPP #include #include #include #include #include #include #include #include #include namespace __gnu_pbds { #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC linear_probe_fn /// A probe sequence policy using fixed increments. template class linear_probe_fn { public: typedef Size_Type size_type; void swap(PB_DS_CLASS_C_DEC& other); protected: /// Returns the i-th offset from the hash value. inline size_type operator()(size_type i) const; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC quadratic_probe_fn /// A probe sequence policy using square increments. template class quadratic_probe_fn { public: typedef Size_Type size_type; void swap(PB_DS_CLASS_C_DEC& other); protected: /// Returns the i-th offset from the hash value. inline size_type operator()(size_type i) const; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC direct_mask_range_hashing /// A mask range-hashing class (uses a bitmask). template class direct_mask_range_hashing : public detail::mask_based_range_hashing { private: typedef detail::mask_based_range_hashing mask_based_base; public: typedef Size_Type size_type; void swap(PB_DS_CLASS_C_DEC& other); protected: void notify_resized(size_type size); /// Transforms the __hash value hash into a ranged-hash value /// (using a bit-mask). inline size_type operator()(size_type hash) const; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC direct_mod_range_hashing /// A mod range-hashing class (uses the modulo function). template class direct_mod_range_hashing : public detail::mod_based_range_hashing { public: typedef Size_Type size_type; void swap(PB_DS_CLASS_C_DEC& other); protected: void notify_resized(size_type size); /// Transforms the __hash value hash into a ranged-hash value /// (using a modulo operation). inline size_type operator()(size_type hash) const; private: typedef detail::mod_based_range_hashing mod_based_base; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC hash_load_check_resize_trigger #define PB_DS_SIZE_BASE_C_DEC detail::hash_load_check_resize_trigger_size_base /// A resize trigger policy based on a load check. It keeps the /// load factor between some load factors load_min and load_max. template class hash_load_check_resize_trigger : private PB_DS_SIZE_BASE_C_DEC { public: typedef Size_Type size_type; enum { /// Specifies whether the load factor can be accessed /// externally. The two options have different trade-offs in /// terms of flexibility, genericity, and encapsulation. external_load_access = External_Load_Access }; /// Default constructor, or constructor taking load_min and /// load_max load factors between which this policy will keep the /// actual load. hash_load_check_resize_trigger(float load_min = 0.125, float load_max = 0.5); void swap(hash_load_check_resize_trigger& other); virtual ~hash_load_check_resize_trigger(); /// Returns a pair of the minimal and maximal loads, respectively. inline std::pair get_loads() const; /// Sets the loads through a pair of the minimal and maximal /// loads, respectively. void set_loads(std::pair load_pair); protected: inline void notify_insert_search_start(); inline void notify_insert_search_collision(); inline void notify_insert_search_end(); inline void notify_find_search_start(); inline void notify_find_search_collision(); inline void notify_find_search_end(); inline void notify_erase_search_start(); inline void notify_erase_search_collision(); inline void notify_erase_search_end(); /// Notifies an element was inserted. The total number of entries /// in the table is num_entries. inline void notify_inserted(size_type num_entries); inline void notify_erased(size_type num_entries); /// Notifies the table was cleared. void notify_cleared(); /// Notifies the table was resized as a result of this object's /// signifying that a resize is needed. void notify_resized(size_type new_size); void notify_externally_resized(size_type new_size); inline bool is_resize_needed() const; inline bool is_grow_needed(size_type size, size_type num_entries) const; private: virtual void do_resize(size_type new_size); typedef PB_DS_SIZE_BASE_C_DEC size_base; #ifdef _GLIBCXX_DEBUG void assert_valid(const char* file, int line) const; #endif float m_load_min; float m_load_max; size_type m_next_shrink_size; size_type m_next_grow_size; bool m_resize_needed; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_SIZE_BASE_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC cc_hash_max_collision_check_resize_trigger /// A resize trigger policy based on collision checks. It keeps the /// simulated load factor lower than some given load factor. template class cc_hash_max_collision_check_resize_trigger { public: typedef Size_Type size_type; enum { /// Specifies whether the load factor can be accessed /// externally. The two options have different trade-offs in /// terms of flexibility, genericity, and encapsulation. external_load_access = External_Load_Access }; /// Default constructor, or constructor taking load, a __load /// factor which it will attempt to maintain. cc_hash_max_collision_check_resize_trigger(float load = 0.5); void swap(PB_DS_CLASS_C_DEC& other); /// Returns the current load. inline float get_load() const; /// Sets the load; does not resize the container. void set_load(float load); protected: /// Notifies an insert search started. inline void notify_insert_search_start(); /// Notifies a search encountered a collision. inline void notify_insert_search_collision(); /// Notifies a search ended. inline void notify_insert_search_end(); /// Notifies a find search started. inline void notify_find_search_start(); /// Notifies a search encountered a collision. inline void notify_find_search_collision(); /// Notifies a search ended. inline void notify_find_search_end(); /// Notifies an erase search started. inline void notify_erase_search_start(); /// Notifies a search encountered a collision. inline void notify_erase_search_collision(); /// Notifies a search ended. inline void notify_erase_search_end(); /// Notifies an element was inserted. inline void notify_inserted(size_type num_entries); /// Notifies an element was erased. inline void notify_erased(size_type num_entries); /// Notifies the table was cleared. void notify_cleared(); /// Notifies the table was resized as a result of this object's /// signifying that a resize is needed. void notify_resized(size_type new_size); /// Notifies the table was resized externally. void notify_externally_resized(size_type new_size); /// Queries whether a resize is needed. inline bool is_resize_needed() const; /// Queries whether a grow is needed. This method is called only /// if this object indicated is needed. inline bool is_grow_needed(size_type size, size_type num_entries) const; private: void calc_max_num_coll(); inline void calc_resize_needed(); float m_load; size_type m_size; size_type m_num_col; size_type m_max_col; bool m_resize_needed; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC hash_exponential_size_policy /// A size policy whose sequence of sizes form an exponential /// sequence (typically powers of 2. template class hash_exponential_size_policy { public: typedef Size_Type size_type; /// Default constructor, or onstructor taking a start_size, or /// constructor taking a start size and grow_factor. The policy /// will use the sequence of sizes start_size, start_size* /// grow_factor, start_size* grow_factor^2, ... hash_exponential_size_policy(size_type start_size = 8, size_type grow_factor = 2); void swap(PB_DS_CLASS_C_DEC& other); protected: size_type get_nearest_larger_size(size_type size) const; size_type get_nearest_smaller_size(size_type size) const; private: size_type m_start_size; size_type m_grow_factor; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC #define PB_DS_CLASS_C_DEC hash_prime_size_policy /// A size policy whose sequence of sizes form a nearly-exponential /// sequence of primes. class hash_prime_size_policy { public: /// Size type. typedef std::size_t size_type; /// Default constructor, or onstructor taking a start_size The /// policy will use the sequence of sizes approximately /// start_size, start_size* 2, start_size* 2^2, ... hash_prime_size_policy(size_type start_size = 8); inline void swap(PB_DS_CLASS_C_DEC& other); protected: size_type get_nearest_larger_size(size_type size) const; size_type get_nearest_smaller_size(size_type size) const; private: size_type m_start_size; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC hash_standard_resize_policy /// A resize policy which delegates operations to size and trigger policies. template, typename Trigger_Policy = hash_load_check_resize_trigger<>, bool External_Size_Access = false, typename Size_Type = std::size_t> class hash_standard_resize_policy : public Size_Policy, public Trigger_Policy { public: typedef Size_Type size_type; typedef Trigger_Policy trigger_policy; typedef Size_Policy size_policy; enum { external_size_access = External_Size_Access }; /// Default constructor. hash_standard_resize_policy(); /// constructor taking some policies r_size_policy will be copied /// by the Size_Policy object of this object. hash_standard_resize_policy(const Size_Policy& r_size_policy); /// constructor taking some policies. r_size_policy will be /// copied by the Size_Policy object of this /// object. r_trigger_policy will be copied by the Trigger_Policy /// object of this object. hash_standard_resize_policy(const Size_Policy& r_size_policy, const Trigger_Policy& r_trigger_policy); virtual ~hash_standard_resize_policy(); inline void swap(PB_DS_CLASS_C_DEC& other); /// Access to the Size_Policy object used. Size_Policy& get_size_policy(); /// Const access to the Size_Policy object used. const Size_Policy& get_size_policy() const; /// Access to the Trigger_Policy object used. Trigger_Policy& get_trigger_policy(); /// Access to the Trigger_Policy object used. const Trigger_Policy& get_trigger_policy() const; /// Returns the actual size of the container. inline size_type get_actual_size() const; /// Resizes the container to suggested_new_size, a suggested size /// (the actual size will be determined by the Size_Policy /// object). void resize(size_type suggested_new_size); protected: inline void notify_insert_search_start(); inline void notify_insert_search_collision(); inline void notify_insert_search_end(); inline void notify_find_search_start(); inline void notify_find_search_collision(); inline void notify_find_search_end(); inline void notify_erase_search_start(); inline void notify_erase_search_collision(); inline void notify_erase_search_end(); inline void notify_inserted(size_type num_e); inline void notify_erased(size_type num_e); void notify_cleared(); void notify_resized(size_type new_size); inline bool is_resize_needed() const; /// Queries what the new size should be, when the container is /// resized naturally. The current __size of the container is /// size, and the number of used entries within the container is /// num_used_e. size_type get_new_size(size_type size, size_type num_used_e) const; private: /// Resizes to new_size. virtual void do_resize(size_type new_size); typedef Trigger_Policy trigger_policy_base; typedef Size_Policy size_policy_base; size_type m_size; }; #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/tag_and_trait.hpp000064400000027756147547540560012457 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file tag_and_trait.hpp * Contains tags and traits, e.g., ones describing underlying * data structures. */ #ifndef PB_DS_TAG_AND_TRAIT_HPP #define PB_DS_TAG_AND_TRAIT_HPP #include #include /** * @namespace __gnu_pbds * @brief GNU extensions for policy-based data structures for public use. */ namespace __gnu_pbds { /** @defgroup pbds Policy-Based Data Structures * @ingroup extensions * * This is a library of policy-based elementary data structures: * associative containers and priority queues. It is designed for * high-performance, flexibility, semantic safety, and conformance * to the corresponding containers in std (except for some points * where it differs by design). * * For details, see: * http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html * * @{ */ /** * @defgroup tags Tags * @{ */ /// A trivial iterator tag. Signifies that the iterators has none of /// std::iterators's movement abilities. struct trivial_iterator_tag { }; /// Prohibit moving trivial iterators. typedef void trivial_iterator_difference_type; /** * @defgroup invalidation_tags Invalidation Guarantees * @ingroup tags * @{ */ /** * Signifies a basic invalidation guarantee that any iterator, * pointer, or reference to a container object's mapped value type * is valid as long as the container is not modified. */ struct basic_invalidation_guarantee { }; /** * Signifies an invalidation guarantee that includes all those of * its base, and additionally, that any point-type iterator, * pointer, or reference to a container object's mapped value type * is valid as long as its corresponding entry has not be erased, * regardless of modifications to the container object. */ struct point_invalidation_guarantee : public basic_invalidation_guarantee { }; /** * Signifies an invalidation guarantee that includes all those of * its base, and additionally, that any range-type iterator * (including the returns of begin() and end()) is in the correct * relative positions to other range-type iterators as long as its * corresponding entry has not be erased, regardless of * modifications to the container object. */ struct range_invalidation_guarantee : public point_invalidation_guarantee { }; //@} /** * @defgroup ds_tags Data Structure Type * @ingroup tags * @{ */ /// Base data structure tag. struct container_tag { }; /// Basic sequence. struct sequence_tag : public container_tag { }; /// Basic string container, inclusive of strings, ropes, etc. struct string_tag : public sequence_tag { }; /// Basic associative-container. struct associative_tag : public container_tag { }; /// Basic hash structure. struct basic_hash_tag : public associative_tag { }; /// Collision-chaining hash. struct cc_hash_tag : public basic_hash_tag { }; /// General-probing hash. struct gp_hash_tag : public basic_hash_tag { }; /// Basic branch structure. struct basic_branch_tag : public associative_tag { }; /// Basic tree structure. struct tree_tag : public basic_branch_tag { }; /// Red-black tree. struct rb_tree_tag : public tree_tag { }; /// Splay tree. struct splay_tree_tag : public tree_tag { }; /// Ordered-vector tree. struct ov_tree_tag : public tree_tag { }; /// Basic trie structure. struct trie_tag : public basic_branch_tag { }; /// PATRICIA trie. struct pat_trie_tag : public trie_tag { }; /// List-update. struct list_update_tag : public associative_tag { }; /// Basic priority-queue. struct priority_queue_tag : public container_tag { }; /// Pairing-heap. struct pairing_heap_tag : public priority_queue_tag { }; /// Binomial-heap. struct binomial_heap_tag : public priority_queue_tag { }; /// Redundant-counter binomial-heap. struct rc_binomial_heap_tag : public priority_queue_tag { }; /// Binary-heap (array-based). struct binary_heap_tag : public priority_queue_tag { }; /// Thin heap. struct thin_heap_tag : public priority_queue_tag { }; //@} //@} /** * @defgroup traits Traits * @{ */ /** * @brief Represents no type, or absence of type, for template tricks. * * In a mapped-policy, indicates that an associative container is a set. * * In a list-update policy, indicates that each link does not need * metadata. * * In a hash policy, indicates that the combining hash function * is actually a ranged hash function. * * In a probe policy, indicates that the combining probe function * is actually a ranged probe function. */ struct null_type { }; /// A null node updator, indicating that no node updates are required. template struct null_node_update : public null_type { }; /// Primary template, container traits base. template struct container_traits_base; /// Specialization, cc hash. template<> struct container_traits_base { typedef cc_hash_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, gp hash. template<> struct container_traits_base { typedef gp_hash_tag container_category; typedef basic_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, rb tree. template<> struct container_traits_base { typedef rb_tree_tag container_category; typedef range_invalidation_guarantee invalidation_guarantee; enum { order_preserving = true, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = true }; }; /// Specialization, splay tree. template<> struct container_traits_base { typedef splay_tree_tag container_category; typedef range_invalidation_guarantee invalidation_guarantee; enum { order_preserving = true, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = true }; }; /// Specialization, ov tree. template<> struct container_traits_base { typedef ov_tree_tag container_category; typedef basic_invalidation_guarantee invalidation_guarantee; enum { order_preserving = true, erase_can_throw = true, split_join_can_throw = true, reverse_iteration = false }; }; /// Specialization, pat trie. template<> struct container_traits_base { typedef pat_trie_tag container_category; typedef range_invalidation_guarantee invalidation_guarantee; enum { order_preserving = true, erase_can_throw = false, split_join_can_throw = true, reverse_iteration = true }; }; /// Specialization, list update. template<> struct container_traits_base { typedef list_update_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, pairing heap. template<> struct container_traits_base { typedef pairing_heap_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, thin heap. template<> struct container_traits_base { typedef thin_heap_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, binomial heap. template<> struct container_traits_base { typedef binomial_heap_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, rc binomial heap. template<> struct container_traits_base { typedef rc_binomial_heap_tag container_category; typedef point_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = false, reverse_iteration = false }; }; /// Specialization, binary heap. template<> struct container_traits_base { typedef binary_heap_tag container_category; typedef basic_invalidation_guarantee invalidation_guarantee; enum { order_preserving = false, erase_can_throw = false, split_join_can_throw = true, reverse_iteration = false }; }; /// Container traits. // See Matt Austern for the name, S. Meyers MEFC++ #2, others. template struct container_traits : public container_traits_base { typedef Cntnr container_type; typedef typename Cntnr::container_category container_category; typedef container_traits_base base_type; typedef typename base_type::invalidation_guarantee invalidation_guarantee; enum { /// True only if Cntnr objects guarantee storing keys by order. order_preserving = base_type::order_preserving, /// True only if erasing a key can throw. erase_can_throw = base_type::erase_can_throw, /// True only if split or join operations can throw. split_join_can_throw = base_type::split_join_can_throw, /// True only reverse iterators are supported. reverse_iteration = base_type::reverse_iteration }; }; //@} namespace detail { /// Dispatch mechanism, primary template for associative types. template struct container_base_dispatch; } // namespace __detail //@} } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/list_update_policy.hpp000064400000010420147547540560013527 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file list_update_policy.hpp * Contains policies for list update containers. */ #ifndef PB_DS_LU_POLICY_HPP #define PB_DS_LU_POLICY_HPP #include #include #include #include namespace __gnu_pbds { /** * A list-update policy that unconditionally moves elements to the * front of the list. A null type means that each link in a * list-based container does not actually need metadata. */ template > class lu_move_to_front_policy { public: typedef _Alloc allocator_type; /// Metadata on which this functor operates. typedef null_type metadata_type; private: typedef typename _Alloc::template rebind __rebind_m; public: /// Reference to metadata on which this functor operates. typedef typename __rebind_m::other::reference metadata_reference; /// Creates a metadata object. metadata_type operator()() const { return s_metadata; } /// Decides whether a metadata object should be moved to the front /// of the list. inline bool operator()(metadata_reference r_metadata) const { return true; } private: static null_type s_metadata; }; /** * A list-update policy that moves elements to the front of the * list based on the counter algorithm. */ template > class lu_counter_policy : private detail::lu_counter_policy_base { public: typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; enum { /// When some element is accessed this number of times, it /// will be moved to the front of the list. max_count = Max_Count }; /// Metadata on which this functor operates. typedef detail::lu_counter_metadata metadata_type; private: typedef detail::lu_counter_policy_base base_type; typedef typename _Alloc::template rebind __rebind_m; public: /// Reference to metadata on which this functor operates. typedef typename __rebind_m::other::reference metadata_reference; /// Creates a metadata object. metadata_type operator()() const { return base_type::operator()(max_count); } /// Decides whether a metadata object should be moved to the front /// of the list. bool operator()(metadata_reference r_data) const { return base_type::operator()(r_data, max_count); } }; } // namespace __gnu_pbds #endif 4.8.2/ext/pb_ds/priority_queue.hpp000064400000012576147547540560012736 0ustar00// -*- C++ -*- // Copyright (C) 2005-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software // Foundation; either version 3, or (at your option) any later // version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. // Permission to use, copy, modify, sell, and distribute this software // is hereby granted without fee, provided that the above copyright // notice appears in all copies, and that both that copyright notice // and this permission notice appear in supporting documentation. None // of the above authors, nor IBM Haifa Research Laboratories, make any // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. /** * @file priority_queue.hpp * Contains priority_queues. */ #ifndef PB_DS_PRIORITY_QUEUE_HPP #define PB_DS_PRIORITY_QUEUE_HPP #include #include #include #include namespace __gnu_pbds { /** * @defgroup heap-based Heap-Based * @ingroup containers-pbds * @{ */ /** * @defgroup heap-detail Base and Policy Classes * @ingroup heap-based */ /** * A priority queue composed of one specific heap policy. * * @tparam _Tv Value type. * @tparam Cmp_Fn Comparison functor. * @tparam Tag Instantiating data structure type, * see container_tag. * @tparam _Alloc Allocator type. * * Base is dispatched at compile time via Tag, from the following * choices: binary_heap_tag, binomial_heap_tag, pairing_heap_tag, * rc_binomial_heap_tag, thin_heap_tag * * Base choices are: detail::binary_heap, detail::binomial_heap, * detail::pairing_heap, detail::rc_binomial_heap, * detail::thin_heap. */ template, typename Tag = pairing_heap_tag, typename _Alloc = std::allocator > class priority_queue : public detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type { public: typedef _Tv value_type; typedef Cmp_Fn cmp_fn; typedef Tag container_category; typedef _Alloc allocator_type; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; private: typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type base_type; typedef typename _Alloc::template rebind<_Tv> __rebind_v; typedef typename __rebind_v::other __rebind_va; public: typedef typename __rebind_va::reference reference; typedef typename __rebind_va::const_reference const_reference; typedef typename __rebind_va::pointer pointer; typedef typename __rebind_va::const_pointer const_pointer; typedef typename base_type::point_iterator point_iterator; typedef typename base_type::point_const_iterator point_const_iterator; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; priority_queue() { } /// Constructor taking some policy objects. r_cmp_fn will be /// copied by the Cmp_Fn object of the container object. priority_queue(const cmp_fn& r_cmp_fn) : base_type(r_cmp_fn) { } /// Constructor taking __iterators to a range of value_types. The /// value_types between first_it and last_it will be inserted into /// the container object. template priority_queue(It first_it, It last_it) { base_type::copy_from_range(first_it, last_it); } /// Constructor taking __iterators to a range of value_types and /// some policy objects The value_types between first_it and /// last_it will be inserted into the container object. r_cmp_fn /// will be copied by the cmp_fn object of the container object. template priority_queue(It first_it, It last_it, const cmp_fn& r_cmp_fn) : base_type(r_cmp_fn) { base_type::copy_from_range(first_it, last_it); } priority_queue(const priority_queue& other) : base_type((const base_type& )other) { } virtual ~priority_queue() { } priority_queue& operator=(const priority_queue& other) { if (this != &other) { priority_queue tmp(other); swap(tmp); } return *this; } void swap(priority_queue& other) { base_type::swap(other); } }; } // namespace __gnu_pbds //@} heap-based #endif 4.8.2/ext/concurrence.h000064400000016673147547540560010532 0ustar00// Support for concurrent programing -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/concurrence.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _CONCURRENCE_H #define _CONCURRENCE_H 1 #pragma GCC system_header #include #include #include #include #include namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Available locking policies: // _S_single single-threaded code that doesn't need to be locked. // _S_mutex multi-threaded code that requires additional support // from gthr.h or abstraction layers in concurrence.h. // _S_atomic multi-threaded code using atomic operations. enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; // Compile time constant that indicates prefered locking policy in // the current configuration. static const _Lock_policy __default_lock_policy = #ifdef __GTHREADS #if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \ && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) _S_atomic; #else _S_mutex; #endif #else _S_single; #endif // NB: As this is used in libsupc++, need to only depend on // exception. No stdexception classes, no use of std::string. class __concurrence_lock_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_lock_error"; } }; class __concurrence_unlock_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_unlock_error"; } }; class __concurrence_broadcast_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_broadcast_error"; } }; class __concurrence_wait_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_wait_error"; } }; // Substitute for concurrence_error object in the case of -fno-exceptions. inline void __throw_concurrence_lock_error() { _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); } inline void __throw_concurrence_unlock_error() { _GLIBCXX_THROW_OR_ABORT(__concurrence_unlock_error()); } #ifdef __GTHREAD_HAS_COND inline void __throw_concurrence_broadcast_error() { _GLIBCXX_THROW_OR_ABORT(__concurrence_broadcast_error()); } inline void __throw_concurrence_wait_error() { _GLIBCXX_THROW_OR_ABORT(__concurrence_wait_error()); } #endif class __mutex { private: #if __GTHREADS && defined __GTHREAD_MUTEX_INIT __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT; #else __gthread_mutex_t _M_mutex; #endif __mutex(const __mutex&); __mutex& operator=(const __mutex&); public: __mutex() { #if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT if (__gthread_active_p()) __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); #endif } #if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT ~__mutex() { if (__gthread_active_p()) __gthread_mutex_destroy(&_M_mutex); } #endif void lock() { #if __GTHREADS if (__gthread_active_p()) { if (__gthread_mutex_lock(&_M_mutex) != 0) __throw_concurrence_lock_error(); } #endif } void unlock() { #if __GTHREADS if (__gthread_active_p()) { if (__gthread_mutex_unlock(&_M_mutex) != 0) __throw_concurrence_unlock_error(); } #endif } __gthread_mutex_t* gthread_mutex(void) { return &_M_mutex; } }; class __recursive_mutex { private: #if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT __gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT; #else __gthread_recursive_mutex_t _M_mutex; #endif __recursive_mutex(const __recursive_mutex&); __recursive_mutex& operator=(const __recursive_mutex&); public: __recursive_mutex() { #if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT if (__gthread_active_p()) __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); #endif } #if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT ~__recursive_mutex() { if (__gthread_active_p()) __gthread_recursive_mutex_destroy(&_M_mutex); } #endif void lock() { #if __GTHREADS if (__gthread_active_p()) { if (__gthread_recursive_mutex_lock(&_M_mutex) != 0) __throw_concurrence_lock_error(); } #endif } void unlock() { #if __GTHREADS if (__gthread_active_p()) { if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0) __throw_concurrence_unlock_error(); } #endif } __gthread_recursive_mutex_t* gthread_recursive_mutex(void) { return &_M_mutex; } }; /// Scoped lock idiom. // Acquire the mutex here with a constructor call, then release with // the destructor call in accordance with RAII style. class __scoped_lock { public: typedef __mutex __mutex_type; private: __mutex_type& _M_device; __scoped_lock(const __scoped_lock&); __scoped_lock& operator=(const __scoped_lock&); public: explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) { _M_device.lock(); } ~__scoped_lock() throw() { _M_device.unlock(); } }; #ifdef __GTHREAD_HAS_COND class __cond { private: #if __GTHREADS && defined __GTHREAD_COND_INIT __gthread_cond_t _M_cond = __GTHREAD_COND_INIT; #else __gthread_cond_t _M_cond; #endif __cond(const __cond&); __cond& operator=(const __cond&); public: __cond() { #if __GTHREADS && ! defined __GTHREAD_COND_INIT if (__gthread_active_p()) __GTHREAD_COND_INIT_FUNCTION(&_M_cond); #endif } #if __GTHREADS && ! defined __GTHREAD_COND_INIT ~__cond() { if (__gthread_active_p()) __gthread_cond_destroy(&_M_cond); } #endif void broadcast() { #if __GTHREADS if (__gthread_active_p()) { if (__gthread_cond_broadcast(&_M_cond) != 0) __throw_concurrence_broadcast_error(); } #endif } void wait(__mutex *mutex) { #if __GTHREADS { if (__gthread_cond_wait(&_M_cond, mutex->gthread_mutex()) != 0) __throw_concurrence_wait_error(); } #endif } void wait_recursive(__recursive_mutex *mutex) { #if __GTHREADS { if (__gthread_cond_wait_recursive(&_M_cond, mutex->gthread_recursive_mutex()) != 0) __throw_concurrence_wait_error(); } #endif } }; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/numeric000064400000011173147547540560007426 0ustar00// Numeric extensions -*- C++ -*- // Copyright (C) 2002-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file ext/numeric * This file is a GNU extension to the Standard C++ Library (possibly * containing extensions from the HP/SGI STL subset). */ #ifndef _EXT_NUMERIC #define _EXT_NUMERIC 1 #pragma GCC system_header #include #include #include // For identity_element namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Returns __x ** __n, where __n >= 0. _Note that "multiplication" // is required to be associative, but not necessarily commutative. template _Tp __power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op) { if (__n == 0) return identity_element(__monoid_op); else { while ((__n & 1) == 0) { __n >>= 1; __x = __monoid_op(__x, __x); } _Tp __result = __x; __n >>= 1; while (__n != 0) { __x = __monoid_op(__x, __x); if ((__n & 1) != 0) __result = __monoid_op(__result, __x); __n >>= 1; } return __result; } } template inline _Tp __power(_Tp __x, _Integer __n) { return __power(__x, __n, std::multiplies<_Tp>()); } /** * This is an SGI extension. * @ingroup SGIextensions * @doctodo */ // Alias for the internal name __power. Note that power is an extension, // not part of the C++ standard. template inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op) { return __power(__x, __n, __monoid_op); } /** * This is an SGI extension. * @ingroup SGIextensions * @doctodo */ template inline _Tp power(_Tp __x, _Integer __n) { return __power(__x, __n); } #if __cplusplus >= 201103L using std::iota; #else /** * This is an SGI extension. * @ingroup SGIextensions * @doctodo */ // iota is not part of the C++ standard. It is an extension. template void iota(_ForwardIter __first, _ForwardIter __last, _Tp __value) { // concept requirements __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>) __glibcxx_function_requires(_ConvertibleConcept<_Tp, typename std::iterator_traits<_ForwardIter>::value_type>) while (__first != __last) *__first++ = __value++; } #endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif 4.8.2/ext/mt_allocator.h000064400000054675147547540560010710 0ustar00// MT-optimized allocator -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file ext/mt_allocator.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _MT_ALLOCATOR_H #define _MT_ALLOCATOR_H 1 #include #include #include #include #include #if __cplusplus >= 201103L #include #endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::size_t; using std::ptrdiff_t; typedef void (*__destroy_handler)(void*); /// Base class for pool object. struct __pool_base { // Using short int as type for the binmap implies we are never // caching blocks larger than 32768 with this allocator. typedef unsigned short int _Binmap_type; // Variables used to configure the behavior of the allocator, // assigned and explained in detail below. struct _Tune { // Compile time constants for the default _Tune values. enum { _S_align = 8 }; enum { _S_max_bytes = 128 }; enum { _S_min_bin = 8 }; enum { _S_chunk_size = 4096 - 4 * sizeof(void*) }; enum { _S_max_threads = 4096 }; enum { _S_freelist_headroom = 10 }; // Alignment needed. // NB: In any case must be >= sizeof(_Block_record), that // is 4 on 32 bit machines and 8 on 64 bit machines. size_t _M_align; // Allocation requests (after round-up to power of 2) below // this value will be handled by the allocator. A raw new/ // call will be used for requests larger than this value. // NB: Must be much smaller than _M_chunk_size and in any // case <= 32768. size_t _M_max_bytes; // Size in bytes of the smallest bin. // NB: Must be a power of 2 and >= _M_align (and of course // much smaller than _M_max_bytes). size_t _M_min_bin; // In order to avoid fragmenting and minimize the number of // new() calls we always request new memory using this // value. Based on previous discussions on the libstdc++ // mailing list we have chosen the value below. // See http://gcc.gnu.org/ml/libstdc++/2001-07/msg00077.html // NB: At least one order of magnitude > _M_max_bytes. size_t _M_chunk_size; // The maximum number of supported threads. For // single-threaded operation, use one. Maximum values will // vary depending on details of the underlying system. (For // instance, Linux 2.4.18 reports 4070 in // /proc/sys/kernel/threads-max, while Linux 2.6.6 reports // 65534) size_t _M_max_threads; // Each time a deallocation occurs in a threaded application // we make sure that there are no more than // _M_freelist_headroom % of used memory on the freelist. If // the number of additional records is more than // _M_freelist_headroom % of the freelist, we move these // records back to the global pool. size_t _M_freelist_headroom; // Set to true forces all allocations to use new(). bool _M_force_new; explicit _Tune() : _M_align(_S_align), _M_max_bytes(_S_max_bytes), _M_min_bin(_S_min_bin), _M_chunk_size(_S_chunk_size), _M_max_threads(_S_max_threads), _M_freelist_headroom(_S_freelist_headroom), _M_force_new(std::getenv("GLIBCXX_FORCE_NEW") ? true : false) { } explicit _Tune(size_t __align, size_t __maxb, size_t __minbin, size_t __chunk, size_t __maxthreads, size_t __headroom, bool __force) : _M_align(__align), _M_max_bytes(__maxb), _M_min_bin(__minbin), _M_chunk_size(__chunk), _M_max_threads(__maxthreads), _M_freelist_headroom(__headroom), _M_force_new(__force) { } }; struct _Block_address { void* _M_initial; _Block_address* _M_next; }; const _Tune& _M_get_options() const { return _M_options; } void _M_set_options(_Tune __t) { if (!_M_init) _M_options = __t; } bool _M_check_threshold(size_t __bytes) { return __bytes > _M_options._M_max_bytes || _M_options._M_force_new; } size_t _M_get_binmap(size_t __bytes) { return _M_binmap[__bytes]; } size_t _M_get_align() { return _M_options._M_align; } explicit __pool_base() : _M_options(_Tune()), _M_binmap(0), _M_init(false) { } explicit __pool_base(const _Tune& __options) : _M_options(__options), _M_binmap(0), _M_init(false) { } private: explicit __pool_base(const __pool_base&); __pool_base& operator=(const __pool_base&); protected: // Configuration options. _Tune _M_options; _Binmap_type* _M_binmap; // Configuration of the pool object via _M_options can happen // after construction but before initialization. After // initialization is complete, this variable is set to true. bool _M_init; }; /** * @brief Data describing the underlying memory pool, parameterized on * threading support. */ template class __pool; /// Specialization for single thread. template<> class __pool : public __pool_base { public: union _Block_record { // Points to the block_record of the next free block. _Block_record* _M_next; }; struct _Bin_record { // An "array" of pointers to the first free block. _Block_record** _M_first; // A list of the initial addresses of all allocated blocks. _Block_address* _M_address; }; void _M_initialize_once() { if (__builtin_expect(_M_init == false, false)) _M_initialize(); } void _M_destroy() throw(); char* _M_reserve_block(size_t __bytes, const size_t __thread_id); void _M_reclaim_block(char* __p, size_t __bytes) throw (); size_t _M_get_thread_id() { return 0; } const _Bin_record& _M_get_bin(size_t __which) { return _M_bin[__which]; } void _M_adjust_freelist(const _Bin_record&, _Block_record*, size_t) { } explicit __pool() : _M_bin(0), _M_bin_size(1) { } explicit __pool(const __pool_base::_Tune& __tune) : __pool_base(__tune), _M_bin(0), _M_bin_size(1) { } private: // An "array" of bin_records each of which represents a specific // power of 2 size. Memory to this "array" is allocated in // _M_initialize(). _Bin_record* _M_bin; // Actual value calculated in _M_initialize(). size_t _M_bin_size; void _M_initialize(); }; #ifdef __GTHREADS /// Specialization for thread enabled, via gthreads.h. template<> class __pool : public __pool_base { public: // Each requesting thread is assigned an id ranging from 1 to // _S_max_threads. Thread id 0 is used as a global memory pool. // In order to get constant performance on the thread assignment // routine, we keep a list of free ids. When a thread first // requests memory we remove the first record in this list and // stores the address in a __gthread_key. When initializing the // __gthread_key we specify a destructor. When this destructor // (i.e. the thread dies) is called, we return the thread id to // the front of this list. struct _Thread_record { // Points to next free thread id record. NULL if last record in list. _Thread_record* _M_next; // Thread id ranging from 1 to _S_max_threads. size_t _M_id; }; union _Block_record { // Points to the block_record of the next free block. _Block_record* _M_next; // The thread id of the thread which has requested this block. size_t _M_thread_id; }; struct _Bin_record { // An "array" of pointers to the first free block for each // thread id. Memory to this "array" is allocated in // _S_initialize() for _S_max_threads + global pool 0. _Block_record** _M_first; // A list of the initial addresses of all allocated blocks. _Block_address* _M_address; // An "array" of counters used to keep track of the amount of // blocks that are on the freelist/used for each thread id. // - Note that the second part of the allocated _M_used "array" // actually hosts (atomic) counters of reclaimed blocks: in // _M_reserve_block and in _M_reclaim_block those numbers are // subtracted from the first ones to obtain the actual size // of the "working set" of the given thread. // - Memory to these "arrays" is allocated in _S_initialize() // for _S_max_threads + global pool 0. size_t* _M_free; size_t* _M_used; // Each bin has its own mutex which is used to ensure data // integrity while changing "ownership" on a block. The mutex // is initialized in _S_initialize(). __gthread_mutex_t* _M_mutex; }; // XXX GLIBCXX_ABI Deprecated void _M_initialize(__destroy_handler); void _M_initialize_once() { if (__builtin_expect(_M_init == false, false)) _M_initialize(); } void _M_destroy() throw(); char* _M_reserve_block(size_t __bytes, const size_t __thread_id); void _M_reclaim_block(char* __p, size_t __bytes) throw (); const _Bin_record& _M_get_bin(size_t __which) { return _M_bin[__which]; } void _M_adjust_freelist(const _Bin_record& __bin, _Block_record* __block, size_t __thread_id) { if (__gthread_active_p()) { __block->_M_thread_id = __thread_id; --__bin._M_free[__thread_id]; ++__bin._M_used[__thread_id]; } } // XXX GLIBCXX_ABI Deprecated _GLIBCXX_CONST void _M_destroy_thread_key(void*) throw (); size_t _M_get_thread_id(); explicit __pool() : _M_bin(0), _M_bin_size(1), _M_thread_freelist(0) { } explicit __pool(const __pool_base::_Tune& __tune) : __pool_base(__tune), _M_bin(0), _M_bin_size(1), _M_thread_freelist(0) { } private: // An "array" of bin_records each of which represents a specific // power of 2 size. Memory to this "array" is allocated in // _M_initialize(). _Bin_record* _M_bin; // Actual value calculated in _M_initialize(). size_t _M_bin_size; _Thread_record* _M_thread_freelist; void* _M_thread_freelist_initial; void _M_initialize(); }; #endif template