Compare commits

...

2 Commits

Author SHA1 Message Date
Barra Ó Catháin 2e36073316 Added queues.h
* source/server/queues.h (QUEUES_H): Defined the interface and structures for universal queues.
2024-04-15 23:39:06 +01:00
Barra Ó Catháin bbcde81eaf Updated gitignore
* .gitignore: Added in tests and logs to be ignored.
2024-04-15 23:36:44 +01:00
2 changed files with 59 additions and 1 deletions

6
.gitignore vendored
View File

@ -110,4 +110,8 @@ config.h
config.h.in
stamp-h1
build/
build/
# Tests:
*.log
*_test*

54
source/server/queues.h Normal file
View File

@ -0,0 +1,54 @@
// =========================================
// | SilverMUD Server - queues.h |
// | Copyright (C) 2023, Barra Ó Catháin |
// | See end of file for copyright notice. |
// =========================================
#ifndef QUEUES_H
#define QUEUES_H
#include "data-type.h"
#include <stdbool.h>
struct Queue
{
size_t itemCount;
enum DataType type;
struct ListNode * front;
struct ListNode * back;
};
struct QueueNode
{
struct ListNode * next;
void * data;
};
// Functions:
// ==========
struct Queue * createQueue(enum DataType type);
int destroyQueue(struct Queue * queue);
int destroyQueueAndContents(void (*deallocationFunction)(void *), struct Queue * queue);
void * peekFromQueue(struct Queue * queue);
size_t popFromQueue(struct Queue * queue);
size_t pushToQueue(enum DataType type, void * data, struct Queue * queue);
size_t popFromQueueAndDestroy(void (*deallocationFunction)(void *), struct Queue * queue);
#endif
// ==============================================
// | End of queues.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/>.