X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FValueUpdateSet.java;fp=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FValueUpdateSet.java;h=8e7144f4df144f991c9b6036fe4c9505a9ea325d;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueUpdateSet.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueUpdateSet.java new file mode 100644 index 000000000..8e7144f4d --- /dev/null +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueUpdateSet.java @@ -0,0 +1,51 @@ +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); + } + } + +}