Add documentation (#18)

This commit is contained in:
Bailey Thompson
2019-04-28 06:16:57 -05:00
committed by GitHub
parent f38199c743
commit 1da4bd890c
35 changed files with 3484 additions and 673 deletions

194
.codedocs Normal file
View File

@@ -0,0 +1,194 @@
# CodeDocs.xyz Configuration File
#
# Rename this example to '.codedocs' and put it in the root directory of your
# repository. This file is optional, documentation will still be generated
# without it using sensible defaults.
#---------------------------------------------------------------------------
# CodeDocs Configuration
#---------------------------------------------------------------------------
# Include the Doxygen configuration from another file.
# The file must be a relative path with respect to the root of the repository.
# If any of the options in this doxyfile include a path (ie, INPUT), these
# paths will be considered relative to the root of the repository, not the
# location of the DOXYFILE.
DOXYFILE = ./
# Specify external repository to link documentation with.
# This is similar to Doxygen's TAGFILES option, but will automatically link to
# tags of other repositories already using CodeDocs. List each repository to
# link with by giving its location in the form of owner/repository.
# For example:
# TAGLINKS = doxygen/doxygen CodeDocs/osg
# Note: these repositories must already be built on CodeDocs.
TAGLINKS = bkthomps/Containers
#---------------------------------------------------------------------------
# Doxygen Configuration
#---------------------------------------------------------------------------
# Doxygen configuration may also be placed in this file.
# Currently, the following Doxygen configuration options are available. Refer
# to http://doxygen.org/manual/config.html for detailed explanation of the
# options. To request support for more options, contact support@codedocs.xyz.
#
# ABBREVIATE_BRIEF =
# ALIASES =
# ALLEXTERNALS =
# ALLOW_UNICODE_NAMES =
# ALPHABETICAL_INDEX =
# ALWAYS_DETAILED_SEC =
# AUTOLINK_SUPPORT =
# BRIEF_MEMBER_DESC =
# BUILTIN_STL_SUPPORT =
# CALLER_GRAPH =
# CALL_GRAPH =
# CASE_SENSE_NAMES =
# CITE_BIB_FILES =
# CLASS_DIAGRAMS =
# CLASS_GRAPH =
# COLLABORATION_GRAPH =
# COLS_IN_ALPHA_INDEX =
# CPP_CLI_SUPPORT =
# DIAFILE_DIRS =
# DIRECTORY_GRAPH =
# DISABLE_INDEX =
# DISTRIBUTE_GROUP_DOC =
# DOTFILE_DIRS =
# DOT_FONTNAME =
# DOT_FONTSIZE =
# DOT_GRAPH_MAX_NODES =
# DOT_IMAGE_FORMAT =
# DOT_TRANSPARENT =
# DOXYFILE_ENCODING =
# ENABLED_SECTIONS =
# ENABLE_PREPROCESSING =
# ENUM_VALUES_PER_LINE =
# EXAMPLE_PATH =
# EXAMPLE_PATTERNS =
# EXAMPLE_RECURSIVE =
# EXCLUDE =
# EXCLUDE_PATTERNS =
# EXCLUDE_SYMBOLS =
# EXPAND_AS_DEFINED =
# EXPAND_ONLY_PREDEF =
# EXTENSION_MAPPING =
# EXTERNAL_GROUPS =
# EXTERNAL_PAGES =
# EXTRACT_ALL =
# EXTRACT_ANON_NSPACES =
# EXTRACT_LOCAL_CLASSES =
# EXTRACT_LOCAL_METHODS =
# EXTRACT_PACKAGE =
# EXTRACT_PRIVATE =
# EXTRACT_STATIC =
# EXT_LINKS_IN_WINDOW =
# FILE_PATTERNS =
# FORCE_LOCAL_INCLUDES =
# FORMULA_FONTSIZE =
# FORMULA_TRANSPARENT =
# FULL_PATH_NAMES =
# GENERATE_BUGLIST =
# GENERATE_DEPRECATEDLIST =
# GENERATE_LEGEND =
# GENERATE_TESTLIST =
# GENERATE_TODOLIST =
# GENERATE_TREEVIEW =
# GRAPHICAL_HIERARCHY =
# GROUP_GRAPHS =
# GROUP_NESTED_COMPOUNDS =
# HIDE_COMPOUND_REFERENCE= =
# HIDE_FRIEND_COMPOUNDS =
# HIDE_IN_BODY_DOCS =
# HIDE_SCOPE_NAMES =
# HIDE_UNDOC_CLASSES =
# HIDE_UNDOC_MEMBERS =
# HIDE_UNDOC_RELATIONS =
# HTML_COLORSTYLE_GAMMA =
# HTML_COLORSTYLE_HUE =
# HTML_COLORSTYLE_SAT =
# HTML_DYNAMIC_SECTIONS =
# HTML_EXTRA_FILES =
# HTML_EXTRA_STYLESHEET =
# HTML_FOOTER =
# HTML_HEADER =
# HTML_INDEX_NUM_ENTRIES =
# HTML_STYLESHEET =
# HTML_TIMESTAMP =
# IDL_PROPERTY_SUPPORT =
# IGNORE_PREFIX =
# IMAGE_PATH =
# INCLUDED_BY_GRAPH =
# INCLUDE_FILE_PATTERNS =
# INCLUDE_GRAPH =
# INCLUDE_PATH =
# INHERIT_DOCS =
# INLINE_GROUPED_CLASSES =
# INLINE_INFO =
# INLINE_INHERITED_MEMB =
# INLINE_SIMPLE_STRUCTS =
# INLINE_SOURCES =
# INPUT =
# INPUT_ENCODING =
# INTERACTIVE_SVG =
# INTERNAL_DOCS =
# JAVADOC_AUTOBRIEF =
# LAYOUT_FILE =
# MACRO_EXPANSION =
# MARKDOWN_SUPPORT =
# MAX_DOT_GRAPH_DEPTH =
# MSCFILE_DIRS =
# MULTILINE_CPP_IS_BRIEF =
# OPTIMIZE_FOR_FORTRAN =
# OPTIMIZE_OUTPUT_FOR_C =
# OPTIMIZE_OUTPUT_JAVA =
# OPTIMIZE_OUTPUT_VHDL =
# OUTPUT_LANGUAGE =
# PLANTUML_JAR_PATH =
# PREDEFINED =
# PROJECT_BRIEF =
# PROJECT_LOGO =
# PROJECT_NAME =
# PROJECT_NUMBER =
# QT_AUTOBRIEF =
# RECURSIVE =
# REFERENCED_BY_RELATION =
# REFERENCES_LINK_SOURCE =
# REFERENCES_RELATION =
# REPEAT_BRIEF =
# SEARCHENGINE =
# SEARCH_INCLUDES =
# SEPARATE_MEMBER_PAGES =
# SHORT_NAMES =
# SHOW_FILES =
# SHOW_GROUPED_MEMB_INC =
# SHOW_INCLUDE_FILES =
# SHOW_NAMESPACES =
# SHOW_USED_FILES =
# SIP_SUPPORT =
# SKIP_FUNCTION_MACROS =
# SORT_BRIEF_DOCS =
# SORT_BY_SCOPE_NAME =
# SORT_GROUP_NAMES =
# SORT_MEMBERS_CTORS_1ST =
# SORT_MEMBER_DOCS =
# SOURCE_BROWSER =
# SOURCE_TOOLTIPS =
# STRICT_PROTO_MATCHING =
# STRIP_CODE_COMMENTS =
# STRIP_FROM_INC_PATH =
# STRIP_FROM_PATH =
# SUBGROUPING =
# TAB_SIZE =
# TEMPLATE_RELATIONS =
# TREEVIEW_WIDTH =
# TYPEDEF_HIDES_STRUCT =
# UML_LIMIT_NUM_FIELDS =
# UML_LOOK =
# USE_MDFILE_AS_MAINPAGE =
# VERBATIM_HEADERS =
#

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.idea/*
cmake-build-debug/*
documentation/*

2565
Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -32,12 +32,12 @@ struct internal_array {
};
/**
* Initializes an array, which is a static contiguous array.
* Initializes an array.
*
* @param element_count The amount of elements in the array. Must be positive.
* @param data_size The size of each element in the array. Must be positive.
* @param element_count the amount of elements in the array; must be positive
* @param data_size the size of each element in the array; must be positive
*
* @return The newly-initialized array, or NULL if memory allocation error.
* @return the newly-initialized array, or NULL if memory allocation error
*/
array array_init(const int element_count, const size_t data_size)
{
@@ -61,9 +61,9 @@ array array_init(const int element_count, const size_t data_size)
/**
* Gets the size of the array.
*
* @param me The array to check.
* @param me the array to check
*
* @return The size of the array.
* @return the size of the array
*/
int array_size(array me)
{
@@ -71,10 +71,10 @@ int array_size(array me)
}
/**
* Copies the storage element of array to an array.
* Copies the array to a raw array.
*
* @param arr The array to copy to.
* @param me The array to copy from.
* @param arr the initialized raw array to copy the array to
* @param me the array to copy to the raw array
*/
void array_copy_to_array(void *const arr, array me)
{
@@ -87,9 +87,9 @@ void array_copy_to_array(void *const arr, array me)
* operation may invalidate this data pointer. The array owns the data pointer,
* thus it must not be freed.
*
* @param me The array to get the storage element from.
* @param me the array to get the storage element from
*
* @return The storage element of the array.
* @return the storage element of the array
*/
void *array_get_data(array me)
{
@@ -107,12 +107,12 @@ static bool array_is_illegal_input(array me, const int index)
/**
* Sets the data for a specified element in the array.
*
* @param me The array to set data for.
* @param index The location to set data at in the array.
* @param data The data to set at the location in the array.
* @param me the array to set data for
* @param index the location to set data at in the array
* @param data the data to set at the location in the array
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int array_set(array me, const int index, void *const data)
{
@@ -126,12 +126,12 @@ int array_set(array me, const int index, void *const data)
/**
* Copies the element at index of the array to data.
*
* @param data The data to copy to.
* @param me The array to copy from.
* @param index The index to copy from in the array.
* @param data the data to copy to
* @param me the array to copy from
* @param index the index to copy from in the array
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int array_get(void *const data, array me, const int index)
{
@@ -145,7 +145,7 @@ int array_get(void *const data, array me, const int index)
/**
* Frees the array memory.
*
* @param me The array to free from memory.
* @param me the array to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The array data structure, which is a static contiguous array.
*/
typedef struct internal_array *array;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,11 +41,11 @@ struct node {
};
/**
* Initializes a deque, which is a doubly-ended queue.
* Initializes a deque.
*
* @param data_size The size of each element in the deque. Must be positive.
* @param data_size the size of each element in the deque; must be positive
*
* @return The newly-initialized deque, or NULL if memory allocation error.
* @return the newly-initialized deque, or NULL if memory allocation error
*/
deque deque_init(const size_t data_size)
{
@@ -80,9 +80,9 @@ deque deque_init(const size_t data_size)
* used. The size starts at zero, and every time an element is added, it
* increases by one.
*
* @param me The deque to check size of.
* @param me the deque to check size of
*
* @return The size of the deque.
* @return the size of the deque
*/
int deque_size(deque me)
{
@@ -92,9 +92,9 @@ int deque_size(deque me)
/**
* Determines if the deque is empty. It is empty if it has no elements.
*
* @param me The deque to check if empty.
* @param me the deque to check if empty
*
* @return If empty.
* @return true if empty
*/
bool deque_is_empty(deque me)
{
@@ -105,10 +105,10 @@ bool deque_is_empty(deque me)
* Trims the deque so that it does not use memory which does not need to be
* used.
*
* @param me The deque to trim.
* @param me the deque to trim
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int deque_trim(deque me)
{
@@ -139,10 +139,10 @@ int deque_trim(deque me)
}
/**
* Copies the deque to an array representation.
* Copies the deque to an array.
*
* @param arr The array to copy the deque to.
* @param me The deque to copy from.
* @param arr the initialized array to copy the deque to
* @param me the deque to copy to the array
*/
void deque_copy_to_array(void *const arr, deque me)
{
@@ -154,11 +154,11 @@ void deque_copy_to_array(void *const arr, deque me)
/**
* Adds an element to the front of the deque.
*
* @param me The deque to add an element to.
* @param data The element to add.
* @param me the deque to add an element to
* @param data the element to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int deque_push_front(deque me, void *const data)
{
@@ -209,11 +209,11 @@ int deque_push_front(deque me, void *const data)
/**
* Adds an element to the back of the deque.
*
* @param me The deque to add an element to.
* @param data The element to add.
* @param me the deque to add an element to
* @param data the element to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int deque_push_back(deque me, void *const data)
{
@@ -252,11 +252,11 @@ int deque_push_back(deque me, void *const data)
/**
* Removes the front element from the deque and copies it to a data value.
*
* @param data The value to copy to.
* @param me The deque to remove from.
* @param data the value to copy to
* @param me the deque to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_pop_front(void *const data, deque me)
{
@@ -274,11 +274,11 @@ int deque_pop_front(void *const data, deque me)
/**
* Removes the back element from the deque and copies it to a data value.
*
* @param data The value to copy to.
* @param me The deque to remove from.
* @param data the value to copy to
* @param me the deque to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_pop_back(void *const data, deque me)
{
@@ -296,11 +296,11 @@ int deque_pop_back(void *const data, deque me)
/**
* Sets the first value of the deque.
*
* @param me The deque to set value of.
* @param data The data to set.
* @param me the deque to set value of
* @param data the data to set
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_set_first(deque me, void *const data)
{
@@ -310,12 +310,12 @@ int deque_set_first(deque me, void *const data)
/**
* Sets the value of the deque at the specified index.
*
* @param me The deque to set value of.
* @param index The index to set at.
* @param data The data to set.
* @param me the deque to set value of
* @param index the index to set at
* @param data the data to set
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_set_at(deque me, int index, void *const data)
{
@@ -333,11 +333,11 @@ int deque_set_at(deque me, int index, void *const data)
/**
* Sets the last value of the deque.
*
* @param me The deque to set value of.
* @param data The data to set.
* @param me the deque to set value of
* @param data the data to set
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_set_last(deque me, void *const data)
{
@@ -347,11 +347,11 @@ int deque_set_last(deque me, void *const data)
/**
* Gets the first value of the deque.
*
* @param data The data to set.
* @param me The deque to set value of.
* @param data the data to set
* @param me the deque to set value of
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_get_first(void *const data, deque me)
{
@@ -361,12 +361,12 @@ int deque_get_first(void *const data, deque me)
/**
* Gets the value of the deque at the specified index.
*
* @param data The data to set.
* @param me The deque to set value of.
* @param index The index to set at.
* @param data the data to set
* @param me the deque to set value of
* @param index the index to set at
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_get_at(void *const data, deque me, int index)
{
@@ -384,11 +384,11 @@ int deque_get_at(void *const data, deque me, int index)
/**
* Gets the last value of the deque.
*
* @param data The data to set.
* @param me The deque to set value of.
* @param data the data to set
* @param me the deque to set value of
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int deque_get_last(void *const data, deque me)
{
@@ -398,10 +398,10 @@ int deque_get_last(void *const data, deque me)
/**
* Clears the deque and sets it to the original state from initialization.
*
* @param me The deque to clear.
* @param me the deque to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int deque_clear(deque me)
{
@@ -431,7 +431,7 @@ int deque_clear(deque me)
/**
* Destroys the deque.
*
* @param me The deque to destroy.
* @param me the deque to destroy
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The deque data structure, which is a doubly-ended queue.
*/
typedef struct internal_deque *deque;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -39,10 +39,10 @@ struct node {
/**
* Initializes a singly-linked list.
*
* @param data_size The size of data to store. Must be positive.
* @param data_size the size of data to store; must be positive
*
* @return The newly-initialized singly-linked list, or NULL if memory
* allocation error.
* @return the newly-initialized singly-linked list, or NULL if memory
* allocation error
*/
forward_list forward_list_init(const size_t data_size)
{
@@ -63,9 +63,9 @@ forward_list forward_list_init(const size_t data_size)
/**
* Gets the amount of elements in the singly-linked list.
*
* @param me The singly-linked list to check.
* @param me the singly-linked list to check
*
* @return The amount of elements.
* @return the amount of elements
*/
int forward_list_size(forward_list me)
{
@@ -75,9 +75,9 @@ int forward_list_size(forward_list me)
/**
* Determines if the singly-linked list is empty.
*
* @param me The singly-linked list to check.
* @param me the singly-linked list to check
*
* @return If the list is empty.
* @return true if the singly-linked list is empty
*/
bool forward_list_is_empty(forward_list me)
{
@@ -87,8 +87,8 @@ bool forward_list_is_empty(forward_list me)
/**
* Copies the nodes of the singly-linked list to an array.
*
* @param arr The array to copy the list to.
* @param me The list to copy to the array.
* @param arr the initialized array to copy the singly-linked list to
* @param me the singly-linked list to copy to the array
*/
void forward_list_copy_to_array(void *const arr, forward_list me)
{
@@ -116,11 +116,11 @@ static struct node *forward_list_get_node_at(forward_list me, const int index)
/**
* Adds data at the first index in the singly-linked list.
*
* @param me The list to add data to.
* @param data The data to add to the list.
* @param me the singly-linked list to add data to
* @param data the data to add to the singly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int forward_list_add_first(forward_list me, void *const data)
{
@@ -130,13 +130,13 @@ int forward_list_add_first(forward_list me, void *const data)
/**
* Adds data at a specified index in the singly-linked list.
*
* @param me The list to add data to.
* @param index The index to add the data at.
* @param data The data to add to the list.
* @param me the singly-linked list to add data to
* @param index the index to add the data at
* @param data the data to add to the singly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -ENOMEM if out of memory
* @return -EINVAL if invalid argument
*/
int forward_list_add_at(forward_list me, const int index, void *const data)
{
@@ -168,11 +168,11 @@ int forward_list_add_at(forward_list me, const int index, void *const data)
/**
* Adds data at the last index in the singly-linked list.
*
* @param me The list to add data to.
* @param data The data to add to the list.
* @param me the singly-linked list to add data to
* @param data the data to add to the singly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int forward_list_add_last(forward_list me, void *const data)
{
@@ -190,10 +190,10 @@ static bool forward_list_is_illegal_input(forward_list me, const int index)
/**
* Removes the first piece of data from the singly-linked list.
*
* @param me The list to remove data from.
* @param me the singly-linked list to remove data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_remove_first(forward_list me)
{
@@ -203,11 +203,11 @@ int forward_list_remove_first(forward_list me)
/**
* Removes data from the singly-linked list at the specified index.
*
* @param me The list to remove data from.
* @param index The index to remove from.
* @param me the singly-linked list to remove data from
* @param index the index to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_remove_at(forward_list me, const int index)
{
@@ -238,10 +238,10 @@ int forward_list_remove_at(forward_list me, const int index)
/**
* Removes the last piece of data from the singly-linked list.
*
* @param me The list to remove data from.
* @param me the singly-linked list to remove data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_remove_last(forward_list me)
{
@@ -251,11 +251,11 @@ int forward_list_remove_last(forward_list me)
/**
* Sets the data at the first index in the singly-linked list.
*
* @param me The list to set data for.
* @param data The data to set in the list.
* @param me the singly-linked list to set data for
* @param data the data to set in the singly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_set_first(forward_list me, void *const data)
{
@@ -265,12 +265,12 @@ int forward_list_set_first(forward_list me, void *const data)
/**
* Sets the data at the specified index in the singly-linked list.
*
* @param me The list to set data for.
* @param index The index to set data in the list.
* @param data The data to set in the list.
* @param me the singly-linked list to set data for
* @param index the index to set data in the singly-linked list
* @param data the data to set in the singly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_set_at(forward_list me, const int index, void *const data)
{
@@ -285,11 +285,11 @@ int forward_list_set_at(forward_list me, const int index, void *const data)
/**
* Sets the data at the last index in the singly-linked list.
*
* @param me The list to set data for.
* @param data The data to set in the list.
* @param me the singly-linked list to set data for
* @param data the data to set in the singly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_set_last(forward_list me, void *const data)
{
@@ -299,11 +299,11 @@ int forward_list_set_last(forward_list me, void *const data)
/**
* Gets the data at the first index in the singly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param data the data to get
* @param me the singly-linked list to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_get_first(void *const data, forward_list me)
{
@@ -313,12 +313,12 @@ int forward_list_get_first(void *const data, forward_list me)
/**
* Gets the data at the specified index in the singly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param index The index to get data from.
* @param data the data to get
* @param me the singly-linked list to get data from
* @param index the index to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_get_at(void *const data, forward_list me, const int index)
{
@@ -333,11 +333,11 @@ int forward_list_get_at(void *const data, forward_list me, const int index)
/**
* Gets the data at the last index in the singly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param data the data to get
* @param me the singly-linked list to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int forward_list_get_last(void *const data, forward_list me)
{
@@ -347,7 +347,7 @@ int forward_list_get_last(void *const data, forward_list me)
/**
* Clears all elements from the singly-linked list.
*
* @param me The list to clear.
* @param me the singly-linked list to clear
*/
void forward_list_clear(forward_list me)
{
@@ -365,7 +365,7 @@ void forward_list_clear(forward_list me)
/**
* Destroys the singly-linked list.
*
* @param me The list to destroy.
* @param me the singly-linked list to destroy
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The forward_list data structure, which is a singly-linked list.
*/
typedef struct internal_forward_list *forward_list;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,10 +41,10 @@ struct node {
/**
* Initializes a doubly-linked list.
*
* @param data_size The size of data to store. Must be positive.
* @param data_size the size of data to store; must be positive
*
* @return The newly-initialized doubly-linked list, or NULL if memory
* allocation error.
* @return the newly-initialized doubly-linked list, or NULL if memory
* allocation error
*/
list list_init(const size_t data_size)
{
@@ -65,9 +65,9 @@ list list_init(const size_t data_size)
/**
* Gets the amount of elements in the doubly-linked list.
*
* @param me The doubly-linked list to check.
* @param me the doubly-linked list to check
*
* @return The amount of elements.
* @return the amount of elements
*/
int list_size(list me)
{
@@ -77,9 +77,9 @@ int list_size(list me)
/**
* Determines if the doubly-linked list is empty.
*
* @param me The doubly-linked list to check.
* @param me the doubly-linked list to check
*
* @return If the list is empty.
* @return true if the list is empty
*/
bool list_is_empty(list me)
{
@@ -89,8 +89,8 @@ bool list_is_empty(list me)
/**
* Copies the nodes of the doubly-linked list to an array.
*
* @param arr The array to copy the list to.
* @param me The list to copy to the array.
* @param arr the initialized array to copy the doubly-linked list to
* @param me the doubly-linked list to copy to the array
*/
void list_copy_to_array(void *const arr, list me)
{
@@ -142,11 +142,11 @@ static struct node *list_get_node_at(list me, const int index)
/**
* Adds data at the first index in the doubly-linked list.
*
* @param me The list to add data to.
* @param data The data to add to the list.
* @param me the doubly-linked list to add data to
* @param data the data to add to the doubly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int list_add_first(list me, void *const data)
{
@@ -177,13 +177,13 @@ int list_add_first(list me, void *const data)
/**
* Adds data at a specified index in the doubly-linked list.
*
* @param me The list to add data to.
* @param index The index to add the data at.
* @param data The data to add to the list.
* @param me the doubly-linked list to add data to
* @param index the index to add the data at
* @param data the data to add to the doubly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -ENOMEM if out of memory
* @return -EINVAL if invalid argument
*/
int list_add_at(list me, const int index, void *const data)
{
@@ -219,11 +219,11 @@ int list_add_at(list me, const int index, void *const data)
/**
* Adds data at the last index in the doubly-linked list.
*
* @param me The list to add data to.
* @param data The data to add to the list.
* @param me the doubly-linked list to add data to
* @param data the data to add to the doubly-linked list
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int list_add_last(list me, void *const data)
{
@@ -259,10 +259,10 @@ static bool list_is_illegal_input(list me, const int index)
/**
* Removes the first piece of data from the doubly-linked list.
*
* @param me The list to remove data from.
* @param me the doubly-linked list to remove data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_remove_first(list me)
{
@@ -272,11 +272,11 @@ int list_remove_first(list me)
/**
* Removes data from the doubly-linked list at the specified index.
*
* @param me The list to remove data from.
* @param index The index to remove from.
* @param me the doubly-linked list to remove data from
* @param index the index to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_remove_at(list me, const int index)
{
@@ -303,10 +303,10 @@ int list_remove_at(list me, const int index)
/**
* Removes the last piece of data from the doubly-linked list.
*
* @param me The list to remove data from.
* @param me the doubly-linked list to remove data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_remove_last(list me)
{
@@ -316,11 +316,11 @@ int list_remove_last(list me)
/**
* Sets the data at the first index in the doubly-linked list.
*
* @param me The list to set data for.
* @param data The data to set in the list.
* @param me the doubly-linked list to set data for
* @param data the data to set in the doubly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_set_first(list me, void *const data)
{
@@ -330,12 +330,12 @@ int list_set_first(list me, void *const data)
/**
* Sets the data at the specified index in the doubly-linked list.
*
* @param me The list to set data for.
* @param index The index to set data in the list.
* @param data The data to set in the list.
* @param me the doubly-linked list to set data for
* @param index the index to set data in the doubly-linked list
* @param data the data to set in the doubly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_set_at(list me, const int index, void *const data)
{
@@ -350,11 +350,11 @@ int list_set_at(list me, const int index, void *const data)
/**
* Sets the data at the last index in the doubly-linked list.
*
* @param me The list to set data for.
* @param data The data to set in the list.
* @param me the doubly-linked list to set data for
* @param data the data to set in the doubly-linked list
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_set_last(list me, void *const data)
{
@@ -364,11 +364,11 @@ int list_set_last(list me, void *const data)
/**
* Gets the data at the first index in the doubly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param data the data to get
* @param me the doubly-linked list to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_get_first(void *const data, list me)
{
@@ -378,12 +378,12 @@ int list_get_first(void *const data, list me)
/**
* Gets the data at the specified index in the doubly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param index The index to get data from.
* @param data the data to get
* @param me the doubly-linked list to get data from
* @param index the index to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_get_at(void *const data, list me, const int index)
{
@@ -398,11 +398,11 @@ int list_get_at(void *const data, list me, const int index)
/**
* Gets the data at the last index in the doubly-linked list.
*
* @param data The data to get.
* @param me The list to get data from.
* @param data the data to get
* @param me the doubly-linked list to get data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int list_get_last(void *const data, list me)
{
@@ -412,7 +412,7 @@ int list_get_last(void *const data, list me)
/**
* Clears all elements from the doubly-linked list.
*
* @param me The list to clear.
* @param me the doubly-linked list to clear
*/
void list_clear(list me)
{
@@ -431,7 +431,7 @@ void list_clear(list me)
/**
* Destroys the doubly-linked list.
*
* @param me The list to destroy.
* @param me the doubly-linked list to destroy
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The list data structure, which is a doubly-linked list.
*/
typedef struct internal_list *list;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -43,15 +43,14 @@ struct node {
};
/**
* Initializes a map, which is a collection of key-value pairs, sorted by keys,
* keys are unique
* Initializes a map.
*
* @param key_size The size of each key in the map. Must be positive.
* @param value_size The size of each value in the map. Must be positive.
* @param comparator The comparator function used for key ordering. Must not be
* NULL.
* @param key_size the size of each key in the map; must be positive
* @param value_size the size of each value in the map; must be positive
* @param comparator the comparator function used for key ordering; must not be
* NULL
*
* @return The newly-initialized map, or NULL if memory allocation error.
* @return the newly-initialized map, or NULL if memory allocation error
*/
map map_init(const size_t key_size,
const size_t value_size,
@@ -75,9 +74,9 @@ map map_init(const size_t key_size,
/**
* Gets the size of the map.
*
* @param me The map to check.
* @param me the map to check
*
* @return The size of the map.
* @return the size of the map
*/
int map_size(map me)
{
@@ -87,9 +86,9 @@ int map_size(map me)
/**
* Determines whether or not the map is empty.
*
* @param me The map to check.
* @param me the map to check
*
* @return If the map is empty.
* @return true if the map is empty
*/
bool map_is_empty(map me)
{
@@ -280,12 +279,12 @@ static struct node *map_create_node(map me,
* Adds a key-value pair to the map. If the map already contains the key, the
* value is updated to the new value.
*
* @param me The map to add to.
* @param key The key to add.
* @param value The value to add.
* @param me the map to add to
* @param key the key to add
* @param value the value to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int map_put(map me, void *const key, void *const value)
{
@@ -363,11 +362,11 @@ static struct node *map_equal_match(map me, const void *const key)
/**
* Gets the value associated with a key in the map.
*
* @param value The value to copy to.
* @param me The map to get from.
* @param key The key to search for.
* @param value the value to copy to
* @param me the map to get from
* @param key the key to search for
*
* @return If the map contained the key-value pair.
* @return true if the map contained the key-value pair
*/
bool map_get(void *const value, map me, void *const key)
{
@@ -382,10 +381,10 @@ bool map_get(void *const value, map me, void *const key)
/**
* Determines if the map contains the specified key.
*
* @param me The map to check for the element.
* @param key The key to check.
* @param me the map to check for the element
* @param key the key to check
*
* @return If the map contained the element.
* @return true if the map contained the element
*/
bool map_contains(map me, void *const key)
{
@@ -579,10 +578,10 @@ static void map_remove_element(map me, struct node *const traverse)
/**
* Removes the key-value pair from the map if it contains it.
*
* @param me The map to remove an element from.
* @param key The key to remove.
* @param me the map to remove an element from
* @param key the key to remove
*
* @return If the map contained the key-value pair.
* @return true if the map contained the key-value pair
*/
bool map_remove(map me, void *const key)
{
@@ -597,7 +596,7 @@ bool map_remove(map me, void *const key)
/**
* Clears the key-value pairs from the map.
*
* @param me The map to clear.
* @param me the map to clear
*/
void map_clear(map me)
{
@@ -609,7 +608,7 @@ void map_clear(map me)
/**
* Frees the map memory.
*
* @param me The map to free from memory.
* @param me the map to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The map data structure, which is a collection of key-value pairs, sorted by
* keys, keys are unique.
*/
typedef struct internal_map *map;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -51,17 +51,16 @@ struct value_node {
};
/**
* Initializes a multi-map, which is a collection of key-value pairs, sorted by
* keys.
* Initializes a multi-map.
*
* @param key_size The size of each key in the multi-map. Must be
* positive.
* @param value_size The size of each value in the multi-map. Must be
* positive.
* @param key_comparator The key comparator function. Must not be NULL.
* @param value_comparator The value comparator function. Must not be NULL.
* @param key_size the size of each key in the multi-map; must be
* positive
* @param value_size the size of each value in the multi-map; must be
* positive
* @param key_comparator the key comparator function; must not be NULL
* @param value_comparator the value comparator function; must not be NULL
*
* @return The newly-initialized multi-map, or NULL if memory allocation error.
* @return the newly-initialized multi-map, or NULL if memory allocation error
*/
multimap multimap_init(const size_t key_size,
const size_t value_size,
@@ -92,9 +91,9 @@ multimap multimap_init(const size_t key_size,
/**
* Gets the size of the multi-map.
*
* @param me The multi-map to check.
* @param me the multi-map to check
*
* @return The size of the multi-map.
* @return the size of the multi-map
*/
int multimap_size(multimap me)
{
@@ -104,9 +103,9 @@ int multimap_size(multimap me)
/**
* Determines whether or not the multi-map is empty.
*
* @param me The multi-map to check.
* @param me the multi-map to check
*
* @return If the multi-map is empty.
* @return true if the multi-map is empty
*/
bool multimap_is_empty(multimap me)
{
@@ -316,12 +315,12 @@ static struct node *multimap_create_node(multimap me,
/**
* Adds a key-value pair to the multi-map.
*
* @param me The multi-map to add to.
* @param key The key to add.
* @param value The value to add.
* @param me the multi-map to add to
* @param key the key to add
* @param value the value to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int multimap_put(multimap me, void *const key, void *const value)
{
@@ -409,8 +408,8 @@ static struct node *multimap_equal_match(multimap me, const void *const key)
* getting the next value. Between starting and iterations, the multi-map must
* not be mutated.
*
* @param me The multi-map to start the iterator for.
* @param key The key to start the iterator for.
* @param me the multi-map to start the iterator for
* @param key the key to start the iterator for
*/
void multimap_get_start(multimap me, void *const key)
{
@@ -424,11 +423,11 @@ void multimap_get_start(multimap me, void *const key)
* Iterates over the values for the specified key. Must be called after starting
* the iterator. The multi-map must not be mutated between start and iterations.
*
* @param value The value to be copied to from iteration.
* @param me The multi-map to iterate over.
* @param value the value to be copied to from iteration
* @param me the multi-map to iterate over
*
* @return If there exist no more values for the key which is being iterated
* over.
* @return true if there exist no more values for the key which is being
* iterated over
*/
bool multimap_get_next(void *const value, multimap me)
{
@@ -444,10 +443,10 @@ bool multimap_get_next(void *const value, multimap me)
/**
* Determines the amount of times the key appears in the multi-map.
*
* @param me The multi-map to check for the key.
* @param key The key to check.
* @param me the multi-map to check for the key
* @param key the key to check
*
* @return The amount of times the key appears in the multi-map.
* @return the amount of times the key appears in the multi-map
*/
int multimap_count(multimap me, void *const key)
{
@@ -461,10 +460,10 @@ int multimap_count(multimap me, void *const key)
/**
* Determines if the multi-map contains the specified key.
*
* @param me The multi-map to check for the key.
* @param key The key to check.
* @param me the multi-map to check for the key
* @param key the key to check
*
* @return If the multi-map contained the key.
* @return true if the multi-map contained the key
*/
bool multimap_contains(multimap me, void *const key)
{
@@ -659,11 +658,11 @@ static void multimap_remove_element(multimap me, struct node *const traverse)
/**
* Removes the key-value pair from the multi-map if it contains it.
*
* @param me The multi-map to remove an key from.
* @param key The key to remove.
* @param value The value to remove.
* @param me the multi-map to remove an key from
* @param key the key to remove
* @param value the value to remove
*
* @return If the multi-map contained the key.
* @return true if the multi-map contained the key
*/
bool multimap_remove(multimap me, void *const key, void *const value)
{
@@ -716,10 +715,10 @@ static void multimap_remove_all_element(multimap me,
/**
* Removes all the key-value pairs from the multi-map specified by the key.
*
* @param me The multi-map to remove a key-value pair from.
* @param key The key to remove.
* @param me the multi-map to remove a key-value pair from
* @param key the key to remove
*
* @return If the multi-map contained the key.
* @return true if the multi-map contained the key
*/
bool multimap_remove_all(multimap me, void *const key)
{
@@ -734,7 +733,7 @@ bool multimap_remove_all(multimap me, void *const key)
/**
* Clears the key-value pairs from the multi-map.
*
* @param me The multi-map to clear.
* @param me the multi-map to clear
*/
void multimap_clear(multimap me)
{
@@ -746,7 +745,7 @@ void multimap_clear(multimap me)
/**
* Frees the multi-map memory.
*
* @param me The multi-map to free from memory.
* @param me the multi-map to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The multimap data structure, which is a collection of key-value pairs, sorted
* by keys.
*/
typedef struct internal_multimap *multimap;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -42,15 +42,14 @@ struct node {
};
/**
* Initializes a multi-set, which is a collection of key-value pairs, sorted by
* keys, keys are unique
* Initializes a multi-set.
*
* @param key_size The size of each element in the multi-set. Must be
* positive.
* @param comparator The comparator function used for key ordering. Must not be
* NULL.
* @param key_size the size of each element in the multi-set; must be
* positive
* @param comparator the comparator function used for key ordering; must not be
* NULL
*
* @return The newly-initialized multi-set, or NULL if memory allocation error.
* @return the newly-initialized multi-set, or NULL if memory allocation error
*/
multiset multiset_init(const size_t key_size,
int (*const comparator)(const void *const,
@@ -74,9 +73,9 @@ multiset multiset_init(const size_t key_size,
/**
* Gets the size of the multi-set.
*
* @param me The multi-set to check.
* @param me the multi-set to check
*
* @return The size of the multi-set.
* @return the size of the multi-set
*/
int multiset_size(multiset me)
{
@@ -86,9 +85,9 @@ int multiset_size(multiset me)
/**
* Determines whether or not the multi-set is empty.
*
* @param me The multi-set to check.
* @param me the multi-set to check
*
* @return If the multi-set is empty.
* @return true if the multi-set is empty
*/
bool multiset_is_empty(multiset me)
{
@@ -271,11 +270,11 @@ static struct node *multiset_create_node(multiset me,
/**
* Adds a key to the multi-set.
*
* @param me The multi-set to add to.
* @param key The key to add.
* @param me the multi-set to add to
* @param key the key to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int multiset_put(multiset me, void *const key)
{
@@ -354,10 +353,10 @@ static struct node *multiset_equal_match(multiset me, const void *const key)
/**
* Determines the count of a specific key in the multi-set.
*
* @param me The multi-set to check for the count.
* @param key The key to check.
* @param me the multi-set to check for the count
* @param key the key to check
*
* @return The count of a specific key in the multi-set.
* @return the count of a specific key in the multi-set
*/
int multiset_count(multiset me, void *const key)
{
@@ -371,10 +370,10 @@ int multiset_count(multiset me, void *const key)
/**
* Determines if the multi-set contains the specified key.
*
* @param me The multi-set to check for the key.
* @param key The key to check.
* @param me the multi-set to check for the key
* @param key the key to check
*
* @return If the multiset contained the key.
* @return true if the multiset contained the key
*/
bool multiset_contains(multiset me, void *const key)
{
@@ -569,10 +568,10 @@ static void multiset_remove_element(multiset me, struct node *const traverse)
/**
* Removes a key from the multi-set if it contains it.
*
* @param me The multi-set to remove a key from.
* @param key The key to remove.
* @param me the multi-set to remove a key from
* @param key the key to remove
*
* @return If the multi-set contained the key.
* @return true if the multi-set contained the key
*/
bool multiset_remove(multiset me, void *const key)
{
@@ -591,10 +590,10 @@ bool multiset_remove(multiset me, void *const key)
/**
* Removes all the occurrences of a specified key in the multi-set.
*
* @param me The multi-set to remove a key from.
* @param key The key to remove.
* @param me the multi-set to remove a key from
* @param key the key to remove
*
* @return If the multi-set contained the key.
* @return true if the multi-set contained the key
*/
bool multiset_remove_all(multiset me, void *const key)
{
@@ -610,7 +609,7 @@ bool multiset_remove_all(multiset me, void *const key)
/**
* Clears the keys from the multiset.
*
* @param me The multi-set to clear.
* @param me the multi-set to clear
*/
void multiset_clear(multiset me)
{
@@ -623,7 +622,7 @@ void multiset_clear(multiset me)
/**
* Frees the multi-set memory.
*
* @param me The multi-set to free from memory.
* @param me the multi-set to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The multiset data structure, which is a collection of key-value pairs, sorted
* by keys, keys are unique
*/
typedef struct internal_multiset *multiset;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -33,15 +33,14 @@ struct internal_priority_queue {
};
/**
* Initializes a priority queue, which adapts a container to provide priority
* queue. Adapts the vector container.
* Initializes a priority queue.
*
* @param data_size The size of the data in the priority queue. Must be
* positive.
* @param comparator The priority comparator function. Must not be NULL.
* @param data_size the size of the data in the priority queue; must be
* positive
* @param comparator the priority comparator function; must not be NULL
*
* @return The newly-initialized priority queue, or NULL if memory allocation
* error.
* @return the newly-initialized priority queue, or NULL if memory allocation
* error
*/
priority_queue priority_queue_init(const size_t data_size,
int (*comparator)(const void *const,
@@ -68,9 +67,9 @@ priority_queue priority_queue_init(const size_t data_size,
/**
* Gets the size of the priority queue.
*
* @param me The priority queue to check.
* @param me the priority queue to check
*
* @return The size of the priority queue.
* @return the size of the priority queue
*/
int priority_queue_size(priority_queue me)
{
@@ -80,9 +79,9 @@ int priority_queue_size(priority_queue me)
/**
* Determines whether or not the priority queue is empty.
*
* @param me The priority queue to check.
* @param me the priority queue to check
*
* @return If the priority queue is empty.
* @return true if the priority queue is empty
*/
bool priority_queue_is_empty(priority_queue me)
{
@@ -92,11 +91,11 @@ bool priority_queue_is_empty(priority_queue me)
/**
* Adds an element to the priority queue.
*
* @param me The priority queue to add an element to.
* @param data The data to add to the queue.
* @param me the priority queue to add an element to
* @param data the data to add to the queue
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int priority_queue_push(priority_queue me, void *const data)
{
@@ -130,10 +129,10 @@ int priority_queue_push(priority_queue me, void *const data)
/**
* Removes the highest priority element from the priority queue.
*
* @param data The data to have copied from the priority queue.
* @param me The priority queue to pop the next element from.
* @param data the data to have copied from the priority queue
* @param me the priority queue to pop the next element from
*
* @return If the priority queue contained elements.
* @return true if the priority queue contained elements
*/
bool priority_queue_pop(void *const data, priority_queue me)
{
@@ -183,10 +182,11 @@ bool priority_queue_pop(void *const data, priority_queue me)
/**
* Gets the highest priority element in the priority queue.
*
* @param data Out copy of the highest priority element in the priority queue.
* @param me The priority queue to copy from.
* @param data the out copy of the highest priority element in the priority
* queue
* @param me the priority queue to copy from
*
* @return If the priority queue contained elements.
* @return true if the priority queue contained elements
*/
bool priority_queue_front(void *const data, priority_queue me)
{
@@ -196,10 +196,10 @@ bool priority_queue_front(void *const data, priority_queue me)
/**
* Clears the elements from the priority queue.
*
* @param me The priority queue to clear.
* @param me the priority queue to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int priority_queue_clear(priority_queue me)
{
@@ -209,7 +209,7 @@ int priority_queue_clear(priority_queue me)
/**
* Frees the priority queue memory.
*
* @param me The priority queue to free from memory.
* @param me the priority queue to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The priority_queue data structure, which adapts a container to provide a
* priority queue. Adapts the vector container.
*/
typedef struct internal_priority_queue *priority_queue;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -32,12 +32,11 @@ struct internal_queue {
};
/**
* Initializes a queue, which adapts a container to provide queue
* (first-in first-out). Adapts the deque container.
* Initializes a queue.
*
* @param data_size The size of each element. Must be positive.
* @param data_size the size of each element; must be positive
*
* @return The newly-initialized queue, or NULL if memory allocation error.
* @return the newly-initialized queue, or NULL if memory allocation error
*/
queue queue_init(const size_t data_size)
{
@@ -60,9 +59,9 @@ queue queue_init(const size_t data_size)
/**
* Determines the size of the queue.
*
* @param me The queue to get size of.
* @param me the queue to get size of
*
* @return The queue size.
* @return the queue size
*/
int queue_size(queue me)
{
@@ -73,9 +72,9 @@ int queue_size(queue me)
* Determines if the queue is empty. The queue is empty if it contains no
* elements.
*
* @param me The queue to check if empty.
* @param me the queue to check if empty
*
* @return If the queue is empty.
* @return true if the queue is empty
*/
bool queue_is_empty(queue me)
{
@@ -85,10 +84,10 @@ bool queue_is_empty(queue me)
/**
* Frees the unused memory in the queue.
*
* @param me The queue to trim.
* @param me the queue to trim
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int queue_trim(queue me)
{
@@ -96,10 +95,10 @@ int queue_trim(queue me)
}
/**
* Copies the queue to an array representation.
* Copies the queue to an array.
*
* @param arr The array to have copied from the queue.
* @param me The queue to copy to the array.
* @param arr the initialized array to copy the queue to
* @param me the queue to copy to the array
*/
void queue_copy_to_array(void *const arr, queue me)
{
@@ -109,11 +108,11 @@ void queue_copy_to_array(void *const arr, queue me)
/**
* Adds an element to the queue.
*
* @param me The queue to add an element to.
* @param data The data to add to the queue.
* @param me the queue to add an element to
* @param data the data to add to the queue
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int queue_push(queue me, void *const data)
{
@@ -123,10 +122,10 @@ int queue_push(queue me, void *const data)
/**
* Removes the next element in the queue and copies the data.
*
* @param data The data to have copied from the queue.
* @param me The queue to pop the next element from.
* @param data the data to have copied from the queue
* @param me the queue to pop the next element from
*
* @return If the queue contained elements.
* @return true if the queue contained elements
*/
bool queue_pop(void *const data, queue me)
{
@@ -141,10 +140,10 @@ bool queue_pop(void *const data, queue me)
/**
* Gets the front element of the queue.
*
* @param data Copies the front element of the queue.
* @param me The queue to copy from.
* @param data the copy of the front element of the queue
* @param me the queue to copy from
*
* @return If the queue contained elements.
* @return true if the queue contained elements
*/
bool queue_front(void *const data, queue me)
{
@@ -154,10 +153,10 @@ bool queue_front(void *const data, queue me)
/**
* Gets the back element of the queue.
*
* @param data Copies the back element of the queue.
* @param me The queue to copy from.
* @param data the copy of the back element of the queue
* @param me the queue to copy from
*
* @return If the queue contained elements.
* @return true if the queue contained elements
*/
bool queue_back(void *const data, queue me)
{
@@ -167,10 +166,10 @@ bool queue_back(void *const data, queue me)
/**
* Clears the queue and sets it to the original state from initialization.
*
* @param me The queue to clear.
* @param me the queue to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int queue_clear(queue me)
{
@@ -180,7 +179,7 @@ int queue_clear(queue me)
/**
* Destroys the queue.
*
* @param me The queue to destroy.
* @param me the queue to destroy
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The queue data structure, which adapts a container to provide a queue
* (first-in first-out). Adapts the deque container.
*/
typedef struct internal_queue *queue;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,13 +41,13 @@ struct node {
};
/**
* Initializes a set, which is a collection of unique keys, sorted by keys.
* Initializes a set.
*
* @param key_size The size of each element in the set. Must be positive.
* @param comparator The comparator function used for key ordering. Must not be
* NULL.
* @param key_size the size of each element in the set; must be positive
* @param comparator the comparator function used for key ordering; must not be
* NULL
*
* @return The newly-initialized set, or NULL if memory allocation error.
* @return the newly-initialized set, or NULL if memory allocation error
*/
set set_init(const size_t key_size,
int (*const comparator)(const void *const, const void *const))
@@ -69,9 +69,9 @@ set set_init(const size_t key_size,
/**
* Gets the size of the set.
*
* @param me The set to check.
* @param me the set to check
*
* @return The size of the set.
* @return the size of the set
*/
int set_size(set me)
{
@@ -81,9 +81,9 @@ int set_size(set me)
/**
* Determines whether or not the set is empty.
*
* @param me The set to check.
* @param me the set to check
*
* @return If the set is empty.
* @return true if the set is empty
*/
bool set_is_empty(set me)
{
@@ -265,11 +265,11 @@ static struct node *set_create_node(set me,
/**
* Adds a key to the set if the set does not already contain it.
*
* @param me The set to add to.
* @param key The key to add.
* @param me the set to add to
* @param key the key to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int set_put(set me, void *const key)
{
@@ -346,10 +346,10 @@ static struct node *set_equal_match(set me, const void *const key)
/**
* Determines if the set contains the specified key.
*
* @param me The set to check for the key.
* @param key The key to check.
* @param me the set to check for the key
* @param key the key to check
*
* @return If the set contained the key.
* @return true if the set contained the key
*/
bool set_contains(set me, void *const key)
{
@@ -542,10 +542,10 @@ static void set_remove_element(set me, struct node *const traverse)
/**
* Removes the key from the set if it contains it.
*
* @param me The set to remove an key from.
* @param key The key to remove.
* @param me the set to remove an key from
* @param key the key to remove
*
* @return If the set contained the key.
* @return true if the set contained the key
*/
bool set_remove(set me, void *const key)
{
@@ -560,7 +560,7 @@ bool set_remove(set me, void *const key)
/**
* Clears the keys from the set.
*
* @param me The set to clear.
* @param me the set to clear
*/
void set_clear(set me)
{
@@ -572,7 +572,7 @@ void set_clear(set me)
/**
* Frees the set memory.
*
* @param me The set to free from memory.
* @param me the set to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The set data structure, which is a collection of unique keys, sorted by keys.
*/
typedef struct internal_set *set;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,13 +29,12 @@ struct internal_stack {
};
/**
* Initializes a stack, which adapts a container to provide stack
* (last-in first-out). Adapts the deque container.
* Initializes a stack.
*
* @param data_size The size of each data element in the stack. Must be
* positive.
* @param data_size the size of each data element in the stack; must be
* positive
*
* @return The newly-initialized stack, or NULL if memory allocation error.
* @return the newly-initialized stack, or NULL if memory allocation error
*/
stack stack_init(const size_t data_size)
{
@@ -57,9 +56,9 @@ stack stack_init(const size_t data_size)
/**
* Determines the size of the stack.
*
* @param me The stack to check size of.
* @param me the stack to check size of
*
* @return The size of the stack.
* @return the size of the stack
*/
int stack_size(stack me)
{
@@ -69,9 +68,9 @@ int stack_size(stack me)
/**
* Determines if the stack is empty, meaning it contains no elements.
*
* @param me The stack to check if empty.
* @param me the stack to check if empty
*
* @return If empty.
* @return true if the stack is empty
*/
bool stack_is_empty(stack me)
{
@@ -81,10 +80,10 @@ bool stack_is_empty(stack me)
/**
* Frees unused memory from the stack.
*
* @param me The stack to trim.
* @param me the stack to trim
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int stack_trim(stack me)
{
@@ -92,10 +91,10 @@ int stack_trim(stack me)
}
/**
* Copies the stack into an array representation.
* Copies the stack to an array.
*
* @param arr The array to copy to.
* @param me The stack to copy from.
* @param arr the initialized array to copy the stack to
* @param me the stack to copy to the array
*/
void stack_copy_to_array(void *const arr, stack me)
{
@@ -105,11 +104,11 @@ void stack_copy_to_array(void *const arr, stack me)
/**
* Adds an element to the top of the stack.
*
* @param me The stack to add an element to.
* @param data The data to add to the stack.
* @param me the stack to add an element to
* @param data the data to add to the stack
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int stack_push(stack me, void *const data)
{
@@ -120,10 +119,10 @@ int stack_push(stack me, void *const data)
* Removes the top element of the stack, and copies the data which is being
* removed.
*
* @param data The copy of the element being removed.
* @param me The stack to remove the top element from.
* @param data the copy of the element being removed
* @param me the stack to remove the top element from
*
* @return If the stack contained elements.
* @return true if the stack contained elements
*/
bool stack_pop(void *const data, stack me)
{
@@ -133,10 +132,10 @@ bool stack_pop(void *const data, stack me)
/**
* Copies the top element of the stack.
*
* @param data The copy of the top element of the stack.
* @param me The stack to copy from.
* @param data the copy of the top element of the stack
* @param me the stack to copy from
*
* @return If the stack contained elements.
* @return true if the stack contained elements
*/
bool stack_top(void *const data, stack me)
{
@@ -146,10 +145,10 @@ bool stack_top(void *const data, stack me)
/**
* Clears the stack and sets it to the state from original initialization.
*
* @param me The stack to clear.
* @param me the stack to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int stack_clear(stack me)
{
@@ -159,7 +158,7 @@ int stack_clear(stack me)
/**
* Destroys the stack and frees the memory associated with it.
*
* @param me The stack to destroy.
* @param me the stack to destroy
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The stack data structure, which adapts a container to provide a stack
* (last-in first-out). Adapts the deque container.
*/
typedef struct internal_stack *stack;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -55,25 +55,24 @@ static inline unsigned long unordered_map_hash(unordered_map me,
const void *const key)
{
unsigned long hash = me->hash(key);
hash ^= (hash >> 20) ^ (hash >> 12);
return hash ^ (hash >> 7) ^ (hash >> 4);
hash ^= (hash >> 20UL) ^ (hash >> 12UL);
return hash ^ (hash >> 7UL) ^ (hash >> 4UL);
}
/**
* Initializes an unordered map, which is a collection of key-value pairs,
* hashed by keys, keys are unique
* Initializes an unordered map.
*
* @param key_size The size of each key in the unordered map. Must be
* positive.
* @param value_size The size of each value in the unordered map. Must be
* positive.
* @param hash The hash function which computes the hash from the key.
* Must not be NULL.
* @param comparator The comparator function which compares two keys. Must not
* be NULL.
* @param key_size the size of each key in the unordered map; must be
* positive
* @param value_size the size of each value in the unordered map; must be
* positive
* @param hash the hash function which computes the hash from the key;
* must not be NULL
* @param comparator the comparator function which compares two keys; must not
* be NULL
*
* @return The newly-initialized unordered map, or NULL if memory allocation
* error.
* @return the newly-initialized unordered map, or NULL if memory allocation
* error
*/
unordered_map unordered_map_init(const size_t key_size,
const size_t value_size,
@@ -125,10 +124,10 @@ static void unordered_map_add_item(unordered_map me, struct node *const add)
* Rehashes all the keys in the unordered map. Used when storing references and
* changing the keys. This should rarely be used.
*
* @param me The unordered map to rehash.
* @param me the unordered map to rehash
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_map_rehash(unordered_map me)
{
@@ -154,9 +153,9 @@ int unordered_map_rehash(unordered_map me)
/**
* Gets the size of the unordered map.
*
* @param me The unordered map to check.
* @param me the unordered map to check
*
* @return The size of the unordered map.
* @return the size of the unordered map
*/
int unordered_map_size(unordered_map me)
{
@@ -166,9 +165,9 @@ int unordered_map_size(unordered_map me)
/**
* Determines whether or not the unordered map is empty.
*
* @param me The unordered map to check.
* @param me the unordered map to check
*
* @return If the unordered map is empty.
* @return true if the unordered map is empty
*/
bool unordered_map_is_empty(unordered_map me)
{
@@ -246,12 +245,12 @@ static struct node *const unordered_map_create_element(unordered_map me,
* Adds a key-value pair to the unordered map. If the unordered map already
* contains the key, the value is updated to the new value.
*
* @param me The unordered map to add to.
* @param key The key to add.
* @param value The value to add.
* @param me the unordered map to add to
* @param key the key to add
* @param value the value to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_map_put(unordered_map me, void *const key, void *const value)
{
@@ -291,11 +290,11 @@ int unordered_map_put(unordered_map me, void *const key, void *const value)
/**
* Gets the value associated with a key in the unordered map.
*
* @param value The value to copy to.
* @param me The unordered map to get from.
* @param key The key to search for.
* @param value the value to copy to
* @param me the unordered map to get from
* @param key the key to search for
*
* @return If the unordered map contained the key-value pair.
* @return true if the unordered map contained the key-value pair
*/
bool unordered_map_get(void *const value, unordered_map me, void *const key)
{
@@ -315,10 +314,10 @@ bool unordered_map_get(void *const value, unordered_map me, void *const key)
/**
* Determines if the unordered map contains the specified key.
*
* @param me The unordered map to check for the key.
* @param key The key to check.
* @param me the unordered map to check for the key
* @param key the key to check
*
* @return If the unordered map contained the key.
* @return true if the unordered map contained the key
*/
bool unordered_map_contains(unordered_map me, void *const key)
{
@@ -337,10 +336,10 @@ bool unordered_map_contains(unordered_map me, void *const key)
/**
* Removes the key-value pair from the unordered map if it contains it.
*
* @param me The unordered map to remove an key from.
* @param key The key to remove.
* @param me the unordered map to remove an key from
* @param key the key to remove
*
* @return If the unordered map contained the key.
* @return true if the unordered map contained the key
*/
bool unordered_map_remove(unordered_map me, void *const key)
{
@@ -376,10 +375,10 @@ bool unordered_map_remove(unordered_map me, void *const key)
/**
* Clears the key-value pairs from the unordered map.
*
* @param me The unordered map to clear.
* @param me the unordered map to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_map_clear(unordered_map me)
{
@@ -409,7 +408,7 @@ int unordered_map_clear(unordered_map me)
/**
* Frees the unordered map memory.
*
* @param me The unordered map to free from memory.
* @param me the unordered map to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The unordered_map data structure, which is a collection of key-value pairs,
* hashed by keys, keys are unique
*/
typedef struct internal_unordered_map *unordered_map;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -59,27 +59,26 @@ static inline unsigned long unordered_multimap_hash(unordered_multimap me,
const void *const key)
{
unsigned long hash = me->hash(key);
hash ^= (hash >> 20) ^ (hash >> 12);
return hash ^ (hash >> 7) ^ (hash >> 4);
hash ^= (hash >> 20UL) ^ (hash >> 12UL);
return hash ^ (hash >> 7UL) ^ (hash >> 4UL);
}
/**
* Initializes an unordered multi-map, which is a collection of key-value pairs,
* hashed by keys
* Initializes an unordered multi-map.
*
* @param key_size The size of each key in the unordered multi-map. Must
* be positive.
* @param value_size The size of each value in the unordered multi-map.
* Must be positive.
* @param hash The hash function which computes the hash from key.
* Must not be NULL.
* @param key_comparator The comparator function which compares two keys.
* Must not be NULL.
* @param value_comparator The comparator function which compares two values.
* Must not be NULL.
* @param key_size the size of each key in the unordered multi-map; must
* be positive
* @param value_size the size of each value in the unordered multi-map;
* must be positive
* @param hash the hash function which computes the hash from key;
* must not be NULL
* @param key_comparator the comparator function which compares two keys; must
* not be NULL
* @param value_comparator the comparator function which compares two values;
* must not be NULL
*
* @return The newly-initialized unordered multi-map, or NULL if memory
* allocation error.
* @return the newly-initialized unordered multi-map, or NULL if memory
* allocation error
*/
unordered_multimap
unordered_multimap_init(const size_t key_size,
@@ -145,10 +144,10 @@ static void unordered_multimap_add_item(unordered_multimap me,
* Rehashes all the keys in the unordered multi-map. Used when storing
* references and changing the keys. This should rarely be used.
*
* @param me The unordered multi-map to rehash.
* @param me the unordered multi-map to rehash
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multimap_rehash(unordered_multimap me)
{
@@ -174,9 +173,9 @@ int unordered_multimap_rehash(unordered_multimap me)
/**
* Gets the size of the unordered multi-map.
*
* @param me The unordered multi-map to check.
* @param me the unordered multi-map to check
*
* @return The size of the unordered multi-map.
* @return the size of the unordered multi-map
*/
int unordered_multimap_size(unordered_multimap me)
{
@@ -186,9 +185,9 @@ int unordered_multimap_size(unordered_multimap me)
/**
* Determines whether or not the unordered multi-map is empty.
*
* @param me The unordered multi-map to check.
* @param me the unordered multi-map to check
*
* @return If the unordered multi-map is empty.
* @return true if the unordered multi-map is empty
*/
bool unordered_multimap_is_empty(unordered_multimap me)
{
@@ -266,12 +265,12 @@ unordered_multimap_create_element(unordered_multimap me,
/**
* Adds a key-value pair to the unordered multi-map.
*
* @param me The unordered multi-map to add to.
* @param key The key to add.
* @param value The value to add.
* @param me the unordered multi-map to add to
* @param key the key to add
* @param value the value to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multimap_put(unordered_multimap me,
void *const key,
@@ -308,8 +307,8 @@ int unordered_multimap_put(unordered_multimap me,
* getting the next value. Between starting and iterations, the unordered
* multi-map must not be mutated.
*
* @param me The unordered multi-map to start the iterator for.
* @param key The key to start the iterator for.
* @param me the unordered multi-map to start the iterator for
* @param key the key to start the iterator for
*/
void unordered_multimap_get_start(unordered_multimap me, void *const key)
{
@@ -332,11 +331,11 @@ void unordered_multimap_get_start(unordered_multimap me, void *const key)
* the iterator. The unordered multi-map must not be mutated between start and
* iterations.
*
* @param value The value to be copied to from iteration.
* @param me The unordered multi-map to iterate over.
* @param value the value to be copied to from iteration
* @param me the unordered multi-map to iterate over
*
* @return If there exist no more values for the key which is being iterated
* over.
* @return true if there exist no more values for the key which is being
* iterated over
*/
bool unordered_multimap_get_next(void *const value, unordered_multimap me)
{
@@ -362,10 +361,10 @@ bool unordered_multimap_get_next(void *const value, unordered_multimap me)
/**
* Determines the amount of times the key appears in the unordered multi-map.
*
* @param me The unordered multi-map to check for the key.
* @param key The key to check.
* @param me the unordered multi-map to check for the key
* @param key the key to check
*
* @return The amount of times the key appears in the unordered multi-map.
* @return the amount of times the key appears in the unordered multi-map
*/
int unordered_multimap_count(unordered_multimap me, void *const key)
{
@@ -385,10 +384,10 @@ int unordered_multimap_count(unordered_multimap me, void *const key)
/**
* Determines if the unordered multi-map contains the specified key.
*
* @param me The unordered multi-map to check for the key.
* @param key The key to check.
* @param me the unordered multi-map to check for the key
* @param key the key to check
*
* @return If the unordered multi-map contained the key.
* @return true if the unordered multi-map contained the key
*/
bool unordered_multimap_contains(unordered_multimap me, void *const key)
{
@@ -407,11 +406,11 @@ bool unordered_multimap_contains(unordered_multimap me, void *const key)
/**
* Removes the key-value pair from the unordered multi-map if it contains it.
*
* @param me The unordered multi-map to remove an key from.
* @param key The key to remove.
* @param value The value to remove.
* @param me the unordered multi-map to remove an key from
* @param key the key to remove
* @param value the value to remove
*
* @return If the unordered multi-map contained the key.
* @return true if the unordered multi-map contained the key
*/
bool unordered_multimap_remove(unordered_multimap me,
void *const key,
@@ -453,10 +452,10 @@ bool unordered_multimap_remove(unordered_multimap me,
* Removes all the key-value pairs from the unordered multi-map specified by the
* key.
*
* @param me The unordered multi-map to remove a key-value pair from.
* @param key The key to remove.
* @param me the unordered multi-map to remove a key-value pair from
* @param key the key to remove
*
* @return If the unordered multi-map contained the key.
* @return true if the unordered multi-map contained the key
*/
bool unordered_multimap_remove_all(unordered_multimap me, void *const key)
{
@@ -498,10 +497,10 @@ bool unordered_multimap_remove_all(unordered_multimap me, void *const key)
/**
* Clears the key-value pairs from the unordered multi-map.
*
* @param me The unordered multi-map to clear.
* @param me the unordered multi-map to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multimap_clear(unordered_multimap me)
{
@@ -531,7 +530,7 @@ int unordered_multimap_clear(unordered_multimap me)
/**
* Frees the unordered multi-map memory.
*
* @param me The unordered multi-map to free from memory.
* @param me the unordered multi-map to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The unordered_multimap data structure, which is a collection of key-value
* pairs, hashed by keys.
*/
typedef struct internal_unordered_multimap *unordered_multimap;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -55,23 +55,22 @@ static inline unsigned long unordered_multiset_hash(unordered_multiset me,
const void *const key)
{
unsigned long hash = me->hash(key);
hash ^= (hash >> 20) ^ (hash >> 12);
return hash ^ (hash >> 7) ^ (hash >> 4);
hash ^= (hash >> 20UL) ^ (hash >> 12UL);
return hash ^ (hash >> 7UL) ^ (hash >> 4UL);
}
/**
* Initializes an unordered multi-set, which is a collection of keys, hashed by
* keys.
* Initializes an unordered multi-set.
*
* @param key_size The size of each key in the unordered multi-set. Must be
* positive.
* @param hash The hash function which computes the hash from the key.
* Must not be NULL.
* @param comparator The comparator function which compares two keys. Must not
* be NULL.
* @param key_size the size of each key in the unordered multi-set; must be
* positive
* @param hash the hash function which computes the hash from the key;
* must not be NULL
* @param comparator the comparator function which compares two keys; must not
* be NULL
*
* @return The newly-initialized unordered multi-set, or NULL if memory
* allocation error.
* @return the newly-initialized unordered multi-set, or NULL if memory
* allocation error
*/
unordered_multiset
unordered_multiset_init(const size_t key_size,
@@ -123,10 +122,10 @@ static void unordered_multiset_add_item(unordered_multiset me,
* Rehashes all the keys in the unordered multi-set. Used when storing
* references and changing the keys. This should rarely be used.
*
* @param me The unordered multi-set to rehash.
* @param me the unordered multi-set to rehash
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multiset_rehash(unordered_multiset me)
{
@@ -152,9 +151,9 @@ int unordered_multiset_rehash(unordered_multiset me)
/**
* Gets the size of the unordered multi-set.
*
* @param me The unordered multi-set to check.
* @param me the unordered multi-set to check
*
* @return The size of the unordered multi-set.
* @return the size of the unordered multi-set
*/
int unordered_multiset_size(unordered_multiset me)
{
@@ -164,9 +163,9 @@ int unordered_multiset_size(unordered_multiset me)
/**
* Determines whether or not the unordered multi-set is empty.
*
* @param me The unordered multi-set to check.
* @param me the unordered multi-set to check
*
* @return If the unordered multi-set is empty.
* @return true if the unordered multi-set is empty
*/
bool unordered_multiset_is_empty(unordered_multiset me)
{
@@ -237,11 +236,11 @@ unordered_multiset_create_element(unordered_multiset me,
/**
* Adds an element to the unordered multi-set.
*
* @param me The unordered multi-set to add to.
* @param key The element to add.
* @param me the unordered multi-set to add to
* @param key the element to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multiset_put(unordered_multiset me, void *const key)
{
@@ -284,10 +283,10 @@ int unordered_multiset_put(unordered_multiset me, void *const key)
/**
* Determines the count of a specific key in the unordered multi-set.
*
* @param me The unordered multi-set to check for the count.
* @param key The element to check.
* @param me the unordered multi-set to check for the count
* @param key the element to check
*
* @return The count of a specific key in the unordered multi-set.
* @return the count of a specific key in the unordered multi-set
*/
int unordered_multiset_count(unordered_multiset me, void *const key)
{
@@ -306,10 +305,10 @@ int unordered_multiset_count(unordered_multiset me, void *const key)
/**
* Determines if the unordered multi-set contains the specified element.
*
* @param me The unordered multi-set to check for the key.
* @param key The key to check.
* @param me the unordered multi-set to check for the key
* @param key the key to check
*
* @return If the unordered multi-set contained the key.
* @return true if the unordered multi-set contained the key
*/
bool unordered_multiset_contains(unordered_multiset me, void *const key)
{
@@ -319,10 +318,10 @@ bool unordered_multiset_contains(unordered_multiset me, void *const key)
/**
* Removes a key from the unordered multi-set if it contains it.
*
* @param me The unordered multi-set to remove a key from.
* @param key The key to remove.
* @param me the unordered multi-set to remove a key from
* @param key the key to remove
*
* @return If the unordered multi-set contained the key.
* @return true if the unordered multi-set contained the key
*/
bool unordered_multiset_remove(unordered_multiset me, void *const key)
{
@@ -365,10 +364,10 @@ bool unordered_multiset_remove(unordered_multiset me, void *const key)
* Removes all the keys specified by the key from an unordered multi-set if it
* contains the key.
*
* @param me The unordered multi-set to remove a key from.
* @param key The key to remove.
* @param me the unordered multi-set to remove a key from
* @param key the key to remove
*
* @return If the unordered multi-set contained the key.
* @return true if the unordered multi-set contained the key
*/
bool unordered_multiset_remove_all(unordered_multiset me, void *const key)
{
@@ -404,10 +403,10 @@ bool unordered_multiset_remove_all(unordered_multiset me, void *const key)
/**
* Clears the keys from the unordered multi-set.
*
* @param me The unordered multi-set to clear.
* @param me the unordered multi-set to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_multiset_clear(unordered_multiset me)
{
@@ -437,7 +436,7 @@ int unordered_multiset_clear(unordered_multiset me)
/**
* Frees the unordered multi-set memory.
*
* @param me The unordered multi-set to free from memory.
* @param me the unordered multi-set to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The unordered_multiset data structure, which is a collection of keys, hashed
* by keys.
*/
typedef struct internal_unordered_multiset *unordered_multiset;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -53,23 +53,22 @@ static inline unsigned long unordered_set_hash(unordered_set me,
const void *const key)
{
unsigned long hash = me->hash(key);
hash ^= (hash >> 20) ^ (hash >> 12);
return hash ^ (hash >> 7) ^ (hash >> 4);
hash ^= (hash >> 20UL) ^ (hash >> 12UL);
return hash ^ (hash >> 7UL) ^ (hash >> 4UL);
}
/**
* Initializes an unordered set, which is a collection of unique keys, hashed by
* keys.
* Initializes an unordered set.
*
* @param key_size The size of each key in the unordered set. Must be
* positive.
* @param hash The hash function which computes the hash from the key.
* Must not be NULL.
* @param comparator The comparator function which compares two keys. Must not
* be NULL.
* @param key_size the size of each key in the unordered set; must be
* positive
* @param hash the hash function which computes the hash from the key;
* must not be NULL
* @param comparator the comparator function which compares two keys; must not
* be NULL
*
* @return The newly-initialized unordered set, or NULL if memory allocation
* error.
* @return the newly-initialized unordered set, or NULL if memory allocation
* error
*/
unordered_set unordered_set_init(const size_t key_size,
unsigned long (*hash)(const void *const),
@@ -119,10 +118,10 @@ static void unordered_set_add_item(unordered_set me, struct node *const add)
* Rehashes all the keys in the unordered set. Used when storing references and
* changing the keys. This should rarely be used.
*
* @param me The unordered set to rehash.
* @param me the unordered set to rehash
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_set_rehash(unordered_set me)
{
@@ -148,9 +147,9 @@ int unordered_set_rehash(unordered_set me)
/**
* Gets the size of the unordered set.
*
* @param me The unordered set to check.
* @param me the unordered set to check
*
* @return The size of the unordered set.
* @return the size of the unordered set
*/
int unordered_set_size(unordered_set me)
{
@@ -160,9 +159,9 @@ int unordered_set_size(unordered_set me)
/**
* Determines whether or not the unordered set is empty.
*
* @param me The unordered set to check.
* @param me the unordered set to check
*
* @return If the unordered set is empty.
* @return true if the unordered set is empty
*/
bool unordered_set_is_empty(unordered_set me)
{
@@ -232,11 +231,11 @@ static struct node *const unordered_set_create_element(unordered_set me,
* Adds an element to the unordered set if the unordered set does not already
* contain it.
*
* @param me The unordered set to add to.
* @param key The element to add.
* @param me the unordered set to add to
* @param key the element to add
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_set_put(unordered_set me, void *const key)
{
@@ -274,10 +273,10 @@ int unordered_set_put(unordered_set me, void *const key)
/**
* Determines if the unordered set contains the specified element.
*
* @param me The unordered set to check for the element.
* @param key The element to check.
* @param me the unordered set to check for the element
* @param key the element to check
*
* @return If the unordered set contained the element.
* @return true if the unordered set contained the element
*/
bool unordered_set_contains(unordered_set me, void *const key)
{
@@ -296,10 +295,10 @@ bool unordered_set_contains(unordered_set me, void *const key)
/**
* Removes the key from the unordered set if it contains it.
*
* @param me The unordered set to remove an key from.
* @param key The key to remove.
* @param me the unordered set to remove an key from
* @param key the key to remove
*
* @return If the unordered set contained the key.
* @return true if the unordered set contained the key
*/
bool unordered_set_remove(unordered_set me, void *const key)
{
@@ -333,10 +332,10 @@ bool unordered_set_remove(unordered_set me, void *const key)
/**
* Clears the keys from the unordered set.
*
* @param me The unordered set to clear.
* @param me the unordered set to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int unordered_set_clear(unordered_set me)
{
@@ -365,7 +364,7 @@ int unordered_set_clear(unordered_set me)
/**
* Frees the unordered set memory.
*
* @param me The unordered set to free from memory.
* @param me the unordered set to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,10 @@
#include <stdbool.h>
/**
* The unordered_set data structure, which is a collection of unique keys,
* hashed by keys.
*/
typedef struct internal_unordered_set *unordered_set;
// Starting

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,11 +36,11 @@ struct internal_vector {
};
/**
* Initializes a vector, which is a dynamic contiguous array.
* Initializes a vector.
*
* @param data_size The size of each element in the vector. Must be positive.
* @param data_size the size of each element in the vector; must be positive
*
* @return The newly-initialized vector, or NULL if memory allocation error.
* @return the newly-initialized vector, or NULL if memory allocation error
*/
vector vector_init(const size_t data_size)
{
@@ -65,9 +65,9 @@ vector vector_init(const size_t data_size)
/**
* Gets the size being used by the vector.
*
* @param me The vector to check.
* @param me the vector to check
*
* @return The size being used by the vector.
* @return the size being used by the vector
*/
int vector_size(vector me)
{
@@ -77,9 +77,9 @@ int vector_size(vector me)
/**
* Gets the capacity that the internal storage of the vector is using.
*
* @param me The vector to check.
* @param me the vector to check
*
* @return The capacity that the internal storage of the vector is using
* @return the capacity that the internal storage of the vector is using
*/
int vector_capacity(vector me)
{
@@ -89,9 +89,9 @@ int vector_capacity(vector me)
/**
* Determines whether or not the vector is empty.
*
* @param me The vector to check.
* @param me the vector to check
*
* @return If the vector is empty.
* @return true if the vector is empty
*/
bool vector_is_empty(vector me)
{
@@ -119,11 +119,11 @@ static int vector_set_space(vector me, const int size)
* Reserves space specified. If more space than specified is already reserved,
* then the previous space will be kept.
*
* @param me The deque to reserve space for.
* @param size The space to reserve.
* @param me the vector to reserve space for
* @param size the space to reserve
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int vector_reserve(vector me, int size)
{
@@ -136,10 +136,10 @@ int vector_reserve(vector me, int size)
/**
* Sets the size of the vector buffer to the current size being used.
*
* @param me The vector to trim.
* @param me the vector to trim
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int vector_trim(vector me)
{
@@ -147,10 +147,10 @@ int vector_trim(vector me)
}
/**
* Copies the storage element of vector to an array.
* Copies the vector to an array.
*
* @param arr The array to copy to.
* @param me The vector to copy from.
* @param arr the initialized array to copy the vector to
* @param me the vector to copy to the array
*/
void vector_copy_to_array(void *const arr, vector me)
{
@@ -163,9 +163,9 @@ void vector_copy_to_array(void *const arr, vector me)
* operation may invalidate this data pointer. The vector owns the data pointer,
* thus it must not be freed.
*
* @param me The vector to get the storage element from.
* @param me the vector to get the storage element from
*
* @return The storage element of the vector.
* @return the storage element of the vector
*/
void *vector_get_data(vector me)
{
@@ -175,11 +175,11 @@ void *vector_get_data(vector me)
/**
* Adds an element to the start of the vector.
*
* @param me The vector to add to.
* @param data The data to add to the vector.
* @param me the vector to add to
* @param data the data to add to the vector
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int vector_add_first(vector me, void *const data)
{
@@ -189,13 +189,13 @@ int vector_add_first(vector me, void *const data)
/**
* Adds an element to the location specified.
*
* @param me The vector to add to.
* @param index The location in the vector to add the data to.
* @param data The data to add to the vector.
* @param me the vector to add to
* @param index the location in the vector to add the data to
* @param data the data to add to the vector
*
* @return 0 No error.
* -ENOMEM Out of memory.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -ENOMEM if out of memory
* @return -EINVAL if invalid argument
*/
int vector_add_at(vector me, const int index, void *const data)
{
@@ -224,11 +224,11 @@ int vector_add_at(vector me, const int index, void *const data)
/**
* Adds an element to the end of the vector.
*
* @param me The vector to add to.
* @param data The data to add to the vector.
* @param me the vector to add to
* @param data the data to add to the vector
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int vector_add_last(vector me, void *const data)
{
@@ -246,10 +246,10 @@ static bool vector_is_illegal_input(vector me, const int index)
/**
* Removes the first element from the vector.
*
* @param me The vector to remove from.
* @param me the vector to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_remove_first(vector me)
{
@@ -259,11 +259,11 @@ int vector_remove_first(vector me)
/**
* Removes element based on its index.
*
* @param me The vector to remove from.
* @param index The location in the vector to remove the data from.
* @param me the vector to remove from
* @param index the location in the vector to remove the data from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_remove_at(vector me, const int index)
{
@@ -280,10 +280,10 @@ int vector_remove_at(vector me, const int index)
/**
* Removes the last element from the vector.
*
* @param me The vector to remove from.
* @param me the vector to remove from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_remove_last(vector me)
{
@@ -297,10 +297,11 @@ int vector_remove_last(vector me)
/**
* Sets the data for the first element in the vector.
*
* @param me The vector to set data for.
* @param me the vector to set data for
* @param data the data to set at the start of the vector
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_set_first(vector me, void *const data)
{
@@ -310,12 +311,12 @@ int vector_set_first(vector me, void *const data)
/**
* Sets the data for a specified element in the vector.
*
* @param me The vector to set data for.
* @param index The location to set data at in the vector.
* @param data The data to set at the location in the vector.
* @param me the vector to set data for
* @param index the location to set data at in the vector
* @param data the data to set at the location in the vector
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_set_at(vector me, const int index, void *const data)
{
@@ -329,10 +330,11 @@ int vector_set_at(vector me, const int index, void *const data)
/**
* Sets the data for the last element in the vector.
*
* @param me The vector to set data for.
* @param me the vector to set data for
* @param data the data to set at the end of the vector
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_set_last(vector me, void *const data)
{
@@ -342,11 +344,11 @@ int vector_set_last(vector me, void *const data)
/**
* Copies the first element of the vector to data.
*
* @param data The data to copy to.
* @param me The vector to copy from.
* @param data the data to copy to
* @param me the vector to copy from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_get_first(void *const data, vector me)
{
@@ -356,12 +358,12 @@ int vector_get_first(void *const data, vector me)
/**
* Copies the element at index of the vector to data.
*
* @param data The data to copy to.
* @param me The vector to copy from.
* @param index The index to copy from in the vector.
* @param data the data to copy to
* @param me the vector to copy from
* @param index the index to copy from in the vector
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_get_at(void *const data, vector me, const int index)
{
@@ -375,11 +377,11 @@ int vector_get_at(void *const data, vector me, const int index)
/**
* Copies the last element of the vector to data.
*
* @param data The data to copy to.
* @param me The vector to copy from.
* @param data the data to copy to
* @param me the vector to copy from
*
* @return 0 No error.
* -EINVAL Invalid argument.
* @return 0 if no error
* @return -EINVAL if invalid argument
*/
int vector_get_last(void *const data, vector me)
{
@@ -389,10 +391,10 @@ int vector_get_last(void *const data, vector me)
/**
* Clears the elements from the vector.
*
* @param me The vector to clear.
* @param me the vector to clear
*
* @return 0 No error.
* -ENOMEM Out of memory.
* @return 0 if no error
* @return -ENOMEM if out of memory
*/
int vector_clear(vector me)
{
@@ -404,7 +406,7 @@ int vector_clear(vector me)
/**
* Frees the vector memory.
*
* @param me The vector to free from memory.
* @param me the vector to free from memory
*
* @return NULL
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018 Bailey Thompson
* Copyright (c) 2017-2019 Bailey Thompson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,9 @@
#include <stdbool.h>
/**
* The vector data structure, which is a dynamic contiguous array.
*/
typedef struct internal_vector *vector;
// Starting