62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
|
// =========================================
|
||
|
// | SilverMUD Server - lists.h |
|
||
|
// | Copyright (C) 2023, Barra Ó Catháin |
|
||
|
// | See end of file for copyright notice. |
|
||
|
// =========================================
|
||
|
#ifndef LISTS_H
|
||
|
#define LISTS_H
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
enum DataType
|
||
|
{
|
||
|
AREA,
|
||
|
PLAYER,
|
||
|
CONNECTION
|
||
|
};
|
||
|
|
||
|
struct List
|
||
|
{
|
||
|
size_t itemCount;
|
||
|
enum DataType type;
|
||
|
struct Node * head;
|
||
|
struct Node * tail;
|
||
|
};
|
||
|
|
||
|
struct Node
|
||
|
{
|
||
|
struct Node * next;
|
||
|
struct Node * previous;
|
||
|
void * data;
|
||
|
};
|
||
|
|
||
|
|
||
|
// Functions:
|
||
|
// ==========
|
||
|
|
||
|
struct List * createList(enum DataType type);
|
||
|
size_t appendToList(enum DataType type, struct List * list, void * data);
|
||
|
void * deleteNodeFromList(size_t index, struct List * list);
|
||
|
ssize_t indexOfFromList(bool (*comparisonFunction)(void *, void *), void * data, struct List * list);
|
||
|
void * getFirstFromList(bool (*comparisonFunction)(void *, void *), void * data, struct List * list);
|
||
|
bool isInList(bool (*comparisonFunction)(void *, void *), void * data, struct List * list);
|
||
|
bool isPointerInList(void * data, struct List * list);
|
||
|
|
||
|
#endif
|
||
|
// =============================================
|
||
|
// | End of lists.h, copyright notice follows. |
|
||
|
// =============================================
|
||
|
|
||
|
// This program is free software: you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU Affero General Public License as published by
|
||
|
// the Free Software Foundation, either version 3 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU Affero General Public License for more details.
|
||
|
|
||
|
// You should have received a copy of the GNU Affero General Public License
|
||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
|