Untitled


SUBMITTED BY: antoineh1

DATE: May 8, 2016, 2:12 p.m.

FORMAT: Text only

SIZE: 580 Bytes

HITS: 4836

  1. public boolean deleteByIndex(int index)
  2. {
  3. Node curNode = head;
  4. while (curNode.getDown() != null)
  5. curNode = curNode.getDown();
  6. for (int i=0; i<index ; i++)
  7. curNode = curNode.getRight();
  8. if (curNode == null)
  9. return false;
  10. while (curNode != null)
  11. {
  12. if (curNode.getRight() != null)
  13. {
  14. curNode.getLeft().setRight(curNode.getRight());
  15. curNode.getRight().setLeft(curNode.getLeft());
  16. }
  17. else
  18. {
  19. curNode.getLeft().setRight(null);
  20. }
  21. curNode = curNode.getUp();
  22. }
  23. return true;
  24. }

comments powered by Disqus