Advertisement
Zenn_

Binary Tree Queue

May 22nd, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. public class BinaryTreeQueue{
  2.         private class BTQNode{
  3.             public BTQNode(BinaryTree bt){
  4.                 this.content = bt;
  5.             }
  6.             public BTQNode next;
  7.             public BinaryTree content;
  8.            
  9.             public void setNext(BTQNode next){this.next = next;}
  10.         }
  11.         BTQNode start;
  12.        
  13.         public void insert(BinaryTree bt){
  14.             BTQNode current = start;
  15.             if(start == null) start = new BTQNode(bt);
  16.             else {
  17.                 while(current.next !=null) current = current.next;
  18.                 current.next = new BTQNode(bt);
  19.             }
  20.         }
  21.        
  22.         public BinaryTree pull(){
  23.             BTQNode temp = start;
  24.             if(start.next != null) start = start.next;
  25.             return temp.content;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement