X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FEquivalenceClasses.h;h=07a5edfdb6ca785b6ea731338dae126ff76aaf47;hb=bd4d66d56a4e761a206dac14ccff4d37139d9ad9;hp=a866cd67e172db455b98ad0b2bcb08906d058ebf;hpb=24a751eccda668e15cca2a84772d504b47c40378;p=oota-llvm.git diff --git a/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index a866cd67e17..07a5edfdb6c 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/include/llvm/ADT/EquivalenceClasses.h @@ -1,22 +1,22 @@ //===-- llvm/ADT/EquivalenceClasses.h - Generic Equiv. Classes --*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// //===----------------------------------------------------------------------===// -// +// // Generic implementation of equivalence classes through the use Tarjan's // efficient union-find algorithm. -// +// //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_EQUIVALENCECLASSES_H #define LLVM_ADT_EQUIVALENCECLASSES_H -#include "llvm/ADT/iterator" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" +#include #include namespace llvm { @@ -43,8 +43,8 @@ namespace llvm { /// if (!I->isLeader()) continue; // Ignore non-leader sets. /// for (EquivalenceClasses::member_iterator MI = EC.member_begin(I); /// MI != EC.member_end(); ++MI) // Loop over members in this set. -/// std::cerr << *MI << " "; // Print member. -/// std::cerr << "\n"; // Finish set. +/// cerr << *MI << " "; // Print member. +/// cerr << "\n"; // Finish set. /// } /// /// This example prints: @@ -128,7 +128,7 @@ public: } return *this; } - + //===--------------------------------------------------------------------===// // Inspection methods // @@ -138,6 +138,8 @@ public: iterator begin() const { return TheMapping.begin(); } iterator end() const { return TheMapping.end(); } + bool empty() const { return TheMapping.empty(); } + /// member_* Iterate over the members of an equivalence class. /// class member_iterator; @@ -167,7 +169,7 @@ public: /// getOrInsertLeaderValue - Return the leader for the specified value that is /// in the set. If the member is not in the set, it is inserted, then /// returned. - const ElemTy &getOrInsertLeaderValue(const ElemTy &V) const { + const ElemTy &getOrInsertLeaderValue(const ElemTy &V) { member_iterator MI = findLeader(insert(V)); assert(MI != member_end() && "Value is not in the set!"); return *MI; @@ -189,7 +191,7 @@ public: /// insert - Insert a new value into the union/find set, ignoring the request /// if the value already exists. iterator insert(const ElemTy &Data) { - return TheMapping.insert(Data).first; + return TheMapping.insert(ECValue(Data)).first; } /// findLeader - Given a value in the set, return a member iterator for the @@ -220,7 +222,7 @@ public: // point to the L2 leader node. const ECValue &L1LV = *L1.Node, &L2LV = *L2.Node; L1LV.getEndOfList()->setNext(&L2LV); - + // Update L1LV's end of list pointer. L1LV.Leader = L2LV.getEndOfList(); @@ -232,8 +234,10 @@ public: return L1; } - class member_iterator : public forward_iterator { - typedef forward_iterator super; + class member_iterator : public std::iterator { + typedef std::iterator super; const ECValue *Node; friend class EquivalenceClasses; public: