##

    random_access_iterator_property_map<RandomAccessIterator, T, R, OffsetMap>

This property map is an adaptor that converts any random access iterator into a LvaluePropertyMap. The `OffsetMap` type is responsible for converting key objects to integers that can be used as offsets with the random access iterator.

### Example

    // print out the capacity and flow for all the edges in the graph
    template <class Graph, class CapacityPMap, class FlowPMap>
    void print_network(Graph& G, CapacityPMap capacity, FlowPMap flow)
    {
      typedef typename boost::graph_traits<Graph>::vertex_iterator    Viter;
      typedef typename boost::graph_traits<Graph>::out_edge_iterator OutEdgeIter;
      typedef typename boost::graph_traits<Graph>::in_edge_iterator InEdgeIter;

      Viter ui, uiend;
      for (boost::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) {
        OutEdgeIter out, out_end;
        std::cout << *ui << "\t";

        for(boost::tie(out, out_end) = out_edges(*ui, G); out != out_end; ++out)
          std::cout << "--(" << get(capacity, *out) << ", "
    	   << get(flow, *out) << ")--> " << target(*out,G) << "\t";
        std::cout << std::endl << "\t";

        InEdgeIter in, in_end;
        for(boost::tie(in, in_end) = in_edges(*ui, G); in != in_end; ++in)
          std::cout << "<--(" << get(capacity, *in) << "," << get(flow, *in) << ")-- "
               << source(*in,G) << "\t";
        std::cout << std::endl;
      }
    }

    int main(int, char*[])
    {
      typedef boost::adjacency_list<boost::vecS, boost::vecS,
        boost::bidirectionalS, boost::no_plugin,
        boost::plugin<boost::id_tag, std::size_t> > Graph;

      const int num_vertices = 9;
      Graph G(num_vertices);

      int capacity[] = { 10, 20, 20, 20, 40, 40, 20, 20, 20, 10 };
      int flow[] = { 8, 12, 12, 12, 12, 12, 16, 16, 16, 8 };

      // add edges to the graph, and assign each edge an ID number
      // to index into the property arrays
      add_edge(G, 0, 1, 0);
      // ...

      typedef boost::graph_traits<Graph>::edge_descriptor Edge;
      typedef boost::property_map<Graph, boost::id_tag>::type EdgeID_PMap;
      EdgeID_PMap edge_id = get(boost::edge_index(), G);

      boost::random_access_iterator_property_map<int*, int, int&, EdgeID_PMap>
         capacity_pa(capacity, edge_id),
         flow_pa(flow, edge_id);

      print_network(G, capacity_pa, flow_pa);

      return 0;
    }

### Where Defined

`boost/property_map.hpp`

### Model Of

LvaluePropertyMap

### Template Parameters

Parameter | Description | Default
--- | --- | ---
`Iterator` | Must be a model of RandomAccessIterator. |
`T` | The value type of the iterator. | `std::iterator_traits<RandomAccessIterator>::value_type`
`R` | The reference type of the iterator. | `std::iterator_traits<RandomAccessIterator>::reference`
`OffsetMap` | Must be a model of ReadablePropertyMap and the value type must be convertible to the difference type of the iterator. | `boost::identity_property_map`

### Members

In addition the methods and functions required by LvaluePropertyMap, this class has the following members.

    property_traits<random_access_iterator_property_map>::value_type

This is the same type as `std::iterator_traits<Iterator>::value_type`.

    random_access_iterator_property_map(Iterator i)

Constructor.

    reference operator[](difference_type v) const

The operator bracket for property access. The `reference` and `difference_type` types are from `std::iterator_traits<Iterator>`.

### Non-Member functions

      template <class RAIter, class OffsetMap>
      random_access_iterator_property_map<RAIter,
        typename std::iterator_traits<RAIter>::value_type,
        typename std::iterator_traits<RAIter>::reference,
        OffsetMap>
      make_iterator_property_map(RAIter iter, OffsetMap omap)

A function for conveniently creating an iterator map.

      template <class RAIter, class OffsetMap, class ValueType>
      random_access_iterator_property_map<RAIter,
        typename std::iterator_traits<RAIter>::value_type,
        typename std::iterator_traits<RAIter>::reference,
        OffsetMap>
      make_iterator_property_map(RAIter iter, OffsetMap omap, ValueType dummy_arg)

Use this function instead of the 2-argument version if your compiler does not support partial specialization (like Visual C++).

Copyright © 2000 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) Lie-Quan Lee, Univ.of Notre Dame (llee1@lsc.nd.edu) Andrew Lumsdaine, Univ.of Notre Dame (lums@lsc.nd.edu)