103#ifndef __ADS_StaticSearch
104 #define __ADS_StaticSearch
123#include <type_traits>
155template<
class T ,
class C = std::less<> >
164template<
class T ,
class Less = std::less< T > , std::
size_t Bytes = 64 >
165 requires std::is_trivially_copyable_v< T >
174 static constexpr std::size_t
B =
175 sizeof( T ) <= Bytes ? std::max< std::size_t >( Bytes /
sizeof( T ) , 2 )
201 explicit SPlusTree(
const std::vector< T > & A , Less less = Less() );
246 [[nodiscard]] std::size_t
size(
void )
const;
249 [[nodiscard]]
bool empty(
void )
const;
256 static constexpr bool FAST =
257 std::is_arithmetic_v< T > && ( std::is_same_v< Less , std::less< T > > ||
258 std::is_same_v< Less , std::less<> > );
260 [[nodiscard]]
static constexpr T pad(
void ) {
261 if constexpr( std::numeric_limits< T >::has_infinity )
262 return( std::numeric_limits< T >::infinity() );
264 return( std::numeric_limits< T >::max() );
269 [[nodiscard]]
static T * allocate( std::size_t n );
274 void operator()( T * p )
const noexcept {
275 if( n *
sizeof( T ) >= HUGE_BYTES )
278 ::operator
delete( p , std::align_val_t( 64 ) );
282 static constexpr std::size_t HUGE_BYTES = std::size_t( 1 ) << 21;
287 [[nodiscard]] std::size_t count(
const T * a ,
const T & v ,
288 std::size_t m )
const;
291 [[nodiscard]] std::size_t search(
const T & v )
const;
293 void layout(
const std::vector< T > & A );
295 std::vector< std::size_t > f_size;
297 std::unique_ptr< T[] , Free > f_a;
298 std::vector< std::size_t > f_off;
299 std::size_t f_items = 0;
313#include "ADS/search/impl/StaticSearch.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The count of the items of a short array smaller than a key, the search in a node of the B-trees in ma...
An allocator for the large blocks of a structure, beyond the book: a request of at least one huge pag...
The primitives of the processor that the compilers spell each in their own way, in one form for all: ...
The prefetch of a line of the cache, beyond the book: ADS::prefetch( p ) asks the processor to bring ...
an allocator of objects of type T, on huge pages for the large blocks
Definition HugePageAllocator.h:169
void deallocate(T *p, std::size_t n) noexcept
the room of objects given back: kept by the thread if it is of 8 MB or more and the cache has room,...
Definition HugePageAllocator.h:221
std::size_t upperBound(const T &v) const
the first place of an item larger than , size() if none
std::size_t lowerBound(const T &v) const
the first place of an item not smaller than , size() if none
const T & operator[](std::size_t i) const
the item of place , in the sorted order
T Item
the type of the items
Definition StaticSearch.h:171
SPlusTree(SPlusTree &&o) noexcept=default
the tree , moved
std::size_t size(void) const
the number of the items
static constexpr std::size_t B
the items of a node, a line of cache
Definition StaticSearch.h:174
SPlusTree(const SPlusTree &o)
a copy of the tree
int height(void) const
the levels, the leaves included
SPlusTree(void)=default
an empty tree
bool empty(void) const
true if there are no items
SPlusTree & operator=(SPlusTree o) noexcept
the tree , assigned by a swap
SPlusTree(const std::vector< T > &A, Less less=Less())
the tree on the sorted items of , in
bool contains(const T &v) const
true if is an item, by lowerBound( v )
#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
std::size_t branchlessLowerBound(const std::vector< T > &A, const T &v, C less=C())
the first place of an item not smaller than in the sorted , if none, by the binary search with no b...