Yeet broken treeset for now
This commit is contained in:
parent
50d6bbed7b
commit
bed5c13dc8
4 changed files with 0 additions and 74 deletions
|
|
@ -1,14 +0,0 @@
|
||||||
CC = gcc
|
|
||||||
CFLAGS = -Wall -O2
|
|
||||||
|
|
||||||
TARGET = main.elf
|
|
||||||
SRC = main.c treeset.c
|
|
||||||
|
|
||||||
#LDFLAGS =
|
|
||||||
|
|
||||||
$(TARGET): $(SRC)
|
|
||||||
@echo CC $@
|
|
||||||
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(TARGET)
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
#include "treeset.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
treeset_t tree = {};
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
#include "treeset.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
struct treeset_node {
|
|
||||||
void *data;
|
|
||||||
struct treeset_node *left;
|
|
||||||
struct treeset_node *right;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct treeset {
|
|
||||||
treeset_node_t *root;
|
|
||||||
size_t node_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ts_node_destroy(treeset_node_t *n) {
|
|
||||||
if (n->left != NULL)
|
|
||||||
ts_node_destroy((treeset_node_t *)n->left);
|
|
||||||
if (n->right != NULL)
|
|
||||||
ts_node_destroy((treeset_node_t *)n->left);
|
|
||||||
|
|
||||||
free(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void treeset_destroy(treeset_t *set) {
|
|
||||||
ts_node_destroy(set->root);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
typedef struct treeset treeset_t;
|
|
||||||
typedef struct treeset_node treeset_node_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cast a and b to your custom struct and return:
|
|
||||||
* 1 for greater than
|
|
||||||
* -1 for less than
|
|
||||||
* 0 for equal
|
|
||||||
*/
|
|
||||||
int treeset_demo_cmp(void *a, void *b) {
|
|
||||||
if (*((int *)a) > *((int *)a))
|
|
||||||
return -1;
|
|
||||||
if (*((int *)a) < *((int *)a))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void treeset_destroy(treeset_t *set);
|
|
||||||
void put(treeset_t *set, void *data, int (*cmp)(void *, void *));
|
|
||||||
// contains
|
|
||||||
// remove
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue