Skip to content

twoteesbrett/linked-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linked List Demo

A small C demo project that implements a doubly linked list of int values.

Because this is implemented as a doubly linked list, it can also be used to model other data structures.

For example, it can behave like a stack by adding and removing items from the same end of the list. It can also behave like a queue by adding items to the back and removing them from the front.

The project keeps the API focused on list operations, but those operations are enough to demonstrate how stacks and queues can be built on top of a linked list.

Background

This project is a small personal revisit of an old university assignment.

Years ago, I had to implement a linked list in C as part of a programming paper. I did not do well on it at the time. I had come from writing BASIC and 6510 assembly language on a Commodore 64, so C felt very different, especially pointers and manual memory management.

I never really felt that I understood the assignment properly back then. This project was a chance to come back to it with more experience, slow down, and implement it properly. The goal was not just to make a linked list work, but to understand what the code is doing and write it in a clear, testable way.

What It Includes

  • list_init
  • list_insert_first
  • list_insert_last
  • list_insert_at
  • list_get
  • list_remove_first
  • list_remove_last
  • list_remove_at
  • list_clear
  • list_print

Build

make

This builds the demo app as linked-list.

Run

make run

Test

make test

This builds and runs the unit tests in tests/linked_list_tests.c.

Clean

make clean

Project Layout

  • src/linked_list.c - linked list implementation
  • src/linked_list.h - public API
  • src/main.c - small demo program
  • tests/linked_list_tests.c - unit tests
  • Makefile - build targets

Notes

  • The list stores int values.
  • The implementation is currently optimized for clarity rather than maximum performance.
  • list_print writes a simple bracketed representation to stdout.

About

A small C demo project that implements a doubly linked list of int values.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors