From 239f248456ad00f894dc26dceefa968898738c9d Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Mon, 22 Jun 2020 16:43:42 +0200 Subject: Getting make to run --- 04_exercise/slotmap.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 04_exercise/slotmap.h (limited to '04_exercise/slotmap.h') diff --git a/04_exercise/slotmap.h b/04_exercise/slotmap.h new file mode 100644 index 0000000..d4044d4 --- /dev/null +++ b/04_exercise/slotmap.h @@ -0,0 +1,37 @@ +// +// Created by stefan on 18.06.20. +// + +#ifndef BETRIEBSYSTEME_SLOTMAP_H +#define BETRIEBSYSTEME_SLOTMAP_H +#include +#include +#include +#include + +typedef struct smNode { + atomic_intptr_t value; +} smEntry; + +typedef struct smHeader { + smEntry *slab; + size_t size; +} smHeader; + +typedef bool (*SearchFunction)(void const *); + +smHeader smInit(smEntry * slab, size_t size); +int smInsert(smHeader const * header, void * value); +void smDelete(smEntry * node); +void smDeleteValue(smHeader const * header, void * value); +/** + * Returns a node whose value is accepted by the SearchFunction + * @param header The header of the slotmap to be searched + * @param func The search function, that will be applied to each element until one is found + * @return the Entry that was found + */ +smEntry *smFindEntry(smHeader const * header, SearchFunction func); + + + +#endif // BETRIEBSYSTEME_SLOTMAP_H -- cgit v1.2.3-54-g00ecf