Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Node<E> addChild(Node<E> node, E elem)
- {
- SLLNode<E> tmp = new SLLNode<E>(elem);
- SLLNode<E> curr = (SLLNode<E>) node;
- SLLNode<E> t = curr.firstChild;
- SLLNode<E> pret = null;
- while(t != null)
- {
- if(t.info.compareTo(elem) > 0)
- {
- break;
- }
- pret = t;
- t = t.sibling;
- }
- if(pret == null)
- {
- tmp.sibling = curr.firstChild;
- curr.firstChild = tmp;
- }
- else
- {
- pret.sibling = tmp;
- tmp.sibling = t;
- }
- tmp.parent = curr;
- return tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement