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:
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)
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;
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); }
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
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
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
}
}
-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