Return to Snippet

Revision: 21619
at December 16, 2009 12:48 by rvachere


Updated Code
package
{
	/***********************************************************************************************\
	* BinaryTreeADT Interface - Designed to give generic functionality to a binary tree collection  *
	* type. This collection is to be implemented in a binary tree principles. With adding, removing,*
	* searching,trace output, and state functions of the collection.                                *
	* @author : Richard Vacheresse /|\ http://www.rvacheresse.com /|\                               *
	* Licensed for free Commercial and Private use creative commons license agreement.              *
	* The provided code is in an "as-is" state. Richard Vacheresse makes no warranties              *
	* regarding the provided code, and disclaims liability for damages resulting from its use.      *
	* @version 1.0                                                                                  *
	\***********************************************************************************************/
	public interface BinaryTreeADT
	{
		/**
		* getRoot() function - Returns the root object of the biary tree structure
		* @return - Object
		**/
		function getRoot():Object;
		
		/**
		* isEmpty() function - Returns true if the binary tree contains no objects
		* @return - Boolean Object
		**/
		function isEmpty():Boolean;
		
		/**
		* size() function - Returns an integer object which represents the number of objects in the
		* tree structure.
		* @return - Integer Object
		**/
		function size():int;
		
		/**
		* contains(obj:Object):Boolean - Returns true if the binary tree contains an element that matches
		* the specified element and false otherwise.
		* @return - Boolean Object
		**/
		function contains(obj:Object):Boolean;
		
		/**
		* find(obj:Object):Boolean - Returns true if the binary tree contains an element that matches
        * the specified element and false otherwise. 
		* @param targetElement  - The element being sought in the tree
		* @return - Boolean Object
		**/
		function find(obj:Object):Boolean;
		
		/**
		* toString():String function - Returns a String representation of the binary tree
		* @return - String Object
		**/
		function toString():String;
		
		/**
		* Performs an inorder traversal on this binary tree by calling an 
	    * overloaded, recursive inorder method that starts with the root.
	    * @return  an iterator over the elements of this binary tree
		**/
		function iteratorInOrder():Iterator;
		
		/**  
		* Performs a preorder traversal on this binary tree by calling an 
		* overloaded, recursive preorder method that starts with the root. 
		* @return  an iterator over the elements of this binary tree
	    **/
	    public iteratorPreOrder():Iterator;
	
		/**  
		* Performs a postorder traversal on this binary tree by calling an 
		* overloaded, recursive postorder method that starts with the root. 
		* @return  an iterator over the elements of this binary tree
		**/
		public Iterator<T> iteratorPostOrder():Iterator;
		
		/**  
		* Performs a levelorder traversal on the binary tree, using a queue.
		* @return  an iterator over the elements of this binary tree
		**/
		public Iterator<T> iteratorLevelOrder():Iterator;
		
	}
}

Revision: 21618
at December 16, 2009 12:48 by rvachere


Initial Code


Initial URL


Initial Description


Initial Title
AS3 BinaryTreeADT Interface

Initial Tags


Initial Language
ActionScript 3