X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fcluster%2FTableIntArraySet2.java;fp=bundles%2Forg.simantics.db.procore%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fcluster%2FTableIntArraySet2.java;h=b9611196d8c24fed77cb446de27310b0835d7d58;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/TableIntArraySet2.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/TableIntArraySet2.java new file mode 100644 index 000000000..b9611196d --- /dev/null +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/TableIntArraySet2.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.procore.cluster; + +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.impl.ClusterI; +import org.simantics.db.impl.IntAllocatorI; +import org.simantics.db.impl.Modifier; + +final class TableIntArraySet2 { + public static final int HeaderSize = 1; + private static final int SIZE_OFFSET = -1; + static int create(final int[] keys, final int[] vals, IntAllocatorI allocator) + throws DatabaseException { + final int LENGTH = keys.length; + if (LENGTH < 1 || LENGTH != vals.length) + throw new DatabaseException("Illegal argument to create TableIntArraySet2."); + int newBase = allocator.allocate(LENGTH*2 + HeaderSize) + HeaderSize; + int[] table = allocator.getTable(); + table[newBase + SIZE_OFFSET] = -LENGTH; + for (int i=0; i 0); + Tables t = new Tables(); + int i; + for (i=0; i 0); + t.keys = new int[size]; + t.vals = new int[size]; + for (i=0; i 0); + for (int i=0; i 0); + int i; + for (i=0; i 0); + int i; + for (i=0; ii; --end) + if (0 != table[base + end*2]) + break; + table[base + i*2] = table[base + end*2]; + table[base + i*2 + 1] = table[base + end*2 + 1]; + table[base + end*2] = 0; + table[base + end*2 + 1] = 0; + return true; + } + + static int getSize(int[] table, int base) { + final int size = -table[base + SIZE_OFFSET]; + assert(size > 0); + int i; + for (i=0; i0); + return size + HeaderSize; + } + + static boolean foreachInt(final int[] table, final int base + , final ClusterI.PredicateProcedure procedure, final Context context, final Modifier modifier) throws DatabaseException { + final int size = -table[base + SIZE_OFFSET]; + assert(size>0); + for (int i=0; i