FST  openfst-1.8.3
OpenFst Library
symbol-table.h
Go to the documentation of this file.
1 // Copyright 2005-2024 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the 'License');
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an 'AS IS' BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 //
18 // Classes to provide symbol-to-integer and integer-to-symbol mappings.
19 
20 #ifndef FST_SYMBOL_TABLE_H_
21 #define FST_SYMBOL_TABLE_H_
22 
23 #include <sys/types.h>
24 
25 #include <cstddef>
26 #include <cstdint>
27 #include <functional>
28 #include <ios>
29 #include <iostream>
30 #include <istream>
31 #include <iterator>
32 #include <memory>
33 #include <ostream>
34 #include <sstream>
35 #include <string>
36 #include <type_traits>
37 #include <utility>
38 #include <vector>
39 
40 #include <fst/compat.h>
41 #include <fst/flags.h>
42 #include <fst/log.h>
43 #include <fstream>
44 #include <fst/windows_defs.inc>
45 #include <map>
46 #include <functional>
47 #include <string_view>
48 #include <fst/lock.h>
49 
50 DECLARE_bool(fst_compat_symbols);
51 DECLARE_string(fst_field_separator);
52 
53 namespace fst {
54 
55 inline constexpr int64_t kNoSymbol = -1;
56 
57 class SymbolTable;
58 
59 namespace internal {
60 
61 // Maximum line length in textual symbols file.
62 inline constexpr int kLineLen = 8096;
63 
64 // List of symbols with a dense hash for looking up symbol index, rehashing at
65 // 75% occupancy.
67  public:
69 
70  std::pair<int64_t, bool> InsertOrFind(std::string_view key);
71 
72  int64_t Find(std::string_view key) const;
73 
74  size_t Size() const { return symbols_.size(); }
75 
76  const std::string &GetSymbol(size_t idx) const { return symbols_[idx]; }
77 
78  void RemoveSymbol(size_t idx);
79 
80  void ShrinkToFit();
81 
82  private:
83  static constexpr int64_t kEmptyBucket = -1;
84 
85  // num_buckets must be power of 2.
86  void Rehash(size_t num_buckets);
87 
88  size_t GetHash(std::string_view key) const {
89  return str_hash_(key) & hash_mask_;
90  }
91 
92  const std::hash<std::string_view> str_hash_;
93  std::vector<std::string> symbols_;
94  std::vector<int64_t> buckets_;
95  uint64_t hash_mask_;
96 };
97 
98 // Base class for SymbolTable implementations.
99 // Use either MutableSymbolTableImpl or ConstSymbolTableImpl to derive
100 // implementation classes.
102  public:
103  SymbolTableImplBase() = default;
104  virtual ~SymbolTableImplBase() = default;
105 
106  // Enforce copying through Copy().
107  SymbolTableImplBase(const SymbolTableImplBase &) = delete;
108  SymbolTableImplBase &operator=(const SymbolTableImplBase &) = delete;
109 
110  virtual std::unique_ptr<SymbolTableImplBase> Copy() const = 0;
111 
112  virtual bool Write(std::ostream &strm) const = 0;
113 
114  virtual int64_t AddSymbol(std::string_view symbol, int64_t key) = 0;
115 
116  virtual int64_t AddSymbol(std::string_view symbol) = 0;
117 
118  // Removes the symbol with the specified key. Subsequent Find() calls
119  // for this key will return the empty string. Does not affect the keys
120  // of other symbols.
121  virtual void RemoveSymbol(int64_t key) = 0;
122 
123  // Returns the symbol for the specified key, or the empty string if not found.
124  virtual std::string Find(int64_t key) const = 0;
125 
126  // Returns the key for the specified symbol, or kNoSymbol if not found.
127  virtual int64_t Find(std::string_view symbol) const = 0;
128 
129  virtual bool Member(int64_t key) const { return !Find(key).empty(); }
130 
131  virtual bool Member(std::string_view symbol) const {
132  return Find(symbol) != kNoSymbol;
133  }
134 
135  virtual void AddTable(const SymbolTable &table) = 0;
136 
137  virtual int64_t GetNthKey(ssize_t pos) const = 0;
138 
139  virtual const std::string &Name() const = 0;
140 
141  virtual void SetName(std::string_view new_name) = 0;
142 
143  virtual const std::string &CheckSum() const = 0;
144 
145  virtual const std::string &LabeledCheckSum() const = 0;
146 
147  virtual int64_t AvailableKey() const = 0;
148 
149  virtual size_t NumSymbols() const = 0;
150 
151  virtual bool IsMutable() const = 0;
152 };
153 
154 // Base class for SymbolTable implementations supporting Add/Remove.
156  public:
157  void AddTable(const SymbolTable &table) override;
158  bool IsMutable() const final { return true; }
159 };
160 
161 // Base class for immutable SymbolTable implementations.
163  public:
164  std::unique_ptr<SymbolTableImplBase> Copy() const final;
165 
166  int64_t AddSymbol(std::string_view symbol, int64_t key) final;
167 
168  int64_t AddSymbol(std::string_view symbol) final;
169 
170  void RemoveSymbol(int64_t key) final;
171 
172  void SetName(std::string_view new_name) final;
173  void AddTable(const SymbolTable &table) final;
174 
175  bool IsMutable() const final { return false; }
176 };
177 
178 // Default SymbolTable implementation using DenseSymbolMap and std::map.
179 // Provides the common text and binary format serialization.
181  public:
182  explicit SymbolTableImpl(std::string_view name)
183  : name_(name),
184  available_key_(0),
185  dense_key_limit_(0),
186  check_sum_finalized_(false) {}
187 
189  : name_(impl.name_),
190  available_key_(impl.available_key_),
191  dense_key_limit_(impl.dense_key_limit_),
192  symbols_(impl.symbols_),
193  idx_key_(impl.idx_key_),
194  key_map_(impl.key_map_),
195  check_sum_finalized_(false) {}
196 
197  std::unique_ptr<SymbolTableImplBase> Copy() const override {
198  return std::make_unique<SymbolTableImpl>(*this);
199  }
200 
201  int64_t AddSymbol(std::string_view symbol, int64_t key) override;
202 
203  int64_t AddSymbol(std::string_view symbol) override {
204  return AddSymbol(symbol, available_key_);
205  }
206 
207  // Removes the symbol with the given key. The removal is costly
208  // (O(NumSymbols)) and may reduce the efficiency of Find() because of a
209  // potentially reduced size of the dense key interval.
210  void RemoveSymbol(int64_t key) override;
211 
212  static SymbolTableImpl * ReadText(
213  std::istream &strm, std::string_view name,
214  // Characters to be used as a separator between fields in a textual
215  // `SymbolTable` file, encoded as a string. Each byte in the string is
216  // considered a valid separator. Multi-byte separators are not permitted.
217  // The default value, "\t ", accepts space and tab.
218  const std::string &sep = FST_FLAGS_fst_field_separator);
219 
220  // Reads a binary SymbolTable from stream, using source in error messages.
221  static SymbolTableImpl * Read(std::istream &strm,
222  std::string_view source);
223 
224  bool Write(std::ostream &strm) const override;
225 
226  // Returns the string associated with the key. If the key is out of
227  // range (<0, >max), return an empty string.
228  std::string Find(int64_t key) const override;
229 
230  // Returns the key associated with the symbol; if the symbol
231  // does not exists, returns kNoSymbol.
232  int64_t Find(std::string_view symbol) const override {
233  int64_t idx = symbols_.Find(symbol);
234  if (idx == kNoSymbol || idx < dense_key_limit_) return idx;
235  return idx_key_[idx - dense_key_limit_];
236  }
237 
238  int64_t GetNthKey(ssize_t pos) const override {
239  if (pos < 0 || static_cast<size_t>(pos) >= symbols_.Size()) {
240  return kNoSymbol;
241  } else if (pos < dense_key_limit_) {
242  return pos;
243  }
244  return Find(symbols_.GetSymbol(pos));
245  }
246 
247  const std::string &Name() const override { return name_; }
248 
249  void SetName(std::string_view new_name) override {
250  name_ = std::string(new_name);
251  }
252 
253  const std::string &CheckSum() const override {
254  MaybeRecomputeCheckSum();
255  return check_sum_string_;
256  }
257 
258  const std::string &LabeledCheckSum() const override {
259  MaybeRecomputeCheckSum();
260  return labeled_check_sum_string_;
261  }
262 
263  int64_t AvailableKey() const override { return available_key_; }
264 
265  size_t NumSymbols() const override { return symbols_.Size(); }
266 
267  void ShrinkToFit();
268 
269  private:
270  // Recomputes the checksums (both of them) if we've had changes since the last
271  // computation (i.e., if check_sum_finalized_ is false).
272  // Takes ~2.5 microseconds (dbg) or ~230 nanoseconds (opt) on a 2.67GHz Xeon
273  // if the checksum is up-to-date (requiring no recomputation).
274  void MaybeRecomputeCheckSum() const;
275 
276  std::string name_;
277  int64_t available_key_;
278  int64_t dense_key_limit_;
279 
280  DenseSymbolMap symbols_;
281  // Maps index to key for index >= dense_key_limit:
282  // key = idx_key_[index - dense_key_limit]
283  std::vector<int64_t> idx_key_;
284  // Maps key to index for key >= dense_key_limit_.
285  // index = key_map_[key]
286  std::map<int64_t, int64_t> key_map_;
287 
288  mutable bool check_sum_finalized_;
289  mutable std::string check_sum_string_;
290  mutable std::string labeled_check_sum_string_;
291  mutable Mutex check_sum_mutex_;
292 };
293 
294 } // namespace internal
295 
296 // Symbol (string) to integer (and reverse) mapping.
297 //
298 // The SymbolTable implements the mappings of labels to strings and reverse.
299 // SymbolTables are used to describe the alphabet of the input and output
300 // labels for arcs in a Finite State Transducer.
301 //
302 // SymbolTables are reference-counted and can therefore be shared across
303 // multiple machines. For example a language model grammar G, with a
304 // SymbolTable for the words in the language model can share this symbol
305 // table with the lexical representation L o G.
306 class SymbolTable {
307  public:
308  class iterator {
309  public:
310  // TODO(wolfsonkin): Expand `SymbolTable::iterator` to be a random access
311  // iterator.
312  using iterator_category = std::input_iterator_tag;
313 
314  class value_type {
315  public:
316  // Return the label of the current symbol.
317  int64_t Label() const { return key_; }
318 
319  // Return the string of the current symbol.
320  // TODO(wolfsonkin): Consider adding caching.
321  std::string Symbol() const { return table_->Find(key_); }
322 
323  private:
324  explicit value_type(const SymbolTable &table, ssize_t pos)
325  : table_(&table), key_(table.GetNthKey(pos)) {}
326 
327  // Sets this item to the pos'th element in the symbol table
328  void SetPosition(ssize_t pos) { key_ = table_->GetNthKey(pos); }
329 
330  friend class SymbolTable::iterator;
331 
332  const SymbolTable *table_; // Does not own the underlying SymbolTable.
333  int64_t key_;
334  };
335 
336  using difference_type = std::ptrdiff_t;
337  using pointer = const value_type *const;
338  using reference = const value_type &;
339 
341  ++pos_;
342  if (static_cast<size_t>(pos_) < nsymbols_) iter_item_.SetPosition(pos_);
343  return *this;
344  }
345 
347  iterator retval = *this;
348  ++(*this);
349  return retval;
350  }
351 
352  bool operator==(const iterator &that) const { return (pos_ == that.pos_); }
353 
354  bool operator!=(const iterator &that) const { return !(*this == that); }
355 
356  reference operator*() { return iter_item_; }
357 
358  pointer operator->() const { return &iter_item_; }
359 
360  private:
361  explicit iterator(const SymbolTable &table, ssize_t pos = 0)
362  : pos_(pos), nsymbols_(table.NumSymbols()), iter_item_(table, pos) {}
363 
364  friend class SymbolTable;
365 
366  ssize_t pos_;
367  size_t nsymbols_;
368  value_type iter_item_;
369  };
370 
372 
373  // Constructs symbol table with an optional name.
374  explicit SymbolTable(std::string_view name = "<unspecified>")
375  : impl_(std::make_shared<internal::SymbolTableImpl>(name)) {}
376 
377  virtual ~SymbolTable() = default;
378 
379  // Reads a text representation of the symbol table from an istream. Pass a
380  // name to give the resulting SymbolTable.
382  std::istream &strm, std::string_view name,
383  const std::string &sep = FST_FLAGS_fst_field_separator) {
384  auto impl =
386  return impl ? new SymbolTable(std::move(impl)) : nullptr;
387  }
388 
389  // Reads a text representation of the symbol table.
390  static SymbolTable * ReadText(
391  const std::string &source,
392  const std::string &sep = FST_FLAGS_fst_field_separator);
393 
394  // Reads a binary dump of the symbol table from a stream.
395  static SymbolTable *Read(std::istream &strm, std::string_view source) {
396  auto impl = fst::WrapUnique(internal::SymbolTableImpl::Read(strm, source));
397  return impl ? new SymbolTable(std::move(impl)) : nullptr;
398  }
399 
400  // Reads a binary dump of the symbol table.
401  static SymbolTable *Read(const std::string &source) {
402  std::ifstream strm(source, std::ios_base::in | std::ios_base::binary);
403  if (!strm.good()) {
404  LOG(ERROR) << "SymbolTable::Read: Can't open file: " << source;
405  return nullptr;
406  }
407  return Read(strm, source);
408  }
409 
410  // Creates a reference counted copy.
411  virtual SymbolTable *Copy() const { return new SymbolTable(*this); }
412 
413  // Adds another symbol table to this table. All keys will be offset by the
414  // current available key (highest key in the symbol table). Note string
415  // symbols with the same key will still have the same key after the symbol
416  // table has been merged, but a different value. Adding symbol tables do not
417  // result in changes in the base table.
418  void AddTable(const SymbolTable &table) {
419  MutateCheck();
420  impl_->AddTable(table);
421  }
422 
423  // Adds a symbol with given key to table. A symbol table also keeps track of
424  // the last available key (highest key value in the symbol table).
425  int64_t AddSymbol(std::string_view symbol, int64_t key) {
426  MutateCheck();
427  return impl_->AddSymbol(symbol, key);
428  }
429 
430  // Adds a symbol to the table. The associated value key is automatically
431  // assigned by the symbol table.
432  int64_t AddSymbol(std::string_view symbol) {
433  MutateCheck();
434  return impl_->AddSymbol(symbol);
435  }
436 
437  // Returns the current available key (i.e., highest key + 1) in the symbol
438  // table.
439  int64_t AvailableKey() const { return impl_->AvailableKey(); }
440 
441  // Return the label-agnostic MD5 check-sum for this table. All new symbols
442  // added to the table will result in an updated checksum.
443  OPENFST_DEPRECATED("Use `LabeledCheckSum()` instead.")
444  const std::string &CheckSum() const { return impl_->CheckSum(); }
445 
446  int64_t GetNthKey(ssize_t pos) const { return impl_->GetNthKey(pos); }
447 
448  // Returns the string associated with the key; if the key is out of
449  // range (<0, >max), returns an empty string.
450  std::string Find(int64_t key) const { return impl_->Find(key); }
451 
452  // Returns the key associated with the symbol; if the symbol does not exist,
453  // kNoSymbol is returned.
454  int64_t Find(std::string_view symbol) const { return impl_->Find(symbol); }
455 
456  // Same as CheckSum(), but returns an label-dependent version.
457  const std::string &LabeledCheckSum() const {
458  return impl_->LabeledCheckSum();
459  }
460 
461  bool Member(int64_t key) const { return impl_->Member(key); }
462 
463  bool Member(std::string_view symbol) const { return impl_->Member(symbol); }
464 
465  // Returns the name of the symbol table.
466  const std::string &Name() const { return impl_->Name(); }
467 
468  // Returns the current number of symbols in table (not necessarily equal to
469  // AvailableKey()).
470  size_t NumSymbols() const { return impl_->NumSymbols(); }
471 
472  void RemoveSymbol(int64_t key) {
473  MutateCheck();
474  return impl_->RemoveSymbol(key);
475  }
476 
477  // Sets the name of the symbol table.
478  void SetName(std::string_view new_name) {
479  MutateCheck();
480  impl_->SetName(new_name);
481  }
482 
483  bool Write(std::ostream &strm) const { return impl_->Write(strm); }
484 
485  bool Write(const std::string &source) const;
486 
487  // Dumps a text representation of the symbol table via a stream.
488  bool WriteText(
489  std::ostream &strm,
490  // Characters to be used as a separator between fields in a textual
491  // `SymbolTable` file, encoded as a string. Each byte in the string is
492  // considered a valid separator. Multi-byte separators are not permitted.
493  // The default value, "\t ", outputs tab.
494  const std::string &sep = FST_FLAGS_fst_field_separator) const;
495 
496  // Dumps a text representation of the symbol table.
497  bool WriteText(const std::string &sink,
498  const std::string &sep = FST_FLAGS_fst_field_separator) const;
499 
500  const_iterator begin() const { return const_iterator(*this, 0); }
501 
502  const_iterator end() const { return const_iterator(*this, NumSymbols()); }
503 
504  const_iterator cbegin() const { return begin(); }
505 
506  const_iterator cend() const { return end(); }
507 
508  protected:
509  explicit SymbolTable(std::shared_ptr<internal::SymbolTableImplBase> impl)
510  : impl_(std::move(impl)) {}
511 
512  template <class T = internal::SymbolTableImplBase>
513  const T *Impl() const {
514  return down_cast<const T *>(impl_.get());
515  }
516 
517  template <class T = internal::SymbolTableImplBase>
518  T *MutableImpl() {
519  MutateCheck();
520  return down_cast<T *>(impl_.get());
521  }
522 
523  private:
524  void MutateCheck() {
525  if (impl_.unique() || !impl_->IsMutable()) return;
526  std::unique_ptr<internal::SymbolTableImplBase> copy = impl_->Copy();
527  CHECK(copy != nullptr);
528  impl_ = std::move(copy);
529  }
530 
531  std::shared_ptr<internal::SymbolTableImplBase> impl_;
532 };
533 
534 // Iterator class for symbols in a symbol table.
536  "Use SymbolTable::iterator, a C++ compliant iterator, instead")
537  SymbolTableIterator {
538  public:
539  explicit SymbolTableIterator(const SymbolTable &table)
540  : table_(table), iter_(table.begin()), end_(table.end()) {}
541 
542  ~SymbolTableIterator() = default;
543 
544  // Returns whether iterator is done.
545  bool Done() const { return (iter_ == end_); }
546 
547  // Return the key of the current symbol.
548  int64_t Value() const { return iter_->Label(); }
549 
550  // Return the string of the current symbol.
551  std::string Symbol() const { return iter_->Symbol(); }
552 
553  // Advances iterator.
554  void Next() { ++iter_; }
555 
556  // Resets iterator.
557  void Reset() { iter_ = table_.begin(); }
558 
559  private:
560  const SymbolTable &table_;
561  SymbolTable::iterator iter_;
562  const SymbolTable::iterator end_;
563 };
564 
565 // Relabels a symbol table as specified by the input vector of pairs
566 // (old label, new label). The new symbol table only retains symbols
567 // for which a relabeling is explicitly specified.
568 //
569 // TODO(allauzen): consider adding options to allow for some form of implicit
570 // identity relabeling.
571 template <class Label>
573  const SymbolTable *table,
574  const std::vector<std::pair<Label, Label>> &pairs) {
575  auto new_table = std::make_unique<SymbolTable>(
576  table->Name().empty() ? std::string()
577  : (std::string("relabeled_") + table->Name()));
578  for (const auto &[old_label, new_label] : pairs) {
579  new_table->AddSymbol(table->Find(old_label), new_label);
580  }
581  return new_table.release();
582 }
583 
584 // Returns true if the two symbol tables have equal checksums. Passing in
585 // nullptr for either table always returns true.
586 bool CompatSymbols(const SymbolTable *syms1, const SymbolTable *syms2,
587  bool warning = true);
588 
589 // Symbol table serialization.
590 
591 void SymbolTableToString(const SymbolTable *table, std::string *result);
592 
593 SymbolTable *StringToSymbolTable(const std::string &str);
594 
595 } // namespace fst
596 
597 #endif // FST_SYMBOL_TABLE_H_
const std::string & Name() const
Definition: symbol-table.h:466
bool Write(std::ostream &strm) const
Definition: symbol-table.h:483
int64_t AddSymbol(std::string_view symbol, int64_t key)
Definition: symbol-table.h:425
void SymbolTableToString(const SymbolTable *table, std::string *result)
class OPENFST_DEPRECATED("allow_negative is no-op") StringCompiler
Definition: string.h:170
void SetName(std::string_view new_name) override
Definition: symbol-table.h:249
void AddTable(const SymbolTable &table)
Definition: symbol-table.h:418
std::pair< int64_t, bool > InsertOrFind(std::string_view key)
Definition: symbol-table.cc:62
virtual bool Member(std::string_view symbol) const
Definition: symbol-table.h:131
const_iterator end() const
Definition: symbol-table.h:502
pointer operator->() const
Definition: symbol-table.h:358
static SymbolTableImpl * Read(std::istream &strm, std::string_view source)
const_iterator cbegin() const
Definition: symbol-table.h:504
SymbolTable(std::string_view name="<unspecified>")
Definition: symbol-table.h:374
virtual SymbolTable * Copy() const
Definition: symbol-table.h:411
void SetName(std::string_view new_name)
Definition: symbol-table.h:478
std::input_iterator_tag iterator_category
Definition: symbol-table.h:312
#define LOG(type)
Definition: log.h:53
SymbolTable * StringToSymbolTable(const std::string &str)
constexpr int kLineLen
Definition: symbol-table.h:62
int64_t AddSymbol(std::string_view symbol) override
Definition: symbol-table.h:203
To down_cast(From *f)
Definition: compat.h:50
std::unique_ptr< T > WrapUnique(T *ptr)
Definition: compat.h:132
constexpr int64_t kNoSymbol
Definition: symbol-table.h:55
const std::string & GetSymbol(size_t idx) const
Definition: symbol-table.h:76
size_t NumSymbols() const
Definition: symbol-table.h:470
SymbolTableImpl(const SymbolTableImpl &impl)
Definition: symbol-table.h:188
bool operator==(const iterator &that) const
Definition: symbol-table.h:352
std::ptrdiff_t difference_type
Definition: symbol-table.h:336
void RemoveSymbol(int64_t key)
Definition: symbol-table.h:472
DECLARE_string(fst_field_separator)
const value_type *const pointer
Definition: symbol-table.h:337
int64_t Find(std::string_view key) const
Definition: symbol-table.cc:79
size_t NumSymbols() const override
Definition: symbol-table.h:265
int64_t GetNthKey(ssize_t pos) const override
Definition: symbol-table.h:238
static SymbolTable * ReadText(std::istream &strm, std::string_view name, const std::string &sep=FST_FLAGS_fst_field_separator)
Definition: symbol-table.h:381
SymbolTable(std::shared_ptr< internal::SymbolTableImplBase > impl)
Definition: symbol-table.h:509
bool operator!=(const iterator &that) const
Definition: symbol-table.h:354
const T * Impl() const
Definition: symbol-table.h:513
int64_t AddSymbol(std::string_view symbol)
Definition: symbol-table.h:432
int64_t Find(std::string_view symbol) const override
Definition: symbol-table.h:232
const std::string & LabeledCheckSum() const override
Definition: symbol-table.h:258
const std::string & Name() const override
Definition: symbol-table.h:247
static SymbolTableImpl * ReadText(std::istream &strm, std::string_view name, const std::string &sep=FST_FLAGS_fst_field_separator)
int64_t AvailableKey() const
Definition: symbol-table.h:439
int64_t AvailableKey() const override
Definition: symbol-table.h:263
virtual bool Member(int64_t key) const
Definition: symbol-table.h:129
DECLARE_bool(fst_compat_symbols)
bool CompatSymbols(const SymbolTable *syms1, const SymbolTable *syms2, bool warning=true)
std::string Find(int64_t key) const
Definition: symbol-table.h:450
const std::string & LabeledCheckSum() const
Definition: symbol-table.h:457
const_iterator begin() const
Definition: symbol-table.h:500
#define CHECK(x)
Definition: log.h:65
std::unique_ptr< SymbolTableImplBase > Copy() const override
Definition: symbol-table.h:197
int64_t GetNthKey(ssize_t pos) const
Definition: symbol-table.h:446
static SymbolTable * Read(const std::string &source)
Definition: symbol-table.h:401
const std::string & CheckSum() const override
Definition: symbol-table.h:253
static SymbolTable * Read(std::istream &strm, std::string_view source)
Definition: symbol-table.h:395
SymbolTable * RelabelSymbolTable(const SymbolTable *table, const std::vector< std::pair< Label, Label >> &pairs)
Definition: symbol-table.h:572
SymbolTableImpl(std::string_view name)
Definition: symbol-table.h:182
bool Member(std::string_view symbol) const
Definition: symbol-table.h:463
bool Member(int64_t key) const
Definition: symbol-table.h:461
int64_t Find(std::string_view symbol) const
Definition: symbol-table.h:454
const_iterator cend() const
Definition: symbol-table.h:506