summaryrefslogtreecommitdiff
path: root/comp/cw/code/ads
diff options
context:
space:
mode:
authorstandenboy <standenboy@seacrossedlovers.xyz>2024-04-30 14:22:45 +0100
committerstandenboy <standenboy@seacrossedlovers.xyz>2024-04-30 14:22:45 +0100
commitc460a26850eca5ded047d0eb0d183b861087aa53 (patch)
tree000c4a117746de71870fbee820809f7df49bcfcf /comp/cw/code/ads
parent2e239a4ed2265f7c7dc2aabedfdb7d7b011704cb (diff)
write up update
Diffstat (limited to 'comp/cw/code/ads')
-rw-r--r--comp/cw/code/ads/dict/Makefile4
-rw-r--r--comp/cw/code/ads/dict/dict.c29
-rw-r--r--comp/cw/code/ads/dict/dict.h9
-rwxr-xr-xcomp/cw/code/ads/dict/dicttestbin20536 -> 0 bytes
-rw-r--r--comp/cw/code/ads/dict/dicttest.c10
-rw-r--r--comp/cw/code/ads/ll/Makefile5
-rw-r--r--comp/cw/code/ads/ll/ll.c50
-rw-r--r--comp/cw/code/ads/ll/ll.h15
-rwxr-xr-xcomp/cw/code/ads/ll/lltestbin20592 -> 0 bytes
-rw-r--r--comp/cw/code/ads/ll/lltest.c18
10 files changed, 0 insertions, 140 deletions
diff --git a/comp/cw/code/ads/dict/Makefile b/comp/cw/code/ads/dict/Makefile
deleted file mode 100644
index f224267..0000000
--- a/comp/cw/code/ads/dict/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-all: dict.c
- cc dict.c -c -o dict.o
-test: all
- cc dict.o dicttest.c -o dicttest
diff --git a/comp/cw/code/ads/dict/dict.c b/comp/cw/code/ads/dict/dict.c
deleted file mode 100644
index 551afca..0000000
--- a/comp/cw/code/ads/dict/dict.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct dict_t {
- int id;
- void *data;
-}dict_t;
-
-dict_t *dictalloc(){
- dict_t *output = malloc(sizeof(dict_t));
- return output;
-}
-
-int dictset(dict_t *dict, int id, void *data){
- dict->id = id;
-
- dict->data = malloc(sizeof(data));
- if (dict->data == NULL)
- return 1;
- memcpy(dict->data, data, sizeof(data));
-
- return 0;
-}
-
-void dictfree(dict_t *dict){
- free(dict->data);
- free(dict);
-}
-
diff --git a/comp/cw/code/ads/dict/dict.h b/comp/cw/code/ads/dict/dict.h
deleted file mode 100644
index e6ab69d..0000000
--- a/comp/cw/code/ads/dict/dict.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef struct dict_t {
- int id;
- void *data;
-}dict_t;
-
-dict_t *dictalloc();
-int dictset(dict_t *dict, int id, void *data);
-void dictfree(dict_t *dict);
-
diff --git a/comp/cw/code/ads/dict/dicttest b/comp/cw/code/ads/dict/dicttest
deleted file mode 100755
index dddf2a0..0000000
--- a/comp/cw/code/ads/dict/dicttest
+++ /dev/null
Binary files differ
diff --git a/comp/cw/code/ads/dict/dicttest.c b/comp/cw/code/ads/dict/dicttest.c
deleted file mode 100644
index 4a20870..0000000
--- a/comp/cw/code/ads/dict/dicttest.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-
-#include "dict.h"
-
-int main(){
- dict_t *dict = dictalloc();
- dictset(dict, 1, "hello");
- printf("%d:%s\n", dict->id, (char *)dict->data);
- dictfree(dict);
-}
diff --git a/comp/cw/code/ads/ll/Makefile b/comp/cw/code/ads/ll/Makefile
deleted file mode 100644
index aaf0241..0000000
--- a/comp/cw/code/ads/ll/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all: ll.c
- cc ll.c -c -o ll.o
-
-test: all
- cc ll.o lltest.c -o lltest
diff --git a/comp/cw/code/ads/ll/ll.c b/comp/cw/code/ads/ll/ll.c
deleted file mode 100644
index c45ab0c..0000000
--- a/comp/cw/code/ads/ll/ll.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-typedef struct ll_t ll_t;
-
-typedef struct ll_t {
- void *data;
- ll_t *next;
-} ll_t;
-
-ll_t *llalloc(){
- ll_t *output = malloc(sizeof(ll_t));
- if (output == NULL)
- return NULL;
- output->next = NULL;
- return output;
-}
-
-void llsetdata(ll_t *node, void *data){
- node->data = malloc(sizeof(data));
- memcpy(node->data, data, sizeof(data));
-}
-
-void llsetnext(ll_t *node, ll_t *next){
- if (node->next == NULL)
- node->next = next;
- else
- llsetnext(node->next, next);
-}
-
-void *llgetat(ll_t *head, int index){
- if (index == 0)
- return head->data;
- else {
- if (head->next != NULL) {
- return llgetat(head->next, index - 1);
- }else {
- return NULL;
- }
- }
-}
-
-void llfreeall(ll_t *head){
- if (head->next != NULL)
- llfreeall(head->next);
- free(head->data);
- free(head);
-}
-
diff --git a/comp/cw/code/ads/ll/ll.h b/comp/cw/code/ads/ll/ll.h
deleted file mode 100644
index 30830b1..0000000
--- a/comp/cw/code/ads/ll/ll.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct ll_t ll_t;
-
-typedef struct ll_t {
- void *data;
- ll_t *next;
-} ll_t;
-
-ll_t *llalloc();
-void llsetdata(ll_t *node, void *data);
-void llsetnext(ll_t *node, ll_t *next);
-void *llgetat(ll_t *head, int index);
-void llfreeall(ll_t *head);
diff --git a/comp/cw/code/ads/ll/lltest b/comp/cw/code/ads/ll/lltest
deleted file mode 100755
index b98c5de..0000000
--- a/comp/cw/code/ads/ll/lltest
+++ /dev/null
Binary files differ
diff --git a/comp/cw/code/ads/ll/lltest.c b/comp/cw/code/ads/ll/lltest.c
deleted file mode 100644
index 8aa6514..0000000
--- a/comp/cw/code/ads/ll/lltest.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-
-#include "ll.h"
-
-int main(){
- ll_t *head = llalloc();
- llsetdata(head, "hello");
-
- for (int i = 0; i < 3; i++){
- ll_t *node = llalloc();
- llsetdata(node, "hi");
- llsetnext(head, node);
- }
- for (int i = 0; i < 4; i++)
- printf("%s\n", (char *)llgetat(head, i));
-
- llfreeall(head);
-}