Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1302)

Unified Diff: third_party/WebKit/Source/wtf/HashTable.h

Issue 2274403002: Replace two ASSERT()s for HashMap iterators with DCHECK_NE()s. (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/HashTable.h
diff --git a/third_party/WebKit/Source/wtf/HashTable.h b/third_party/WebKit/Source/wtf/HashTable.h
index ec55677c973b6a0c511053126595d6a089ead487..e4e5f54ee2ff571a2abfa4b3227839e8d3365e7c 100644
--- a/third_party/WebKit/Source/wtf/HashTable.h
+++ b/third_party/WebKit/Source/wtf/HashTable.h
@@ -204,6 +204,15 @@ public:
return *this != static_cast<const_iterator>(other);
}
+ std::ostream& printTo(std::ostream& stream) const
+ {
+ if (m_position == m_endPosition)
+ return stream << "iterator representing <end>";
+ // TODO(tkent): Change |m_position| to |*m_position| to show the
+ // pointed object. It requires a lot of new stream printer functions.
+ return stream << "iterator pointing to " << m_position;
+ }
+
private:
PointerType m_position;
PointerType m_endPosition;
@@ -213,6 +222,12 @@ private:
#endif
};
+template <typename Key, typename Value, typename Extractor, typename Hash, typename Traits, typename KeyTraits, typename Allocator>
+std::ostream& operator<<(std::ostream& stream, const HashTableConstIterator<Key, Value, Extractor, Hash, Traits, KeyTraits, Allocator>& iterator)
+{
+ return iterator.printTo(stream);
+}
+
template <typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
class HashTableIterator final {
DISALLOW_NEW();
@@ -249,11 +264,18 @@ public:
bool operator!=(const const_iterator& other) const { return m_iterator != other; }
operator const_iterator() const { return m_iterator; }
+ std::ostream& printTo(std::ostream& stream) const { return m_iterator.printTo(stream); }
private:
const_iterator m_iterator;
};
+template <typename Key, typename Value, typename Extractor, typename Hash, typename Traits, typename KeyTraits, typename Allocator>
+std::ostream& operator<<(std::ostream& stream, const HashTableIterator<Key, Value, Extractor, Hash, Traits, KeyTraits, Allocator>& iterator)
+{
+ return iterator.printTo(stream);
+}
+
using std::swap;
template <typename T, typename Allocator, bool enterGCForbiddenScope> struct Mover {
@@ -1460,6 +1482,12 @@ template <typename HashTableType, typename Traits> struct HashTableConstIterator
typename HashTableType::const_iterator m_impl;
};
+template <typename HashTable, typename Traits>
+std::ostream& operator<<(std::ostream& stream, const HashTableConstIteratorAdapter<HashTable, Traits>& iterator)
+{
+ return stream << iterator.m_impl;
+}
+
template <typename HashTableType, typename Traits> struct HashTableIteratorAdapter {
STACK_ALLOCATED();
typedef typename Traits::IteratorGetType GetType;
@@ -1484,6 +1512,12 @@ template <typename HashTableType, typename Traits> struct HashTableIteratorAdapt
typename HashTableType::iterator m_impl;
};
+template <typename HashTable, typename Traits>
+std::ostream& operator<<(std::ostream& stream, const HashTableIteratorAdapter<HashTable, Traits>& iterator)
+{
+ return stream << iterator.m_impl;
+}
+
template <typename T, typename U>
inline bool operator==(const HashTableConstIteratorAdapter<T, U>& a, const HashTableConstIteratorAdapter<T, U>& b)
{
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698