SHARE
TWEET

Untitled

a guest Apr 25th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void setElement(int r, int c, int v){
  2.         ListIterator<Node> iterator = element.listIterator();
  3.         Node cur = new Node(0, 0, 0);
  4.         while (iterator.hasNext()) {
  5.             cur = iterator.next();
  6.             if ((cur.getRow() >= r) & (cur.getColumn() >= c)){
  7.                 if ((cur.getRow() == r) & (cur.getColumn() == c)){
  8.                     iterator.previous();
  9.                     iterator.remove();
  10.                     iterator.add(new Node(r, c, v));
  11.                 }
  12.                 iterator.previous();
  13.                 iterator.add(new Node (r, c, v));
  14.                 return;
  15.             }
  16.         }
  17.         iterator.add(new Node (r, c, v));
  18.     }
  19.  
  20.     public int getElement(int r, int c){
  21.         ListIterator<Node> iterator = element.listIterator();
  22.         Node cur = new Node(0, 0, 0);
  23.         while (iterator.hasNext()) {
  24.             cur = iterator.next();
  25.             if ((cur.getRow() == r) & (cur.getColumn() == c)){
  26.                 return cur.getValue();
  27.             }
  28.             if ((cur.getRow() >= r) & (cur.getColumn() > c)) return 0;
  29.         }
  30.         return 0;
  31.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top