]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/TableIntSet.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / TableIntSet.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.procore.cluster;
13
14 import org.simantics.db.Resource;
15 import org.simantics.db.exception.DatabaseException;
16 import org.simantics.db.impl.ClusterI;
17 import org.simantics.db.impl.IntAllocatorI;
18 import org.simantics.db.impl.Modifier;
19 import org.simantics.db.impl.graph.ReadGraphImpl;
20 import org.simantics.db.impl.query.QueryProcessor;
21 import org.simantics.db.procedure.SyncMultiProcedure;
22
23 final class TableIntSet {
24     public static final int HeaderSize = IntHash.HeaderSize;
25 //    static int create(int initialSize, IntAllocatorI allocator) {
26 //        return IntHash.create(initialSize, allocator);
27 //    }
28     static int create(int[] ints, IntAllocatorI allocator) {
29         return IntHash.create(ints, allocator);
30     }
31
32     /**
33      * @param table
34      * @param base
35      * @param object
36      * @param allocator
37      * @return true if object was actually added.
38      */
39     static int addInt(int[] table, int base, int object, IntAllocatorI allocator) {
40         return IntHash.add(table, base, object, allocator);
41     }
42     
43     static boolean removeInt(int[] table, int base, int object) {
44         return IntHash.remove(table, base, object);
45     }
46
47     static int removeIntLast(int[] table, int base)
48     throws DatabaseException {
49         return IntHash.removeLast(table, base);
50     }
51
52     static int getSize(int[] table, int base) {
53         return IntHash.getUsedSize(table, base);
54     }
55     
56     static int getAllocatedSize(int[] table, int base) {
57         return IntHash.getAllocatedSize(table, base);
58     }
59     
60     static void foreachInt(int[] table, int base, QueryProcessor processor, ReadGraphImpl graph, SyncMultiProcedure<Resource> procedure, Modifier modifier) throws DatabaseException {
61         IntHash.foreachInt(graph, table, base, procedure, modifier);
62     }
63
64     static <Context> boolean foreachInt(int[] table, int base
65                 , ClusterI.ObjectProcedure<Context> procedure, Context context, Modifier modifier) throws DatabaseException {
66         return IntHash.foreachInt(table, base, procedure, context, modifier);
67     }
68     
69     static boolean contains(int[] table, int base, int a) {
70         return IntHash.contains(table, base, a);
71     }
72 }
73