Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
allocunorderedset.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_STLALLOC_ALLOCUNORDEREDSET_H_
19 #define ION_BASE_STLALLOC_ALLOCUNORDEREDSET_H_
20 
21 #include <unordered_set>
22 
23 #include "ion/base/allocatable.h"
26 
27 namespace ion {
28 namespace base {
29 
48 
49 template <typename Value,
50  typename Hash = ::std::hash<Value>,
51  typename Pred = ::std::equal_to<Value> >
53  : public std::unordered_set<Value, Hash, Pred, StlAllocator<Value> > {
54  public:
56  typedef std::unordered_set<Value, Hash, Pred, AllocType> SetType;
57 
58  explicit AllocUnorderedSet(const AllocatorPtr& alloc)
59  : SetType(kBucketCountHint, Hash(), Pred(),
60  AllocType(AllocationManager::GetNonNullAllocator(alloc))) {}
61  explicit AllocUnorderedSet(const Allocatable& owner)
62  : SetType(kBucketCountHint, Hash(), Pred(),
63  AllocType(owner.GetNonNullAllocator())) {}
64 
67  template <typename ContainerT>
68  AllocUnorderedSet(const AllocatorPtr& alloc, const ContainerT& from)
69  : SetType(from.begin(), from.end(), kBucketCountHint, Hash(), Pred(),
70  AllocType(AllocationManager::GetNonNullAllocator(alloc))) {}
71  template <typename ContainerT>
72  AllocUnorderedSet(const Allocatable& owner, const ContainerT& from)
73  : SetType(from.begin(), from.end(), kBucketCountHint, Hash(), Pred(),
74  AllocType(owner.GetNonNullAllocator())) {}
75 
76  private:
80  enum { kBucketCountHint = 10 };
81 };
82 
83 } // namespace base
84 } // namespace ion
85 
86 #endif // ION_BASE_STLALLOC_ALLOCUNORDEREDSET_H_
StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containe...
Definition: stlallocator.h:35
AllocationManager is a singleton class that is used to manage Allocators used to allocate Ion objects...
AllocUnorderedSet(const AllocatorPtr &alloc)
std::unordered_set< Value, Hash, Pred, AllocType > SetType
This class can be used in place of std::unordered_set to allow an Ion Allocator to be used for memory...
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
Definition: allocatable.h:60
AllocUnorderedSet(const AllocatorPtr &alloc, const ContainerT &from)
These constructors can be used to copy from "STL iterables": anything that provides a pair of compati...
AllocUnorderedSet(const Allocatable &owner, const ContainerT &from)
AllocUnorderedSet(const Allocatable &owner)
StlAllocator< Value > AllocType