get rid of the destructive updates for seq_ids

This commit is contained in:
Krasimir Angelov
2022-01-10 10:27:09 +01:00
parent 19f7fb8d5e
commit d87b3ce166
12 changed files with 191 additions and 62 deletions

View File

@@ -5,6 +5,41 @@ class PgfSequence;
class PgfSequenceItor;
typedef ref<Node<PgfSequence>> PgfPhrasetable;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
struct PgfPhrasetableIds {
public:
PGF_INTERNAL_DECL PgfPhrasetableIds();
PGF_INTERNAL_DECL ~PgfPhrasetableIds() { end(); }
PGF_INTERNAL_DECL void start(ref<PgfConcr> concr);
PGF_INTERNAL_DECL size_t add(ref<PgfSequence> seq);
PGF_INTERNAL_DECL size_t get(ref<PgfSequence> seq);
PGF_INTERNAL_DECL void end();
private:
size_t next_id;
struct PGF_INTERNAL_DECL SeqIdChain;
struct PGF_INTERNAL_DECL SeqIdPair {
SeqIdChain *chain;
ref<PgfSequence> seq;
size_t seq_id;
};
struct PGF_INTERNAL_DECL SeqIdChain : public SeqIdPair {
SeqIdChain *next;
};
size_t n_pairs;
SeqIdPair *pairs;
SeqIdChain *chains;
};
#pragma GCC diagnostic pop
PGF_INTERNAL_DECL
PgfPhrasetable phrasetable_internalize(PgfPhrasetable table, ref<PgfSequence> *seq);
@@ -12,7 +47,8 @@ PGF_INTERNAL_DECL
ref<PgfSequence> phrasetable_get(PgfPhrasetable table, size_t seq_id);
PGF_INTERNAL_DECL
void phrasetable_iter(PgfPhrasetable table, PgfSequenceItor* itor, size_t *p_next_id, PgfExn *err);
void phrasetable_iter(PgfPhrasetable table, PgfSequenceItor* itor,
PgfPhrasetableIds *seq_ids, PgfExn *err);
PGF_INTERNAL_DECL
void phrasetable_release(PgfPhrasetable table);