File: CCuddFirstIter.h

package info (click to toggle)
brial 1.2.12-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,404 kB
  • sloc: cpp: 219,610; ansic: 43,783; python: 4,172; makefile: 336; sh: 5
file content (98 lines) | stat: -rw-r--r-- 2,381 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// -*- c++ -*-
//*****************************************************************************
/** @file CCuddFirstIter.h
 *
 * @author Alexander Dreyer
 * @date 2006-03-26
 *
 * This file defines an stl-like iterator for accessing the nonzero indices of
 * the leading (first) minimal term of Cudd decision diagrams.
 *
 * @note: Tested for Cudd's ZDDs only.
 *
 * @par Copyright:
 *   (c) 2006 by The PolyBoRi Team
**/
//*****************************************************************************

#ifndef polybori_iterators_CCuddFirstIter_h_
#define polybori_iterators_CCuddFirstIter_h_

// include basic definitions
#include "CCuddNavigator.h"

// include boost's interator facade
#include <boost/iterator/iterator_facade.hpp>

BEGIN_NAMESPACE_PBORI

/** @class CCuddFirstIter
 * @brief This class defines an iterator over the first minimal term of a given
 * ZDD node.
 *
 **/

class CCuddFirstIter : 
  public boost::iterator_facade<
  CCuddFirstIter,
  CCuddNavigator::value_type,
  std::forward_iterator_tag,
  CCuddNavigator::reference
  > {

public:

  /// Interface type for standard iterator access
  typedef std::forward_iterator_tag iterator_category;

  /// Get type of *this
  typedef CCuddFirstIter self;

  /// Get navigator type 
  typedef CCuddNavigator navigator;

  /// Type for constantly accessing node pointer
  typedef navigator::const_access_type const_access_type;

  /// Type for boolean values
  typedef navigator::bool_type bool_type;

  /// Default constructor
  CCuddFirstIter(): m_navi() {}

  /// Construct from navigator over nodes
  CCuddFirstIter(navigator rhs): m_navi(rhs) { terminateConstant(); }

  /// Destructor
  ~CCuddFirstIter() {}

  /// Incrementation operation
  void increment() {
    m_navi.incrementThen();
    terminateConstant();
  }

  /// Equality test
  bool_type equal (const self& rhs) const { return (m_navi == rhs.m_navi); }

  /// Dereferencing of the iterator
  navigator::reference dereference() const { return *m_navi; }

  /// Check, whether end of iteration is reached
  bool_type isEnd() const { return !m_navi.isValid(); }

protected:
  /// Constant nodes are marked as the end of a path
  void terminateConstant() {
    if (m_navi.isConstant()) 
      *this = self();           // mark end of path reached

  }

  /// Use navigator to access diagram nodes
  navigator m_navi;
};

END_NAMESPACE_PBORI

#endif