示例#1
0
int
sb_trie_save (SBTrie *sb_trie)
{
    if (!sb_trie)
        return -1;

    return trie_save (sb_trie->trie);
}
示例#2
0
void 
ATTrie :: save(const char * path) 
{
    if (data->trie == NULL)
        return;

    int ret = trie_save(data->trie, path);
    if (ret != 0)
        throw "TrieSaveException";
}
示例#3
0
/**
  Testuje zapisywanie drzewa.
  @param state Środowisko testowe.
  */
static void trie_save_test(void** state)
{
    Trie *trie = trie_new();

    FILE *stream;
    wchar_t *buf = NULL;
    size_t len;

    stream = open_wmemstream(&buf, &len);
    if (stream == NULL)
    {
        fprintf(stderr, "Failed to open memory stream\n");
        exit(EXIT_FAILURE);
    }

    IO *io = io_new(stdin, stream, stderr);

    assert_true(trie_save(trie, io) == 0);
    fflush(stream);
    assert_true(wcscmp(L"\n", buf) == 0);
    fseek(stream, 0, SEEK_SET);

    trie_insert_word(trie, L"ciupaga");
    assert_true(trie_save(trie, io) == 0);
    fflush(stream);
    assert_true(wcscmp(L"ciupaga*^^^^^^^\n", buf) == 0);
    fseek(stream, 0, SEEK_SET);

    trie_delete_word(trie, L"ciupaga");
    assert_true(trie_save(trie, io) == 0);
    fflush(stream);
    assert_true(wcscmp(L"\n", buf) == 0);

    fclose(stream);
    io_done(io);
#   undef free
    free(buf);
#   define free(ptr) _test_free(ptr, __FILE__, __LINE__)
    trie_done(trie);
}
示例#4
0
文件: tries.c 项目: edechter/yap
static int p_trie_save(void) {
  const char *file_str;
  FILE *file;

  /* check args */
  if (!YAP_IsIntTerm(arg_trie))
    return FALSE;
  if (!YAP_IsAtomTerm(arg_file))
    return FALSE;

  /* open file */
  file_str = YAP_AtomName(YAP_AtomOfTerm(arg_file));
  if (!(file = fopen(file_str, "w")))
    return FALSE;

  /* save trie and close file */
  trie_save((TrEntry) YAP_IntOfTerm(arg_trie), file);
  if (fclose(file))
    return FALSE;
  return TRUE;
}
示例#5
0
int
sb_trie_save (SBTrie *sb_trie)
{
    return trie_save (sb_trie->trie);
}
示例#6
0
int dictionary_save(const struct dictionary *dict, FILE* stream)
{
    return trie_save(dict->tree, stream);
}