Saturday, June 11, 2016

Main file for testing the Trie

This is the main file that I use to test my string builder and Trie classes.

#include "typestring.h"
#include "typetrie.h"

typeString   str;
typeNode     trie;
char         buffer[4096];
const char*  strings[] =  {
  "remove",
  "rename",
  "renumber",
  "repack",
  "repaint",
  "repay",
  "replace",
  "replay",
  "reread",
  "rerun",
  "resale",
  "reshape",
  "retell",
  "rethink",
  "retrace",
  "reword",
  "rewrite",
  "rethinking",
  "retracing",
  "rewording",
  "impatience",
  "imperfect",
  "impolite",
  "impossible",
  "impure",
  "inactive",
  "incorrect",
  "indefinite",
  "incident",
  "ant",
  "apple",
  "zebra",
  "cross",
  "rock",
  "cloud",
  "turtle",
  "rodent",
  "solar",
  "volume",
  "purple",
  "romeo",
  "overlord",
  "sequence",
  "virtue",
  "parent",
  "starlight",
  "source",
  "theory",
  "underworld" };

int main()
  {
  stringCreate(&str,4096);

  stringAppendCString(&str,"Hello World = ");
  stringAppendInt64(&str,92233736854775807,2);
  stringGetCString(&str,buffer,4096);
  printf("%s\n",buffer);

  stringSetLength(&str,0);
  stringAppendInt64(&str,92233720364775807,16);
  stringGetCString(&str,buffer,4096);
  printf("%s\n",buffer);

  stringSetLength(&str,0);
  stringAppendInt64(&str,92233720364775807,64);
  stringGetCString(&str,buffer,4096);
  printf("%s\n",buffer);

  trieCreate(&trie);
  int length = sizeof(strings) / sizeof(strings[0]);
  for (int I = 0;I < length;I++)
    trieInsertCString(&trie,strings[I]);
  trieDraw(&trie,0);

  return 1;
  }

No comments:

Post a Comment