001 /* 002 * Copyright (C) 2008-2010 by Holger Arndt 003 * 004 * This file is part of the Universal Java Matrix Package (UJMP). 005 * See the NOTICE file distributed with this work for additional 006 * information regarding copyright ownership and licensing. 007 * 008 * UJMP is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation; either version 2 011 * of the License, or (at your option) any later version. 012 * 013 * UJMP is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public 019 * License along with UJMP; if not, write to the 020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 021 * Boston, MA 02110-1301 USA 022 */ 023 024 package org.ujmp.core.util; 025 026 import java.util.Collection; 027 import java.util.Iterator; 028 import java.util.Set; 029 030 import org.ujmp.core.Coordinates; 031 import org.ujmp.core.interfaces.Wrapper; 032 033 public class CoordinateSetToLongWrapper implements Set<long[]>, Wrapper<Set<Coordinates>> { 034 035 private Set<Coordinates> set = null; 036 037 public CoordinateSetToLongWrapper(Set<Coordinates> set) { 038 this.set = set; 039 } 040 041 public Set<Coordinates> getWrappedObject() { 042 return set; 043 } 044 045 public void setWrappedObject(Set<Coordinates> object) { 046 this.set = object; 047 } 048 049 public boolean add(long[] e) { 050 return set.add(new Coordinates(e)); 051 } 052 053 public boolean addAll(Collection<? extends long[]> c) { 054 return false; 055 } 056 057 public void clear() { 058 set.clear(); 059 } 060 061 public boolean contains(Object o) { 062 return set.contains(new Coordinates((long[]) o)); 063 } 064 065 public boolean containsAll(Collection<?> c) { 066 throw new RuntimeException("not implemented"); 067 } 068 069 public boolean isEmpty() { 070 return set.isEmpty(); 071 } 072 073 public Iterator<long[]> iterator() { 074 return new LongIterator(this); 075 } 076 077 class LongIterator implements Iterator<long[]> { 078 079 Iterator<Coordinates> it = null; 080 081 public LongIterator(CoordinateSetToLongWrapper wrapper) { 082 it = wrapper.set.iterator(); 083 } 084 085 public boolean hasNext() { 086 return it.hasNext(); 087 } 088 089 public long[] next() { 090 return it.next().co; 091 } 092 093 public void remove() { 094 throw new RuntimeException("not implemented"); 095 } 096 097 } 098 099 public boolean remove(Object o) { 100 return set.remove(new Coordinates((long[]) o)); 101 } 102 103 public boolean removeAll(Collection<?> c) { 104 throw new RuntimeException("not implemented"); 105 } 106 107 public boolean retainAll(Collection<?> c) { 108 throw new RuntimeException("not implemented"); 109 } 110 111 public int size() { 112 return set.size(); 113 } 114 115 public Object[] toArray() { 116 throw new RuntimeException("not implemented"); 117 } 118 119 public <T> T[] toArray(T[] a) { 120 throw new RuntimeException("not implemented"); 121 } 122 123 }