From 510b10b96b546fcc6c6b6be85050305ddd192a41 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 5 Feb 2022 17:30:11 +0800 Subject: replace some hash table usage by tuples Previously I used hash tables, which consume too much memory. Now the critical parts are replaced by a new hand-written library called "tuple.h". Now we can easily parse larger inputs. I haven't tested its limits, though. --- src/pair.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/pair.h (limited to 'src/pair.h') diff --git a/src/pair.h b/src/pair.h new file mode 100644 index 0000000..baae9f5 --- /dev/null +++ b/src/pair.h @@ -0,0 +1,57 @@ +#ifndef PAIR_H +#define PAIR_H +#include "util.h" + +/* This header contains struct definitions of some pairs. */ + +/* I probably should have named the fields by numbers, such as x1, x2, + etc, so that we can recursively declare these structs by macros. + But it is not worth the trouble to rewrite this I guess. */ + +typedef NUM pair1; + +struct pair2_s { NUM x; NUM y; }; + +typedef struct pair2_s pair2; + +struct pair3_s { NUM x; NUM y; NUM z; }; + +typedef struct pair3_s pair3; + +struct pair4_s { NUM x; NUM y; NUM z; NUM u; }; + +typedef struct pair4_s pair4; + +struct pair5_s { NUM x; NUM y; NUM z; NUM u; NUM v; }; + +typedef struct pair5_s pair5; + +struct pair6_s { NUM x; NUM y; NUM z; NUM u; NUM v; NUM w; }; + +typedef struct pair6_s pair6; + +#define COPY_PAIR1(DEST, SOUR) do { \ + DEST.x = SOUR.y; \ + } while (0) + +#define COPY_PAIR2(DEST, SOUR) do { \ + COPY_PAIR1(DEST, SOUR); \ + DEST.y = SOUR.z; \ + } while (0) + +#define COPY_PAIR3(DEST, SOUR) do { \ + COPY_PAIR2(DEST, SOUR); \ + DEST.z = SOUR.u; \ + } while (0) + +#define COPY_PAIR4(DEST, SOUR) do { \ + COPY_PAIR3(DEST, SOUR); \ + DEST.u = SOUR.v; \ + } while (0) + +#define COPY_PAIR5(DEST, SOUR) do { \ + COPY_PAIR4(DEST, SOUR); \ + DEST.v = SOUR.w; \ + } while (0) + +#endif -- cgit v1.2.3-18-g5258