14 33 23.parent.rightnext.leftnext.lefttree.righttree class cell { cell *lefttree, *righttree,...

29
14 33 23 .parent .rightnext .leftnext .lefttree .righttree Class Cell { Cell *lefttree, *righttree, *leftnext, *rightnext, *parent; TreeObject *object; Cell (TreeObject *obj, Cell *lnx, Cell *prt) { parent = prt; leftnext = lnx; object = obj; rightnext = righttree = lefttree = NULL; } };

Post on 21-Dec-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

14

33 23

.parent

.rightnext.leftnext

.lefttree .righttree

Class Cell { Cell *lefttree, *righttree, *leftnext, *rightnext, *parent; TreeObject *object;

Cell (TreeObject *obj, Cell *lnx, Cell *prt) { parent = prt; leftnext = lnx; object = obj; rightnext = righttree = lefttree = NULL; }};

.tail

NULL

.head

14

.tailNULL

.head

NULL

TreeObject *t = new IntegerObject(14);

...

if (head == NULL) { head = tail = new Cell(t, NULL, NULL);}

14

.tail

.head

14

.tail

.head

13

TreeObject *t = new IntegerObject(13);

...

if (head == NULL) { head = tail = new Cell(t, NULL, NULL);} else if (tail->lefttree == NULL) { if (tail->leftnext == NULL) { tail->lefttree = new Cell(...

14

.tail

.head

13

TreeObject *t = new IntegerObject(13);

...

if (head == NULL) { head = tail = new Cell(t, NULL, NULL);} else if (tail->lefttree == NULL) { if (tail->leftnext == NULL) { tail->lefttree = new Cell(t, tail, tail); ...

14

.tail

.head

13

TreeObject *t = new IntegerObject(13);

...

if (head == NULL) { head = tail = new Cell(t, NULL, NULL);} else if (tail->lefttree == NULL) { if (tail->leftnext == NULL) { tail->lefttree = new Cell(t, tail, tail); tail->rightnext = tail->lefttree;}

14 34

33 23 35 55

89 54

12

31

.head

.tail

.last Cell *last = tail->lefttree;

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

.lasttail->righttree = new Cell(t, ...

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

.last.tail->righttree = new Cell(t, last, tail);

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

.lastlast->rightnext = tail->righttree;

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

.last.tail = tail->rightnext;

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

14 34

33 23 35 55

89 54

12

31

.head

.tail

13

.h.h = tail->leftnext->righttree;

14 34

33 13 35 55

89 54

12

31

.head

.tail

23

.h

TreeObject *obj = h->object;h->object = h->parent->object;h->parent->object = obj;

14 34

33 13 35 55

89 54

12

31

.head

.tail

23.h

H = h->parent;

13 34

33 14 35 55

89 54

12

31

.head

.tail

23.h

13 34

33 14 35 55

89 54

12

31

.head

.tail

23

.h

13 34

33 14 35 55

89 54

12

34

.head

.tail

23

.last .last = tail->leftnext->righttree;

13 34

33 14 35 55

89 54

12

34

.head

.tail

2325

.last.tail->lefttree = new Cell(t, ...

13 34

33 14 35 55

89 54

12

34

.head

.tail

2325

.last.tail->lefttree = new Cell(t, last, tail);

13 34

33 14 35 55

89 54

12

34

.head

.tail

2325

.last.last->rightnext = tail->lefttree;

13 34

33 14 35 55

89 54

12

31

.head

.tail

23 25

13 34

33 14 35 55

89 54

12

31

.head

.tail

23 25

.h

13 34

33 14 25 55

89 54

12

31

.head

.tail

23 35

.h

13 34

33 14 25 55

89 54

12

31

.head

.tail

23 35

.h

13 25

33 14 34 55

89 54

12

31

.head

.tail

23 35

.h

13 25

33 14 34 55

89 54

12

31

.head

.tail

23 35

.h

13 25

33 14 34 55

89 54

12

31

.head

.tail

23 35