Deleted Added
full compact
MaximumSpanningTree.h (198090) MaximumSpanningTree.h (200581)
1//===- llvm/Analysis/MaximumSpanningTree.h - Interface ----------*- 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// This module privides means for calculating a maximum spanning tree for a
11// given set of weighted edges. The type parameter T is the type of a node.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H
16#define LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H
17
1//===- llvm/Analysis/MaximumSpanningTree.h - Interface ----------*- 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// This module privides means for calculating a maximum spanning tree for a
11// given set of weighted edges. The type parameter T is the type of a node.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H
16#define LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H
17
18#include "llvm/BasicBlock.h"
18#include "llvm/ADT/EquivalenceClasses.h"
19#include <vector>
20#include <algorithm>
21
22namespace llvm {
23
24 /// MaximumSpanningTree - A MST implementation.
25 /// The type parameter T determines the type of the nodes of the graph.
26 template <typename T>
27 class MaximumSpanningTree {
28
29 // A comparing class for comparing weighted edges.
30 template <typename CT>
31 struct EdgeWeightCompare {
32 bool operator()(typename MaximumSpanningTree<CT>::EdgeWeight X,
33 typename MaximumSpanningTree<CT>::EdgeWeight Y) const {
34 if (X.second > Y.second) return true;
35 if (X.second < Y.second) return false;
19#include "llvm/ADT/EquivalenceClasses.h"
20#include <vector>
21#include <algorithm>
22
23namespace llvm {
24
25 /// MaximumSpanningTree - A MST implementation.
26 /// The type parameter T determines the type of the nodes of the graph.
27 template <typename T>
28 class MaximumSpanningTree {
29
30 // A comparing class for comparing weighted edges.
31 template <typename CT>
32 struct EdgeWeightCompare {
33 bool operator()(typename MaximumSpanningTree<CT>::EdgeWeight X,
34 typename MaximumSpanningTree<CT>::EdgeWeight Y) const {
35 if (X.second > Y.second) return true;
36 if (X.second < Y.second) return false;
37 if (const BasicBlock *BBX = dyn_cast<BasicBlock>(X.first.first)) {
38 if (const BasicBlock *BBY = dyn_cast<BasicBlock>(Y.first.first)) {
39 if (BBX->size() > BBY->size()) return true;
40 if (BBX->size() < BBY->size()) return false;
41 }
42 }
43 if (const BasicBlock *BBX = dyn_cast<BasicBlock>(X.first.second)) {
44 if (const BasicBlock *BBY = dyn_cast<BasicBlock>(Y.first.second)) {
45 if (BBX->size() > BBY->size()) return true;
46 if (BBX->size() < BBY->size()) return false;
47 }
48 }
36 return false;
37 }
38 };
39
40 public:
41 typedef std::pair<const T*, const T*> Edge;
42 typedef std::pair<Edge, double> EdgeWeight;
43 typedef std::vector<EdgeWeight> EdgeWeights;

--- 52 unchanged lines hidden ---
49 return false;
50 }
51 };
52
53 public:
54 typedef std::pair<const T*, const T*> Edge;
55 typedef std::pair<Edge, double> EdgeWeight;
56 typedef std::vector<EdgeWeight> EdgeWeights;

--- 52 unchanged lines hidden ---