- Introduction
- Data Structures
- Jerry Object Management
- Key Features
- Instructions
- Makefile Explanation
- Example Usage
- Notes
This project demonstrates the design and implementation of three generic data structures: a Linked List, a Hash Table, and a MultiValue Hash Table. These structures are designed to manage various data types through customizable functions, offering flexibility for many applications.
In the second part, these data structures are applied to manage custom Jerry objects, demonstrating practical applications in handling data efficiently.
A Linked List is a dynamic data structure that supports:
- Insertion: Add new data.
- Deletion: Remove data.
- Search by Position: Retrieve data at a specific position.
- Search by Value: Find data based on its value.
This structure is ideal for flexible memory usage and sequential data management.
A Hash Table enables fast lookups using a key-value pair mechanism:
- Constant-Time Lookup: Fast retrieval of values by their keys.
- Collision Handling: Manages key collisions through linked lists in hash buckets.
- Single Value per Key: Each key maps to a single value, optimizing storage.
The MultiValue Hash Table extends the Hash Table by allowing:
- Multi-Value Mapping: Each key can map to multiple values.
- Efficient Value Storage: Useful when a key needs to reference multiple related data points.
These structures are generic, allowing them to handle any data type through custom functions for copying, comparing, destroying, and creating data. This makes them flexible and reusable across different use cases.
In the second part, the data structures are used to manage Jerry objects. The system provides options for:
- Adding a New Jerry: Insert a new Jerry into the system.
- Deleting a Jerry: Remove a Jerry from the system.
- Adding Attributes: Attach custom properties to a Jerry.
- Displaying Jerry Information: Print detailed information about a Jerry.
This demonstrates how generic data structures can be adapted to solve real-world problems.
- Efficiency: O(1) average lookup time with the Hash Table ensures quick data retrieval.
- Flexibility: The generic design allows for easy adaptation to various data types.
- Scalability: Supports complex relationships, like mapping multiple values to a single key.
- Reusability: The modular design makes it easy to integrate these structures into other projects.
Before running the project, make sure you have gcc
installed. You can install it using:
sudo apt-get install gcc
To compile the project, navigate to the project directory and use the Makefile
provided:
-
Navigate to the project directory:
cd /path/to/project/directory
-
Compile the program:
make
This will compile all .c
files and create an executable called JerryBoree
.
Run the JerryBoree
executable with the required parameters:
./JerryBoree [number_of_planets] [configuration_file_path]
- [number_of_planets]: An integer representing the number of planets used to set up the planet list.
- [configuration_file_path]: A string representing the path to a file containing the planet and Jerry data.
For example:
./JerryBoree 4 configuration_file.txt
This will start the Jerry management system using 4 planets, reading data from configuration_file.txt
.
After you run the program, you can clean up the compiled files with:
make clean
This removes all object files (*.o
) and the executable.
The Makefile automates the build process. It includes the following key rules:
- Compiling: The
make
command compiles all source files into object files. - Linking: It links the object files to create the
JerryBoree
executable. - Cleaning: The
make clean
command removes the object files and the executable.
-
Compile the project:
make
-
Run the program:
./JerryBoree 4 configuration_file.txt
-
Clean up the directory:
make clean
- Ensure the input file
configuration_file.txt
is in the same directory as the executable. - You can modify the input file to adjust the program’s behavior.