Added some comments and some cleanups.
authorTed Kremenek <kremenek@apple.com>
Mon, 30 Jun 2008 20:41:22 +0000 (20:41 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 30 Jun 2008 20:41:22 +0000 (20:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52922 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ImmutableList.h

index 2490f0c49efce3829f3bdbaf08fd9ed4486233a3..26a20c39acee5c4721a2996719c073f8a482d9e3 100644 (file)
@@ -85,24 +85,39 @@ public:
     iterator() : L(0) {}
     iterator(ImmutableList l) : L(l.getInternalPointer()) {}
     
-    iterator& operator++() { L = L->Tail; }
+    iterator& operator++() { L = L->Tail; return *this; }
     bool operator==(const iterator& I) const { return L == I.L; }
     ImmutableList operator*() const { return L; }
   };
 
+  /// begin - Returns an iterator referring to the head of the list, or
+  ///  an iterator denoting the end of the list if the list is empty.
   iterator begin() const { return iterator(X); }
+    
+  /// end - Returns an iterator denoting the end of the list.  This iterator
+  ///  does not refer to a valid list element.
   iterator end() const { return iterator(); }
 
+  /// isEmpty - Returns true if the list is empty.
   bool isEmpty() const { return !X; }
   
+  /// isEqual - Returns true if two lists are equal.  Because all lists created
+  ///  from the same ImmutableListFactory are uniqued, this has O(1) complexity
+  ///  because it the contents of the list do not need to be compared.  Note
+  ///  that you should only compare two lists created from the same
+  ///  ImmutableListFactory.
   bool isEqual(const ImmutableList& L) const { return X == L.X; }  
+
   bool operator==(const ImmutableList& L) const { return isEqual(L); }
 
+  /// getHead - Returns the head of the list.
   const T& getHead() {
     assert (!isEmpty() && "Cannot get the head of an empty list.");
     return X->getHead();
   }
   
+  /// getTail - Returns the tail of the list, which is another (possibly empty)
+  ///  ImmutableList.
   ImmutableList getTail() {
     return X ? X->getTail() : 0;
   }