1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.impl.graph;
\r
14 import java.util.Collection;
\r
15 import java.util.Iterator;
\r
16 import java.util.Set;
\r
18 import org.simantics.db.Resource;
\r
19 import org.simantics.db.impl.query.IntSet;
\r
20 import org.simantics.db.impl.query.QuerySupport;
\r
22 public class ArraySet implements Set<Resource> {
\r
24 final Resource[] set;
\r
26 ArraySet(IntSet intSet, QuerySupport support) {
\r
28 if(intSet.data == null) {
\r
29 if(intSet.sizeOrData != IntSet.NO_DATA) {
\r
30 set = new Resource[] { support.getResource(intSet.sizeOrData) };
\r
32 set = Resource.NONE;
\r
35 set = new Resource[intSet.sizeOrData];
\r
36 for(int i=0;i<intSet.sizeOrData;i++) set[i] = support.getResource(intSet.data[i]);
\r
42 public boolean add(Resource e) {
\r
43 throw new UnsupportedOperationException();
\r
47 public boolean addAll(Collection<? extends Resource> c) {
\r
48 throw new UnsupportedOperationException();
\r
52 public void clear() {
\r
53 throw new UnsupportedOperationException();
\r
57 public boolean contains(Object o) {
\r
58 for(int i=0;i<set.length;i++) if(o.equals(set[i])) return true;
\r
63 public boolean containsAll(Collection<?> c) {
\r
64 throw new UnsupportedOperationException();
\r
68 public boolean isEmpty() {
\r
69 return set.length == 0;
\r
73 public Iterator<Resource> iterator() {
\r
75 class ArraySetIterator implements Iterator<Resource> {
\r
80 public boolean hasNext() {
\r
81 return next < set.length;
\r
85 public Resource next() {
\r
90 public void remove() {
\r
91 throw new UnsupportedOperationException();
\r
96 return new ArraySetIterator();
\r
101 public boolean remove(Object o) {
\r
102 throw new UnsupportedOperationException();
\r
106 public boolean removeAll(Collection<?> c) {
\r
107 throw new UnsupportedOperationException();
\r
111 public boolean retainAll(Collection<?> c) {
\r
112 throw new UnsupportedOperationException();
\r
116 public int size() {
\r
121 public Object[] toArray() {
\r
122 throw new UnsupportedOperationException();
\r
126 public <T> T[] toArray(T[] a) {
\r
127 throw new UnsupportedOperationException();
\r