PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/libs/property_map/doc/associative_property_map.html

http://hadesmem.googlecode.com/
HTML | 190 lines | 138 code | 45 blank | 7 comment | 0 complexity | f54675860ab8df46483e8ff0e38e63e2 MD5 | raw file
  1<HTML>
  2<!--
  3     Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  4    
  5     Distributed under the Boost Software License, Version 1.0.
  6     (See accompanying file LICENSE_1_0.txt or copy at
  7     http://www.boost.org/LICENSE_1_0.txt)
  8  -->
  9<Head>
 10<Title>Associative Property Map Adaptor</Title>
 11<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
 12	ALINK="#ff0000"> 
 13<IMG SRC="../../../boost.png" 
 14     ALT="C++ Boost" width="277" height="86"> 
 15
 16<BR Clear>
 17
 18
 19<H2><A NAME="sec:associative-property-map"></A>
 20</h2>
 21<PRE>
 22associative_property_map&lt;UniquePairAssociativeContainer&gt;
 23</PRE>
 24
 25<P>
 26This property map is an adaptor that converts any type that is a model
 27of both <a
 28href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
 29Associative Container</a> and <a
 30href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
 31Associative Container</a> such as <a
 32href="http://www.sgi.com/tech/stl/Map.html"><tt>std::map</tt></a> into
 33a mutable <a href="./LvaluePropertyMap.html">Lvalue Property Map</a>.
 34Note that the adaptor only retains a reference to the container, so
 35the lifetime of the container must encompass the use of the adaptor.
 36</P>
 37
 38<h3>Example</h3>
 39
 40<a href="../example/example1.cpp">example1.cpp</a>:
 41<pre>#include &lt;iostream&gt;
 42#include &lt;map&gt;
 43#include &lt;string&gt;
 44#include &lt;boost/property_map/property_map.hpp&gt;
 45
 46
 47template &lt;typename AddressMap&gt;
 48void foo(AddressMap address)
 49{
 50  typedef typename boost::property_traits&lt;AddressMap&gt;::value_type value_type;
 51  typedef typename boost::property_traits&lt;AddressMap&gt;::key_type key_type;
 52
 53  value_type old_address, new_address;
 54  key_type fred = &quot;Fred&quot;;
 55  old_address = get(address, fred);
 56  new_address = &quot;384 Fitzpatrick Street&quot;;
 57  put(address, fred, new_address);
 58
 59  key_type joe = &quot;Joe&quot;;
 60  value_type&amp; joes_address = address[joe];
 61  joes_address = &quot;325 Cushing Avenue&quot;;
 62}
 63
 64int
 65main()
 66{
 67  std::map&lt;std::string, std::string&gt; name2address;
 68  boost::associative_property_map&lt; std::map&lt;std::string, std::string&gt; &gt;
 69    address_map(name2address);
 70
 71  name2address.insert(make_pair(std::string(&quot;Fred&quot;), 
 72				std::string(&quot;710 West 13th Street&quot;)));
 73  name2address.insert(make_pair(std::string(&quot;Joe&quot;), 
 74				std::string(&quot;710 West 13th Street&quot;)));
 75
 76  foo(address_map);
 77  
 78  for (std::map&lt;std::string, std::string&gt;::iterator i = name2address.begin();
 79       i != name2address.end(); ++i)
 80    std::cout &lt;&lt; i-&gt;first &lt;&lt; &quot;: &quot; &lt;&lt; i-&gt;second &lt;&lt; &quot;\n&quot;;
 81
 82  return EXIT_SUCCESS;
 83}</pre>
 84
 85<H3>Where Defined</H3>
 86
 87<P>
 88<a href="../../../boost/property_map/property_map.hpp"><TT>boost/property_map/property_map.hpp</TT></a>
 89
 90<p>
 91<H3>Model Of</H3>
 92
 93<a href="./LvaluePropertyMap.html">Lvalue Property Map</a>
 94
 95<P>
 96
 97<H3>Template Parameters</H3>
 98
 99<P>
100
101<TABLE border>
102<TR>
103<th>Parameter</th><th>Description</th><th>Default</th>
104</tr>
105
106
107<TR>
108<TD><TT>UniquePairAssociativeContainer</TT></TD> 
109<TD>Must be a model of both <a
110href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
111Associative Container</a> and <a
112href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
113Associative Container</a> .</TD>
114<TD>&nbsp;</td>
115</tr>
116
117</TABLE>
118<P>
119
120<H3>Members</H3>
121
122<P>
123In addition to the methods and functions required by <a
124href="./LvaluePropertyMap.html">Lvalue Property Map</a>, this
125class has the following members.
126
127<hr>
128
129<pre>
130property_traits&lt;associative_property_map&gt;::value_type
131</pre>
132This is the same type as
133<TT>UniquePairAssociativeContainer::data_type</TT>.
134
135<hr>
136
137<pre>
138associative_property_map()
139</pre>
140Default Constructor.
141
142<pre>
143associative_property_map(UniquePairAssociativeContainer&amp; c)
144</pre>
145Constructor.
146
147<hr>
148
149<pre>
150data_type&amp; operator[](const key_type&amp; k) const
151</pre>
152The operator bracket for property access.
153The <TT>key_type</TT> and
154<TT>data_type</TT> types are from the typedefs inside of
155<TT>UniquePairAssociativeContainer</TT>.
156
157<hr>
158
159<h3>Non-Member functions</h3>
160
161<hr>
162
163<pre>
164  template &lt;typename UniquePairAssociativeContainer&gt;
165  associative_property_map&lt;UniquePairAssociativeContainer&gt;
166  make_assoc_property_map(UniquePairAssociativeContainer&amp; c);
167</pre>
168A function for conveniently creating an associative property map.
169
170
171
172<hr>
173
174
175<br>
176<HR>
177<TABLE>
178<TR valign=top>
179<TD nowrap>Copyright &copy 2002</TD><TD>
180<a HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>,
181Indiana University (<A
182HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
183<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee1@osl.iu.edu">llee1@osl.iu.edu</A>)<br>
184<A HREF="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</A>,
185Indiana University (<A
186HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
187</TD></TR></TABLE>
188
189</BODY>
190</HTML>