Sha256: 94c2d2f7afac63bfc01e5667b80314ac96e989cad43b47ee897827e4d7b7bd7f

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

#pragma once
#include <stdbool.h>
#include <stdbool.h>

#define MAX_AHO_CHILD_NODE 256 /* Character 1 byte => 256 */

struct aho_trie_node
{
    unsigned char text;
    unsigned int ref_count;

    struct aho_trie_node* parent;
    struct aho_trie_node* child_list[MAX_AHO_CHILD_NODE];
    unsigned int child_count;

    bool text_end;
    struct aho_text_t* output_text; /* when text_end is true */

    struct aho_trie_node* failure_link;
    struct aho_trie_node* output_link;
};

struct aho_trie
{
    struct aho_trie_node root;
};

void aho_init_trie(struct aho_trie * restrict t);
void aho_destroy_trie(struct aho_trie * restrict t);

bool aho_add_trie_node(struct aho_trie * restrict t, struct aho_text_t * restrict text);
void aho_connect_link(struct aho_trie * restrict t);
void aho_clean_trie_node(struct aho_trie * restrict t);

struct aho_text_t* aho_find_trie_node(struct aho_trie_node** restrict start, const unsigned char text);

void aho_print_trie(struct aho_trie * restrict t);

/* TODO:
 * bool aho_del_trie_node(struct aho_trie* t, struct aho_text_t* text);
 */

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
multi_string_replace-1.0.2 ext/multi_string_replace/aho_trie.h
multi_string_replace-1.0.1 ext/multi_string_replace/aho_trie.h
multi_string_replace-0.1.1 ext/multi_string_replace/aho_trie.h
multi_string_replace-0.1.0 ext/multi_string_replace/aho_trie.h