libwordring
公開型 | 公開メンバ関数 | 限定公開型 | 限定公開メンバ関数 | フレンド | 全メンバ一覧
wordring::detail::basic_atom< String, Allocator > クラステンプレート

文字列アトム [詳解]

#include <wordring/string/atom.hpp>

wordring::detail::basic_atom< String, Allocator > の継承関係図
wordring::detail::const_trie_iterator< Label, Base >

公開型

using string_type = String
 
using label_type = typename string_type::value_type
 
- 基底クラス wordring::detail::const_trie_iterator< Label, Base > に属する継承公開型
using difference_type = std::ptrdiff_t
 
using value_type = Label
 
using pointer = value_type *
 
using reference = value_type &
 
using iterator_category = std::input_iterator_tag
 

公開メンバ関数

 basic_atom ()
 空のアトムを構築する [詳解]
 
 operator std::uint32_t () const
 アトムをIDに変換する [詳解]
 
 operator string_type () const
 アトムを文字列に変換する [詳解]
 
string_type & string (string_type &result) const
 アトムを文字列に変換する [詳解]
 
- 基底クラス wordring::detail::const_trie_iterator< Label, Base > に属する継承公開メンバ関数
value_type operator* () const
 
const_trie_iterator operator[] (value_type label) const
 ラベルで遷移できる子を返す [詳解]
 
const_trie_iteratoroperator++ ()
 
const_trie_iterator operator++ (int)
 
template<typename String >
void string (String &result) const
 根からイテレータが指すノードまでのラベル列を返す [詳解]
 
const_trie_iterator parent () const
 親を取得する [詳解]
 
const_trie_iterator begin () const
 
const_trie_iterator end () const
 

限定公開型

using base_type = typename stable_trie< typename String::value_type >::const_iterator
 
- 基底クラス wordring::detail::const_trie_iterator< Label, Base > に属する継承限定公開型
using base_type = Base
 
using unsigned_type = std::make_unsigned_t< Label >
 

限定公開メンバ関数

 basic_atom (base_type it)
 アトムを構築する [詳解]
 
 basic_atom (container const &c, index_type idx)
 アトムを構築する [詳解]
 
- 基底クラス wordring::detail::const_trie_iterator< Label, Base > に属する継承限定公開メンバ関数
 const_trie_iterator (container &c, index_type index)
 
 const_trie_iterator (base_type const &it)
 

フレンド

template<typename String1 , typename Allocator1 >
class wordring::basic_atom_set
 
template<typename String1 , typename Allocator1 >
bool operator== (basic_atom< String1, Allocator1 > const &, basic_atom< String1, Allocator1 > const &)
 
template<typename String1 , typename Allocator1 >
bool operator!= (basic_atom< String1, Allocator1 > const &, basic_atom< String1, Allocator1 > const &)
 

その他の継承メンバ

- 基底クラス wordring::detail::const_trie_iterator< Label, Base > に属する継承静的公開変数類
static constexpr std::uint16_t null_value = 256u
 
static constexpr std::uint32_t coefficient = sizeof(value_type) / sizeof(typename base_type::value_type)
 

詳解

template<typename String, typename Allocator = std::allocator<detail::trie_node>>
class wordring::detail::basic_atom< String, Allocator >

文字列アトム

このクラスの実体は整数値と文字列を返す。 この文字列と整数値は一対一に対応する。

参照
wordring::basic_atom_set

構築子と解体子

◆ basic_atom() [1/3]

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
wordring::detail::basic_atom< String, Allocator >::basic_atom ( base_type  it)
inlineprotected

アトムを構築する

引数
[in]it基本クラスのイテレータ

◆ basic_atom() [2/3]

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
wordring::detail::basic_atom< String, Allocator >::basic_atom ( container const &  c,
index_type  idx 
)
inlineprotected

アトムを構築する

引数
[in]cダブル・アレイの内部コンテナ
[in]idxノードの索引

◆ basic_atom() [3/3]

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
wordring::detail::basic_atom< String, Allocator >::basic_atom ( )
inline

空のアトムを構築する

// 空のアトムを構築する
basic_atom<std::string> a;

関数詳解

◆ operator std::uint32_t()

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
wordring::detail::basic_atom< String, Allocator >::operator std::uint32_t ( ) const
inline

アトムをIDに変換する

戻り値
アトムが文字列を持つ場合、IDを示す整数値、それ以外の場合0

アトムのIDが0になることは無いため、0を無効な値として使用する。

// コンテナを構築する
std::vector<std::u32string> v{ U"あ", U"あう", U"い", U"うあい", U"うえ" };
auto as = basic_atom_set<std::u32string>(v.begin(), v.end());
// コンテナからアトムを取得する
auto a = as.at(U"い");
// アトムをIDに変換する
auto i = static_cast<std::uint32_t>(a);
// 検証
assert(i != 0);

◆ operator string_type()

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
wordring::detail::basic_atom< String, Allocator >::operator string_type ( ) const
inline

アトムを文字列に変換する

戻り値
アトムが文字列を持つ場合、その文字列、それ以外の場合、空の文字列
// コンテナを構築する
std::vector<std::u32string> v{ U"あ", U"あう", U"い", U"うあい", U"うえ" };
auto as = basic_atom_set<std::u32string>(v.begin(), v.end());
// コンテナからアトムを取得する
auto a = as.at(U"い");
// アトムを文字列に変換する
auto s = static_cast<std::u32string>(a);
// 検証
assert(s == U"い");

◆ string()

template<typename String , typename Allocator = std::allocator<detail::trie_node>>
string_type& wordring::detail::basic_atom< String, Allocator >::string ( string_type &  result) const
inline

アトムを文字列に変換する

引数
[out]result文字列を書き込むバッファ
戻り値
アトムが文字列を持つ場合、その文字列、それ以外の場合、何もしない

バッファが十分であれば文字列を書き込むためのメモリーを確保しないため、繰り返し呼び出すための最速の方法となる。

// コンテナを構築する
std::vector<std::u32string> v{ U"あ", U"あう", U"い", U"うあい", U"うえ" };
auto as = basic_atom_set<std::u32string>(v.begin(), v.end());
// コンテナからアトムを取得する
auto a = as.at(U"い");
std::u32string s;
// アトムを文字列に変換する
a.string(s);
// 検証
assert(s == U"い");

このクラス詳解は次のファイルから抽出されました: