#ifndef DARTS_H_
#define DARTS_H_
#include <cstdio>
#include <exception>
#include <new>
#if DARTS_DISABLE_EXCEPTIONS
#include "absl/log/absl_check.h"
#endif
#define DARTS_VERSION …
#define DARTS_INT_TO_STR …
#define DARTS_LINE_TO_STR …
#define DARTS_LINE_STR …
#if DARTS_DISABLE_EXCEPTIONS
#define DARTS_THROW …
#else
#define DARTS_THROW …
#endif
namespace Darts {
namespace Details {
char_type;
uchar_type;
value_type;
id_type;
progress_func_type;
class DoubleArrayUnit { … };
#if !DARTS_DISABLE_EXCEPTIONS
class Exception : public std::exception {
public:
explicit Exception(const char* msg = NULL) throw() : msg_(msg) {}
Exception(const Exception& rhs) throw() : msg_(rhs.msg_) {}
virtual ~Exception() throw() {}
virtual const char* what() const throw() {
return (msg_ != NULL) ? msg_ : "";
}
private:
const char* msg_;
Exception& operator=(const Exception&);
};
#endif
}
template <typename, typename, typename T, typename>
class DoubleArrayImpl { … };
DoubleArray;
template <typename A, typename B, typename T, typename C>
int DoubleArrayImpl<A, B, T, C>::open(const char* file_name,
const char* mode,
std::size_t offset,
std::size_t size) { … }
template <typename A, typename B, typename T, typename C>
int DoubleArrayImpl<A, B, T, C>::save(const char* file_name,
const char* mode,
std::size_t) const { … }
template <typename A, typename B, typename T, typename C>
template <typename U>
inline U DoubleArrayImpl<A, B, T, C>::exactMatchSearch(
const key_type* key,
std::size_t length,
std::size_t node_pos) const { … }
template <typename A, typename B, typename T, typename C>
template <typename U>
inline std::size_t DoubleArrayImpl<A, B, T, C>::commonPrefixSearch(
const key_type* key,
U* results,
std::size_t max_num_results,
std::size_t length,
std::size_t node_pos) const { … }
template <typename A, typename B, typename T, typename C>
inline typename DoubleArrayImpl<A, B, T, C>::value_type
DoubleArrayImpl<A, B, T, C>::traverse(const key_type* key,
std::size_t& node_pos,
std::size_t& key_pos,
std::size_t length) const { … }
namespace Details {
template <typename T>
class AutoArray { … };
template <typename T>
class AutoPool { … };
template <typename T>
void AutoPool<T>::resize_buf(std::size_t size) { … }
template <typename T>
class AutoStack { … };
class BitVector { … };
inline void BitVector::build() { … }
template <typename T>
class Keyset { … };
class DawgNode { … };
class DawgUnit { … };
class DawgBuilder { … };
inline void DawgBuilder::init() { … }
inline void DawgBuilder::finish() { … }
inline void DawgBuilder::insert(const char* key,
std::size_t length,
value_type value) { … }
inline void DawgBuilder::clear() { … }
inline void DawgBuilder::flush(id_type id) { … }
inline void DawgBuilder::expand_table() { … }
inline id_type DawgBuilder::find_unit(id_type id, id_type* hash_id) const { … }
inline id_type DawgBuilder::find_node(id_type node_id, id_type* hash_id) const { … }
inline bool DawgBuilder::are_equal(id_type node_id, id_type unit_id) const { … }
inline id_type DawgBuilder::hash_unit(id_type id) const { … }
inline id_type DawgBuilder::hash_node(id_type id) const { … }
inline id_type DawgBuilder::append_unit() { … }
inline id_type DawgBuilder::append_node() { … }
class DoubleArrayBuilderUnit { … };
class DoubleArrayBuilderExtraUnit { … };
class DoubleArrayBuilder { … };
template <typename T>
void DoubleArrayBuilder::build(const Keyset<T>& keyset) { … }
inline void DoubleArrayBuilder::copy(std::size_t* size_ptr,
DoubleArrayUnit** buf_ptr) const { … }
inline void DoubleArrayBuilder::clear() { … }
template <typename T>
void DoubleArrayBuilder::build_dawg(const Keyset<T>& keyset,
DawgBuilder* dawg_builder) { … }
inline void DoubleArrayBuilder::build_from_dawg(const DawgBuilder& dawg) { … }
inline void DoubleArrayBuilder::build_from_dawg(const DawgBuilder& dawg,
id_type dawg_id,
id_type dic_id) { … }
inline id_type DoubleArrayBuilder::arrange_from_dawg(const DawgBuilder& dawg,
id_type dawg_id,
id_type dic_id) { … }
template <typename T>
void DoubleArrayBuilder::build_from_keyset(const Keyset<T>& keyset) { … }
template <typename T>
void DoubleArrayBuilder::build_from_keyset(const Keyset<T>& keyset,
std::size_t begin,
std::size_t end,
std::size_t depth,
id_type dic_id) { … }
template <typename T>
id_type DoubleArrayBuilder::arrange_from_keyset(const Keyset<T>& keyset,
std::size_t begin,
std::size_t end,
std::size_t depth,
id_type dic_id) { … }
inline id_type DoubleArrayBuilder::find_valid_offset(id_type id) const { … }
inline bool DoubleArrayBuilder::is_valid_offset(id_type id,
id_type offset) const { … }
inline void DoubleArrayBuilder::reserve_id(id_type id) { … }
inline void DoubleArrayBuilder::expand_units() { … }
inline void DoubleArrayBuilder::fix_all_blocks() { … }
inline void DoubleArrayBuilder::fix_block(id_type block_id) { … }
}
template <typename A, typename B, typename T, typename C>
int DoubleArrayImpl<A, B, T, C>::build(
std::size_t num_keys,
const key_type* const* keys,
const std::size_t* lengths,
const value_type* values,
Details::progress_func_type progress_func) { … }
}
#undef DARTS_INT_TO_STR
#undef DARTS_LINE_TO_STR
#undef DARTS_LINE_STR
#undef DARTS_THROW
#endif