Advertisement
Guest User

LinkedBinaryTree.java

a guest
Mar 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.util.Iterator;
  2.  
  3. import javax.lang.model.util.Elements;
  4.  
  5.  
  6. public class LinkedBinaryTree implements BinaryTree{
  7. private BTNode root; //reference to the root
  8. private int size; //number of nodes
  9.  
  10. public LinkedBinaryTree(){
  11. root = null;
  12. size = 0;
  13. }
  14.  
  15. public Iterator iterator()
  16. {
  17. Iterable<Position> positions = positions();
  18. PositionalList elements = new PositionalList();
  19. for(Position pos: positions)
  20. elements.addLast(pos.getElement()); //can we use getElement?.... it was element() in ques
  21. return elements.iterator();
  22. }
  23.  
  24. //How can I implement Iterable
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement