X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FIntArray.java;h=6ee30ad70fd1d341930f11c35eabe2ecdf69af87;hb=refs%2Fchanges%2F99%2F799%2F1;hp=8770b4d49d27a196da2e63fd456623d9c4c7f46a;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntArray.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntArray.java
index 8770b4d49..6ee30ad70 100644
--- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntArray.java
+++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntArray.java
@@ -1,133 +1,133 @@
-/*******************************************************************************
- * 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.impl.query;
-
-import java.util.Arrays;
-
-
-final public class IntArray {
-
- public static IntArray EMPTY = new IntArray();
-
- public int[] data;
-
- /** the index after the last entry in the list */
- public int sizeOrData;
-
- /** the default capacity for new lists */
- protected static final int DEFAULT_CAPACITY = 3;
-
- protected static final int NO_DATA = -1;
-
- public IntArray() {
- data = null;
- sizeOrData = NO_DATA;
- }
-
- /**
- * Returns the number of values in the list.
- *
- * @return the number of values in the list.
- */
- public int size() {
- return data != null ? sizeOrData : (sizeOrData != NO_DATA ? 1 : 0);
- }
-
- /**
- * Tests whether this list contains any values.
- *
- * @return true if the list is empty.
- */
- public boolean isEmpty() {
- return sizeOrData == NO_DATA;
- }
-
-// /**
-// * Sheds any excess capacity above and beyond the current size of
-// * the list.
-// */
-// public void trimToSize() {
-// if (_data.length > size()) {
-// int[] tmp = new int[size()];
-// toNativeArray(tmp, 0, tmp.length);
-// _data = tmp;
-// }
-// }
-
- // modifying
-
- public void trim() {
- if(data != null) {
- int[] newData = new int[sizeOrData];
- System.arraycopy(data, 0, newData, 0, sizeOrData);
- data = newData;
- }
- }
-
- /**
- * Adds val to the end of the list, growing as needed.
- *
- * @param val an int
value
- */
- public void add(int val) {
- if(data == null) {
- if(sizeOrData == NO_DATA) {
- sizeOrData = val;
- } else {
- data = new int[DEFAULT_CAPACITY];
- data[0] = sizeOrData;
- data[1] = val;
- sizeOrData = 2;
- }
- } else {
- if(data.length == sizeOrData) {
- int newCap = data.length << 1;
- int[] tmp = new int[newCap];
- System.arraycopy(data, 0, tmp, 0, data.length);
- data = tmp;
- data[sizeOrData++] = val;
- } else {
- data[sizeOrData++] = val;
- }
- }
- }
-
- int[] toArray() {
- int size = size();
- int[] result = new int[size];
- if(size == 1) {
- result[0] = sizeOrData;
- } else {
- System.arraycopy(data, 0, result, 0, size);
- }
- return result;
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object)
- return true;
- else if (object == null)
- return false;
- else if (IntArray.class != object.getClass())
- return false;
- IntArray r = (IntArray)object;
-// System.out.println("equals " + this + " vs. " + r);
- return sizeOrData == r.sizeOrData && Arrays.equals(data, r.data);
- }
-
- @Override
- public String toString() {
- return "IntArray " + sizeOrData + " " + Arrays.toString(data);
- }
-
+/*******************************************************************************
+ * 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.impl.query;
+
+import java.util.Arrays;
+
+
+final public class IntArray {
+
+ public static IntArray EMPTY = new IntArray();
+
+ public int[] data;
+
+ /** the index after the last entry in the list */
+ public int sizeOrData;
+
+ /** the default capacity for new lists */
+ protected static final int DEFAULT_CAPACITY = 3;
+
+ protected static final int NO_DATA = -1;
+
+ public IntArray() {
+ data = null;
+ sizeOrData = NO_DATA;
+ }
+
+ /**
+ * Returns the number of values in the list.
+ *
+ * @return the number of values in the list.
+ */
+ public int size() {
+ return data != null ? sizeOrData : (sizeOrData != NO_DATA ? 1 : 0);
+ }
+
+ /**
+ * Tests whether this list contains any values.
+ *
+ * @return true if the list is empty.
+ */
+ public boolean isEmpty() {
+ return sizeOrData == NO_DATA;
+ }
+
+// /**
+// * Sheds any excess capacity above and beyond the current size of
+// * the list.
+// */
+// public void trimToSize() {
+// if (_data.length > size()) {
+// int[] tmp = new int[size()];
+// toNativeArray(tmp, 0, tmp.length);
+// _data = tmp;
+// }
+// }
+
+ // modifying
+
+ public void trim() {
+ if(data != null) {
+ int[] newData = new int[sizeOrData];
+ System.arraycopy(data, 0, newData, 0, sizeOrData);
+ data = newData;
+ }
+ }
+
+ /**
+ * Adds val to the end of the list, growing as needed.
+ *
+ * @param val an int
value
+ */
+ public void add(int val) {
+ if(data == null) {
+ if(sizeOrData == NO_DATA) {
+ sizeOrData = val;
+ } else {
+ data = new int[DEFAULT_CAPACITY];
+ data[0] = sizeOrData;
+ data[1] = val;
+ sizeOrData = 2;
+ }
+ } else {
+ if(data.length == sizeOrData) {
+ int newCap = data.length << 1;
+ int[] tmp = new int[newCap];
+ System.arraycopy(data, 0, tmp, 0, data.length);
+ data = tmp;
+ data[sizeOrData++] = val;
+ } else {
+ data[sizeOrData++] = val;
+ }
+ }
+ }
+
+ int[] toArray() {
+ int size = size();
+ int[] result = new int[size];
+ if(size == 1) {
+ result[0] = sizeOrData;
+ } else {
+ System.arraycopy(data, 0, result, 0, size);
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object)
+ return true;
+ else if (object == null)
+ return false;
+ else if (IntArray.class != object.getClass())
+ return false;
+ IntArray r = (IntArray)object;
+// System.out.println("equals " + this + " vs. " + r);
+ return sizeOrData == r.sizeOrData && Arrays.equals(data, r.data);
+ }
+
+ @Override
+ public String toString() {
+ return "IntArray " + sizeOrData + " " + Arrays.toString(data);
+ }
+
}
\ No newline at end of file