AVLTree.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. {
  2. File: AVLTree.p
  3. Contains: Prototypes for routines which create, destroy, allow for
  4. Version: Universal Interfaces 3.4.2
  5. Copyright: © 1999-2002 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. {
  11. Modified for use with Free Pascal
  12. Version 200
  13. Please report any bugs to <[email protected]>
  14. }
  15. {$mode macpas}
  16. {$packenum 1}
  17. {$macro on}
  18. {$inline on}
  19. {$CALLING MWPASCAL}
  20. unit AVLTree;
  21. interface
  22. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  23. {$setc GAP_INTERFACES_VERSION := $0200}
  24. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  25. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  26. {$endc}
  27. {$ifc defined CPUPOWERPC and defined CPUI386}
  28. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  29. {$endc}
  30. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  31. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  32. {$endc}
  33. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  34. {$setc __ppc__ := 1}
  35. {$elsec}
  36. {$setc __ppc__ := 0}
  37. {$endc}
  38. {$ifc not defined __i386__ and defined CPUI386}
  39. {$setc __i386__ := 1}
  40. {$elsec}
  41. {$setc __i386__ := 0}
  42. {$endc}
  43. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  44. {$error Conflicting definitions for __ppc__ and __i386__}
  45. {$endc}
  46. {$ifc defined __ppc__ and __ppc__}
  47. {$setc TARGET_CPU_PPC := TRUE}
  48. {$setc TARGET_CPU_X86 := FALSE}
  49. {$elifc defined __i386__ and __i386__}
  50. {$setc TARGET_CPU_PPC := FALSE}
  51. {$setc TARGET_CPU_X86 := TRUE}
  52. {$elsec}
  53. {$error Neither __ppc__ nor __i386__ is defined.}
  54. {$endc}
  55. {$setc TARGET_CPU_PPC_64 := FALSE}
  56. {$ifc defined FPC_BIG_ENDIAN}
  57. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  58. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  59. {$elifc defined FPC_LITTLE_ENDIAN}
  60. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  61. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  62. {$elsec}
  63. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  64. {$endc}
  65. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  66. {$setc CALL_NOT_IN_CARBON := FALSE}
  67. {$setc OLDROUTINENAMES := FALSE}
  68. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  69. {$setc OPAQUE_UPP_TYPES := TRUE}
  70. {$setc OTCARBONAPPLICATION := TRUE}
  71. {$setc OTKERNEL := FALSE}
  72. {$setc PM_USE_SESSION_APIS := TRUE}
  73. {$setc TARGET_API_MAC_CARBON := TRUE}
  74. {$setc TARGET_API_MAC_OS8 := FALSE}
  75. {$setc TARGET_API_MAC_OSX := TRUE}
  76. {$setc TARGET_CARBON := TRUE}
  77. {$setc TARGET_CPU_68K := FALSE}
  78. {$setc TARGET_CPU_MIPS := FALSE}
  79. {$setc TARGET_CPU_SPARC := FALSE}
  80. {$setc TARGET_OS_MAC := TRUE}
  81. {$setc TARGET_OS_UNIX := FALSE}
  82. {$setc TARGET_OS_WIN32 := FALSE}
  83. {$setc TARGET_RT_MAC_68881 := FALSE}
  84. {$setc TARGET_RT_MAC_CFM := FALSE}
  85. {$setc TARGET_RT_MAC_MACHO := TRUE}
  86. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  87. {$setc TYPE_BOOL := FALSE}
  88. {$setc TYPE_EXTENDED := FALSE}
  89. {$setc TYPE_LONGLONG := TRUE}
  90. uses MacTypes,MixedMode;
  91. {$ALIGN MAC68K}
  92. type
  93. AVLFlags = UInt32;
  94. const
  95. kAVLFlagUseHandleForDataStorageMask = $00000001;
  96. { The visit stage for AVLWalk() walkProcs }
  97. type
  98. AVLVisitStage = UInt16;
  99. const
  100. kAVLPreOrder = 0;
  101. kAVLInOrder = 1;
  102. kAVLPostOrder = 2;
  103. { The order the tree is walked or disposed of. }
  104. type
  105. AVLOrder = UInt16;
  106. const
  107. kAVLLeftToRight = 0;
  108. kAVLRightToLeft = 1;
  109. { The type of the node being passed to a callback proc. }
  110. type
  111. AVLNodeType = UInt16;
  112. const
  113. kAVLIsTree = 0;
  114. kAVLIsLeftBranch = 1;
  115. kAVLIsRightBranch = 2;
  116. kAVLIsLeaf = 3;
  117. kAVLNullNode = 4;
  118. errItemAlreadyInTree = -960;
  119. errNotValidTree = -961;
  120. errItemNotFoundInTree = -962;
  121. errCanNotInsertWhileWalkProcInProgress = -963;
  122. errTreeIsLocked = -964;
  123. errTreeIsCorrupt = -965;
  124. { The structure of a tree. It's opaque; don't assume it's 52 bytes in size. }
  125. type
  126. AVLTreeStructPtr = ^AVLTreeStruct;
  127. AVLTreeStruct = record
  128. signature: OSType;
  129. privateStuff: array [0..11] of UInt32;
  130. end;
  131. AVLTreePtr = ^AVLTreeStruct;
  132. {
  133. Every tree must have a function which compares the data for two items and returns < 0, 0, or >0
  134. for the items - < 0 if the first item is 'before' the second item according to some criteria,
  135. == 0 if the two items are identical according to the criteria, or > 0 if the first item is
  136. 'after' the second item according to the criteria. The comparison function is also passed the
  137. node type, but most of the time this can be ignored.
  138. }
  139. {$ifc TYPED_FUNCTION_POINTERS}
  140. AVLCompareItemsProcPtr = function(tree: AVLTreePtr; i1: UnivPtr; i2: UnivPtr; nd_typ: AVLNodeType): SInt32;
  141. {$elsec}
  142. AVLCompareItemsProcPtr = ProcPtr;
  143. {$endc}
  144. {
  145. Every tree must have a itemSizeProc; this routine gets passed a pointer to the item's data and
  146. returns the size of the data. If a tree contains records of a fixed size, this function can
  147. just return sizeof( that-struct ); otherwise it should calculate the size of the item based on
  148. the data for the item.
  149. }
  150. {$ifc TYPED_FUNCTION_POINTERS}
  151. AVLItemSizeProcPtr = function(tree: AVLTreePtr; itemPtr: UnivPtr): UInt32;
  152. {$elsec}
  153. AVLItemSizeProcPtr = ProcPtr;
  154. {$endc}
  155. {
  156. A tree may have an optional disposeItemProc, which gets called whenever an item is removed
  157. from the tree ( via AVLRemove() or when AVLDispose() deletes all of the items in the tree ).
  158. This might be useful if the nodes in the tree own 'resources' ( like, open files ) which
  159. should be released before the item is removed.
  160. }
  161. {$ifc TYPED_FUNCTION_POINTERS}
  162. AVLDisposeItemProcPtr = procedure(tree: AVLTreePtr; dataP: UnivPtr);
  163. {$elsec}
  164. AVLDisposeItemProcPtr = ProcPtr;
  165. {$endc}
  166. {
  167. The common way to iterate across all of the items in a tree is via AVLWalk(), which takes
  168. a walkProcPtr. This function will get called for every item in the tree three times, as
  169. the tree is being walked across. First, the walkProc will get called with visitStage ==
  170. kAVLPreOrder, at which point internally the node of the tree for the given data has just
  171. been reached. Later, this function will get called with visitStage == kAVLInOrder, and
  172. lastly this function will get called with visitStage == kAVLPostOrder.
  173. The 'minimum' item in the tree will get called with visitStage == kInOrder first, followed
  174. by the 'next' item in the tree, up until the last item in the tree structure is called.
  175. In general, you'll only care about calls to this function when visitStage == kAVLInOrder.
  176. }
  177. {$ifc TYPED_FUNCTION_POINTERS}
  178. AVLWalkProcPtr = function(tree: AVLTreePtr; dataP: UnivPtr; visitStage: AVLVisitStage; node: AVLNodeType; level: UInt32; balance: SInt32; refCon: UnivPtr): OSErr;
  179. {$elsec}
  180. AVLWalkProcPtr = ProcPtr;
  181. {$endc}
  182. {$ifc OPAQUE_UPP_TYPES}
  183. AVLCompareItemsUPP = ^SInt32; { an opaque UPP }
  184. {$elsec}
  185. AVLCompareItemsUPP = UniversalProcPtr;
  186. {$endc}
  187. {$ifc OPAQUE_UPP_TYPES}
  188. AVLItemSizeUPP = ^SInt32; { an opaque UPP }
  189. {$elsec}
  190. AVLItemSizeUPP = UniversalProcPtr;
  191. {$endc}
  192. {$ifc OPAQUE_UPP_TYPES}
  193. AVLDisposeItemUPP = ^SInt32; { an opaque UPP }
  194. {$elsec}
  195. AVLDisposeItemUPP = UniversalProcPtr;
  196. {$endc}
  197. {$ifc OPAQUE_UPP_TYPES}
  198. AVLWalkUPP = ^SInt32; { an opaque UPP }
  199. {$elsec}
  200. AVLWalkUPP = UniversalProcPtr;
  201. {$endc}
  202. const
  203. uppAVLCompareItemsProcInfo = $00002FF0;
  204. uppAVLItemSizeProcInfo = $000003F0;
  205. uppAVLDisposeItemProcInfo = $000003C0;
  206. uppAVLWalkProcInfo = $000FEBE0;
  207. {
  208. * NewAVLCompareItemsUPP()
  209. *
  210. * Availability:
  211. * Non-Carbon CFM: available as macro/inline
  212. * CarbonLib: in CarbonLib 1.0 and later
  213. * Mac OS X: in version 10.0 and later
  214. }
  215. function NewAVLCompareItemsUPP(userRoutine: AVLCompareItemsProcPtr): AVLCompareItemsUPP; external name '_NewAVLCompareItemsUPP'; { old name was NewAVLCompareItemsProc }
  216. {
  217. * NewAVLItemSizeUPP()
  218. *
  219. * Availability:
  220. * Non-Carbon CFM: available as macro/inline
  221. * CarbonLib: in CarbonLib 1.0 and later
  222. * Mac OS X: in version 10.0 and later
  223. }
  224. function NewAVLItemSizeUPP(userRoutine: AVLItemSizeProcPtr): AVLItemSizeUPP; external name '_NewAVLItemSizeUPP'; { old name was NewAVLItemSizeProc }
  225. {
  226. * NewAVLDisposeItemUPP()
  227. *
  228. * Availability:
  229. * Non-Carbon CFM: available as macro/inline
  230. * CarbonLib: in CarbonLib 1.0 and later
  231. * Mac OS X: in version 10.0 and later
  232. }
  233. function NewAVLDisposeItemUPP(userRoutine: AVLDisposeItemProcPtr): AVLDisposeItemUPP; external name '_NewAVLDisposeItemUPP'; { old name was NewAVLDisposeItemProc }
  234. {
  235. * NewAVLWalkUPP()
  236. *
  237. * Availability:
  238. * Non-Carbon CFM: available as macro/inline
  239. * CarbonLib: in CarbonLib 1.0 and later
  240. * Mac OS X: in version 10.0 and later
  241. }
  242. function NewAVLWalkUPP(userRoutine: AVLWalkProcPtr): AVLWalkUPP; external name '_NewAVLWalkUPP'; { old name was NewAVLWalkProc }
  243. {
  244. * DisposeAVLCompareItemsUPP()
  245. *
  246. * Availability:
  247. * Non-Carbon CFM: available as macro/inline
  248. * CarbonLib: in CarbonLib 1.0 and later
  249. * Mac OS X: in version 10.0 and later
  250. }
  251. procedure DisposeAVLCompareItemsUPP(userUPP: AVLCompareItemsUPP); external name '_DisposeAVLCompareItemsUPP';
  252. {
  253. * DisposeAVLItemSizeUPP()
  254. *
  255. * Availability:
  256. * Non-Carbon CFM: available as macro/inline
  257. * CarbonLib: in CarbonLib 1.0 and later
  258. * Mac OS X: in version 10.0 and later
  259. }
  260. procedure DisposeAVLItemSizeUPP(userUPP: AVLItemSizeUPP); external name '_DisposeAVLItemSizeUPP';
  261. {
  262. * DisposeAVLDisposeItemUPP()
  263. *
  264. * Availability:
  265. * Non-Carbon CFM: available as macro/inline
  266. * CarbonLib: in CarbonLib 1.0 and later
  267. * Mac OS X: in version 10.0 and later
  268. }
  269. procedure DisposeAVLDisposeItemUPP(userUPP: AVLDisposeItemUPP); external name '_DisposeAVLDisposeItemUPP';
  270. {
  271. * DisposeAVLWalkUPP()
  272. *
  273. * Availability:
  274. * Non-Carbon CFM: available as macro/inline
  275. * CarbonLib: in CarbonLib 1.0 and later
  276. * Mac OS X: in version 10.0 and later
  277. }
  278. procedure DisposeAVLWalkUPP(userUPP: AVLWalkUPP); external name '_DisposeAVLWalkUPP';
  279. {
  280. * InvokeAVLCompareItemsUPP()
  281. *
  282. * Availability:
  283. * Non-Carbon CFM: available as macro/inline
  284. * CarbonLib: in CarbonLib 1.0 and later
  285. * Mac OS X: in version 10.0 and later
  286. }
  287. function InvokeAVLCompareItemsUPP(tree: AVLTreePtr; i1: UnivPtr; i2: UnivPtr; nd_typ: AVLNodeType; userRoutine: AVLCompareItemsUPP): SInt32; external name '_InvokeAVLCompareItemsUPP'; { old name was CallAVLCompareItemsProc }
  288. {
  289. * InvokeAVLItemSizeUPP()
  290. *
  291. * Availability:
  292. * Non-Carbon CFM: available as macro/inline
  293. * CarbonLib: in CarbonLib 1.0 and later
  294. * Mac OS X: in version 10.0 and later
  295. }
  296. function InvokeAVLItemSizeUPP(tree: AVLTreePtr; itemPtr: UnivPtr; userRoutine: AVLItemSizeUPP): UInt32; external name '_InvokeAVLItemSizeUPP'; { old name was CallAVLItemSizeProc }
  297. {
  298. * InvokeAVLDisposeItemUPP()
  299. *
  300. * Availability:
  301. * Non-Carbon CFM: available as macro/inline
  302. * CarbonLib: in CarbonLib 1.0 and later
  303. * Mac OS X: in version 10.0 and later
  304. }
  305. procedure InvokeAVLDisposeItemUPP(tree: AVLTreePtr; dataP: UnivPtr; userRoutine: AVLDisposeItemUPP); external name '_InvokeAVLDisposeItemUPP'; { old name was CallAVLDisposeItemProc }
  306. {
  307. * InvokeAVLWalkUPP()
  308. *
  309. * Availability:
  310. * Non-Carbon CFM: available as macro/inline
  311. * CarbonLib: in CarbonLib 1.0 and later
  312. * Mac OS X: in version 10.0 and later
  313. }
  314. function InvokeAVLWalkUPP(tree: AVLTreePtr; dataP: UnivPtr; visitStage: AVLVisitStage; node: AVLNodeType; level: UInt32; balance: SInt32; refCon: UnivPtr; userRoutine: AVLWalkUPP): OSErr; external name '_InvokeAVLWalkUPP'; { old name was CallAVLWalkProc }
  315. {
  316. Create an AVL tree. The compareItemsProc and the sizeItemProc are required; disposeItemProc is
  317. optional and can be nil. The refCon is stored with the list, and is passed back to the
  318. compareItemsProc, sizeItemProc, and disposeItemsProc calls. The allocation of the tree ( and all
  319. nodes later added to the list with AVLInsert ) will be created in what is the current zone at the
  320. time AVLInit() is called. Always call AVLDispose() to dispose of a list created with AVLInit().
  321. }
  322. {
  323. * AVLInit()
  324. *
  325. * Availability:
  326. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  327. * CarbonLib: in CarbonLib 1.0 and later
  328. * Mac OS X: in version 10.0 and later
  329. }
  330. function AVLInit(flags: UInt32; compareItemsProc: AVLCompareItemsUPP; sizeItemProc: AVLItemSizeUPP; disposeItemProc: AVLDisposeItemUPP; refCon: UnivPtr; var tree: AVLTreePtr): OSErr; external name '_AVLInit';
  331. {
  332. Dispose of an AVL tree. This will dispose of each item in the tree in the order specified,
  333. call the tree's disposeProc proc for each item, and then dispose of the space allocated for
  334. the tree itself.
  335. }
  336. {
  337. * AVLDispose()
  338. *
  339. * Availability:
  340. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  341. * CarbonLib: in CarbonLib 1.0 and later
  342. * Mac OS X: in version 10.0 and later
  343. }
  344. function AVLDispose(var tree: AVLTreePtr; order: AVLOrder): OSErr; external name '_AVLDispose';
  345. {
  346. Iterate across all of the items in the tree, in the order specified. kLeftToRight is
  347. basically lowest-to-highest order, kRightToLeft is highest-to-lowest order. For each
  348. node in the tree, it will call the walkProc with three messages ( at the appropriate
  349. time ). First, with kAVLPreOrder when the walking gets to this node in the tree,
  350. before handling either the left or right subtree, secondly, with kAVLInOrder after
  351. handling one subtree but before handling the other, and lastly with kAVLPostOrder after
  352. handling both subtrees. If you want to handle items in order, then only do something
  353. if the visit stage is kAVLInOrder. You can only call AVLRemove() from inside a walkProc
  354. if visit stage is kAVLPostOrder ( because if you remove a node during the pre or in order
  355. stages you will corrupt the list ) OR if you return a non-zero result from the walkProc
  356. call which called AVLRemove() to immediately terminate the walkProc. Do not call AVLInsert()
  357. to insert a node into the tree from inside a walkProc.
  358. The walkProc function gets called with the AVLTreePtr, a pointer to the data for the
  359. current node ( which you can change in place as long as you do not affect the order within
  360. the tree ), the visit stage, the type of the current node ( leaf node, right or left branch,
  361. or full tree ), the level within the tree ( the root is level 1 ), the balance for the
  362. current node, and the refCon passed to AVLWalk(). This refCon is different from the one passed
  363. into AVLInit(); use AVLGetRefCon() to get that refCon if you want it inside a walkProc.
  364. ( Most walkProcs will not care about the values for node type, level, or balance. )
  365. }
  366. {
  367. * AVLWalk()
  368. *
  369. * Availability:
  370. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  371. * CarbonLib: in CarbonLib 1.0 and later
  372. * Mac OS X: in version 10.0 and later
  373. }
  374. function AVLWalk(tree: AVLTreePtr; walkProc: AVLWalkUPP; order: AVLOrder; walkRefCon: UnivPtr): OSErr; external name '_AVLWalk';
  375. { Return the number of items in the given tree. }
  376. {
  377. * AVLCount()
  378. *
  379. * Availability:
  380. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  381. * CarbonLib: in CarbonLib 1.0 and later
  382. * Mac OS X: in version 10.0 and later
  383. }
  384. function AVLCount(tree: AVLTreePtr; var count: UInt32): OSErr; external name '_AVLCount';
  385. {
  386. Return the one-based index-th item from the tree by putting it's data at dataPtr
  387. if dataPtr is non-nil, and it's size into *itemSize if itemSize is non-nil.
  388. If index is out of range, return errItemNotFoundInTree. ( Internally, this does
  389. an AVLWalk(), so the tree can not be modified while this call is in progress ).
  390. }
  391. {
  392. * AVLGetIndItem()
  393. *
  394. * Availability:
  395. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  396. * CarbonLib: in CarbonLib 1.0 and later
  397. * Mac OS X: in version 10.0 and later
  398. }
  399. function AVLGetIndItem(tree: AVLTreePtr; index: UInt32; dataPtr: UnivPtr; var itemSize: UInt32): OSErr; external name '_AVLGetIndItem';
  400. {
  401. Insert the given item into the tree. This will call the tree's sizeItemProc
  402. to determine how big the item at data is, and then will make a copy of the
  403. item and insert it into the tree in the appropriate place. If an item already
  404. exists in the tree with the same key ( so that the compareItemsUPP returns 0
  405. when asked to compare this item to an existing one ), then it will return
  406. errItemNotFoundInTree.
  407. }
  408. {
  409. * AVLInsert()
  410. *
  411. * Availability:
  412. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  413. * CarbonLib: in CarbonLib 1.0 and later
  414. * Mac OS X: in version 10.0 and later
  415. }
  416. function AVLInsert(tree: AVLTreePtr; data: UnivPtr): OSErr; external name '_AVLInsert';
  417. {
  418. Remove any item from the tree with the given key. If dataPtr != nil, then
  419. copy the item's data to dataPtr before removing it from the tree. Before
  420. removing the item, call the tree's disposeItemProc to let it release anything
  421. used by the data in the tree. It is not necessary to fill in a complete
  422. record for key, only that the compareItemsProc return 0 when asked to compare
  423. the data at key with the node in the tree to be deleted. If the item cannot
  424. be found in the tree, this will return errItemNotFoundInTree.
  425. }
  426. {
  427. * AVLRemove()
  428. *
  429. * Availability:
  430. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  431. * CarbonLib: in CarbonLib 1.0 and later
  432. * Mac OS X: in version 10.0 and later
  433. }
  434. function AVLRemove(tree: AVLTreePtr; key: UnivPtr; dataPtr: UnivPtr; var itemSize: UInt32): OSErr; external name '_AVLRemove';
  435. {
  436. Find the item in the tree with the given key, and return it's data in
  437. dataPtr ( if dataPtr != nil ), and it's size in *itemSize ( if itemSize
  438. != nil ). It is not necessary to fill in a complete record for key,
  439. only that the compareItemsProc return 0 when asked to compare the data
  440. at key with the node in the tree to be deleted. If the item cannot
  441. be found in the tree, this will return errItemNotFoundInTree.
  442. }
  443. {
  444. * AVLFind()
  445. *
  446. * Availability:
  447. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  448. * CarbonLib: in CarbonLib 1.0 and later
  449. * Mac OS X: in version 10.0 and later
  450. }
  451. function AVLFind(tree: AVLTreePtr; key: UnivPtr; dataPtr: UnivPtr; var itemSize: UInt32): OSErr; external name '_AVLFind';
  452. {
  453. Get the refCon for the given tree ( set in AVLInit ) and return it.
  454. If the given tree is invalid, then return nil.
  455. }
  456. {
  457. * AVLGetRefcon()
  458. *
  459. * Availability:
  460. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  461. * CarbonLib: in CarbonLib 1.0 and later
  462. * Mac OS X: in version 10.0 and later
  463. }
  464. function AVLGetRefcon(tree: AVLTreePtr; var refCon: UnivPtr): OSErr; external name '_AVLGetRefcon';
  465. {
  466. Get the refCon for the given tree ( set in AVLInit ) and return it.
  467. If the given tree is invalid, then return nil.
  468. }
  469. {$ifc CALL_NOT_IN_CARBON}
  470. {
  471. * AVLLockTree()
  472. *
  473. * Availability:
  474. * Non-Carbon CFM: in InterfaceLib 9.2.1 and later
  475. * CarbonLib: not available
  476. * Mac OS X: not available
  477. }
  478. function AVLLockTree(tree: AVLTreePtr): OSErr; external name '_AVLLockTree';
  479. {
  480. Get the refCon for the given tree ( set in AVLInit ) and return it.
  481. If the given tree is invalid, then return nil.
  482. }
  483. {
  484. * AVLUnlockTree()
  485. *
  486. * Availability:
  487. * Non-Carbon CFM: in InterfaceLib 9.2.1 and later
  488. * CarbonLib: not available
  489. * Mac OS X: not available
  490. }
  491. function AVLUnlockTree(tree: AVLTreePtr): OSErr; external name '_AVLUnlockTree';
  492. {
  493. Get the refCon for the given tree ( set in AVLInit ) and return it.
  494. If the given tree is invalid, then return nil.
  495. }
  496. {
  497. * AVLCheckTree()
  498. *
  499. * Availability:
  500. * Non-Carbon CFM: in InterfaceLib 9.2.1 and later
  501. * CarbonLib: not available
  502. * Mac OS X: not available
  503. }
  504. function AVLCheckTree(tree: AVLTreePtr): OSErr; external name '_AVLCheckTree';
  505. {$endc} {CALL_NOT_IN_CARBON}
  506. {$ALIGN MAC68K}
  507. end.