Changeset 1873:d73c7f115f53 in lemon0.x
 Timestamp:
 01/04/06 14:19:12 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2448
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/iterable_maps.h
r1810 r1873 228 228 }; 229 229 230 /// Iterable bool UpperNodeMap 231 232 /// This map can be used in the same way 233 /// as the standard UpperNodeMap<bool> of the 234 /// given graph \c Graph. 235 /// In addition, this class provides two iterators called \ref TrueIt 236 /// and \ref FalseIt to iterate through the "true" and "false" nodes. 237 template <class Graph> 238 class IterableBoolUpperNodeMap 239 { 240 typename Graph::template UpperNodeMap<int> cmap; 241 242 public: 243 244 typedef IterableBoolMap<typename Graph::template UpperNodeMap<int> > BimType; 245 BimType imap; 246 247 248 typedef typename BimType::RefType RefType; 249 typedef typename Graph::Node Key; 250 typedef bool Value; 251 252 friend class FalseIt; 253 friend class TrueIt; 254 255 ///\e 256 IterableBoolUpperNodeMap(const Graph &g,bool b=false) : cmap(g), imap(cmap,b) {} 257 258 public: 259 ///\e 260 void set(Key k, bool v) { imap.set(k,v);} 261 ///Number of \c true items in the map 262 263 ///Returns the number of \c true values in the map. 264 ///This is a constant time operation. 265 int countTrue() { return imap.countTrue(); } 266 ///Number of \c false items in the map 267 268 ///Returns the number of \c false values in the map. 269 ///This is a constant time operation. 270 int countFalse() { return imap.countFalse(); } 271 #ifdef DOXYGEN 272 ///\e 273 bool &operator[](Key k) { return imap[k];} 274 ///\e 275 const bool &operator[](Key k) const { return imap[k];} 276 #else 277 Value operator[](Key k) const { return imap[k];} 278 RefType operator[](Key k) { return imap[k];} 279 #endif 280 ///Iterator for the "false" nodes 281 class FalseIt : public BimType::FalseIt 282 { 283 public: 284 ///\e 285 explicit FalseIt(const IterableBoolUpperNodeMap &m) 286 : BimType::FalseIt(m.imap) { } 287 ///\e 288 FalseIt(Invalid i) : BimType::FalseIt(i) { } 289 }; 290 ///Iterator for the "true" nodes 291 class TrueIt : public BimType::TrueIt 292 { 293 public: 294 ///\e 295 explicit TrueIt(const IterableBoolUpperNodeMap &m) 296 : BimType::TrueIt(m.imap) { } 297 ///\e 298 TrueIt(Invalid i) : BimType::TrueIt(i) { } 299 }; 300 }; 301 302 /// Iterable bool LowerNodeMap 303 304 /// This map can be used in the same way 305 /// as the standard LowerNodeMap<bool> of the 306 /// given graph \c Graph. 307 /// In addition, this class provides two iterators called \ref TrueIt 308 /// and \ref FalseIt to iterate through the "true" and "false" nodes. 309 template <class Graph> 310 class IterableBoolLowerNodeMap 311 { 312 typename Graph::template LowerNodeMap<int> cmap; 313 314 public: 315 316 typedef IterableBoolMap<typename Graph::template LowerNodeMap<int> > BimType; 317 BimType imap; 318 319 320 typedef typename BimType::RefType RefType; 321 typedef typename Graph::Node Key; 322 typedef bool Value; 323 324 friend class FalseIt; 325 friend class TrueIt; 326 327 ///\e 328 IterableBoolLowerNodeMap(const Graph &g,bool b=false) : cmap(g), imap(cmap,b) {} 329 330 public: 331 ///\e 332 void set(Key k, bool v) { imap.set(k,v);} 333 ///Number of \c true items in the map 334 335 ///Returns the number of \c true values in the map. 336 ///This is a constant time operation. 337 int countTrue() { return imap.countTrue(); } 338 ///Number of \c false items in the map 339 340 ///Returns the number of \c false values in the map. 341 ///This is a constant time operation. 342 int countFalse() { return imap.countFalse(); } 343 #ifdef DOXYGEN 344 ///\e 345 bool &operator[](Key k) { return imap[k];} 346 ///\e 347 const bool &operator[](Key k) const { return imap[k];} 348 #else 349 Value operator[](Key k) const { return imap[k];} 350 RefType operator[](Key k) { return imap[k];} 351 #endif 352 ///Iterator for the "false" nodes 353 class FalseIt : public BimType::FalseIt 354 { 355 public: 356 ///\e 357 explicit FalseIt(const IterableBoolLowerNodeMap &m) 358 : BimType::FalseIt(m.imap) { } 359 ///\e 360 FalseIt(Invalid i) : BimType::FalseIt(i) { } 361 }; 362 ///Iterator for the "true" nodes 363 class TrueIt : public BimType::TrueIt 364 { 365 public: 366 ///\e 367 explicit TrueIt(const IterableBoolLowerNodeMap &m) 368 : BimType::TrueIt(m.imap) { } 369 ///\e 370 TrueIt(Invalid i) : BimType::TrueIt(i) { } 371 }; 372 }; 373 230 374 /// Iterable bool EdgeMap 231 375
Note: See TracChangeset
for help on using the changeset viewer.