/******************************************************************************* * 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