From 007b23db8e6e57da59e0821dea3c95508c0f7003 Mon Sep 17 00:00:00 2001 From: hiddenalpha.ch Date: Sun, 12 Jul 2026 02:31:08 +0200 Subject: Introduce `HshIdx` Introduce `HshIdx`, a multi-dimensional HashTable. WARN: Early draft, not really usable yet. --- include/qntan/Qntan.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/qntan/Qntan.h b/include/qntan/Qntan.h index e159546..d5e77a7 100644 --- a/include/qntan/Qntan.h +++ b/include/qntan/Qntan.h @@ -73,6 +73,7 @@ struct Qntan_FileSystem_Dirent; struct Qntan_FileSystem; struct Qntan_FourierTransform; struct Qntan_Process; +struct Qntan_HshIdx; struct Qntan_HshTbl; struct Qntan_HshTbl_Cursor; struct Qntan_Socket; @@ -819,6 +820,39 @@ struct Qntan_Process { +struct Qntan_HshIdx { + /* An n-dimensional HashTable. Where as many properties as wanted + * can be used to index into the table. + * BUT: ONLY the 1st index is considered to be unique (for + * consistency reasons, only ONE index can be used to decide if an + * object already exists for exmaple. Allowing multiple would cause + * conflicts as soon indexes disagree in such a case). + */ + size_t (*getCnt)( struct Qntan_HshIdx** ); + /* Returns number of objects currently present in this collection. + */ + int (*addIfNew)( struct Qntan_HshIdx**, void*elm ); + /* Returns 0 if 'elm' got copied into the hashtable. + * Returns '-EEXIST' (yep, negated) if 'elm' already exists. Nothing got + * copied anywhere. + * Returns negative values to indicate errors. + */ + int (*get)( struct Qntan_HshIdx**, void*srch, void*ptrToDst, int idx ); + /* Returns 0 if there's no object matching 'srch'. + * Returns 1 if found object got copied to 'ptrToDst'. The element itelf + * will swill be present in the table. + */ +}; + + + + + + + + + + struct Qntan_HshTbl { /**/ int (*swap)( struct Qntan_HshTbl**, void*elm, void*ptrToDst ); -- cgit v1.3.1