CS 241 MP1 Dictionary

CS 241

Due: Wednesday, February 5th, 11:59pm


Introduction

In this MP, you will be creating a simple dictionary data structure to parse and hold the values of the parsed strings.

For this MP, you may modify:

All other files will be replaced with new/different files for grading. If you modify any other files for debugging purposes, please ensure you test your program with the original file.

What you must do...

Now that you have some review of pointers, we're ready to make a simple, but useful library. This library will be a simple "dictionary" that associates a key with value, much like the Map interface in Java (Interface Map<K, V> in Java). While a true library may contain many useful functions, we only require a few very basic functions to be completed in order to complete Part 2: _init(), _destroy(), _add(), _get(), _remove(), and _parse().

In all six functions, the first parameter is a pointer to a dictionary_t struct. You can find this struct defined in the libdictionary.h file inside the /libdictionary/ folder in MP1. You will find the dictionary_t structure, with a single reference to a dictionary_entry_t struct. You may want to add variables to dictionary_t, change it to a pointer, or anything else to work with your data structure. It may be useful to add variables inside the dictionary_entry_t struct in order to store state about your dictionary. You may find that the dictionary_entry_t struct is enough, or you may create any number of other structs inside your .h file. A pointer to the same dictionary_t will be used through the entire use of a single dictionary. Sample code of use of your library can be found in main.c, re-printed (in part) below:

dictionary_t dictionary;
dictionary_init(&dictionary);

result = dictionary_add(&dictionary, "key", "value");
result = dictionary_add(&dictionary, "key2", "value");
result = dictionary_parse(&dictionary, "Hello: World");
[...]
dictionary_remove(&dictionary, "key3");

You should modify main.c to include more robust testing your library. We will not use main.c in grading, but our grader will use a custom file that makes use of your library -- it's up to you to robustly test your dictionary.

You must implement the six functions defined in libdictionary/libdictionary.c. These functions are self-descriptive, but a full function outline is provided for in the links below. In this MP, we are looking for correctness over efficiency -- all the test cases are small enough that even an O(n^3) algorithm will run just fine.

Compile and Run

To compile libdictionary (the dictionary itself), and main.c (the dictionary tester), run:
make clean
make
To run:
./main

Grading, Submission, and Other Details

Please fully read mp_grading.html for more details on grading, submission, and other topics that are shared between all MPs in CS 241.

Generated on 30 Jan 2014 for MP1 First Steps in C by  doxygen 1.6.1