Lines Matching refs:splay_tree
154 MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, in AddValueToSplayTree() argument
163 LockSemaphoreInfo(splay_tree->semaphore); in AddValueToSplayTree()
164 SplaySplayTree(splay_tree,key); in AddValueToSplayTree()
166 if (splay_tree->root != (NodeInfo *) NULL) in AddValueToSplayTree()
168 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in AddValueToSplayTree()
169 compare=splay_tree->compare(splay_tree->root->key,key); in AddValueToSplayTree()
171 compare=(splay_tree->root->key > key) ? 1 : in AddValueToSplayTree()
172 ((splay_tree->root->key < key) ? -1 : 0); in AddValueToSplayTree()
175 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in AddValueToSplayTree()
176 (splay_tree->root->value != (void *) NULL)) in AddValueToSplayTree()
177 splay_tree->root->value=splay_tree->relinquish_value( in AddValueToSplayTree()
178 splay_tree->root->value); in AddValueToSplayTree()
179 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in AddValueToSplayTree()
180 (splay_tree->root->key != (void *) NULL)) in AddValueToSplayTree()
181 splay_tree->root->key=splay_tree->relinquish_key( in AddValueToSplayTree()
182 splay_tree->root->key); in AddValueToSplayTree()
183 splay_tree->root->key=(void *) key; in AddValueToSplayTree()
184 splay_tree->root->value=(void *) value; in AddValueToSplayTree()
185 UnlockSemaphoreInfo(splay_tree->semaphore); in AddValueToSplayTree()
192 UnlockSemaphoreInfo(splay_tree->semaphore); in AddValueToSplayTree()
197 if (splay_tree->root == (NodeInfo *) NULL) in AddValueToSplayTree()
205 node->left=splay_tree->root; in AddValueToSplayTree()
211 node->right=splay_tree->root; in AddValueToSplayTree()
215 splay_tree->root=node; in AddValueToSplayTree()
216 splay_tree->key=(void *) NULL; in AddValueToSplayTree()
217 splay_tree->nodes++; in AddValueToSplayTree()
218 UnlockSemaphoreInfo(splay_tree->semaphore); in AddValueToSplayTree()
280 static void BalanceSplayTree(SplayTreeInfo *splay_tree) in BalanceSplayTree() argument
286 if (splay_tree->nodes <= 2) in BalanceSplayTree()
288 splay_tree->balance=MagickFalse; in BalanceSplayTree()
291 nodes=(NodeInfo **) AcquireQuantumMemory((size_t) splay_tree->nodes, in BalanceSplayTree()
296 (void) IterateOverSplayTree(splay_tree,SplayTreeToNodeArray,(const void *) in BalanceSplayTree()
298 splay_tree->root=LinkSplayTreeNodes(nodes,0,splay_tree->nodes-1); in BalanceSplayTree()
299 splay_tree->balance=MagickFalse; in BalanceSplayTree()
333 static inline void *GetFirstSplayTreeNode(SplayTreeInfo *splay_tree) in GetFirstSplayTreeNode() argument
338 node=splay_tree->root; in GetFirstSplayTreeNode()
339 if (splay_tree->root == (NodeInfo *) NULL) in GetFirstSplayTreeNode()
346 MagickExport SplayTreeInfo *CloneSplayTree(SplayTreeInfo *splay_tree, in CloneSplayTree() argument
356 assert(splay_tree != (SplayTreeInfo *) NULL); in CloneSplayTree()
357 assert(splay_tree->signature == MagickCoreSignature); in CloneSplayTree()
358 if (splay_tree->debug != MagickFalse) in CloneSplayTree()
360 clone_tree=NewSplayTree(splay_tree->compare,splay_tree->relinquish_key, in CloneSplayTree()
361 splay_tree->relinquish_value); in CloneSplayTree()
362 LockSemaphoreInfo(splay_tree->semaphore); in CloneSplayTree()
363 if (splay_tree->root == (NodeInfo *) NULL) in CloneSplayTree()
365 UnlockSemaphoreInfo(splay_tree->semaphore); in CloneSplayTree()
368 next=(NodeInfo *) GetFirstSplayTreeNode(splay_tree); in CloneSplayTree()
371 SplaySplayTree(splay_tree,next); in CloneSplayTree()
372 (void) AddValueToSplayTree(clone_tree,clone_key(splay_tree->root->key), in CloneSplayTree()
373 clone_value(splay_tree->root->value)); in CloneSplayTree()
375 node=splay_tree->root->right; in CloneSplayTree()
383 UnlockSemaphoreInfo(splay_tree->semaphore); in CloneSplayTree()
487 SplayTreeInfo *splay_tree,const void *value) in DeleteNodeByValueFromSplayTree() argument
493 assert(splay_tree != (SplayTreeInfo *) NULL); in DeleteNodeByValueFromSplayTree()
494 assert(splay_tree->signature == MagickCoreSignature); in DeleteNodeByValueFromSplayTree()
495 if (splay_tree->debug != MagickFalse) in DeleteNodeByValueFromSplayTree()
497 LockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
498 if (splay_tree->root == (NodeInfo *) NULL) in DeleteNodeByValueFromSplayTree()
500 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
503 next=(NodeInfo *) GetFirstSplayTreeNode(splay_tree); in DeleteNodeByValueFromSplayTree()
506 SplaySplayTree(splay_tree,next); in DeleteNodeByValueFromSplayTree()
508 node=splay_tree->root->right; in DeleteNodeByValueFromSplayTree()
515 if (splay_tree->root->value == value) in DeleteNodeByValueFromSplayTree()
530 key=splay_tree->root->key; in DeleteNodeByValueFromSplayTree()
531 SplaySplayTree(splay_tree,key); in DeleteNodeByValueFromSplayTree()
532 splay_tree->key=(void *) NULL; in DeleteNodeByValueFromSplayTree()
533 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in DeleteNodeByValueFromSplayTree()
534 compare=splay_tree->compare(splay_tree->root->key,key); in DeleteNodeByValueFromSplayTree()
536 compare=(splay_tree->root->key > key) ? 1 : in DeleteNodeByValueFromSplayTree()
537 ((splay_tree->root->key < key) ? -1 : 0); in DeleteNodeByValueFromSplayTree()
540 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
543 left=splay_tree->root->left; in DeleteNodeByValueFromSplayTree()
544 right=splay_tree->root->right; in DeleteNodeByValueFromSplayTree()
545 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in DeleteNodeByValueFromSplayTree()
546 (splay_tree->root->value != (void *) NULL)) in DeleteNodeByValueFromSplayTree()
547 splay_tree->root->value=splay_tree->relinquish_value( in DeleteNodeByValueFromSplayTree()
548 splay_tree->root->value); in DeleteNodeByValueFromSplayTree()
549 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in DeleteNodeByValueFromSplayTree()
550 (splay_tree->root->key != (void *) NULL)) in DeleteNodeByValueFromSplayTree()
551 splay_tree->root->key=splay_tree->relinquish_key( in DeleteNodeByValueFromSplayTree()
552 splay_tree->root->key); in DeleteNodeByValueFromSplayTree()
553 splay_tree->root=(NodeInfo *) RelinquishMagickMemory(splay_tree->root); in DeleteNodeByValueFromSplayTree()
554 splay_tree->nodes--; in DeleteNodeByValueFromSplayTree()
557 splay_tree->root=right; in DeleteNodeByValueFromSplayTree()
558 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
561 splay_tree->root=left; in DeleteNodeByValueFromSplayTree()
568 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
572 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeByValueFromSplayTree()
604 SplayTreeInfo *splay_tree,const void *key) in DeleteNodeFromSplayTree() argument
613 assert(splay_tree != (SplayTreeInfo *) NULL); in DeleteNodeFromSplayTree()
614 assert(splay_tree->signature == MagickCoreSignature); in DeleteNodeFromSplayTree()
615 if (splay_tree->debug != MagickFalse) in DeleteNodeFromSplayTree()
617 if (splay_tree->root == (NodeInfo *) NULL) in DeleteNodeFromSplayTree()
619 LockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeFromSplayTree()
620 SplaySplayTree(splay_tree,key); in DeleteNodeFromSplayTree()
621 splay_tree->key=(void *) NULL; in DeleteNodeFromSplayTree()
622 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in DeleteNodeFromSplayTree()
623 compare=splay_tree->compare(splay_tree->root->key,key); in DeleteNodeFromSplayTree()
625 compare=(splay_tree->root->key > key) ? 1 : in DeleteNodeFromSplayTree()
626 ((splay_tree->root->key < key) ? -1 : 0); in DeleteNodeFromSplayTree()
629 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeFromSplayTree()
632 left=splay_tree->root->left; in DeleteNodeFromSplayTree()
633 right=splay_tree->root->right; in DeleteNodeFromSplayTree()
634 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in DeleteNodeFromSplayTree()
635 (splay_tree->root->value != (void *) NULL)) in DeleteNodeFromSplayTree()
636 splay_tree->root->value=splay_tree->relinquish_value( in DeleteNodeFromSplayTree()
637 splay_tree->root->value); in DeleteNodeFromSplayTree()
638 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in DeleteNodeFromSplayTree()
639 (splay_tree->root->key != (void *) NULL)) in DeleteNodeFromSplayTree()
640 splay_tree->root->key=splay_tree->relinquish_key(splay_tree->root->key); in DeleteNodeFromSplayTree()
641 splay_tree->root=(NodeInfo *) RelinquishMagickMemory(splay_tree->root); in DeleteNodeFromSplayTree()
642 splay_tree->nodes--; in DeleteNodeFromSplayTree()
645 splay_tree->root=right; in DeleteNodeFromSplayTree()
646 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeFromSplayTree()
649 splay_tree->root=left; in DeleteNodeFromSplayTree()
656 UnlockSemaphoreInfo(splay_tree->semaphore); in DeleteNodeFromSplayTree()
682 MagickExport SplayTreeInfo *DestroySplayTree(SplayTreeInfo *splay_tree) in DestroySplayTree() argument
691 LockSemaphoreInfo(splay_tree->semaphore); in DestroySplayTree()
692 if (splay_tree->root != (NodeInfo *) NULL) in DestroySplayTree()
694 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in DestroySplayTree()
695 (splay_tree->root->value != (void *) NULL)) in DestroySplayTree()
696 splay_tree->root->value=splay_tree->relinquish_value( in DestroySplayTree()
697 splay_tree->root->value); in DestroySplayTree()
698 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in DestroySplayTree()
699 (splay_tree->root->key != (void *) NULL)) in DestroySplayTree()
700 splay_tree->root->key=splay_tree->relinquish_key(splay_tree->root->key); in DestroySplayTree()
701 splay_tree->root->key=(void *) NULL; in DestroySplayTree()
702 for (pend=splay_tree->root; pend != (NodeInfo *) NULL; ) in DestroySplayTree()
709 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in DestroySplayTree()
711 active->left->value=splay_tree->relinquish_value( in DestroySplayTree()
713 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in DestroySplayTree()
715 active->left->key=splay_tree->relinquish_key(active->left->key); in DestroySplayTree()
721 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in DestroySplayTree()
723 active->right->value=splay_tree->relinquish_value( in DestroySplayTree()
725 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in DestroySplayTree()
727 active->right->key=splay_tree->relinquish_key( in DestroySplayTree()
738 splay_tree->signature=(~MagickCoreSignature); in DestroySplayTree()
739 UnlockSemaphoreInfo(splay_tree->semaphore); in DestroySplayTree()
740 RelinquishSemaphoreInfo(&splay_tree->semaphore); in DestroySplayTree()
741 splay_tree=(SplayTreeInfo *) RelinquishMagickMemory(splay_tree); in DestroySplayTree()
742 return(splay_tree); in DestroySplayTree()
769 MagickExport const void *GetNextKeyInSplayTree(SplayTreeInfo *splay_tree) in GetNextKeyInSplayTree() argument
777 assert(splay_tree != (SplayTreeInfo *) NULL); in GetNextKeyInSplayTree()
778 assert(splay_tree->signature == MagickCoreSignature); in GetNextKeyInSplayTree()
779 if (splay_tree->debug != MagickFalse) in GetNextKeyInSplayTree()
781 if ((splay_tree->root == (NodeInfo *) NULL) || in GetNextKeyInSplayTree()
782 (splay_tree->next == (void *) NULL)) in GetNextKeyInSplayTree()
784 LockSemaphoreInfo(splay_tree->semaphore); in GetNextKeyInSplayTree()
785 SplaySplayTree(splay_tree,splay_tree->next); in GetNextKeyInSplayTree()
786 splay_tree->next=(void *) NULL; in GetNextKeyInSplayTree()
787 node=splay_tree->root->right; in GetNextKeyInSplayTree()
792 splay_tree->next=node->key; in GetNextKeyInSplayTree()
794 key=splay_tree->root->key; in GetNextKeyInSplayTree()
795 UnlockSemaphoreInfo(splay_tree->semaphore); in GetNextKeyInSplayTree()
823 MagickExport const void *GetNextValueInSplayTree(SplayTreeInfo *splay_tree) in GetNextValueInSplayTree() argument
831 assert(splay_tree != (SplayTreeInfo *) NULL); in GetNextValueInSplayTree()
832 assert(splay_tree->signature == MagickCoreSignature); in GetNextValueInSplayTree()
833 if (splay_tree->debug != MagickFalse) in GetNextValueInSplayTree()
835 if ((splay_tree->root == (NodeInfo *) NULL) || in GetNextValueInSplayTree()
836 (splay_tree->next == (void *) NULL)) in GetNextValueInSplayTree()
838 LockSemaphoreInfo(splay_tree->semaphore); in GetNextValueInSplayTree()
839 SplaySplayTree(splay_tree,splay_tree->next); in GetNextValueInSplayTree()
840 splay_tree->next=(void *) NULL; in GetNextValueInSplayTree()
841 node=splay_tree->root->right; in GetNextValueInSplayTree()
846 splay_tree->next=node->key; in GetNextValueInSplayTree()
848 value=splay_tree->root->value; in GetNextValueInSplayTree()
849 UnlockSemaphoreInfo(splay_tree->semaphore); in GetNextValueInSplayTree()
877 MagickExport const void *GetRootValueFromSplayTree(SplayTreeInfo *splay_tree) in GetRootValueFromSplayTree() argument
882 assert(splay_tree != (SplayTreeInfo *) NULL); in GetRootValueFromSplayTree()
883 assert(splay_tree->signature == MagickCoreSignature); in GetRootValueFromSplayTree()
884 if (splay_tree->debug != MagickFalse) in GetRootValueFromSplayTree()
887 LockSemaphoreInfo(splay_tree->semaphore); in GetRootValueFromSplayTree()
888 if (splay_tree->root != (NodeInfo *) NULL) in GetRootValueFromSplayTree()
889 value=splay_tree->root->value; in GetRootValueFromSplayTree()
890 UnlockSemaphoreInfo(splay_tree->semaphore); in GetRootValueFromSplayTree()
921 MagickExport const void *GetValueFromSplayTree(SplayTreeInfo *splay_tree, in GetValueFromSplayTree() argument
930 assert(splay_tree != (SplayTreeInfo *) NULL); in GetValueFromSplayTree()
931 assert(splay_tree->signature == MagickCoreSignature); in GetValueFromSplayTree()
932 if (splay_tree->debug != MagickFalse) in GetValueFromSplayTree()
934 if (splay_tree->root == (NodeInfo *) NULL) in GetValueFromSplayTree()
936 LockSemaphoreInfo(splay_tree->semaphore); in GetValueFromSplayTree()
937 SplaySplayTree(splay_tree,key); in GetValueFromSplayTree()
938 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in GetValueFromSplayTree()
939 compare=splay_tree->compare(splay_tree->root->key,key); in GetValueFromSplayTree()
941 compare=(splay_tree->root->key > key) ? 1 : in GetValueFromSplayTree()
942 ((splay_tree->root->key < key) ? -1 : 0); in GetValueFromSplayTree()
945 UnlockSemaphoreInfo(splay_tree->semaphore); in GetValueFromSplayTree()
948 value=splay_tree->root->value; in GetValueFromSplayTree()
949 UnlockSemaphoreInfo(splay_tree->semaphore); in GetValueFromSplayTree()
977 const SplayTreeInfo *splay_tree) in GetNumberOfNodesInSplayTree() argument
979 assert(splay_tree != (SplayTreeInfo *) NULL); in GetNumberOfNodesInSplayTree()
980 assert(splay_tree->signature == MagickCoreSignature); in GetNumberOfNodesInSplayTree()
981 if (splay_tree->debug != MagickFalse) in GetNumberOfNodesInSplayTree()
983 return(splay_tree->nodes); in GetNumberOfNodesInSplayTree()
1013 static int IterateOverSplayTree(SplayTreeInfo *splay_tree, in IterateOverSplayTree() argument
1045 if (splay_tree->root == (NodeInfo *) NULL) in IterateOverSplayTree()
1047 nodes=(NodeInfo **) AcquireQuantumMemory((size_t) splay_tree->nodes, in IterateOverSplayTree()
1049 transitions=(unsigned char *) AcquireQuantumMemory((size_t) splay_tree->nodes, in IterateOverSplayTree()
1055 nodes[0]=splay_tree->root; in IterateOverSplayTree()
1146 *splay_tree; in NewSplayTree() local
1148 splay_tree=(SplayTreeInfo *) AcquireCriticalMemory(sizeof(*splay_tree)); in NewSplayTree()
1149 (void) memset(splay_tree,0,sizeof(*splay_tree)); in NewSplayTree()
1150 splay_tree->root=(NodeInfo *) NULL; in NewSplayTree()
1151 splay_tree->compare=compare; in NewSplayTree()
1152 splay_tree->relinquish_key=relinquish_key; in NewSplayTree()
1153 splay_tree->relinquish_value=relinquish_value; in NewSplayTree()
1154 splay_tree->balance=MagickFalse; in NewSplayTree()
1155 splay_tree->key=(void *) NULL; in NewSplayTree()
1156 splay_tree->next=(void *) NULL; in NewSplayTree()
1157 splay_tree->nodes=0; in NewSplayTree()
1158 splay_tree->debug=IsEventLogging(); in NewSplayTree()
1159 splay_tree->semaphore=AcquireSemaphoreInfo(); in NewSplayTree()
1160 splay_tree->signature=MagickCoreSignature; in NewSplayTree()
1161 return(splay_tree); in NewSplayTree()
1190 MagickExport void *RemoveNodeByValueFromSplayTree(SplayTreeInfo *splay_tree, in RemoveNodeByValueFromSplayTree() argument
1200 assert(splay_tree != (SplayTreeInfo *) NULL); in RemoveNodeByValueFromSplayTree()
1201 assert(splay_tree->signature == MagickCoreSignature); in RemoveNodeByValueFromSplayTree()
1202 if (splay_tree->debug != MagickFalse) in RemoveNodeByValueFromSplayTree()
1205 if (splay_tree->root == (NodeInfo *) NULL) in RemoveNodeByValueFromSplayTree()
1207 LockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeByValueFromSplayTree()
1208 next=(NodeInfo *) GetFirstSplayTreeNode(splay_tree); in RemoveNodeByValueFromSplayTree()
1211 SplaySplayTree(splay_tree,next); in RemoveNodeByValueFromSplayTree()
1213 node=splay_tree->root->right; in RemoveNodeByValueFromSplayTree()
1220 if (splay_tree->root->value == value) in RemoveNodeByValueFromSplayTree()
1232 key=splay_tree->root->key; in RemoveNodeByValueFromSplayTree()
1233 SplaySplayTree(splay_tree,key); in RemoveNodeByValueFromSplayTree()
1234 splay_tree->key=(void *) NULL; in RemoveNodeByValueFromSplayTree()
1235 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in RemoveNodeByValueFromSplayTree()
1236 compare=splay_tree->compare(splay_tree->root->key,key); in RemoveNodeByValueFromSplayTree()
1238 compare=(splay_tree->root->key > key) ? 1 : in RemoveNodeByValueFromSplayTree()
1239 ((splay_tree->root->key < key) ? -1 : 0); in RemoveNodeByValueFromSplayTree()
1242 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeByValueFromSplayTree()
1245 left=splay_tree->root->left; in RemoveNodeByValueFromSplayTree()
1246 right=splay_tree->root->right; in RemoveNodeByValueFromSplayTree()
1247 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in RemoveNodeByValueFromSplayTree()
1248 (splay_tree->root->value != (void *) NULL)) in RemoveNodeByValueFromSplayTree()
1249 splay_tree->root->value=splay_tree->relinquish_value( in RemoveNodeByValueFromSplayTree()
1250 splay_tree->root->value); in RemoveNodeByValueFromSplayTree()
1251 splay_tree->root=(NodeInfo *) RelinquishMagickMemory(splay_tree->root); in RemoveNodeByValueFromSplayTree()
1252 splay_tree->nodes--; in RemoveNodeByValueFromSplayTree()
1255 splay_tree->root=right; in RemoveNodeByValueFromSplayTree()
1256 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeByValueFromSplayTree()
1259 splay_tree->root=left; in RemoveNodeByValueFromSplayTree()
1266 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeByValueFromSplayTree()
1270 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeByValueFromSplayTree()
1299 MagickExport void *RemoveNodeFromSplayTree(SplayTreeInfo *splay_tree, in RemoveNodeFromSplayTree() argument
1312 assert(splay_tree != (SplayTreeInfo *) NULL); in RemoveNodeFromSplayTree()
1313 assert(splay_tree->signature == MagickCoreSignature); in RemoveNodeFromSplayTree()
1314 if (splay_tree->debug != MagickFalse) in RemoveNodeFromSplayTree()
1317 if (splay_tree->root == (NodeInfo *) NULL) in RemoveNodeFromSplayTree()
1319 LockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeFromSplayTree()
1320 SplaySplayTree(splay_tree,key); in RemoveNodeFromSplayTree()
1321 splay_tree->key=(void *) NULL; in RemoveNodeFromSplayTree()
1322 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in RemoveNodeFromSplayTree()
1323 compare=splay_tree->compare(splay_tree->root->key,key); in RemoveNodeFromSplayTree()
1325 compare=(splay_tree->root->key > key) ? 1 : in RemoveNodeFromSplayTree()
1326 ((splay_tree->root->key < key) ? -1 : 0); in RemoveNodeFromSplayTree()
1329 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeFromSplayTree()
1332 left=splay_tree->root->left; in RemoveNodeFromSplayTree()
1333 right=splay_tree->root->right; in RemoveNodeFromSplayTree()
1334 value=splay_tree->root->value; in RemoveNodeFromSplayTree()
1335 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in RemoveNodeFromSplayTree()
1336 (splay_tree->root->key != (void *) NULL)) in RemoveNodeFromSplayTree()
1337 splay_tree->root->key=splay_tree->relinquish_key(splay_tree->root->key); in RemoveNodeFromSplayTree()
1338 splay_tree->root=(NodeInfo *) RelinquishMagickMemory(splay_tree->root); in RemoveNodeFromSplayTree()
1339 splay_tree->nodes--; in RemoveNodeFromSplayTree()
1342 splay_tree->root=right; in RemoveNodeFromSplayTree()
1343 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeFromSplayTree()
1346 splay_tree->root=left; in RemoveNodeFromSplayTree()
1353 UnlockSemaphoreInfo(splay_tree->semaphore); in RemoveNodeFromSplayTree()
1380 MagickExport void ResetSplayTree(SplayTreeInfo *splay_tree) in ResetSplayTree() argument
1389 assert(splay_tree != (SplayTreeInfo *) NULL); in ResetSplayTree()
1390 assert(splay_tree->signature == MagickCoreSignature); in ResetSplayTree()
1391 if (splay_tree->debug != MagickFalse) in ResetSplayTree()
1393 LockSemaphoreInfo(splay_tree->semaphore); in ResetSplayTree()
1394 if (splay_tree->root != (NodeInfo *) NULL) in ResetSplayTree()
1396 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in ResetSplayTree()
1397 (splay_tree->root->value != (void *) NULL)) in ResetSplayTree()
1398 splay_tree->root->value=splay_tree->relinquish_value( in ResetSplayTree()
1399 splay_tree->root->value); in ResetSplayTree()
1400 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in ResetSplayTree()
1401 (splay_tree->root->key != (void *) NULL)) in ResetSplayTree()
1402 splay_tree->root->key=splay_tree->relinquish_key(splay_tree->root->key); in ResetSplayTree()
1403 splay_tree->root->key=(void *) NULL; in ResetSplayTree()
1404 for (pend=splay_tree->root; pend != (NodeInfo *) NULL; ) in ResetSplayTree()
1411 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in ResetSplayTree()
1413 active->left->value=splay_tree->relinquish_value( in ResetSplayTree()
1415 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in ResetSplayTree()
1417 active->left->key=splay_tree->relinquish_key(active->left->key); in ResetSplayTree()
1423 if ((splay_tree->relinquish_value != (void *(*)(void *)) NULL) && in ResetSplayTree()
1425 active->right->value=splay_tree->relinquish_value( in ResetSplayTree()
1427 if ((splay_tree->relinquish_key != (void *(*)(void *)) NULL) && in ResetSplayTree()
1429 active->right->key=splay_tree->relinquish_key( in ResetSplayTree()
1440 splay_tree->root=(NodeInfo *) NULL; in ResetSplayTree()
1441 splay_tree->key=(void *) NULL; in ResetSplayTree()
1442 splay_tree->next=(void *) NULL; in ResetSplayTree()
1443 splay_tree->nodes=0; in ResetSplayTree()
1444 splay_tree->balance=MagickFalse; in ResetSplayTree()
1445 UnlockSemaphoreInfo(splay_tree->semaphore); in ResetSplayTree()
1472 MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree) in ResetSplayTreeIterator() argument
1474 assert(splay_tree != (SplayTreeInfo *) NULL); in ResetSplayTreeIterator()
1475 assert(splay_tree->signature == MagickCoreSignature); in ResetSplayTreeIterator()
1476 if (splay_tree->debug != MagickFalse) in ResetSplayTreeIterator()
1478 LockSemaphoreInfo(splay_tree->semaphore); in ResetSplayTreeIterator()
1479 splay_tree->next=GetFirstSplayTreeNode(splay_tree); in ResetSplayTreeIterator()
1480 UnlockSemaphoreInfo(splay_tree->semaphore); in ResetSplayTreeIterator()
1515 static NodeInfo *Splay(SplayTreeInfo *splay_tree,const size_t depth, in Splay() argument
1531 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in Splay()
1532 compare=splay_tree->compare(n->key,key); in Splay()
1545 splay_tree->balance=MagickTrue; in Splay()
1548 n=Splay(splay_tree,depth+1,key,next,node,parent); in Splay()
1549 if ((n != *node) || (splay_tree->balance != MagickFalse)) in Splay()
1606 static void SplaySplayTree(SplayTreeInfo *splay_tree,const void *key) in SplaySplayTree() argument
1608 if (splay_tree->root == (NodeInfo *) NULL) in SplaySplayTree()
1610 if (splay_tree->key != (void *) NULL) in SplaySplayTree()
1615 if (splay_tree->compare != (int (*)(const void *,const void *)) NULL) in SplaySplayTree()
1616 compare=splay_tree->compare(splay_tree->root->key,key); in SplaySplayTree()
1618 compare=(splay_tree->key > key) ? 1 : in SplaySplayTree()
1619 ((splay_tree->key < key) ? -1 : 0); in SplaySplayTree()
1623 (void) Splay(splay_tree,0UL,key,&splay_tree->root,(NodeInfo **) NULL, in SplaySplayTree()
1625 if (splay_tree->balance != MagickFalse) in SplaySplayTree()
1627 BalanceSplayTree(splay_tree); in SplaySplayTree()
1628 (void) Splay(splay_tree,0UL,key,&splay_tree->root,(NodeInfo **) NULL, in SplaySplayTree()
1630 if (splay_tree->balance != MagickFalse) in SplaySplayTree()
1633 splay_tree->key=(void *) key; in SplaySplayTree()