blob: 1d687fc5d1f9111fd85566af7d3f9f4b3291c87f (
plain) (
tree)
|
|
//
// Created by stefan on 18.06.20.
//
#ifndef BETRIEBSYSTEME_SLOTMAP_H
#define BETRIEBSYSTEME_SLOTMAP_H
#include <stdatomic.h>
#include <stdlib.h>
#include <stdbool.h>
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
|