| ... | ... |
@@ -1854,96 +1854,104 @@ |
| 1854 | 1854 |
/// |
| 1855 | 1855 |
/// Gives back the immutable and unique \e id of the item. |
| 1856 | 1856 |
int operator[](const Item& item) const { return _graph->id(item);}
|
| 1857 | 1857 |
|
| 1858 | 1858 |
/// \brief Gives back the \e item by its id. |
| 1859 | 1859 |
/// |
| 1860 | 1860 |
/// Gives back the \e item by its id. |
| 1861 | 1861 |
Item operator()(int id) { return _graph->fromId(id, Item()); }
|
| 1862 | 1862 |
|
| 1863 | 1863 |
private: |
| 1864 | 1864 |
const Graph* _graph; |
| 1865 | 1865 |
|
| 1866 | 1866 |
public: |
| 1867 | 1867 |
|
| 1868 | 1868 |
/// \brief The inverse map type of IdMap. |
| 1869 | 1869 |
/// |
| 1870 | 1870 |
/// The inverse map type of IdMap. The subscript operator gives back |
| 1871 | 1871 |
/// an item by its id. |
| 1872 | 1872 |
/// This type conforms to the \ref concepts::ReadMap "ReadMap" concept. |
| 1873 | 1873 |
/// \see inverse() |
| 1874 | 1874 |
class InverseMap {
|
| 1875 | 1875 |
public: |
| 1876 | 1876 |
|
| 1877 | 1877 |
/// \brief Constructor. |
| 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). |
| 1926 | 1934 |
/// \tparam V The value type of the map. |
| 1927 | 1935 |
/// |
| 1928 | 1936 |
/// \see IterableValueMap |
| 1929 | 1937 |
template <typename GR, typename K, typename V> |
| 1930 | 1938 |
class CrossRefMap |
| 1931 | 1939 |
: protected ItemSetTraits<GR, K>::template Map<V>::Type {
|
| 1932 | 1940 |
private: |
| 1933 | 1941 |
|
| 1934 | 1942 |
typedef typename ItemSetTraits<GR, K>:: |
| 1935 | 1943 |
template Map<V>::Type Map; |
| 1936 | 1944 |
|
| 1937 | 1945 |
typedef std::multimap<V, K> Container; |
| 1938 | 1946 |
Container _inv_map; |
| 1939 | 1947 |
|
| 1940 | 1948 |
public: |
| 1941 | 1949 |
|
| 1942 | 1950 |
/// The graph type of CrossRefMap. |
| 1943 | 1951 |
typedef GR Graph; |
| 1944 | 1952 |
typedef GR Digraph; |
| 1945 | 1953 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). |
| 1946 | 1954 |
typedef K Item; |
| 1947 | 1955 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). |
| 1948 | 1956 |
typedef K Key; |
| 1949 | 1957 |
/// The value type of CrossRefMap. |
| ... | ... |
@@ -2317,96 +2325,105 @@ |
| 2317 | 2325 |
public: |
| 2318 | 2326 |
|
| 2319 | 2327 |
/// \brief The inverse map type of RangeIdMap. |
| 2320 | 2328 |
/// |
| 2321 | 2329 |
/// The inverse map type of RangeIdMap. The subscript operator gives |
| 2322 | 2330 |
/// back an item by its \e range \e id. |
| 2323 | 2331 |
/// This type conforms to the \ref concepts::ReadMap "ReadMap" concept. |
| 2324 | 2332 |
class InverseMap {
|
| 2325 | 2333 |
public: |
| 2326 | 2334 |
/// \brief Constructor |
| 2327 | 2335 |
/// |
| 2328 | 2336 |
/// Constructor of the InverseMap. |
| 2329 | 2337 |
explicit InverseMap(const RangeIdMap& inverted) |
| 2330 | 2338 |
: _inverted(inverted) {}
|
| 2331 | 2339 |
|
| 2332 | 2340 |
|
| 2333 | 2341 |
/// The value type of the InverseMap. |
| 2334 | 2342 |
typedef typename RangeIdMap::Key Value; |
| 2335 | 2343 |
/// The key type of the InverseMap. |
| 2336 | 2344 |
typedef typename RangeIdMap::Value Key; |
| 2337 | 2345 |
|
| 2338 | 2346 |
/// \brief Subscript operator. |
| 2339 | 2347 |
/// |
| 2340 | 2348 |
/// Subscript operator. It gives back the item |
| 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; |
| 2389 | 2406 |
|
| 2390 | 2407 |
std::vector<K> _array; |
| 2391 | 2408 |
int _sep; |
| 2392 | 2409 |
|
| 2393 | 2410 |
public: |
| 2394 | 2411 |
|
| 2395 | 2412 |
/// Indicates that the map is reference map. |
| 2396 | 2413 |
typedef True ReferenceMapTag; |
| 2397 | 2414 |
|
| 2398 | 2415 |
/// The key type |
| 2399 | 2416 |
typedef K Key; |
| 2400 | 2417 |
/// The value type |
| 2401 | 2418 |
typedef bool Value; |
| 2402 | 2419 |
/// The const reference type. |
| 2403 | 2420 |
typedef const Value& ConstReference; |
| 2404 | 2421 |
|
| 2405 | 2422 |
private: |
| 2406 | 2423 |
|
| 2407 | 2424 |
int position(const Key& key) const {
|
| 2408 | 2425 |
return Parent::operator[](key); |
| 2409 | 2426 |
} |
| 2410 | 2427 |
|
| 2411 | 2428 |
public: |
| 2412 | 2429 |
|
0 comments (0 inline)