[ADT] Add a 'find_as' operation to DenseSet.
[oota-llvm.git] / include / llvm / ADT / ilist.h
index 6aeaa91f1b1671db292ca0bfaf595c251ee9a97f..8c19a6f4547a72895a8bca980865f7fbd7498993 100644 (file)
@@ -83,7 +83,7 @@ struct ilist_sentinel_traits {
   /// provideInitialHead - when constructing an ilist, provide a starting
   /// value for its Head
   /// @return null node to indicate that it needs to be allocated later
-  static NodeTy *provideInitialHead() { return 0; }
+  static NodeTy *provideInitialHead() { return nullptr; }
 
   /// ensureHead - make sure that Head is either already
   /// initialized or assigned a fresh sentinel
@@ -92,7 +92,7 @@ struct ilist_sentinel_traits {
     if (!Head) {
       Head = ilist_traits<NodeTy>::createSentinel();
       ilist_traits<NodeTy>::noteHead(Head, Head);
-      ilist_traits<NodeTy>::setNext(Head, 0);
+      ilist_traits<NodeTy>::setNext(Head, nullptr);
       return Head;
     }
     return ilist_traits<NodeTy>::getPrev(Head);
@@ -175,7 +175,7 @@ public:
 
   ilist_iterator(pointer NP) : NodePtr(NP) {}
   ilist_iterator(reference NR) : NodePtr(&NR) {}
-  ilist_iterator() : NodePtr(0) {}
+  ilist_iterator() : NodePtr(nullptr) {}
 
   // This is templated so that we can allow constructing a const iterator from
   // a nonconst iterator...
@@ -383,7 +383,7 @@ public:
   // Miscellaneous inspection routines.
   size_type max_size() const { return size_type(-1); }
   bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const {
-    return Head == 0 || Head == getTail();
+    return !Head || Head == getTail();
   }
 
   // Front and back accessor functions...
@@ -451,8 +451,8 @@ public:
     // an ilist (and potentially deleted) with iterators still pointing at it.
     // When those iterators are incremented or decremented, they will assert on
     // the null next/prev pointer instead of "usually working".
-    this->setNext(Node, 0);
-    this->setPrev(Node, 0);
+    this->setNext(Node, nullptr);
+    this->setPrev(Node, nullptr);
     return Node;
   }
 
@@ -494,9 +494,9 @@ private:
       // Note: we have to be careful about the case when we move the first node
       // in the list.  This node is the list sentinel node and we can't move it.
       NodeTy *ThisSentinel = getTail();
-      setTail(0);
+      setTail(nullptr);
       NodeTy *L2Sentinel = L2.getTail();
-      L2.setTail(0);
+      L2.setTail(nullptr);
 
       // Remove [first, last) from its old position.
       NodeTy *First = &*first, *Prev = this->getPrev(First);
@@ -537,7 +537,7 @@ public:
   //
 
   size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const {
-    if (Head == 0) return 0; // Don't require construction of sentinel if empty.
+    if (!Head) return 0; // Don't require construction of sentinel if empty.
     return std::distance(begin(), end());
   }
 
@@ -579,60 +579,6 @@ public:
   void splice(iterator where, iplist &L2, iterator first, iterator last) {
     if (first != last) transfer(where, L2, first, last);
   }
-
-
-
-  //===----------------------------------------------------------------------===
-  // High-Level Functionality that shouldn't really be here, but is part of list
-  //
-
-  // These two functions are actually called remove/remove_if in list<>, but
-  // they actually do the job of erase, rename them accordingly.
-  //
-  void erase(const NodeTy &val) {
-    for (iterator I = begin(), E = end(); I != E; ) {
-      iterator next = I; ++next;
-      if (*I == val) erase(I);
-      I = next;
-    }
-  }
-  template<class Pr1> void erase_if(Pr1 pred) {
-    for (iterator I = begin(), E = end(); I != E; ) {
-      iterator next = I; ++next;
-      if (pred(*I)) erase(I);
-      I = next;
-    }
-  }
-
-  template<class Pr2> void unique(Pr2 pred) {
-    if (empty()) return;
-    for (iterator I = begin(), E = end(), Next = begin(); ++Next != E;) {
-      if (pred(*I))
-        erase(Next);
-      else
-        I = Next;
-      Next = I;
-    }
-  }
-  void unique() { unique(op_equal); }
-
-  template<class Pr3> void merge(iplist &right, Pr3 pred) {
-    iterator first1 = begin(), last1 = end();
-    iterator first2 = right.begin(), last2 = right.end();
-    while (first1 != last1 && first2 != last2)
-      if (pred(*first2, *first1)) {
-        iterator next = first2;
-        transfer(first1, right, first2, ++next);
-        first2 = next;
-      } else {
-        ++first1;
-      }
-    if (first2 != last2) transfer(last1, right, first2, last2);
-  }
-  void merge(iplist &right) { return merge(right, op_less); }
-
-  template<class Pr3> void sort(Pr3 pred);
-  void sort() { sort(op_less); }
 };