omni::graph::exec::unstable::detail::SmallStack

Defined in omni/graph/exec/unstable/SmallStack.h

template<typename T = uint64_t>
class SmallStack

ABI-aware stack with inline memory to avoid heap allocation.

Reserved memory within the stack will be used until it is exceeded, at which heap memory will be used.

It is assumed the items stored are sizeof(uint64_t).

This class can safely be passed by pointer across the ABI. However, since it is not a trivial type, it cannot be passed by value across the ABI. See OMNI_STATIC_ASSERT_CAN_BE_PASSED_BY_VALUE_IN_ABI for details.

Public Types

using ItemType = T

Type of the item in the stack.

Public Functions

inline SmallStack() noexcept

Constructor.

inline SmallStack(ItemType item) noexcept

Constructor with a single item.

inline SmallStack(const SmallStack &other) noexcept

Copy constructor.

inline SmallStack(ItemType *begin, ItemType *end) noexcept

Construct from a range.

end must be equal or greater than begin.

inline SmallStack(const SmallStack &other, ItemType item) noexcept

Copies the contents of the given stack and pushes the given item.

inline SmallStack(SmallStack &&other) noexcept

Move constructor.

inline ~SmallStack() noexcept

Destructor.

inline SmallStack &operator=(const SmallStack &other) noexcept

Assignment operator.

inline SmallStack &operator=(SmallStack &&other) noexcept

Assignment operator.

inline int compare(const SmallStack &other) const noexcept

Compares two stacks, returning either a negative number, positive number, or zero.

Works similar to std::memcmp.

Returns a negative value if this stack less than other.

Returns a positive value if this stack greater than other.

Returns zero if the stacks are equal.

The returned negative or positive values are not guaranteed to be exactly -1 or 1.

inline bool empty() const noexcept

Return true if the stack is empty.

inline ItemType top() const noexcept

Returns the top of the stack.

Reading the top of an empty stack is undefined behavior.

inline void push(ItemType elem) noexcept

Push the given item to the top of the stack.

inline void pop() noexcept

Removes the top of the stack.

Popping an empty stack is undefined behavior.

inline uint32_t count() const noexcept

Returns the number of items in the stack.

inline uint32_t size() const noexcept

Returns the number of items in the stack.

inline const ItemType *begin() const noexcept

Returns a pointer to the oldest item in the stack.

If the stack is empty, the returned pointer should not be read or written though can be compared to end().

inline const ItemType *end() const noexcept

Returns a pointer to one past the top of the stack.

If the stack is empty, the returned pointer should not be read or written though can be compared to begin().

inline const ItemType *data() const noexcept

Returns a pointer to the oldest item in the stack.

Result are undefined if the stack is empty.

Public Members

ExternalData m_external
InternalData m_internal