51 lines
No EOL
2.3 KiB
C
51 lines
No EOL
2.3 KiB
C
/*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* -----------------------------------------------------------------------------
|
|
* File: DoublyLinkedList.c
|
|
* Description:
|
|
* This file contains the functions for modifying the Doubly Linked List. It
|
|
* includes functions to append, Insert before, Insert after, Insert at index,
|
|
* Get, Remove element, Remove at index, Check if has element and Check if is empty.
|
|
*
|
|
* Author: Mineplay
|
|
* -----------------------------------------------------------------------------
|
|
*/
|
|
#ifndef FLEDASTY_DOUBLY_LINKED_LIST
|
|
#define FLEDASTY_DOUBLY_LINKED_LIST
|
|
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "../Utils/Error.h"
|
|
|
|
typedef struct FledastyDoublyLinkedListNode {
|
|
void *value;
|
|
struct FledastyDoublyLinkedListNode *previous, *next;
|
|
} FledastyDoublyLinkedListNode;
|
|
|
|
typedef struct {
|
|
size_t size, element_byte_size;
|
|
FledastyDoublyLinkedListNode *start, *end;
|
|
} FledastyDoublyLinkedList;
|
|
|
|
FledastyError fledasty_doubly_linked_list_initialize(FledastyDoublyLinkedList *new_doubly_linked_list, void *values, const size_t values_size, const size_t element_byte_size);
|
|
FledastyError fledasty_doubly_list_destroy(FledastyDoublyLinkedList *current_doubly_linked_list);
|
|
|
|
FledastyError fledasty_doubly_linked_list_append(FledastyDoublyLinkedList *current_doubly_linked_list, void *value);
|
|
|
|
FledastyError fledasty_doubly_linked_list_insert_at_index(FledastyDoublyLinkedList *current_doubly_linked_list, const size_t index, void *value);
|
|
FledastyError fledasty_doubly_linked_list_insert_before_value(FledastyDoublyLinkedList *current_doubly_linked_list, void *before_value, void *value);
|
|
FledastyError fledasty_doubly_linked_list_insert_after_value(FledastyDoublyLinkedList *current_doubly_linked_list, void *after_value, void *value);
|
|
|
|
#endif |