AS3 BinaryTreeADT Interface


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. package
  2. {
  3. /***********************************************************************************************\
  4. * BinaryTreeADT Interface - Designed to give generic functionality to a binary tree collection *
  5. * type. This collection is to be implemented in a binary tree principles. With adding, removing,*
  6. * searching,trace output, and state functions of the collection. *
  7. * @author : Richard Vacheresse /|\ http://www.rvacheresse.com /|\ *
  8. * Licensed for free Commercial and Private use creative commons license agreement. *
  9. * The provided code is in an "as-is" state. Richard Vacheresse makes no warranties *
  10. * regarding the provided code, and disclaims liability for damages resulting from its use. *
  11. * @version 1.0 *
  12. \***********************************************************************************************/
  13. public interface BinaryTreeADT
  14. {
  15. /**
  16. * getRoot() function - Returns the root object of the biary tree structure
  17. * @return - Object
  18. **/
  19. function getRoot():Object;
  20.  
  21. /**
  22. * isEmpty() function - Returns true if the binary tree contains no objects
  23. * @return - Boolean Object
  24. **/
  25. function isEmpty():Boolean;
  26.  
  27. /**
  28. * size() function - Returns an integer object which represents the number of objects in the
  29. * tree structure.
  30. * @return - Integer Object
  31. **/
  32. function size():int;
  33.  
  34. /**
  35. * contains(obj:Object):Boolean - Returns true if the binary tree contains an element that matches
  36. * the specified element and false otherwise.
  37. * @return - Boolean Object
  38. **/
  39. function contains(obj:Object):Boolean;
  40.  
  41. /**
  42. * find(obj:Object):Boolean - Returns true if the binary tree contains an element that matches
  43.   * the specified element and false otherwise.
  44. * @param targetElement - The element being sought in the tree
  45. * @return - Boolean Object
  46. **/
  47. function find(obj:Object):Boolean;
  48.  
  49. /**
  50. * toString():String function - Returns a String representation of the binary tree
  51. * @return - String Object
  52. **/
  53. function toString():String;
  54.  
  55. /**
  56. * Performs an inorder traversal on this binary tree by calling an
  57. * overloaded, recursive inorder method that starts with the root.
  58. * @return an iterator over the elements of this binary tree
  59. **/
  60. function iteratorInOrder():Iterator;
  61.  
  62. /**
  63. * Performs a preorder traversal on this binary tree by calling an
  64. * overloaded, recursive preorder method that starts with the root.
  65. * @return an iterator over the elements of this binary tree
  66. **/
  67. public iteratorPreOrder():Iterator;
  68.  
  69. /**
  70. * Performs a postorder traversal on this binary tree by calling an
  71. * overloaded, recursive postorder method that starts with the root.
  72. * @return an iterator over the elements of this binary tree
  73. **/
  74. public Iterator<T> iteratorPostOrder():Iterator;
  75.  
  76. /**
  77. * Performs a levelorder traversal on the binary tree, using a queue.
  78. * @return an iterator over the elements of this binary tree
  79. **/
  80. public Iterator<T> iteratorLevelOrder():Iterator;
  81.  
  82. }
  83. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.