1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.impl.graph;
14 import java.util.Collection;
15 import java.util.Iterator;
18 import org.simantics.db.Resource;
19 import org.simantics.db.impl.query.IntSet;
20 import org.simantics.db.impl.query.QuerySupport;
22 public class ArraySet implements Set<Resource> {
26 ArraySet(IntSet intSet, QuerySupport support) {
28 if(intSet.data == null) {
29 if(intSet.sizeOrData != IntSet.NO_DATA) {
30 set = new Resource[] { support.getResource(intSet.sizeOrData) };
35 set = new Resource[intSet.sizeOrData];
36 for(int i=0;i<intSet.sizeOrData;i++) set[i] = support.getResource(intSet.data[i]);
42 public boolean add(Resource e) {
43 throw new UnsupportedOperationException();
47 public boolean addAll(Collection<? extends Resource> c) {
48 throw new UnsupportedOperationException();
53 throw new UnsupportedOperationException();
57 public boolean contains(Object o) {
58 for(int i=0;i<set.length;i++) if(o.equals(set[i])) return true;
63 public boolean containsAll(Collection<?> c) {
64 throw new UnsupportedOperationException();
68 public boolean isEmpty() {
69 return set.length == 0;
73 public Iterator<Resource> iterator() {
75 class ArraySetIterator implements Iterator<Resource> {
80 public boolean hasNext() {
81 return next < set.length;
85 public Resource next() {
90 public void remove() {
91 throw new UnsupportedOperationException();
96 return new ArraySetIterator();
101 public boolean remove(Object o) {
102 throw new UnsupportedOperationException();
106 public boolean removeAll(Collection<?> c) {
107 throw new UnsupportedOperationException();
111 public boolean retainAll(Collection<?> c) {
112 throw new UnsupportedOperationException();
121 public Object[] toArray() {
122 throw new UnsupportedOperationException();
126 public <T> T[] toArray(T[] a) {
127 throw new UnsupportedOperationException();