ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
KnuthSearches.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File KnuthSearches.h --------------------------*/
3/*--------------------------------------------------------------------------*/
46/*--------------------------------------------------------------------------*/
47/*----------------------------- DEFINITIONS --------------------------------*/
48/*--------------------------------------------------------------------------*/
49
50#ifndef __ADS_KnuthSearches
51 #define __ADS_KnuthSearches
52/* self-identification: #endif constant */
53
54/*--------------------------------------------------------------------------*/
55/*------------------------------ INCLUDES ----------------------------------*/
56/*--------------------------------------------------------------------------*/
57
58#include "ADS/Contract.h"
59
60#include <algorithm>
61#include <cstddef>
62#include <vector>
63
64/*--------------------------------------------------------------------------*/
65/*--------------------------- NAMESPACE ------------------------------------*/
66/*--------------------------------------------------------------------------*/
67
68namespace ADS
69{
70
98template< class T >
99long fibonacciSearch( const std::vector< T > & A , const T & v ,
100 long * cmp = nullptr );
101
127template< class T >
128long uniformBinarySearch( const std::vector< T > & A , const T & v ,
129 long * cmp = nullptr );
130
131/*--------------------------------------------------------------------------*/
132
133} // end( namespace ADS )
134
135/*--------------------------------------------------------------------------*/
136/*-------------------------- IMPLEMENTATION --------------------------------*/
137/*--------------------------------------------------------------------------*/
138
139#include "ADS/search/impl/KnuthSearches.tpp"
140
141/*--------------------------------------------------------------------------*/
142
143#endif /* KnuthSearches.h included */
144
145/*--------------------------------------------------------------------------*/
146/*------------------------ End File KnuthSearches.h ------------------------*/
147/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
long fibonacciSearch(const std::vector< T > &A, const T &v, long *cmp=nullptr)
the Fibonacci search of in the sorted : its place, or -1; the comparisons go to *cmp,...
long uniformBinarySearch(const std::vector< T > &A, const T &v, long *cmp=nullptr)
the uniform binary search of in the sorted : its place, or -1; the comparisons go to *cmp,...
Definition ADT.h:96