| ... | ... |
@@ -1878,48 +1878,56 @@ |
| 1878 | 1878 |
/// |
| 1879 | 1879 |
/// Constructor for creating an id-to-item map. |
| 1880 | 1880 |
explicit InverseMap(const Graph& graph) : _graph(&graph) {}
|
| 1881 | 1881 |
|
| 1882 | 1882 |
/// \brief Constructor. |
| 1883 | 1883 |
/// |
| 1884 | 1884 |
/// Constructor for creating an id-to-item map. |
| 1885 | 1885 |
explicit InverseMap(const IdMap& map) : _graph(map._graph) {}
|
| 1886 | 1886 |
|
| 1887 | 1887 |
/// \brief Gives back an item by its id. |
| 1888 | 1888 |
/// |
| 1889 | 1889 |
/// Gives back an item by its id. |
| 1890 | 1890 |
Item operator[](int id) const { return _graph->fromId(id, Item());}
|
| 1891 | 1891 |
|
| 1892 | 1892 |
private: |
| 1893 | 1893 |
const Graph* _graph; |
| 1894 | 1894 |
}; |
| 1895 | 1895 |
|
| 1896 | 1896 |
/// \brief Gives back the inverse of the map. |
| 1897 | 1897 |
/// |
| 1898 | 1898 |
/// Gives back the inverse of the IdMap. |
| 1899 | 1899 |
InverseMap inverse() const { return InverseMap(*_graph);}
|
| 1900 | 1900 |
}; |
| 1901 | 1901 |
|
| 1902 |
/// \brief Returns an \c IdMap class. |
|
| 1903 |
/// |
|
| 1904 |
/// This function just returns an \c IdMap class. |
|
| 1905 |
/// \relates IdMap |
|
| 1906 |
template <typename K, typename GR> |
|
| 1907 |
inline IdMap<GR, K> idMap(const GR& graph) {
|
|
| 1908 |
return IdMap<GR, K>(graph); |
|
| 1909 |
} |
|
| 1902 | 1910 |
|
| 1903 | 1911 |
/// \brief General cross reference graph map type. |
| 1904 | 1912 |
|
| 1905 | 1913 |
/// This class provides simple invertable graph maps. |
| 1906 | 1914 |
/// It wraps a standard graph map (\c NodeMap, \c ArcMap or \c EdgeMap) |
| 1907 | 1915 |
/// and if a key is set to a new value, then stores it in the inverse map. |
| 1908 | 1916 |
/// The graph items can be accessed by their values either using |
| 1909 | 1917 |
/// \c InverseMap or \c operator()(), and the values of the map can be |
| 1910 | 1918 |
/// accessed with an STL compatible forward iterator (\c ValueIt). |
| 1911 | 1919 |
/// |
| 1912 | 1920 |
/// This map is intended to be used when all associated values are |
| 1913 | 1921 |
/// different (the map is actually invertable) or there are only a few |
| 1914 | 1922 |
/// items with the same value. |
| 1915 | 1923 |
/// Otherwise consider to use \c IterableValueMap, which is more |
| 1916 | 1924 |
/// suitable and more efficient for such cases. It provides iterators |
| 1917 | 1925 |
/// to traverse the items with the same associated value, however |
| 1918 | 1926 |
/// it does not have \c InverseMap. |
| 1919 | 1927 |
/// |
| 1920 | 1928 |
/// This type is not reference map, so it cannot be modified with |
| 1921 | 1929 |
/// the subscript operator. |
| 1922 | 1930 |
/// |
| 1923 | 1931 |
/// \tparam GR The graph type. |
| 1924 | 1932 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or |
| 1925 | 1933 |
/// \c GR::Edge). |
| ... | ... |
@@ -2341,48 +2349,57 @@ |
| 2341 | 2349 |
/// that the given \e range \e id currently belongs to. |
| 2342 | 2350 |
Value operator[](const Key& key) const {
|
| 2343 | 2351 |
return _inverted(key); |
| 2344 | 2352 |
} |
| 2345 | 2353 |
|
| 2346 | 2354 |
/// \brief Size of the map. |
| 2347 | 2355 |
/// |
| 2348 | 2356 |
/// Returns the size of the map. |
| 2349 | 2357 |
unsigned int size() const {
|
| 2350 | 2358 |
return _inverted.size(); |
| 2351 | 2359 |
} |
| 2352 | 2360 |
|
| 2353 | 2361 |
private: |
| 2354 | 2362 |
const RangeIdMap& _inverted; |
| 2355 | 2363 |
}; |
| 2356 | 2364 |
|
| 2357 | 2365 |
/// \brief Gives back the inverse of the map. |
| 2358 | 2366 |
/// |
| 2359 | 2367 |
/// Gives back the inverse of the RangeIdMap. |
| 2360 | 2368 |
const InverseMap inverse() const {
|
| 2361 | 2369 |
return InverseMap(*this); |
| 2362 | 2370 |
} |
| 2363 | 2371 |
}; |
| 2364 | 2372 |
|
| 2373 |
/// \brief Returns a \c RangeIdMap class. |
|
| 2374 |
/// |
|
| 2375 |
/// This function just returns an \c RangeIdMap class. |
|
| 2376 |
/// \relates RangeIdMap |
|
| 2377 |
template <typename K, typename GR> |
|
| 2378 |
inline RangeIdMap<GR, K> rangeIdMap(const GR& graph) {
|
|
| 2379 |
return RangeIdMap<GR, K>(graph); |
|
| 2380 |
} |
|
| 2381 |
|
|
| 2365 | 2382 |
/// \brief Dynamic iterable \c bool map. |
| 2366 | 2383 |
/// |
| 2367 | 2384 |
/// This class provides a special graph map type which can store a |
| 2368 | 2385 |
/// \c bool value for graph items (\c Node, \c Arc or \c Edge). |
| 2369 | 2386 |
/// For both \c true and \c false values it is possible to iterate on |
| 2370 | 2387 |
/// the keys mapped to the value. |
| 2371 | 2388 |
/// |
| 2372 | 2389 |
/// This type is a reference map, so it can be modified with the |
| 2373 | 2390 |
/// subscript operator. |
| 2374 | 2391 |
/// |
| 2375 | 2392 |
/// \tparam GR The graph type. |
| 2376 | 2393 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or |
| 2377 | 2394 |
/// \c GR::Edge). |
| 2378 | 2395 |
/// |
| 2379 | 2396 |
/// \see IterableIntMap, IterableValueMap |
| 2380 | 2397 |
/// \see CrossRefMap |
| 2381 | 2398 |
template <typename GR, typename K> |
| 2382 | 2399 |
class IterableBoolMap |
| 2383 | 2400 |
: protected ItemSetTraits<GR, K>::template Map<int>::Type {
|
| 2384 | 2401 |
private: |
| 2385 | 2402 |
typedef GR Graph; |
| 2386 | 2403 |
|
| 2387 | 2404 |
typedef typename ItemSetTraits<GR, K>::ItemIt KeyIt; |
| 2388 | 2405 |
typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Parent; |
0 comments (0 inline)