9#ifndef MCRL2_UTILITIES_DETAIL_FREELIST_H_
10#define MCRL2_UTILITIES_DETAIL_FREELIST_H_
30template<
typename Element>
36 static constexpr std::uintptr_t
FreeListSentinel = std::numeric_limits<std::uintptr_t>::max();
75 template<
bool Constant = true>
80 using tag = std::input_iterator_tag;
84 using reference =
typename std::conditional<Constant, const Element&, Element&>::type;
85 using slot_pointer =
typename std::conditional<Constant, const slot*, slot*>::type;
109 template<
bool Constant_ = Constant>
110 typename std::enable_if<!Constant_, reference>::type
operator*()
115 template<
bool Constant_ = Constant>
116 typename std::enable_if<Constant_, reference>::type
operator*()
const
123 return m_slot != it.m_slot;
164 slot* current_node = it.get_node();
165 assert(current_node->
next() !=
nullptr);
168 slot* erased_node = current_node->
next();
169 slot* next_node = erased_node->
next();
172 current_node->
next(next_node);
183 for (
auto it =
begin(); it !=
end(); ++it)
197 std::size_t length = 0;
198 for (
auto it =
begin(); it !=
end(); ++it)
208 for (
auto it =
begin(); it !=
end();)
210 slot* current_slot = it.get_slot();
212 current_slot->
mark();
229 current.
next(&element);
252 position.
get_slot()->next(last.get_slot());
Iterator over all keys in a bucket list.
typename std::conditional< Constant, const free_list< Element >, free_list< Element > >::type Freelist
static constexpr Sentinel EndIterator
A end of the iterator sentinel.
slot_iterator(Freelist &list)
bool operator!=(const slot_iterator &it) const noexcept
std::input_iterator_tag tag
slot_iterator(slot_pointer slot)
std::enable_if< Constant_, reference >::type operator*() const
typename std::conditional< Constant, const slot *, slot * >::type slot_pointer
slot_iterator & operator++()
std::enable_if<!Constant_, reference >::type operator*()
typename std::conditional< Constant, const Element &, Element & >::type reference
This essentially implements the std::forward_list, with the difference that it does not own the nodes...
bool empty() const noexcept
void clear()
Empties the bucket list.
void erase_after(iterator position, iterator last)
Erases elements in the range (position, last], constant complexity since no destructors will be calle...
bool contains(Element *pointer)
slot_iterator< false > iterator
static constexpr std::uintptr_t FreeListSentinel
A sentinel value for the next of a slot to indicate that it belonged to the freelist.
void push_front(slot &slot)
Puts the given node before the head of the list.
const_iterator before_begin() const
slot m_head
The first node in the bucket list.
const_iterator begin() const
slot_iterator< true > const_iterator
iterator erase_after(iterator it)
Removes the element after the given iterator from the list. The returned iterator.
Element & pop_front()
Removes the head of the list and returns a reference to this head slot.
void destructive_mark()
Mark all elements in this list with a special value, destroys the list.
slot & head() noexcept
Provides access to the head as if it was an actual slot.
iterator insert_after(iterator it, slot &element)
Inserts an element at the position after the iterator.
const_iterator end() const
const slot & head() const noexcept
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
The nodes of the free list without.
slot * m_next
Pointer to the next node.
void next(slot *next) noexcept
Set the next pointer to the given next pointer.
Element & element() noexcept
slot * next() const noexcept
bool is_marked() const noexcept
Element m_element
Store the actual element.
bool has_next() const noexcept
void mark()
Mark this slot with a special value, destroys the slot.