Advertisement
Shanix

Untitled

Mar 2nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. Node n = n1;
  2. while (n != null) {
  3. n.setMark();
  4. n = n.parent;
  5. }
  6.  
  7. // check for intersect moving up from n2
  8. // will unmark ancestor
  9. boolean haveMetAncestor = false;
  10. n = n2;
  11. while (n != null) {
  12. if (n.mark) {
  13. bLength++;
  14. haveMetAncestor = true;
  15. }
  16. if (!haveMetAncestor) {
  17. bLength++;
  18. } else {
  19. n.setMark();
  20. }
  21. n = n.parent;
  22. }
  23.  
  24. // calculate distance from n1 to intersect, while unmarking.
  25. n = n1;
  26. while (n.mark) {
  27. aLength++;
  28. n = n.parent;
  29. }
  30. while (n != null) {
  31. n.setMark();
  32. n = n.parent;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement