Linked List
Linked List implementation in C
Linked List Documentation

Table of Contents

Introduction
Version Log
API
Coding Standard
Documentation
Testing
ToDo


Introduction

A Linked List is used to implement different data structures like queues and state machines. The behaviour of a Linked List is similar to a Last In First Out (LIFO) memory but methods to push and pop to the front of the list are also implemented.

Linked_list.png


Table of Contents


Version Log

Release 1

  • added Node structure and typedef
  • added Linked list structure and typedef
  • added Push back and front methods
  • added Pop back and front methods
  • added Print method

Release 2

  • added Generic type linked list
  • added For each element method


Table of Contents


API

The Linked List implementation provides APIs to write and get elements from the linked list. The following API's are implemented:

  • Initialize the linked list
  • Free the memory of the linked list
  • Push to the tail of the linked list
  • Push to the front of the linked list
  • Pop from the tail of the linked list
  • Pop from the front of the linked list
  • Get element in a given index
  • Print the linked list
  • Get the number of elements in the linked list


Table of Contents


Coding Standard

The following Coding Standard was used to develop the embedded firmware for this project. A general overview is presented here so that a basic understanding of how the code is organized and developed can be understood.

Code Naming Convention

Function names should conform to the following standard,

  • Function names should start with the library name followed by an under-score.
  • The first character of the sub-system name shall not be capitalized.
  • The rest of the function name must have under-scores between words.
  • The rest of the function name should describe what the function does.
  • The first character of each word should not be capitalized.
  • Global variables and variables that are static to a module should have their names conform to the same standard as function names.
  • Sub-system names aren't required, but use them if you can.

For example,

  • list_init(&list), where "list_" is the sub-system and "init" describes the action to be performed.

Common first words after the sub-system name,

  • init
  • pop
  • push
  • destroy
  • get
  • print

For function prototype parameters,

  • The sub-system shall not be used.
  • The first character of each word shall not be capitalized.
  • There should be no under-scores in the name.

For local variables (to a function),

  • The sub-system shall not be used.
  • The first character of the first word shall not be capitalized.
  • If the name contains more than one word, each word after the first shall have its first character capitalized.

For example,

int list_pop(list_t* list)
{
uint8 i;
uint8 myVariable;
// Some code
statements;
}


  • The parameter "list" has the first character not apitalized and does not start with a sub-system name because it is a parameter.
  • The variable "i" is not capitalized and does not start with a sub-system name because it is a local variable.
  • The variable "myVariable" has it's first word un-capitalized, it's second word capitalized, and does not start with a sub-system name because it is a local variable.

Code Formatting/Style

Code formatting and style shall conform to the following guidelines.

  • Indentation shall be 4 spaces (not tabs).
  • Opening braces shall be placed on separate lines.
  • Closing braces shall be placed on separate lines.
  • If, for, switch, and while statements shall always use braces.
  • A comment block shall be placed before every function definition describing what the function does, any parameters passed to it, any return value, and anything else that would be relevant or useful to someone that has to maintain it.

For example,

// This is correct.
if (condition)
{
statement1;
statement2;
}
else
{
statement3;
statement4;
}
if (condition)
{
statement;
}
else
{
statement2;
}
// This is NOT.
if (condition) {
statement1;
statement2;
} else {
statement3;
statement4;
}
if (condition)
statement;
else
statement2;


Table of Contents


Documentation

Doxygen

Doxygen is used to generate all the HTML related documentation directly from the source.


Table of Contents


Testing

Unity is used for testing and the tests are located in the tests folder.


Table of Contents


ToDo

  • Implement doubly linked list.


Table of Contents