ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
StackAlgorithms.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File StackAlgorithms.h -------------------------*/
3/*--------------------------------------------------------------------------*/
56/*--------------------------------------------------------------------------*/
57/*----------------------------- DEFINITIONS --------------------------------*/
58/*--------------------------------------------------------------------------*/
59
60#ifndef __ADS_StackAlgorithms
61 #define __ADS_StackAlgorithms
62/* self-identification: #endif constant */
63
64/*--------------------------------------------------------------------------*/
65/*------------------------------ INCLUDES ----------------------------------*/
66/*--------------------------------------------------------------------------*/
67
68#include "ADS/ADT.h"
69#include "ADS/Contract.h"
71#include "ADS/sequence/List.h"
74
75#include <algorithm>
76#include <span>
77#include <string>
78#include <string_view>
79#include <vector>
80
81/*--------------------------------------------------------------------------*/
82/*--------------------------- NAMESPACE ------------------------------------*/
83/*--------------------------------------------------------------------------*/
84
85namespace ADS
86{
87
105inline bool isPalindrome( const std::string & s );
106
128template< Stack S >
129void sortStack( S & s );
130
149template< Stack S >
150void removeGreater( S & s , const typename S::Item & k );
151
167template< Stack S , class F >
168void forEachBottomUp( S & s , F && f );
169
188inline bool isDyckWord( std::span< const int > w );
189
209inline bool isMatched( std::string_view s );
210
226template< Stack S , Queue Q = LinkedQueue< typename S::Item > >
227void reverseWithQueue( S & s );
228
229/*--------------------------------------------------------------------------*/
230
231} // end( namespace ADS )
232
233/*--------------------------------------------------------------------------*/
234/*-------------------------- IMPLEMENTATION --------------------------------*/
235/*--------------------------------------------------------------------------*/
236
237#include "ADS/stack/impl/StackAlgorithms.tpp"
238
239/*--------------------------------------------------------------------------*/
240
241#endif /* StackAlgorithms.h included */
242
243/*--------------------------------------------------------------------------*/
244/*----------------------- End File StackAlgorithms.h -----------------------*/
245/*--------------------------------------------------------------------------*/
The abstract data types of the book, as concepts of C++20: SEQUENCE, SET and DICTIONARY (chapter 3),...
The STACK of the book [see ADT.h] realized with a vector of a given capacity : the items are in the ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
A QUEUE [see ADT.h] realized as a singly linked list with a pointer to the first cell,...
The LIST of the book: a SEQUENCE [see ADT.h] realized as a bidirectional circular list of cells with ...
SequenceStack is the STACK [see ADT.h] simulated with the operations of any SEQUENCE,...
bool isMatched(std::string_view s)
whether , a string of the brackets (), [] and {}, is matched, in
void forEachBottomUp(S &s, F &&f)
f( x ) on each item , from the bottom to the top
void sortStack(S &s)
sorts with the least item on top
bool isPalindrome(const std::string &s)
whether reads the same from both ends
void reverseWithQueue(S &s)
the order of the items of reversed by a QUEUE, the only operations of being push() and pop()
void removeGreater(S &s, const typename S::Item &k)
removes the items larger than , the others in their order
bool isDyckWord(std::span< const int > w)
whether the sequence of and is a Dyck word, i.e., has no negative prefix sum
Definition ADT.h:96