Lines Matching refs:self
70 #define TREE_DELTA(self, field) \ argument
71 (( (((self)->field.avl_left) ? (self)->field.avl_left->field.avl_height : 0)) \
72 - (((self)->field.avl_right) ? (self)->field.avl_right->field.avl_height : 0))
80 static struct node *_HU_FUNCTION(TREE_ROTL_##node##_##field)(struct node *self) \
82 struct node *r= self->field.avl_right; \
83 self->field.avl_right= r->field.avl_left; \
84 r->field.avl_left= TREE_BALANCE_##node##_##field(self); \
88 static struct node *_HU_FUNCTION(TREE_ROTR_##node##_##field)(struct node *self) \
90 struct node *l= self->field.avl_left; \
91 self->field.avl_left= l->field.avl_right; \
92 l->field.avl_right= TREE_BALANCE_##node##_##field(self); \
96 static struct node *_HU_FUNCTION(TREE_BALANCE_##node##_##field)(struct node *self) \
98 int delta= TREE_DELTA(self, field); \
102 if (TREE_DELTA(self->field.avl_right, field) > 0) \
103 self->field.avl_right= TREE_ROTR_##node##_##field(self->field.avl_right); \
104 return TREE_ROTL_##node##_##field(self); \
108 if (TREE_DELTA(self->field.avl_left, field) < 0) \
109 self->field.avl_left= TREE_ROTL_##node##_##field(self->field.avl_left); \
110 return TREE_ROTR_##node##_##field(self); \
112 self->field.avl_height= 0; \
113 if (self->field.avl_left && (self->field.avl_left->field.avl_height > self->field.avl_height)) \
114 self->field.avl_height= self->field.avl_left->field.avl_height; \
115 … if (self->field.avl_right && (self->field.avl_right->field.avl_height > self->field.avl_height)) \
116 self->field.avl_height= self->field.avl_right->field.avl_height; \
117 self->field.avl_height += 1; \
118 return self; \
122 (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \
124 if (!self) \
126 if (compare(elm, self) < 0) \
127 self->field.avl_left= TREE_INSERT_##node##_##field(self->field.avl_left, elm, compare); \
129 self->field.avl_right= TREE_INSERT_##node##_##field(self->field.avl_right, elm, compare); \
130 return TREE_BALANCE_##node##_##field(self); \
134 (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \
136 if (!self) \
138 if (compare(elm, self) == 0) \
139 return self; \
140 if (compare(elm, self) < 0) \
141 return TREE_FIND_##node##_##field(self->field.avl_left, elm, compare); \
143 return TREE_FIND_##node##_##field(self->field.avl_right, elm, compare); \
146 static struct node *_HU_FUNCTION(TREE_MOVE_RIGHT)(struct node *self, struct node *rhs) \
148 if (!self) \
150 self->field.avl_right= TREE_MOVE_RIGHT(self->field.avl_right, rhs); \
151 return TREE_BALANCE_##node##_##field(self); \
155 (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \
157 if (!self) return 0; \
159 if (compare(elm, self) == 0) \
161 struct node *tmp= TREE_MOVE_RIGHT(self->field.avl_left, self->field.avl_right); \
162 self->field.avl_left= 0; \
163 self->field.avl_right= 0; \
166 if (compare(elm, self) < 0) \
167 self->field.avl_left= TREE_REMOVE_##node##_##field(self->field.avl_left, elm, compare); \
169 self->field.avl_right= TREE_REMOVE_##node##_##field(self->field.avl_right, elm, compare); \
170 return TREE_BALANCE_##node##_##field(self); \
174 (struct node *self, void (*function)(struct node *node, void *data), void *data) \
176 if (self) \
178 TREE_FORWARD_APPLY_ALL_##node##_##field(self->field.avl_left, function, data); \
179 function(self, data); \
180 TREE_FORWARD_APPLY_ALL_##node##_##field(self->field.avl_right, function, data); \
185 (struct node *self, void (*function)(struct node *node, void *data), void *data) \
187 if (self) \
189 TREE_REVERSE_APPLY_ALL_##node##_##field(self->field.avl_right, function, data); \
190 function(self, data); \
191 TREE_REVERSE_APPLY_ALL_##node##_##field(self->field.avl_left, function, data); \