Program Listing for File TwoLevelDictionary.h
↰ Return to documentation for file (ADS/dictionary/TwoLevelDictionary.h)
/*--------------------------------------------------------------------------*/
/*----------------------- File TwoLevelDictionary.h ------------------------*/
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*----------------------------- DEFINITIONS --------------------------------*/
/*--------------------------------------------------------------------------*/
#ifndef __ADS_TwoLevelDictionary
#define __ADS_TwoLevelDictionary
/* self-identification: #endif constant */
/*--------------------------------------------------------------------------*/
/*------------------------------ INCLUDES ----------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/Contract.h"
#include "ADS/dictionary/PatriciaTrie.h"
#include "ADS/string/FrontCoding.h"
#include <cstddef>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
/*--------------------------------------------------------------------------*/
/*--------------------------- NAMESPACE ------------------------------------*/
/*--------------------------------------------------------------------------*/
namespace ADS {
/*--------------------------------------------------------------------------*/
/*----------------------- CLASS TwoLevelDictionary -------------------------*/
/*--------------------------------------------------------------------------*/
class TwoLevelDictionary {
/*--------------------------------------------------------------------------*/
public:
explicit TwoLevelDictionary( FrontCodedDictionary F );
[[nodiscard]] std::size_t lexicographicPosition( std::string_view Q ) const;
[[nodiscard]] std::size_t prefixEnd( std::string_view P ) const;
[[nodiscard]] std::pair< std::size_t , std::size_t > prefixRange(
std::string_view P ) const;
[[nodiscard]] std::string access( std::size_t i ) const;
[[nodiscard]] std::size_t size( void ) const;
[[nodiscard]] const PatriciaTrie & upper( void ) const;
[[nodiscard]] const FrontCodedDictionary & lower( void ) const;
/*------------------------- THE STANDARD INTERFACE -------------------------*/
// the strings in their order, those of the lower level
using value_type = std::string;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using reference = const std::string &;
using const_reference = const std::string &;
using const_iterator = FrontCodedDictionary::const_iterator;
using iterator = const_iterator;
[[nodiscard]] const_iterator begin( void ) const { return( f_F.begin() ); }
[[nodiscard]] const_iterator end( void ) const { return( f_F.end() ); }
[[nodiscard]] const_iterator cbegin( void ) const { return( begin() ); }
[[nodiscard]] const_iterator cend( void ) const { return( end() ); }
/*--------------------------------------------------------------------------*/
private:
[[nodiscard]] static std::vector< std::string > anchorsOf(
const FrontCodedDictionary & F );
FrontCodedDictionary f_F;
PatriciaTrie f_T;
}; // end( class TwoLevelDictionary )
/*--------------------------------------------------------------------------*/
} // end( namespace ADS )
/*--------------------------------------------------------------------------*/
/*-------------------------- IMPLEMENTATION --------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/dictionary/impl/TwoLevelDictionary.tpp"
/*--------------------------------------------------------------------------*/
#endif /* TwoLevelDictionary.h included */
/*--------------------------------------------------------------------------*/
/*--------------------- End File TwoLevelDictionary.h ----------------------*/
/*--------------------------------------------------------------------------*/