57#ifndef __ADS_SetInterfaces
58 #define __ADS_SetInterfaces
89concept USet =
requires( S s ,
const S cs ,
const typename S::Item & x )
92 { cs.size() } -> std::convertible_to< std::size_t >;
93 { s.insert( x ) } -> std::same_as< bool >;
94 { s.remove( x ) } -> std::same_as< bool >;
95 { cs.find( x ) } -> std::convertible_to< const typename S::Item * >;
101 USet< S > &&
requires(
const S cs ,
const typename S::Item & x )
103 { cs.lowerBound( x ) } -> std::convertible_to< const typename S::Item * >;
111 requires( D d ,
const typename D::Key & k ,
const typename D::Value & v )
115 { d.findKey( k ) } -> std::convertible_to< const typename D::Key * >;
126 { d.lowerBoundKey( k ) } -> std::convertible_to< const typename D::Key * >;
134template<
class T ,
class Eq = std::equal_to<> >
143 explicit ArrayUSet( Eq eq = Eq() ) : f_eq( std::move( eq ) ) { }
146 [[nodiscard]] std::size_t
size(
void )
const {
return( f_A.size() ); }
149 [[nodiscard]]
const T *
find(
const T & x )
const;
175 [[nodiscard]]
const std::vector< T > &
items(
void )
const {
return( f_A ); }
179 std::vector< T > f_A;
189template<
class T ,
class C = std::less<> >
198 explicit ArraySSet( C less = C() ) : f_less( std::move( less ) ) { }
201 [[nodiscard]] std::size_t
size(
void )
const {
return( f_A.size() ); }
204 [[nodiscard]]
const T *
find(
const T & x )
const;
236 [[nodiscard]]
const std::vector< T > &
items(
void )
const {
return( f_A ); }
241 [[nodiscard]]
bool sorted(
void )
const;
243 std::vector< T > f_A;
256#include "ADS/set/impl/SetInterfaces.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The primitives of the processor that the compilers spell each in their own way, in one form for all: ...
bool insert(const T &x)
added in its place if no item equal to it is there, the items after it moved by one place,...
T Item
the type of the items
Definition SetInterfaces.h:195
bool remove(const T &x)
the item equal to removed, ; true if there was one
const std::vector< T > & items(void) const
the items, increasing
Definition SetInterfaces.h:236
std::size_t size(void) const
the number of items
Definition SetInterfaces.h:201
const T * lowerBound(const T &x) const
the least item not smaller than , nil if none, by binary search in (Morin's find( x ) of an SSet)
const T * find(const T &x) const
the item equal to , nil if none,
ArraySSet(C less=C())
the empty set
Definition SetInterfaces.h:198
bool insert(const T &x)
added if no item equal to it is there, ; true if added
const T * find(const T &x) const
the item equal to , nil if none,
ArrayUSet(Eq eq=Eq())
the empty set
Definition SetInterfaces.h:143
bool remove(const T &x)
the item equal to removed, the last one moved into its place, ; true if there was one
T Item
the type of the items
Definition SetInterfaces.h:140
const std::vector< T > & items(void) const
the items, in no order
Definition SetInterfaces.h:175
std::size_t size(void) const
the number of items
Definition SetInterfaces.h:146
a dictionary that gives the address of the key equal to the one asked, on which DictionarySet is a US...
Definition SetInterfaces.h:110
a KeyedDictionary that gives the address of the smallest key not smaller than the one asked,...
Definition SetInterfaces.h:123
the sorted set of Morin, a USet with the successor search
Definition SetInterfaces.h:100
the unordered set of Morin, whose find() gives the item equal to the one asked
Definition SetInterfaces.h:89
#define ADS_NO_UNIQUE_ADDRESS
an empty member that takes no storage, by the attribute that does so (the standard one is accepted bu...
Definition Portable.h:81