From a41fe79404f257c57986f19e429450c3fc417876 Mon Sep 17 00:00:00 2001 From: "Harry Clark (clarkh9)" Date: Mon, 13 Mar 2023 06:15:29 +0000 Subject: [PATCH] Add files via upload --- include/common.h | 49 +++++++++++++++++++++++++++++++++++++++++ include/huffman_types.h | 45 +++++++++++++++++++++++++++++++++++++ src/main.cpp | 0 3 files changed, 94 insertions(+) create mode 100644 include/common.h create mode 100644 include/huffman_types.h create mode 100644 src/main.cpp diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..fc69706 --- /dev/null +++ b/include/common.h @@ -0,0 +1,49 @@ +/* Copyright (C) 2023 Harry Clark - Student No. 12340530 */ +/* DATE: 13/03/23 */ + +/* HUFFMAN CODE DEMONSTRATION */ +/* JUST A LITTLE THING I WANTED TO MAKE FOR FUN AFTER WATCHING A +/* TOM SCOTT VIDEO ABOUT THE SUBJECT */ + +/* THESE ARE ALL OF THE COMMON DATA TYPES ASSOCIATED WITH THIS PROJECT */ + +#ifndef COMMON_TYPES +#define COMMON_TYPES + +#include +#include +#include + +#ifndef UNSIGNED_TYPES +#define UNSIGNED_TYPES + +typedef uint8_t U8; +typedef uint16_t U16; +typedef uint32_t U32; +typedef uint64_t U64; +typedef size_t UNK_SIZE; + +#endif + +#ifndef SIGNED_TYPES +#define SIGNED_TYPES + +typedef int8_t S8; +typedef int16_t S16; +typedef int32_t S32; +typedef int64_t S64; + +#endif + +#ifndef UNKNOWN_TYPES +#define UNKNOWN_TYPES + +typedef unsigned char UNK_8; +typedef unsigned short UNK_16; +typedef unsigned int UNK_32; +typedef unsigned long UNK_64; +typedef size_t UNK_SIZE; + +#endif + +#endif \ No newline at end of file diff --git a/include/huffman_types.h b/include/huffman_types.h new file mode 100644 index 0000000..d38b4df --- /dev/null +++ b/include/huffman_types.h @@ -0,0 +1,45 @@ +/* Copyright (C) 2023 Harry Clark - Student No. 12340530 */ +/* DATE: 13/03/23 */ + +/* HUFFMAN CODE DEMONSTRATION */ +/* JUST A LITTLE THING I WANTED TO MAKE FOR FUN AFTER WATCHING A +/* TOM SCOTT VIDEO ABOUT THE SUBJECT */ + +/* THESE ARE THE TYPES AND FUNCTIONALITY PERTAINING TO THIS ALGORITHM */ + +#ifndef HUFFMAN_TYPES +#define HUFFMAN_TYPES + +/* SYSTEM INCLUDES */ + +#include + +/* NESTED INCLUDES */ + +#include "common.h" + +typedef struct NODE +{ + typedef UNK_SIZE* FREQUENCY; + typedef U8* CHAR; + + NODE* LEAF(FREQUENCY, CHAR); + NODE* INTERNAL_NODE(FREQUENCY, CHAR); + NODE* LEFT_PTR(); + NODE* RIGHT_PTR(); +}; + +typedef struct ENCODER : NODE +{ + typedef U8* DATA[]; + typedef UNK_SIZE* BITWISE_LENGTH; +}; + +typedef struct TREE +{ + ENCODER* ENCODE(UNK_8* ENCODE_CHAR); + ENCODER* DECODE(UNK_8* DECODE_CHAR); + TREE* BUILD_TREE(void); +}; + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..e69de29