~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/CodeGen/PBQP/Solution.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===-- Solution.h ------- PBQP Solution ------------------------*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
//
10
 
// PBQP Solution class.
11
 
//
12
 
//===----------------------------------------------------------------------===//
13
 
 
14
 
#ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
15
 
#define LLVM_CODEGEN_PBQP_SOLUTION_H
16
 
 
17
 
#include "Math.h"
18
 
#include "Graph.h"
19
 
 
20
 
#include <map>
21
 
 
22
 
namespace PBQP {
23
 
 
24
 
  /// \brief Represents a solution to a PBQP problem.
25
 
  ///
26
 
  /// To get the selection for each node in the problem use the getSelection method.
27
 
  class Solution {
28
 
  private:
29
 
 
30
 
    typedef std::map<Graph::NodeItr, unsigned, NodeItrComparator> SelectionsMap;
31
 
    SelectionsMap selections;
32
 
 
33
 
    unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions;
34
 
 
35
 
  public:
36
 
 
37
 
    /// \brief Number of nodes for which selections have been made.
38
 
    /// @return Number of nodes for which selections have been made.
39
 
    unsigned numNodes() const { return selections.size(); }
40
 
 
41
 
    /// \brief Records a reduction via the R0 rule. Should be called from the
42
 
    ///        solver only.
43
 
    void recordR0() { ++r0Reductions; }
44
 
 
45
 
    /// \brief Returns the number of R0 reductions applied to solve the problem.
46
 
    unsigned numR0Reductions() const { return r0Reductions; }
47
 
 
48
 
    /// \brief Records a reduction via the R1 rule. Should be called from the
49
 
    ///        solver only.
50
 
    void recordR1() { ++r1Reductions; }
51
 
 
52
 
    /// \brief Returns the number of R1 reductions applied to solve the problem.
53
 
    unsigned numR1Reductions() const { return r1Reductions; }
54
 
 
55
 
    /// \brief Records a reduction via the R2 rule. Should be called from the
56
 
    ///        solver only.
57
 
    void recordR2() { ++r2Reductions; }
58
 
 
59
 
    /// \brief Returns the number of R2 reductions applied to solve the problem.
60
 
    unsigned numR2Reductions() const { return r2Reductions; }
61
 
 
62
 
    /// \brief Records a reduction via the RN rule. Should be called from the
63
 
    ///        solver only.
64
 
    void recordRN() { ++ rNReductions; }
65
 
 
66
 
    /// \brief Returns the number of RN reductions applied to solve the problem.
67
 
    unsigned numRNReductions() const { return rNReductions; }
68
 
 
69
 
    /// \brief Set the selection for a given node.
70
 
    /// @param nItr Node iterator.
71
 
    /// @param selection Selection for nItr.
72
 
    void setSelection(Graph::NodeItr nItr, unsigned selection) {
73
 
      selections[nItr] = selection;
74
 
    }
75
 
 
76
 
    /// \brief Get a node's selection.
77
 
    /// @param nItr Node iterator.
78
 
    /// @return The selection for nItr;
79
 
    unsigned getSelection(Graph::NodeItr nItr) const {
80
 
      SelectionsMap::const_iterator sItr = selections.find(nItr);
81
 
      assert(sItr != selections.end() && "No selection for node.");
82
 
      return sItr->second;
83
 
    }
84
 
 
85
 
  };
86
 
 
87
 
}
88
 
 
89
 
#endif // LLVM_CODEGEN_PBQP_SOLUTION_H