Candidate_v1.7.0
        stable
      
      
      
| Line |   | 
|---|
| 1 | /*
 | 
|---|
| 2 |  * BoostGraphHelpers.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: May 18, 2017
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | 
 | 
|---|
| 9 | #ifndef GRAPH_BOOSTGRAPHHELPERS_HPP_
 | 
|---|
| 10 | #define GRAPH_BOOSTGRAPHHELPERS_HPP_
 | 
|---|
| 11 | 
 | 
|---|
| 12 | // include config.h
 | 
|---|
| 13 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 14 | #include <config.h>
 | 
|---|
| 15 | #endif
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include <vector>
 | 
|---|
| 18 | 
 | 
|---|
| 19 | #include "types.hpp"
 | 
|---|
| 20 | 
 | 
|---|
| 21 | namespace BoostGraphHelpers {
 | 
|---|
| 22 | 
 | 
|---|
| 23 |   typedef std::vector<atomId_t> Nodeset_t;
 | 
|---|
| 24 | 
 | 
|---|
| 25 | #ifdef HAVE_INLINE
 | 
|---|
| 26 | inline
 | 
|---|
| 27 | #else
 | 
|---|
| 28 | static
 | 
|---|
| 29 | #endif
 | 
|---|
| 30 |   bool isCommonNodeInVector(
 | 
|---|
| 31 |       const Nodeset_t &_firstnodes,
 | 
|---|
| 32 |       const Nodeset_t &_secondnodes) {
 | 
|---|
| 33 |     // std::set_intersection builds full set in bad case: too much work, just
 | 
|---|
| 34 |     // seek single element contained in either set
 | 
|---|
| 35 |     Nodeset_t::const_iterator firstiter = _firstnodes.begin();
 | 
|---|
| 36 |     Nodeset_t::const_iterator seconditer = _secondnodes.begin();
 | 
|---|
| 37 |     while ((firstiter != _firstnodes.end()) && (seconditer != _secondnodes.end())) {
 | 
|---|
| 38 |       if (*firstiter == *seconditer) {
 | 
|---|
| 39 |         break;
 | 
|---|
| 40 |       } else if (*firstiter > *seconditer) {
 | 
|---|
| 41 |         ++seconditer;
 | 
|---|
| 42 |       } else {
 | 
|---|
| 43 |         ++firstiter;
 | 
|---|
| 44 |       }
 | 
|---|
| 45 |     }
 | 
|---|
| 46 |     return ((firstiter != _firstnodes.end())
 | 
|---|
| 47 |         && (seconditer != _secondnodes.end()));
 | 
|---|
| 48 |   }
 | 
|---|
| 49 | } /* namespace BoostGraphHelpers */
 | 
|---|
| 50 | 
 | 
|---|
| 51 | 
 | 
|---|
| 52 | #endif /* GRAPH_BOOSTGRAPHHELPERS_HPP_ */
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.