libime
Public Types | Public Member Functions | Static Public Member Functions | List of all members
libime::DATrie< T > Class Template Reference

This is a trie based on cedar<www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar/>. More...

#include <libime/core/datrie.h>

Public Types

enum  { LIBIMECORE_DEPRECATED = NaN<value_type>::N1, LIBIMECORE_DEPRECATED = NaN<value_type>::N1 }
 
using value_type = T
 
using position_type = uint64_t
 
using callback_type = std::function< bool(value_type, size_t, position_type)>
 
using updater_type = std::function< value_type(value_type)>
 

Public Member Functions

 DATrie (const char *filename)
 
 DATrie (std::istream &in)
 
void load (std::istream &in)
 
void save (const char *filename)
 
void save (std::ostream &stream)
 
size_t size () const
 
bool empty () const
 
void suffix (std::string &s, size_t len, position_type pos) const
 
value_type exactMatchSearch (const char *key, size_t len) const
 
value_type exactMatchSearch (std::string_view key) const
 
int32_t exactMatchSearchRaw (const char *key, size_t len) const
 
int32_t exactMatchSearchRaw (std::string_view key) const
 
bool hasExactMatch (std::string_view key) const
 
DATrie< T >::value_type traverse (std::string_view key, position_type &from) const
 
DATrie< T >::value_type traverse (const char *key, size_t len, position_type &from) const
 
int32_t traverseRaw (std::string_view key, position_type &from) const
 
int32_t traverseRaw (const char *key, size_t len, position_type &from) const
 
void set (std::string_view key, value_type val)
 
void set (const char *key, size_t len, value_type val)
 
void update (std::string_view key, updater_type updater)
 
void update (const char *key, size_t len, updater_type updater)
 
void dump (value_type *data, std::size_t size) const
 
void dump (std::vector< value_type > &data) const
 
void dump (std::vector< std::tuple< value_type, size_t, position_type >> &data) const
 
bool erase (std::string_view key, position_type from=0)
 
bool erase (const char *key, size_t len, position_type from=0)
 
bool erase (position_type from=0)
 
bool foreach (callback_type func, position_type pos=0) const
 
bool foreach (const char *prefix, size_t size, callback_type func, position_type pos=0) const
 
bool foreach (std::string_view prefix, callback_type func, position_type pos=0) const
 
void clear ()
 
void shrink_tail ()
 
size_t mem_size () const
 

Static Public Member Functions

static bool isValid (value_type v)
 
static bool isNoPath (value_type v)
 
static bool isNoValue (value_type v)
 
static bool isValidRaw (int32_t v)
 
static bool isNoPathRaw (int32_t v)
 
static bool isNoValueRaw (int32_t v)
 
static value_type noPath ()
 
static value_type noValue ()
 
static value_type decode (int32_t raw)
 

Detailed Description

template<typename T>
class libime::DATrie< T >

This is a trie based on cedar<www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar/>.

comparing with original version, this version takes care of endianness when doing serialization, and handle the possible unaligned memory access on some platform.

It also exploits the C++11 feature which can let you implement update easily with lambda, comparing with the original version's add/set.

Definition at line 55 of file datrie.h.


The documentation for this class was generated from the following files: