Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Iterator;
- import javax.lang.model.util.Elements;
- public class LinkedBinaryTree implements BinaryTree{
- private BTNode root; //reference to the root
- private int size; //number of nodes
- public LinkedBinaryTree(){
- root = null;
- size = 0;
- }
- public Iterator iterator()
- {
- Iterable<Position> positions = positions();
- PositionalList elements = new PositionalList();
- for(Position pos: positions)
- elements.addLast(pos.getElement()); //can we use getElement?.... it was element() in ques
- return elements.iterator();
- }
- //How can I implement Iterable
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement