notes/snippet/cpp/xor_list.c

35 lines
522 B
C

#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
void *npx;
} Node;
typedef struct XorList {
Node *head;
Node *tail;
} XorList;
int insert(XorList *list, int data) {
Node *p;
p = (Node *)malloc(sizeof(Node));
p->data = data;
p->npx = NULL;
if (list == NULL) {
list = (XorList *)malloc(sizeof(XorList));
}
if (list->head == NULL) {
list->head = p;
list->tail = p;
} else {
// TODO: calc npx
}
return 0;
}