|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-02-13 21:19:20
Hi all,
I often want to iterate over just the values of a
map or perhaps just the keys of a map. Therefore I
would like to see the following iterator adapters in the
iterator library:
template< class Map >
struct map_key_iterator;
template< class Map >
struct map_value_iterator;
template< class Map >
struct map_const_value_iterator;
I have outlined an implementation in the attached file, but basically
it just a wrapper around transform_iterator<typename Map::iterator>.
Comments?
br
Thorsten
begin 666 map_value_iterator.cpp
M(VEN8VQU9&4@/&)O;W-T+VET97)A=&]R+W1R86YS9F]R;5]I=&5R871O<BYH
M<' ^#0H-"G1E;7!L871E/"!C;&%S<R!-87 @/@T*<W1R=6-T('-E;&5C=%]F
M:7)S= T*>PT*(" @('1Y<&5D968@='EP96YA;64_at_36%P.CIK97E?='EP928@
M<F5S=6QT7W1Y<&4[#0H@(" @#0H@(" @<F5S=6QT7W1Y<&4@;W!E<F%T;W(H
M*2@@8V]N<W0@='EP96YA;64_at_36%P.CIV86QU95]T>7!E)B!R("D_at_8V]N<W0-
M"B @("![#0H@(" @(" @(')E='5R;B!R+F9I<G-T.PT*(" @('T-"GT[#0H-
M"G1E;7!L871E/"!C;&%S<R!-87 @/@T*<W1R=6-T('-E;&5C=%]S96-O;F0-
M"GL-"B @("!T>7!E9&5F('1Y<&5N86UE($UA<#HZ;6%P<&5D7W1Y<&4F(')E
M<W5L=%]T>7!E.PT*(" @( T*(" @(')E<W5L=%]T>7!E(&]P97)A=&]R*"DH
M(&-O;G-T('1Y<&5N86UE($UA<#HZ=F%L=65?='EP928@<B I(&-O;G-T#0H@
M(" @>PT*(" @(" @("!R971U<FX@<BYS96-O;F0[#0H@(" @?0T*?3L-"@T*
M=&5M<&QA=&4\(&-L87-S($UA<" ^#0IS=')U8W0@;6%P7VME>5]I=&5R871O
M<B Z( T*(" @('!U8FQI8R!B;V]S=#HZ=')A;G-F;W)M7VET97)A=&]R/"!S
M96QE8W1?9FER<W0\36%P/BP@#0H@(" @(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @('1Y<&5N86UE($UA<#HZ8V]N<W1?:71E<F%T;W(@/@T*
M>PT*<')I=F%T93H-"B @("!T>7!E9&5F(&)O;W-T.CIT<F%N<V9O<FU?:71E
M<F%T;W(\('-E;&5C=%]F:7)S=#Q-87 ^+" -"B @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @(" @(" @('1Y<&5N86UE($UA<#HZ8V]N<W1?:71E
M<F%T;W(@/@T*(" @(" @("!B87-E.PT*(" @( T*(" @('1Y<&5D968@='EP
M96YA;64_at_36%P.CIC;VYS=%]I=&5R871O<B!I=&5R871O<CL-"G!U8FQI8SH-
M"B @("!M87!?:V5Y7VET97)A=&]R*"D_at_.B!B87-E*"D-"B @("![('T-"@T*
M(" @(&UA<%]K97E?:71E<F%T;W(H(&ET97)A=&]R('@@*2 Z(&)A<V4H>"D-
M"B @("![('T-"@T*(" @(&UA<%]K97E?:71E<F%T;W(F(&]P97)A=&]R/2@@
M:71E<F%T;W(@<B I#0H@(" @>PT*(" @(" @("!B87-E.CIO<&5R871O<CTH
M<BD[#0H@(" @(" @(')E='5R;B J=&AI<SL-"B @("!]#0I].PT*#0H-"G1E
M;7!L871E/"!C;&%S<R!-87 @/@T*<W1R=6-T(&UA<%]V86QU95]I=&5R871O
M<B Z( T*(" @('!U8FQI8R!B;V]S=#HZ=')A;G-F;W)M7VET97)A=&]R/"!S
M96QE8W1?<V5C;VYD/$UA<#XL( T*(" @(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @("!T>7!E;F%M92!-87 Z.FET97)A=&]R(#X-"GL-"G!R
M:79A=&4Z#0H@(" @='EP961E9B!B;V]S=#HZ=')A;G-F;W)M7VET97)A=&]R
M/"!S96QE8W1?<V5C;VYD/$UA<#XL( T*(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @(" @='EP96YA;64_at_36%P.CII=&5R871O<B ^#0H@
M(" @(" @(&)A<V4[#0H@(" @='EP961E9B!T>7!E;F%M92!-87 Z.FET97)A
M=&]R(&ET97)A=&]R.PT*(" @( T*<'5B;&EC._at_T*(" @(&UA<%]V86QU95]I
M=&5R871O<B_at_I(#H_at_8F%S92_at_I#0H@(" @>R!]#0H-"B @("!M87!?=F%L=65?
M:71E<F%T;W(H(&ET97)A=&]R('@@*2 Z(&)A<V4H>"D-"B @("![('T@(" @
M#0H-"B @("!M87!?=F%L=65?:71E<F%T;W(F(&]P97)A=&]R/2@@:71E<F%T
M;W(@<B I#0H@(" @>PT*(" @(" @("!B87-E.CIO<&5R871O<CTH<BD[#0H@
M(" @(" @(')E='5R;B J=&AI<SL-"B @("!]#0H-"GT[#0H-"@T*=&5M<&QA
M=&4\(&-L87-S($UA<" ^#0IS=')U8W0@;6%P7V-O;G-T7W9A;'5E7VET97)A
M=&]R(#H@#0H@(" @<'5B;&EC(&)O;W-T.CIT<F%N<V9O<FU?:71E<F%T;W(\
M('-E;&5C=%]S96-O;F0\36%P/BP@#0H@(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @('1Y<&5N86UE($UA<#HZ8V]N<W1?:71E<F%T;W(@
M/@T*>PT*<')I=F%T93H-"B @("!T>7!E9&5F(&)O;W-T.CIT<F%N<V9O<FU?
M:71E<F%T;W(\('-E;&5C=%]S96-O;F0\36%P/BP@#0H@(" @(" @(" @(" @
M(" @(" @(" @(" @(" @(" @(" @(" @("!T>7!E;F%M92!-87 Z.F-O;G-T
M7VET97)A=&]R(#X-"B @(" @(" @8F%S93L-"B @("!T>7!E9&5F('1Y<&5N
M86UE($UA<#HZ8V]N<W1?:71E<F%T;W(@:71E<F%T;W([#0IP=6)L:6,Z#0H@
M(" @;6%P7V-O;G-T7W9A;'5E7VET97)A=&]R*"D_at_.B!B87-E*"D-"B @("![
M('T-"@T*(" @(&UA<%]C;VYS=%]V86QU95]I=&5R871O<B@@:71E<F%T;W(@
M>" I(#H_at_8F%S92AX*0T*(" @('L@?0T*#0H@(" @;6%P7V-O;G-T7W9A;'5E
M7VET97)A=&]R)B!O<&5R871O<CTH(&ET97)A=&]R('(@*0T*(" @('L-"B @
M(" @(" @8F%S93HZ;W!E<F%T;W(]*'(I.PT*(" @(" @("!R971U<FX@*G1H
M:7,[#0H@(" @?0T*?3L-"@T*(VEN8VQU9&4@/&UA<#X-"@T*:6YT(&UA:6XH
M*0T*>PT*(" @('1Y<&5D968@<W1D.CIM87 \:6YT+&EN=#X@;6%P.PT*#0H@
M(" @;6%P(&T[#0H@(" @;6%P7VME>5]I=&5R871O<CQM87 ^(&ME>5]B96=I
M;B ](&TN8F5G:6XH*3L-"B @("!M87!?=F%L=65?:71E<F%T;W(\;6%P/B!V
M86QU95]B96=I;B ](&TN8F5G:6XH*3L-"B @("!M87!?8V]N<W1?=F%L=65?
M:71E<F%T;W(\;6%P/B!V86QU95]E;F0@/2!M+F5N9"@I.PT*(" @(" @(" -
M"B @("!K97E?8F5G:6XK*SL-"B @("!V86QU95]B96=I;BLK.PT*(" @('9A
3;'5E7V5N9"TM.PT*?0T*#0H-"@``
`
end
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk