snippets 0.1.0
Loading...
Searching...
No Matches
hsc_snippets::MonotonicStack< T, Comparator > Class Template Reference

#include <monotonic_stack.hpp>

Public Member Functions

std::optional< T > push (const T &value)
 
const T & top () const
 
bool empty () const
 

Detailed Description

template<typename T, typename Comparator>
class hsc_snippets::MonotonicStack< T, Comparator >

A stack that maintains a monotonic order based on a comparator.

Template Parameters
TThe type of elements in the stack.
ComparatorThe comparator that defines the monotonic order.

Member Function Documentation

◆ empty()

template<typename T , typename Comparator >
bool hsc_snippets::MonotonicStack< T, Comparator >::empty ( ) const
inline

Checks if the stack is empty.

Returns
True if the stack is empty, false otherwise.

◆ push()

template<typename T , typename Comparator >
std::optional< T > hsc_snippets::MonotonicStack< T, Comparator >::push ( const T & value)
inline

Pushes a value onto the stack. Values not meeting the monotonic condition are popped.

Parameters
valueThe value to be pushed.
Returns
The previous top value that meets the monotonic condition, if any.

◆ top()

template<typename T , typename Comparator >
const T & hsc_snippets::MonotonicStack< T, Comparator >::top ( ) const
inline

Returns the top value of the stack.

Returns
The top value of the stack.

The documentation for this class was generated from the following file: