Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Map;
- public class Controller{
- Tuple3f defaultColor = new Tuple3f();
- Map<Tuple3f, TestBuffer> colorToBufferMap = new HashMap<Tuple3f, TestBuffer>();
- int i=0;
- public void addSome(Integer toAdd) {
- TestBuffer buffer = getBuffer();
- for (int j=0;j<toAdd;j++) {
- buffer.add(i++);
- }
- }
- public void remove() {
- TestBuffer oldBuffer = getBuffer();
- oldBuffer.remove(i++);
- }
- public TestBuffer getBuffer() {
- TestBuffer buffer = null;
- if (colorToBufferMap.containsKey(defaultColor)) {
- buffer = colorToBufferMap.get(defaultColor);
- } else {
- buffer = new TestBuffer();
- colorToBufferMap.put(defaultColor, buffer);
- }
- return buffer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement