package org.simantics.db.impl.query; import gnu.trove.procedure.TIntProcedure; import gnu.trove.set.hash.TIntHashSet; final public class ValueUpdateSet { private int first = 0; public TIntHashSet rest = new TIntHashSet(); public int size() { if(first != 0) return 1; else return rest.size(); } public int getFirst() { return first; } public void add(int l) { if(first == 0) { if(rest.isEmpty()) { first = l; } else { rest.add(l); } } else { if(l == first) return; rest.add(first); rest.add(l); first = 0; } } public void clear() { first = 0; if(!rest.isEmpty()) { rest = new TIntHashSet(); //System.err.println("new rest!"); } } public void forEach(TIntProcedure proc) { if(first != 0) { proc.execute(first); } else { rest.forEach(proc); } } }