Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / wtf / LinkedHashSet.h
index b0a5859..e254e15 100644 (file)
@@ -45,9 +45,9 @@ template<typename LinkedHashSet> class LinkedHashSetConstIterator;
 template<typename LinkedHashSet> class LinkedHashSetReverseIterator;
 template<typename LinkedHashSet> class LinkedHashSetConstReverseIterator;
 
-template<typename Value, typename HashFunctions> struct LinkedHashSetTranslator;
-template<typename Value> struct LinkedHashSetExtractor;
-template<typename Value, typename ValueTraits> struct LinkedHashSetTraits;
+template<typename Value, typename HashFunctions, typename Allocator> struct LinkedHashSetTranslator;
+template<typename Value, typename Allocator> struct LinkedHashSetExtractor;
+template<typename Value, typename ValueTraits, typename Allocator> struct LinkedHashSetTraits;
 
 class LinkedHashSetNodeBase {
 public:
@@ -116,7 +116,7 @@ private:
     LinkedHashSetNodeBase& operator=(const LinkedHashSetNodeBase& other);
 };
 
-template<typename ValueArg>
+template<typename ValueArg, typename Allocator>
 class LinkedHashSetNode : public LinkedHashSetNodeBase {
 public:
     LinkedHashSetNode(const ValueArg& value, LinkedHashSetNodeBase* prev, LinkedHashSetNodeBase* next)
@@ -142,10 +142,10 @@ class LinkedHashSet {
 private:
     typedef ValueArg Value;
     typedef TraitsArg Traits;
-    typedef LinkedHashSetNode<Value> Node;
+    typedef LinkedHashSetNode<Value, Allocator> Node;
     typedef LinkedHashSetNodeBase NodeBase;
-    typedef LinkedHashSetTranslator<Value, HashFunctions> NodeHashFunctions;
-    typedef LinkedHashSetTraits<Value, Traits> NodeHashTraits;
+    typedef LinkedHashSetTranslator<Value, HashFunctions, Allocator> NodeHashFunctions;
+    typedef LinkedHashSetTraits<Value, Traits, Allocator> NodeHashTraits;
 
     typedef HashTable<Node, Node, IdentityExtractor,
         NodeHashFunctions, NodeHashTraits, NodeHashTraits, Allocator> ImplType;
@@ -267,9 +267,9 @@ private:
     NodeBase m_anchor;
 };
 
-template<typename Value, typename HashFunctions>
+template<typename Value, typename HashFunctions, typename Allocator>
 struct LinkedHashSetTranslator {
-    typedef LinkedHashSetNode<Value> Node;
+    typedef LinkedHashSetNode<Value, Allocator> Node;
     typedef LinkedHashSetNodeBase NodeBase;
     typedef typename HashTraits<Value>::PeekInType ValuePeekInType;
     static unsigned hash(const Node& node) { return HashFunctions::hash(node.m_value); }
@@ -278,8 +278,8 @@ struct LinkedHashSetTranslator {
     static bool equal(const Node& a, const Node& b) { return HashFunctions::equal(a.m_value, b.m_value); }
     static void translate(Node& location, ValuePeekInType key, NodeBase* anchor)
     {
-        location.m_value = key;
         anchor->insertBefore(location);
+        location.m_value = key;
     }
 
     // Empty (or deleted) slots have the m_next pointer set to null, but we
@@ -289,14 +289,14 @@ struct LinkedHashSetTranslator {
     static const bool safeToCompareToEmptyOrDeleted = false;
 };
 
-template<typename Value>
+template<typename Value, typename Allocator>
 struct LinkedHashSetExtractor {
-    static const Value& extract(const LinkedHashSetNode<Value>& node) { return node.m_value; }
+    static const Value& extract(const LinkedHashSetNode<Value, Allocator>& node) { return node.m_value; }
 };
 
-template<typename Value, typename ValueTraitsArg>
-struct LinkedHashSetTraits : public SimpleClassHashTraits<LinkedHashSetNode<Value> > {
-    typedef LinkedHashSetNode<Value> Node;
+template<typename Value, typename ValueTraitsArg, typename Allocator>
+struct LinkedHashSetTraits : public SimpleClassHashTraits<LinkedHashSetNode<Value, Allocator> > {
+    typedef LinkedHashSetNode<Value, Allocator> Node;
     typedef ValueTraitsArg ValueTraits;
 
     // The slot is empty when the m_next field is zero so it's safe to zero
@@ -308,7 +308,7 @@ struct LinkedHashSetTraits : public SimpleClassHashTraits<LinkedHashSetNode<Valu
 
     static const int deletedValue = -1;
 
-    static void constructDeletedValue(Node& slot) { slot.m_next = reinterpret_cast<Node*>(deletedValue); }
+    static void constructDeletedValue(Node& slot, bool) { slot.m_next = reinterpret_cast<Node*>(deletedValue); }
     static bool isDeletedValue(const Node& slot) { return slot.m_next == reinterpret_cast<Node*>(deletedValue); }
 
     // We always need to call destructors, that's how we get linked and
@@ -705,13 +705,14 @@ inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b)
     }
 }
 
-template<typename T>
-inline void swap(LinkedHashSetNode<T>& a, LinkedHashSetNode<T>& b)
+template<typename T, typename Allocator>
+inline void swap(LinkedHashSetNode<T, Allocator>& a, LinkedHashSetNode<T, Allocator>& b)
 {
     typedef LinkedHashSetNodeBase Base;
-
+    Allocator::enterNoAllocationScope();
     swap(static_cast<Base&>(a), static_cast<Base&>(b));
     swap(a.m_value, b.m_value);
+    Allocator::leaveNoAllocationScope();
 }
 
 // Warning: After and while calling this you have a collection with deleted