Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include "linear_sequence_assoc.h"
- typedef enum {
- NORMAL,
- typedef struct node {
- LSQ_IntegerIndexT key;
- LSQ_BaseTypeT value;
- int level;
- struct node **previous;
- struct node **next;
- } Node;
- typedef struct {
- int size;
- int level;
- Node *head;
- } Container;
- typedef struct {
- Node *node;
- Container *container;
- } Iterator;
- LSQ_HandleT LSQ_CreateSequence(void) {
- Container *container = malloc(sizeof(Container));
- if (container == NULL) {
- return LSQ_HandleInvalid;
- }
- container->beforeFirst = malloc(sizeof(Node));
- if (container->beforeFirst == NULL) {
- free(container);
- return LSQ_HandleInvalid;
- }
- container->pastRear = malloc(sizeof(Node));
- if (container->pastRear == NULL) {
- free(container->beforeFirst);
- free(container);
- return LSQ_HandleInvalid;
- }
- container->pastRear->level = 0;
- container->root = container->pastRear;
- container->size = 0;
- return container;
- }
- }
Add Comment
Please, Sign In to add comment