|
ATLAS Offline Software
|
Go to the documentation of this file.
14 #ifndef CXXUTILS_POINTER_LIST_H
15 #define CXXUTILS_POINTER_LIST_H
18 #include <type_traits>
79 static size_t size (
size_t nelt);
108 unsigned long end_mask,
109 unsigned long end_offs);
239 template <
size_t NELT = 15>
259 static_assert (((NELT+1) & NELT) == 0);
337 #endif // not CXXUTILS_POINTER_LIST_H
list_block * m_head
The first block in the list.
size_t m_nelt
Number of elements per block (excluding the end-pointer).
reference operator*()
Dereference.
void clear()
Erase the container.
value_type m_data[1]
The elements.
std::forward_iterator_tag iterator_category
A single block in the list.
unsigned long m_end_mask
Mask for testing for an end pointer.
bool operator==(const iterator &other) const
Equality comparison.
value_type * m_insert
The current insertion point in the list.
void refill()
Allocate a new chunk of blocks.
pointer_list_base::value_type value_type
Stored value type.
size_t m_nblock
Number of blocks per chunk.
void * value_type
The element type we store.
pointer_list(pool_type &pool)
Constructor. pool gives the allocator for this container.
static bool at_end_static(const void *p)
Test if P is pointing at the end-pointer of a block.
Very simple allocator for use with pointer_list.
bool at_end(const void *p) const
Test if P is pointing at the end-pointer of a block.
void nextblock()
Extend the list with another block.
list_block * getblock()
Allocate a new block.
iterator end()
Iterator at the end of the container.
static const unsigned long END_OFFS
Verify that NELT is one less than a power of two.
iterator operator++(int)
Advance (post-increment).
allocator(size_t nblock=100)
Constructor.
allocator & m_pool
The list allocator.
size_t m_size
The current list size.
pointer_list_base(pool_type &pool)
Constructor. pool gives the allocator for this container.
list_block::value_type value_type
The stored element type.
iterator begin()
Iterator at the beginning of the container.
unsigned long m_end_offs
Offset for testing for an end pointer.
size_t nelt() const
Return the number of pointers per block (excluding the end-pointer).
value_type * m_p
Current iteration position.
allocator(size_t nelt, size_t nblock, unsigned long end_mask, unsigned long end_offs)
Constructor.
list_block * allocate()
Allocate a new block.
bool operator!=(const iterator &other) const
Inequality comparison.
chunk * m_chunks
Most recent chunk allocated.
size_t m_nchunks
Current number of allocated chunks.
A fast way to store a variable-sized collection of pointers.
void push_back(value_type p)
Add a new element to the end of the container. O(1)
allocator pool_type
Alias for allocator.
A fast way to store a variable-sized collection of pointers.
One memory allocation chunk.
void erase(iterator it)
Erase one element. O(n)
Allocator for pointer_list, specialized for NELT.
iterator(value_type *p)
Constructor, from a pointer into a pointer_list.
size_t size() const
The current size of the container. O(1).
Forward iterator over the list.
size_t m_nthis
Number of blocks allocated so far from that chunk.
size_t nchunks() const
Return the current number of allocated chunks.
void firstblock()
Allocate the first block of the list.
static const unsigned long END_MASK
list_block * m_blocks
Pointer to the first block contained within this chunk.
bool empty() const
Test to see if the container is empty.
std::ptrdiff_t difference_type
chunk * m_next
Link to the next chunk.
iterator & operator++()
Advance (pre-increment).
~allocator()
Destructor. Deletes all blocks from this allocator.
static size_t size(size_t nelt)
Size in bytes of a block holding nelt elements (excluding the end-pointer).