lemon/maps.h
changeset 1208 c6aa2cc1af04
parent 1092 dceba191c00d
child 1210 da87dbdf3daf
equal deleted inserted replaced
50:36e4583afc32 51:282aa1568fa4
    23 #include <functional>
    23 #include <functional>
    24 #include <vector>
    24 #include <vector>
    25 #include <map>
    25 #include <map>
    26 
    26 
    27 #include <lemon/core.h>
    27 #include <lemon/core.h>
       
    28 #include <lemon/bits/stl_iterators.h>
    28 
    29 
    29 ///\file
    30 ///\file
    30 ///\ingroup maps
    31 ///\ingroup maps
    31 ///\brief Miscellaneous property maps
    32 ///\brief Miscellaneous property maps
    32 
    33 
  2579 
  2580 
  2580     private:
  2581     private:
  2581       const IterableBoolMap* _map;
  2582       const IterableBoolMap* _map;
  2582     };
  2583     };
  2583 
  2584 
       
  2585     /// \brief STL style iterator for the keys mapped to \c true.
       
  2586     ///
       
  2587     /// This is an STL style wrapper for \ref TrueIt.
       
  2588     /// It can be used in range-based for loops, STL algorithms, etc.
       
  2589     LemonRangeWrapper1<TrueIt, IterableBoolMap>
       
  2590     trueKeys() {
       
  2591       return LemonRangeWrapper1<TrueIt, IterableBoolMap>(*this);
       
  2592     }
       
  2593 
       
  2594 
  2584     /// \brief Iterator for the keys mapped to \c false.
  2595     /// \brief Iterator for the keys mapped to \c false.
  2585     ///
  2596     ///
  2586     /// Iterator for the keys mapped to \c false. It works
  2597     /// Iterator for the keys mapped to \c false. It works
  2587     /// like a graph item iterator, it can be converted to
  2598     /// like a graph item iterator, it can be converted to
  2588     /// the key type of the map, incremented with \c ++ operator, and
  2599     /// the key type of the map, incremented with \c ++ operator, and
  2617       }
  2628       }
  2618 
  2629 
  2619     private:
  2630     private:
  2620       const IterableBoolMap* _map;
  2631       const IterableBoolMap* _map;
  2621     };
  2632     };
       
  2633 
       
  2634     /// \brief STL style iterator for the keys mapped to \c false.
       
  2635     ///
       
  2636     /// This is an STL style wrapper for \ref FalseIt.
       
  2637     /// It can be used in range-based for loops, STL algorithms, etc.
       
  2638     LemonRangeWrapper1<FalseIt, IterableBoolMap>
       
  2639     falseKeys() {
       
  2640       return LemonRangeWrapper1<FalseIt, IterableBoolMap>(*this);
       
  2641     }
       
  2642 
  2622 
  2643 
  2623     /// \brief Iterator for the keys mapped to a given value.
  2644     /// \brief Iterator for the keys mapped to a given value.
  2624     ///
  2645     ///
  2625     /// Iterator for the keys mapped to a given value. It works
  2646     /// Iterator for the keys mapped to a given value. It works
  2626     /// like a graph item iterator, it can be converted to
  2647     /// like a graph item iterator, it can be converted to
  2661       }
  2682       }
  2662 
  2683 
  2663     private:
  2684     private:
  2664       const IterableBoolMap* _map;
  2685       const IterableBoolMap* _map;
  2665     };
  2686     };
       
  2687 
       
  2688     /// \brief STL style iterator for the keys mapped to a given value.
       
  2689     ///
       
  2690     /// This is an STL style wrapper for \ref ItemIt.
       
  2691     /// It can be used in range-based for loops, STL algorithms, etc.
       
  2692     LemonRangeWrapper2<ItemIt, IterableBoolMap, bool>
       
  2693     items(bool value) {
       
  2694       return LemonRangeWrapper2<ItemIt, IterableBoolMap, bool>(*this, value);
       
  2695     }
  2666 
  2696 
  2667   protected:
  2697   protected:
  2668 
  2698 
  2669     virtual void add(const Key& key) {
  2699     virtual void add(const Key& key) {
  2670       Parent::add(key);
  2700       Parent::add(key);
  3003 
  3033 
  3004     private:
  3034     private:
  3005       const IterableIntMap* _map;
  3035       const IterableIntMap* _map;
  3006     };
  3036     };
  3007 
  3037 
       
  3038     /// \brief STL style iterator for the keys with the same value.
       
  3039     ///
       
  3040     /// This is an STL style wrapper for \ref ItemIt.
       
  3041     /// It can be used in range-based for loops, STL algorithms, etc.
       
  3042     LemonRangeWrapper2<ItemIt, IterableIntMap, int>
       
  3043     items(int value) {
       
  3044       return LemonRangeWrapper2<ItemIt, IterableIntMap, int>(*this, value);
       
  3045     }
       
  3046 
       
  3047 
  3008   protected:
  3048   protected:
  3009 
  3049 
  3010     virtual void erase(const Key& key) {
  3050     virtual void erase(const Key& key) {
  3011       unlace(key);
  3051       unlace(key);
  3012       Parent::erase(key);
  3052       Parent::erase(key);
  3246 
  3286 
  3247     private:
  3287     private:
  3248       const IterableValueMap* _map;
  3288       const IterableValueMap* _map;
  3249     };
  3289     };
  3250 
  3290 
       
  3291     /// \brief STL style iterator for the keys with the same value.
       
  3292     ///
       
  3293     /// This is an STL style wrapper for \ref ItemIt.
       
  3294     /// It can be used in range-based for loops, STL algorithms, etc.
       
  3295     LemonRangeWrapper2<ItemIt, IterableValueMap, V>
       
  3296     items(const V& value) {
       
  3297       return LemonRangeWrapper2<ItemIt, IterableValueMap, V>(*this, value);
       
  3298     }
       
  3299 
       
  3300 
  3251   protected:
  3301   protected:
  3252 
  3302 
  3253     virtual void add(const Key& key) {
  3303     virtual void add(const Key& key) {
  3254       Parent::add(key);
  3304       Parent::add(key);
  3255       lace(key);
  3305       lace(key);