Add comments to single linked list header, and start documenting it in groff files.
This commit is contained in:
parent
da6cf60a78
commit
0296538762
|
@ -0,0 +1,47 @@
|
|||
.DA
|
||||
|
||||
.TL
|
||||
single_linked_list.h
|
||||
|
||||
.AU
|
||||
Wael Karram
|
||||
|
||||
.AB no
|
||||
Documentation for single_linked_list.h
|
||||
.AE
|
||||
|
||||
.ND
|
||||
|
||||
.PP
|
||||
This header defines a linked list, with one link per node. Using the prepoccessor variable SINGLE_LINKED_LIST_H used as an include guard.
|
||||
.br
|
||||
Relies on single_node.h to implement the nodes.
|
||||
|
||||
.PP
|
||||
These are the compile-time constants declared by this header:
|
||||
.br
|
||||
SUCCESS_CODE_SINGLE_LINKED_LIST_C, this is the code returned by a function on succcess, evaluates to 1.
|
||||
.br
|
||||
FAILURE_CODE_SINGLE_LINKED_LIST_C, this is the code returned by a function on failure, evaluates to 0.
|
||||
.br
|
||||
INDEX_NOT_FOUND_CODE_SINGLE_LINKED_LIST_C, this is the code returned by a function when a requested index is not found, evaluates to -1.
|
||||
.br
|
||||
INVALID_INPUT_CODE_SINGLE_LINKED_LIST_C, this is the code returned by a function when recieving invalid input, evaluates to -2.
|
||||
.br
|
||||
CODE_FREE_SUCCESS_MALFORMED_SINGLE_LINKED_LIST_C, this code is returned when freeing the data is successful, but the list is maformed, evaluates to -1.
|
||||
.br
|
||||
INDEX_HEAD_LINKED_LIST, this is the index of the head of the linked list, evaluates to 0.
|
||||
|
||||
|
||||
.PP
|
||||
These are the function defitions and input arguments for this data structre.
|
||||
.br
|
||||
Defines a single struct
|
||||
.UL node_t \0which
|
||||
has the fields
|
||||
.I "next" \0and
|
||||
.I "data" ,
|
||||
the former of which is another node pointer, and the latter is a void pointer.
|
||||
.br
|
||||
It is of note that this header type-defines the aformentioned node as
|
||||
.I "node_t" .
|
|
@ -1,19 +1,25 @@
|
|||
/* This header defines a single-linked-list and related functions. */
|
||||
/* Use the single nodes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h> /* Used in allocations and deallocations. */
|
||||
#ifndef SINGLE_LINKED_LIST_H
|
||||
#define SINGLE_LINKED_LIST_H
|
||||
#include "../nodes/single_node.h"
|
||||
|
||||
/* Constants. */
|
||||
/* Function error/return code on success. */
|
||||
#define SUCCESS_CODE_SIGNLE_LINKED_LIST_C 1
|
||||
/* Function error/return code on failure. */
|
||||
#define FAILURE_CODE_SIGNLE_LINKED_LIST_C 0
|
||||
/* Function error/return code on failure to find index. */
|
||||
#define INDEX_NOT_FOUND_CODE_SINGLE_LINKED_LIST_C -1
|
||||
/* Function error/return code on invalid input. */
|
||||
#define INVALID_INPUT_CODE_SINGLE_LINKED_LIST_C -2
|
||||
/* Error code returned when input fails sanity check. */
|
||||
#define CODE_FREE_SUCCESS_MALFORMED_SINGLE_LINKED_LIST_C -1
|
||||
/* The default index of the list's head. */
|
||||
#define INDEX_HEAD_LINKED_LIST_C 0
|
||||
|
||||
/* The actual linked list struct. */
|
||||
/* The linked list's struct. */
|
||||
typedef struct linked_list {
|
||||
/* Stores the list's length. */
|
||||
int length;
|
||||
|
|
Loading…
Reference in New Issue