Advertisement
lukejessee

Sync Issue - Controller.java

Jun 13th, 2012
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Map;
  3.  
  4. public class Controller{
  5.     Tuple3f defaultColor = new Tuple3f();
  6.     Map<Tuple3f, TestBuffer> colorToBufferMap = new HashMap<Tuple3f, TestBuffer>();
  7.     int i=0;
  8.    
  9.     public void addSome(Integer toAdd) {
  10.         TestBuffer buffer = getBuffer();
  11.  
  12.         for (int j=0;j<toAdd;j++) {
  13.             buffer.add(i++);
  14.         }
  15.     }
  16.  
  17.     public void remove() {
  18.         TestBuffer oldBuffer = getBuffer();
  19.         oldBuffer.remove(i++);
  20.     }
  21.  
  22.     public TestBuffer getBuffer() {
  23.         TestBuffer buffer = null;
  24.         if (colorToBufferMap.containsKey(defaultColor)) {
  25.             buffer = colorToBufferMap.get(defaultColor);
  26.         } else {
  27.             buffer = new TestBuffer();
  28.             colorToBufferMap.put(defaultColor, buffer);
  29.         }
  30.         return buffer;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement