[llvm-commits] [llvm] r52922 - /llvm/trunk/include/llvm/ADT/ImmutableList.h
Ted Kremenek
kremenek at apple.com
Mon Jun 30 13:41:23 PDT 2008
Author: kremenek
Date: Mon Jun 30 15:41:22 2008
New Revision: 52922
URL: http://llvm.org/viewvc/llvm-project?rev=52922&view=rev
Log:
Added some comments and some cleanups.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableList.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableList.h?rev=52922&r1=52921&r2=52922&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableList.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableList.h Mon Jun 30 15:41:22 2008
@@ -85,24 +85,39 @@
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;
}
More information about the llvm-commits
mailing list