# Changeset 1805:d284f81f02a5 in lemon-0.x

Ignore:
Timestamp:
11/16/05 14:19:05 (19 years ago)
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2348
Message:

Iterable Bool maps can count the number of true and false values.

File:
1 edited

Unmodified
Removed
• ## lemon/iterable_maps.h

 r1759 ///\todo This is only a static map! ///\todo Undocumented. ///\param BaseMap is an interger map. template ///\e void set(Key k,Value v) { if(v) setTrue(k); else setFalse(k);} ///Number of \c true items in the map ///Returns the number of \c true values in the map. ///This is a constant time operation. int countTrue() { return vals.size()-sep; } ///Number of \c false items in the map ///Returns the number of \c false values in the map. ///This is a constant time operation. int countFalse() { return sep; } ///\e int i; public: ///\e explicit FalseIt(const IterableBoolMap &_M) : M(_M), i(0) { } ///\e FalseIt(Invalid) : M(*((IterableBoolMap*)(0))), i(std::numeric_limits::max()) { } ///\e FalseIt &operator++() { ++i; return *this;} ///\e operator Key() const { return i=M.sep; } }; int i; public: ///\e explicit TrueIt(const IterableBoolMap &_M) : M(_M), i(M.vals.size()-1) { } ///\e TrueIt(Invalid) : M(*((IterableBoolMap*)(0))), i(-1) { } ///\e TrueIt &operator++() { --i; return *this;} ///\e operator Key() const { return i>=M.sep ? M.vals[i] : INVALID; } ///\e bool operator !=(Invalid) const { return i>=M.sep; } ///\e bool operator ==(Invalid) const { return i
Note: See TracChangeset for help on using the changeset viewer.