ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
IndexedList.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File IndexedList.h ---------------------------*/
3/*--------------------------------------------------------------------------*/
44/*--------------------------------------------------------------------------*/
45/*----------------------------- DEFINITIONS --------------------------------*/
46/*--------------------------------------------------------------------------*/
47
48#ifndef __ADS_IndexedList
49 #define __ADS_IndexedList
50/* self-identification: #endif constant */
51
52/*--------------------------------------------------------------------------*/
53/*------------------------------ INCLUDES ----------------------------------*/
54/*--------------------------------------------------------------------------*/
55
56#include "ADS/Contract.h"
57
58#include <concepts>
59#include <cstddef>
60#include <numeric>
61#include <span>
62#include <utility>
63#include <vector>
64
65/*--------------------------------------------------------------------------*/
66/*--------------------------- NAMESPACE ------------------------------------*/
67/*--------------------------------------------------------------------------*/
68
69namespace ADS
70{
71
72/*--------------------------------------------------------------------------*/
73/*-------------------------------- CONCEPTS --------------------------------*/
74/*--------------------------------------------------------------------------*/
75
78template< class L >
79concept IndexedList = requires( L l , const L cl , std::size_t i ,
80 const typename L::value_type & x )
81{
82 typename L::value_type;
83 { cl.size() } -> std::convertible_to< std::size_t >;
84 { l[ i ] } -> std::convertible_to< const typename L::value_type & >;
85 l.insert( i , x );
86 l.erase( i );
87 };
88
90template< class D >
91concept IndexedDeque = requires( D d , const typename D::value_type & x )
92{
93 typename D::value_type;
94 { d.size() } -> std::convertible_to< std::size_t >;
95 d.push_front( x );
96 d.push_back( x );
97 d.pop_front();
98 d.pop_back();
99 d.front();
100 d.back();
101 };
102
103/*--------------------------------------------------------------------------*/
104/*------------------------------- FUNCTIONS --------------------------------*/
105/*--------------------------------------------------------------------------*/
106
123template< class T >
124void rotateArray( std::span< T > a , std::size_t r );
125
146template< IndexedList L >
147void rotate( L & l , std::size_t r );
148
149/*--------------------------------------------------------------------------*/
150
151} // end( namespace ADS )
152
153/*--------------------------------------------------------------------------*/
154/*-------------------------- IMPLEMENTATION --------------------------------*/
155/*--------------------------------------------------------------------------*/
156
157#include "ADS/sequence/impl/IndexedList.tpp"
158
159/*--------------------------------------------------------------------------*/
160
161#endif /* IndexedList.h included */
162
163/*--------------------------------------------------------------------------*/
164/*------------------------- End File IndexedList.h -------------------------*/
165/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
the DEQUE of Morin: a sequence changed and read at both ends
Definition IndexedList.h:91
the LIST of Morin: a sequence read, written, extended and shortened by rank
Definition IndexedList.h:79
void rotate(L &l, std::size_t r)
the item of rank of moved to the rank : the rotate() of the list if it has one, the cycles of the p...
void rotateArray(std::span< T > a, std::size_t r)
the item moved to , for every , by three reversals: swaps at most and space
Definition ADT.h:96