diff --git a/capsule/LICENSE b/capsule/LICENSE
deleted file mode 100644
index f735bee0e..000000000
--- a/capsule/LICENSE
+++ /dev/null
@@ -1,203 +0,0 @@
-Eclipse Public License - v 1.0
-
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
-LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
-CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. DEFINITIONS
-
-"Contribution" means:
-
-a) in the case of the initial Contributor, the initial code and documentation
- distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
- i) changes to the Program, and
- ii) additions to the Program;
-
- where such changes and/or additions to the Program originate from and are
- distributed by that particular Contributor. A Contribution 'originates'
- from a Contributor if it was added to the Program by such Contributor
- itself or anyone acting on such Contributor's behalf. Contributions do not
- include additions to the Program which: (i) are separate modules of
- software distributed in conjunction with the Program under their own
- license agreement, and (ii) are not derivative works of the Program.
-
-"Contributor" means any person or entity that distributes the Program.
-
-"Licensed Patents" mean patent claims licensable by a Contributor which are
-necessarily infringed by the use or sale of its Contribution alone or when
-combined with the Program.
-
-"Program" means the Contributions distributed in accordance with this
-Agreement.
-
-"Recipient" means anyone who receives the Program under this Agreement,
-including all Contributors.
-
-2. GRANT OF RIGHTS
- a) Subject to the terms of this Agreement, each Contributor hereby grants
- Recipient a non-exclusive, worldwide, royalty-free copyright license to
- reproduce, prepare derivative works of, publicly display, publicly
- perform, distribute and sublicense the Contribution of such Contributor,
- if any, and such derivative works, in source code and object code form.
- b) Subject to the terms of this Agreement, each Contributor hereby grants
- Recipient a non-exclusive, worldwide, royalty-free patent license under
- Licensed Patents to make, use, sell, offer to sell, import and otherwise
- transfer the Contribution of such Contributor, if any, in source code and
- object code form. This patent license shall apply to the combination of
- the Contribution and the Program if, at the time the Contribution is
- added by the Contributor, such addition of the Contribution causes such
- combination to be covered by the Licensed Patents. The patent license
- shall not apply to any other combinations which include the Contribution.
- No hardware per se is licensed hereunder.
- c) Recipient understands that although each Contributor grants the licenses
- to its Contributions set forth herein, no assurances are provided by any
- Contributor that the Program does not infringe the patent or other
- intellectual property rights of any other entity. Each Contributor
- disclaims any liability to Recipient for claims brought by any other
- entity based on infringement of intellectual property rights or
- otherwise. As a condition to exercising the rights and licenses granted
- hereunder, each Recipient hereby assumes sole responsibility to secure
- any other intellectual property rights needed, if any. For example, if a
- third party patent license is required to allow Recipient to distribute
- the Program, it is Recipient's responsibility to acquire that license
- before distributing the Program.
- d) Each Contributor represents that to its knowledge it has sufficient
- copyright rights in its Contribution, if any, to grant the copyright
- license set forth in this Agreement.
-
-3. REQUIREMENTS
-
-A Contributor may choose to distribute the Program in object code form under
-its own license agreement, provided that:
-
- a) it complies with the terms and conditions of this Agreement; and
- b) its license agreement:
- i) effectively disclaims on behalf of all Contributors all warranties
- and conditions, express and implied, including warranties or
- conditions of title and non-infringement, and implied warranties or
- conditions of merchantability and fitness for a particular purpose;
- ii) effectively excludes on behalf of all Contributors all liability for
- damages, including direct, indirect, special, incidental and
- consequential damages, such as lost profits;
- iii) states that any provisions which differ from this Agreement are
- offered by that Contributor alone and not by any other party; and
- iv) states that source code for the Program is available from such
- Contributor, and informs licensees how to obtain it in a reasonable
- manner on or through a medium customarily used for software exchange.
-
-When the Program is made available in source code form:
-
- a) it must be made available under this Agreement; and
- b) a copy of this Agreement must be included with each copy of the Program.
- Contributors may not remove or alter any copyright notices contained
- within the Program.
-
-Each Contributor must identify itself as the originator of its Contribution,
-if
-any, in a manner that reasonably allows subsequent Recipients to identify the
-originator of the Contribution.
-
-4. COMMERCIAL DISTRIBUTION
-
-Commercial distributors of software may accept certain responsibilities with
-respect to end users, business partners and the like. While this license is
-intended to facilitate the commercial use of the Program, the Contributor who
-includes the Program in a commercial product offering should do so in a manner
-which does not create potential liability for other Contributors. Therefore,
-if a Contributor includes the Program in a commercial product offering, such
-Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
-every other Contributor ("Indemnified Contributor") against any losses,
-damages and costs (collectively "Losses") arising from claims, lawsuits and
-other legal actions brought by a third party against the Indemnified
-Contributor to the extent caused by the acts or omissions of such Commercial
-Contributor in connection with its distribution of the Program in a commercial
-product offering. The obligations in this section do not apply to any claims
-or Losses relating to any actual or alleged intellectual property
-infringement. In order to qualify, an Indemnified Contributor must:
-a) promptly notify the Commercial Contributor in writing of such claim, and
-b) allow the Commercial Contributor to control, and cooperate with the
-Commercial Contributor in, the defense and any related settlement
-negotiations. The Indemnified Contributor may participate in any such claim at
-its own expense.
-
-For example, a Contributor might include the Program in a commercial product
-offering, Product X. That Contributor is then a Commercial Contributor. If
-that Commercial Contributor then makes performance claims, or offers
-warranties related to Product X, those performance claims and warranties are
-such Commercial Contributor's responsibility alone. Under this section, the
-Commercial Contributor would have to defend claims against the other
-Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.
-
-5. NO WARRANTY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
-IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
-Recipient is solely responsible for determining the appropriateness of using
-and distributing the Program and assumes all risks associated with its
-exercise of rights under this Agreement , including but not limited to the
-risks and costs of program errors, compliance with applicable laws, damage to
-or loss of data, programs or equipment, and unavailability or interruption of
-operations.
-
-6. DISCLAIMER OF LIABILITY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
-CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
-LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
-EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGES.
-
-7. GENERAL
-
-If any provision of this Agreement is invalid or unenforceable under
-applicable law, it shall not affect the validity or enforceability of the
-remainder of the terms of this Agreement, and without further action by the
-parties hereto, such provision shall be reformed to the minimum extent
-necessary to make such provision valid and enforceable.
-
-If Recipient institutes patent litigation against any entity (including a
-cross-claim or counterclaim in a lawsuit) alleging that the Program itself
-(excluding combinations of the Program with other software or hardware)
-infringes such Recipient's patent(s), then such Recipient's rights granted
-under Section 2(b) shall terminate as of the date such litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails to
-comply with any of the material terms or conditions of this Agreement and does
-not cure such failure in a reasonable period of time after becoming aware of
-such noncompliance. If all Recipient's rights under this Agreement terminate,
-Recipient agrees to cease use and distribution of the Program as soon as
-reasonably practicable. However, Recipient's obligations under this Agreement
-and any licenses granted by Recipient relating to the Program shall continue
-and survive.
-
-Everyone is permitted to copy and distribute copies of this Agreement, but in
-order to avoid inconsistency the Agreement is copyrighted and may only be
-modified in the following manner. The Agreement Steward reserves the right to
-publish new versions (including revisions) of this Agreement from time to
-time. No one other than the Agreement Steward has the right to modify this
-Agreement. The Eclipse Foundation is the initial Agreement Steward. The
-Eclipse Foundation may assign the responsibility to serve as the Agreement
-Steward to a suitable separate entity. Each new version of the Agreement will
-be given a distinguishing version number. The Program (including
-Contributions) may always be distributed subject to the version of the
-Agreement under which it was received. In addition, after a new version of the
-Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly
-stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
-licenses to the intellectual property of any Contributor under this Agreement,
-whether expressly, by implication, estoppel or otherwise. All rights in the
-Program not expressly granted under this Agreement are reserved.
-
-This Agreement is governed by the laws of the State of New York and the
-intellectual property laws of the United States of America. No party to this
-Agreement will bring a legal action under this Agreement more than one year
-after the cause of action arose. Each party waives its rights to a jury trial in
-any resulting litigation.
diff --git a/capsule/pom.xml b/capsule/pom.xml
deleted file mode 100644
index 7d491300a..000000000
--- a/capsule/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
- 4.0.0
-
- io.usethesource
- capsule
- 0.1.0-SNAPSHOT
- jar
-
-
- scm:git:https://github.com/cwi-swat/pdb.values.git
-
-
-
-
- UTF-8
- 1.8
- 1.8
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- attach-sources
-
- jar
-
-
-
-
-
-
-
-
-
-
- junit
- junit
- 4.11
- test
-
-
-
-
diff --git a/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableMap.java b/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableMap.java
deleted file mode 100644
index a5edbb6d8..000000000
--- a/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableMap.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013-2014 CWI
- * 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:
- *
- * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
- *******************************************************************************/
-package io.usethesource.capsule;
-
-import java.util.AbstractMap;
-import java.util.Map;
-
-@Deprecated
-public abstract class AbstractImmutableMap extends AbstractMap implements ImmutableMap {
-
- @Override
- public V remove(Object key) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public V put(K key, V value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void putAll(Map extends K, ? extends V> m) {
- throw new UnsupportedOperationException();
- }
-
-}
-
diff --git a/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableSet.java b/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableSet.java
deleted file mode 100644
index 1a94a0fb1..000000000
--- a/capsule/src/main/java/io/usethesource/capsule/AbstractImmutableSet.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013-2014 CWI
- * 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:
- *
- * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
- *******************************************************************************/
-package io.usethesource.capsule;
-
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.Comparator;
-
-@Deprecated
-public abstract class AbstractImmutableSet extends AbstractSet implements ImmutableSet {
-
- @Override
- public boolean add(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection extends E> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isTransientSupported() {
- return false;
- }
-
- @Override
- public TransientSet asTransient() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean containsAll(Collection> c) {
- for (Object item : c) {
- if (!contains(item)) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean containsAllEquivalent(Collection> c, Comparator cmp) {
- for (Object item : c) {
- if (!containsEquivalent(item, cmp)) {
- return false;
- }
- }
- return true;
- }
-
-}
diff --git a/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableMap.java b/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableMap.java
deleted file mode 100644
index 2212deb77..000000000
--- a/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableMap.java
+++ /dev/null
@@ -1,1549 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013-2014 CWI
- * 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:
- *
- * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
- *******************************************************************************/
-package io.usethesource.capsule;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.Set;
-
-public abstract class AbstractSpecialisedImmutableMap implements ImmutableMap,
- Cloneable {
- @SuppressWarnings("rawtypes")
- private static ImmutableMap EMPTY_MAP = new Map0();
-
- @SuppressWarnings("unchecked")
- public static ImmutableMap mapOf() {
- return EMPTY_MAP;
- }
-
- @SuppressWarnings("unchecked")
- public static final > T entryOf(final K key, final V val) {
- return (T) new MapEntry(key, val);
- }
-
- public static ImmutableMap mapOf(K key1, V val1) {
- return new Map1(key1, val1);
- }
-
- public static ImmutableMap mapOf(K key1, V val1, K key2, V val2) {
- return new Map2(key1, val1, key2, val2);
- }
-
- public static ImmutableMap mapOf(K key1, V val1, K key2, V val2, K key3, V val3) {
- return new Map3(key1, val1, key2, val2, key3, val3);
- }
-
- public static ImmutableMap mapOf(K key1, V val1, K key2, V val2, K key3, V val3,
- K key4, V val4) {
- return new Map4(key1, val1, key2, val2, key3, val3, key4, val4);
- }
-
- public static ImmutableMap mapOf(K key1, V val1, K key2, V val2, K key3, V val3,
- K key4, V val4, K key5, V val5) {
- return new Map5(key1, val1, key2, val2, key3, val3, key4, val4, key5, val5);
- }
-
- public static ImmutableMap mapOf(K key1, V val1, K key2, V val2, K key3, V val3,
- K key4, V val4, K key5, V val5, K key6, V val6) {
- final TransientMap tmp = DefaultTrieMap.transientOf(key1, val1, key2, val2, key3,
- val3, key4, val4, key5, val5, key6, val6);
- return tmp.freeze();
- }
-
- public static ImmutableMap mapOf(Map map) {
- if (map instanceof ImmutableMap) {
- return (ImmutableMap) map;
- } else {
- final TransientMap tmp = DefaultTrieMap.transientOf();
- tmp.__putAll(map);
- return tmp.freeze();
- }
- }
-
- @Override
- public V remove(Object key) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public V put(K key, V value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void putAll(Map extends K, ? extends V> m) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isEmpty() {
- return size() == 0;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this)
- return true;
- if (other == null)
- return false;
-
- if (other instanceof Map) {
- try {
- @SuppressWarnings("unchecked")
- Map that = (Map) other;
-
- if (this.size() == that.size()) {
- for (Entry e : this.entrySet()) {
- if (!that.containsKey(e.getKey()))
- return false;
- if (!Objects.equals(e.getValue(), that.get(e.getKey())))
- return false;
- }
- return true;
- }
- } catch (ClassCastException unused) {
- return false;
- }
- }
-
- return false;
- }
-
- @Override
- public Iterator valueIterator() {
- return values().iterator();
- }
-
- @Override
- public Iterator> entryIterator() {
- return entrySet().iterator();
- }
-
- @Override
- public ImmutableMap __putAll(Map extends K, ? extends V> map) {
- TransientMap tmp = asTransient();
- if (tmp.__putAll(map)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __putAllEquivalent(Map extends K, ? extends V> map,
- Comparator cmp) {
- TransientMap tmp = asTransient();
- if (tmp.__putAllEquivalent(map, cmp)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- @Override
- public boolean isTransientSupported() {
- return true;
- }
-}
-
-class MapEntry implements Map.Entry {
-
- private final K key1;
- private final V val1;
-
- MapEntry(final K key1, final V val1) {
- this.key1 = key1;
- this.val1 = val1;
- }
-
- @Override
- public K getKey() {
- return key1;
- }
-
- @Override
- public V getValue() {
- return val1;
- }
-
- @Override
- public V setValue(V value) {
- throw new UnsupportedOperationException();
- }
-
-}
-
-class Map0 extends AbstractSpecialisedImmutableMap {
-
- Map0() {
-
- }
-
- @Override
- public boolean containsKey(Object key) {
- return false;
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- return false;
- }
-
- @Override
- public boolean containsValue(Object val) {
- return false;
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- return false;
- }
-
- @Override
- public V get(Object key) {
- return null;
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- return null;
- }
-
- @Override
- public int size() {
- return 0;
- }
-
- @Override
- public Set> entrySet() {
- return Collections.emptySet();
- }
-
- @Override
- public Set keySet() {
- return Collections.emptySet();
- }
-
- @Override
- public Collection values() {
- return Collections.emptySet();
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return EmptySupplierIterator.emptyIterator();
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- return mapOf(key, val);
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- return mapOf(key, val);
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- return this;
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- return this;
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf();
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- @Override
- public String toString() {
- return "{}";
- }
-
-}
-
-class Map1 extends AbstractSpecialisedImmutableMap {
-
- private final K key1;
- private final V val1;
-
- Map1(final K key1, final V val1) {
- this.key1 = key1;
- this.val1 = val1;
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (key.equals(key1)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValue(Object val) {
- if (val.equals(val1)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- if (cmp.compare(val, val1) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public V get(Object key) {
- if (key.equals(key1)) {
- return val1;
- } else {
- return null;
- }
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return val1;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 1;
- }
-
- @Override
- public Set> entrySet() {
- return Collections.singleton(entryOf(key1, val1));
- }
-
- @Override
- public Set keySet() {
- return Collections.singleton(key1);
- }
-
- @Override
- public Collection values() {
- return Collections.singleton(val1);
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Map1.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public V get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return val1;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- if (key.equals(key1)) {
- return mapOf(key, val);
- } else {
- return mapOf(key1, val1, key, val);
- }
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key, val);
- } else {
- return mapOf(key1, val1, key, val);
- }
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- if (key.equals(key1)) {
- return mapOf();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf();
- } else {
- return this;
- }
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf(key1, val1);
- }
-
- @Override
- public int hashCode() {
- return ((Objects.hashCode(key1) ^ Objects.hashCode(val1)));
- }
-
- @Override
- public String toString() {
- return String.format("{%s=%s}", key1, val1);
- }
-
-}
-
-class Map2 extends AbstractSpecialisedImmutableMap {
-
- private final K key1;
- private final V val1;
-
- private final K key2;
- private final V val2;
-
- Map2(final K key1, final V val1, final K key2, final V val2) {
- if (key1.equals(key2)) {
- throw new IllegalArgumentException("Duplicate keys are not allowed in specialised map.");
- }
-
- this.key1 = key1;
- this.val1 = val1;
-
- this.key2 = key2;
- this.val2 = val2;
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValue(Object val) {
- if (val.equals(val1)) {
- return true;
- } else if (val.equals(val2)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- if (cmp.compare(val, val1) == 0) {
- return true;
- } else if (cmp.compare(val, val2) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public V get(Object key) {
- if (key.equals(key1)) {
- return val1;
- } else if (key.equals(key2)) {
- return val2;
- } else {
- return null;
- }
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return val1;
- } else if (cmp.compare(key, key2) == 0) {
- return val2;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 2;
- }
-
- @Override
- public Set> entrySet() {
- return AbstractSpecialisedImmutableSet.> setOf(entryOf(key1, val1),
- entryOf(key2, val2));
- }
-
- @Override
- public Set keySet() {
- return AbstractSpecialisedImmutableSet.setOf(key1, key2);
- }
-
- @Override
- public Collection values() {
- // TODO: will fail if two values are equals; return listOf(...)
- return AbstractSpecialisedImmutableSet.setOf(val1, val2);
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Map2.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public V get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return val1;
- case 2:
- return val2;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- if (key.equals(key1)) {
- return mapOf(key, val, key2, val2);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key, val);
- }
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key, val, key2, val2);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key, val);
- }
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- if (key.equals(key1)) {
- return mapOf(key2, val2);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key2, val2);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf(key1, val1, key2, val2);
- }
-
- @Override
- public int hashCode() {
- return ((Objects.hashCode(key1) ^ Objects.hashCode(val1)) + (Objects.hashCode(key2) ^ Objects
- .hashCode(val2)));
- }
-
- @Override
- public String toString() {
- return String.format("{%s=%s, %s=%s}", key1, val1, key2, val2);
- }
-
-}
-
-class Map3 extends AbstractSpecialisedImmutableMap {
-
- private final K key1;
- private final V val1;
-
- private final K key2;
- private final V val2;
-
- private final K key3;
- private final V val3;
-
- Map3(final K key1, final V val1, final K key2, final V val2, final K key3, final V val3) {
- if (key1.equals(key2) || key1.equals(key3) || key2.equals(key3)) {
- throw new IllegalArgumentException("Duplicate keys are not allowed in specialised map.");
- }
-
- this.key1 = key1;
- this.val1 = val1;
-
- this.key2 = key2;
- this.val2 = val2;
-
- this.key3 = key3;
- this.val3 = val3;
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else if (key.equals(key3)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else if (cmp.compare(key, key3) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValue(Object val) {
- if (val.equals(val1)) {
- return true;
- } else if (val.equals(val2)) {
- return true;
- } else if (val.equals(val3)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- if (cmp.compare(val, val1) == 0) {
- return true;
- } else if (cmp.compare(val, val2) == 0) {
- return true;
- } else if (cmp.compare(val, val3) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public V get(Object key) {
- if (key.equals(key1)) {
- return val1;
- } else if (key.equals(key2)) {
- return val2;
- } else if (key.equals(key3)) {
- return val3;
- } else {
- return null;
- }
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return val1;
- } else if (cmp.compare(key, key2) == 0) {
- return val2;
- } else if (cmp.compare(key, key3) == 0) {
- return val3;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 3;
- }
-
- @Override
- public Set> entrySet() {
- return AbstractSpecialisedImmutableSet.> setOf(entryOf(key1, val1),
- entryOf(key2, val2), entryOf(key3, val3));
- }
-
- @Override
- public Set keySet() {
- return AbstractSpecialisedImmutableSet.setOf(key1, key2, key3);
- }
-
- @Override
- public Collection values() {
- // TODO: will fail if two values are equals; return listOf(...)
- return AbstractSpecialisedImmutableSet.setOf(val1, val2, val3);
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Map3.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- case 3:
- return key3;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public V get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return val1;
- case 2:
- return val2;
- case 3:
- return val3;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- if (key.equals(key1)) {
- return mapOf(key, val, key2, val2, key3, val3);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key, val, key3, val3);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val);
- }
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key, val, key2, val2, key3, val3);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key, val, key3, val3);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val);
- }
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- if (key.equals(key1)) {
- return mapOf(key2, val2, key3, val3);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key3, val3);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key2, val2, key3, val3);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key3, val3);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf(key1, val1, key2, val2, key3, val3);
- }
-
- @Override
- public int hashCode() {
- return ((Objects.hashCode(key1) ^ Objects.hashCode(val1))
- + (Objects.hashCode(key2) ^ Objects.hashCode(val2)) + (Objects
- .hashCode(key3) ^ Objects.hashCode(val3)));
- }
-
- @Override
- public String toString() {
- return String.format("{%s=%s, %s=%s, %s=%s}", key1, val1, key2, val2, key3, val3);
- }
-
-}
-
-class Map4 extends AbstractSpecialisedImmutableMap {
-
- private final K key1;
- private final V val1;
-
- private final K key2;
- private final V val2;
-
- private final K key3;
- private final V val3;
-
- private final K key4;
- private final V val4;
-
- Map4(final K key1, final V val1, final K key2, final V val2, final K key3, final V val3,
- final K key4, final V val4) {
- if (key1.equals(key2) || key1.equals(key3) || key1.equals(key4) || key2.equals(key3)
- || key2.equals(key4) || key3.equals(key4)) {
- throw new IllegalArgumentException("Duplicate keys are not allowed in specialised map.");
- }
-
- this.key1 = key1;
- this.val1 = val1;
-
- this.key2 = key2;
- this.val2 = val2;
-
- this.key3 = key3;
- this.val3 = val3;
-
- this.key4 = key4;
- this.val4 = val4;
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else if (key.equals(key3)) {
- return true;
- } else if (key.equals(key4)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else if (cmp.compare(key, key3) == 0) {
- return true;
- } else if (cmp.compare(key, key4) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValue(Object val) {
- if (val.equals(val1)) {
- return true;
- } else if (val.equals(val2)) {
- return true;
- } else if (val.equals(val3)) {
- return true;
- } else if (val.equals(val4)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- if (cmp.compare(val, val1) == 0) {
- return true;
- } else if (cmp.compare(val, val2) == 0) {
- return true;
- } else if (cmp.compare(val, val3) == 0) {
- return true;
- } else if (cmp.compare(val, val4) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public V get(Object key) {
- if (key.equals(key1)) {
- return val1;
- } else if (key.equals(key2)) {
- return val2;
- } else if (key.equals(key3)) {
- return val3;
- } else if (key.equals(key4)) {
- return val4;
- } else {
- return null;
- }
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return val1;
- } else if (cmp.compare(key, key2) == 0) {
- return val2;
- } else if (cmp.compare(key, key3) == 0) {
- return val3;
- } else if (cmp.compare(key, key4) == 0) {
- return val4;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 4;
- }
-
- @Override
- public Set> entrySet() {
- return AbstractSpecialisedImmutableSet.> setOf(entryOf(key1, val1),
- entryOf(key2, val2), entryOf(key3, val3), entryOf(key4, val4));
- }
-
- @Override
- public Set keySet() {
- return AbstractSpecialisedImmutableSet.setOf(key1, key2, key3, key4);
- }
-
- @Override
- public Collection values() {
- // TODO: will fail if two values are equals; return listOf(...)
- return AbstractSpecialisedImmutableSet.setOf(val1, val2, val3, val4);
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Map4.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- case 3:
- return key3;
- case 4:
- return key4;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public V get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return val1;
- case 2:
- return val2;
- case 3:
- return val3;
- case 4:
- return val4;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- if (key.equals(key1)) {
- return mapOf(key, val, key2, val2, key3, val3, key4, val4);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key, val, key3, val3, key4, val4);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2, key, val, key4, val4);
- } else if (key.equals(key4)) {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key, val);
- }
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key, val, key2, val2, key3, val3, key4, val4);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key, val, key3, val3, key4, val4);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2, key, val, key4, val4);
- } else if (cmp.compare(key, key4) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key, val);
- }
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- if (key.equals(key1)) {
- return mapOf(key2, val2, key3, val3, key4, val4);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key3, val3, key4, val4);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2, key4, val4);
- } else if (key.equals(key4)) {
- return mapOf(key1, val1, key2, val2, key3, val3);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key2, val2, key3, val3, key4, val4);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key3, val3, key4, val4);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2, key4, val4);
- } else if (cmp.compare(key, key4) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf(key1, val1, key2, val2, key3, val3, key4, val4);
- }
-
- @Override
- public int hashCode() {
- return ((Objects.hashCode(key1) ^ Objects.hashCode(val1))
- + (Objects.hashCode(key2) ^ Objects.hashCode(val2))
- + (Objects.hashCode(key3) ^ Objects.hashCode(val3)) + (Objects
- .hashCode(key4) ^ Objects.hashCode(val4)));
- }
-
- @Override
- public String toString() {
- return String.format("{%s=%s, %s=%s, %s=%s, %s=%s}", key1, val1, key2, val2, key3, val3,
- key4, val4);
- }
-
-}
-
-class Map5 extends AbstractSpecialisedImmutableMap {
-
- private final K key1;
- private final V val1;
-
- private final K key2;
- private final V val2;
-
- private final K key3;
- private final V val3;
-
- private final K key4;
- private final V val4;
-
- private final K key5;
- private final V val5;
-
- Map5(final K key1, final V val1, final K key2, final V val2, final K key3, final V val3,
- final K key4, final V val4, final K key5, final V val5) {
- if (key1.equals(key2) || key1.equals(key3) || key1.equals(key4) || key1.equals(key5)
- || key2.equals(key3) || key2.equals(key4) || key2.equals(key5)
- || key3.equals(key4) || key3.equals(key5) || key4.equals(key5)) {
- throw new IllegalArgumentException("Duplicate keys are not allowed in specialised map.");
- }
-
- this.key1 = key1;
- this.val1 = val1;
-
- this.key2 = key2;
- this.val2 = val2;
-
- this.key3 = key3;
- this.val3 = val3;
-
- this.key4 = key4;
- this.val4 = val4;
-
- this.key5 = key5;
- this.val5 = val5;
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else if (key.equals(key3)) {
- return true;
- } else if (key.equals(key4)) {
- return true;
- } else if (key.equals(key5)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsKeyEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else if (cmp.compare(key, key3) == 0) {
- return true;
- } else if (cmp.compare(key, key4) == 0) {
- return true;
- } else if (cmp.compare(key, key5) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValue(Object val) {
- if (val.equals(val1)) {
- return true;
- } else if (val.equals(val2)) {
- return true;
- } else if (val.equals(val3)) {
- return true;
- } else if (val.equals(val4)) {
- return true;
- } else if (val.equals(val5)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsValueEquivalent(Object val, Comparator cmp) {
- if (cmp.compare(val, val1) == 0) {
- return true;
- } else if (cmp.compare(val, val2) == 0) {
- return true;
- } else if (cmp.compare(val, val3) == 0) {
- return true;
- } else if (cmp.compare(val, val4) == 0) {
- return true;
- } else if (cmp.compare(val, val5) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public V get(Object key) {
- if (key.equals(key1)) {
- return val1;
- } else if (key.equals(key2)) {
- return val2;
- } else if (key.equals(key3)) {
- return val3;
- } else if (key.equals(key4)) {
- return val4;
- } else if (key.equals(key5)) {
- return val5;
- } else {
- return null;
- }
- }
-
- @Override
- public V getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return val1;
- } else if (cmp.compare(key, key2) == 0) {
- return val2;
- } else if (cmp.compare(key, key3) == 0) {
- return val3;
- } else if (cmp.compare(key, key4) == 0) {
- return val4;
- } else if (cmp.compare(key, key5) == 0) {
- return val5;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 5;
- }
-
- @Override
- public Set> entrySet() {
- return AbstractSpecialisedImmutableSet.> setOf(entryOf(key1, val1),
- entryOf(key2, val2), entryOf(key3, val3), entryOf(key4, val4),
- entryOf(key5, val5));
- }
-
- @Override
- public Set keySet() {
- return AbstractSpecialisedImmutableSet.setOf(key1, key2, key3, key4, key5);
- }
-
- @Override
- public Collection values() {
- // TODO: will fail if two values are equals; return listOf(...)
- return AbstractSpecialisedImmutableSet.setOf(val1, val2, val3, val4, val5);
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Map5.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- case 3:
- return key3;
- case 4:
- return key4;
- case 5:
- return key5;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public V get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return val1;
- case 2:
- return val2;
- case 3:
- return val3;
- case 4:
- return val4;
- case 5:
- return val5;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableMap __put(K key, V val) {
- if (key.equals(key1)) {
- return mapOf(key, val, key2, val2, key3, val3, key4, val4, key5, val5);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key, val, key3, val3, key4, val4, key5, val5);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2, key, val, key4, val4, key5, val5);
- } else if (key.equals(key4)) {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val, key5, val5);
- } else if (key.equals(key5)) {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key5, val5, key, val);
- }
- }
-
- @Override
- public ImmutableMap __putEquivalent(K key, V val, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key, val, key2, val2, key3, val3, key4, val4, key5, val5);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key, val, key3, val3, key4, val4, key5, val5);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2, key, val, key4, val4, key5, val5);
- } else if (cmp.compare(key, key4) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3, key, val, key5, val5);
- } else if (cmp.compare(key, key5) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key, val);
- } else {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4, key5, val5, key, val);
- }
- }
-
- @Override
- public ImmutableMap __remove(K key) {
- if (key.equals(key1)) {
- return mapOf(key2, val2, key3, val3, key4, val4, key5, val5);
- } else if (key.equals(key2)) {
- return mapOf(key1, val1, key3, val3, key4, val4, key5, val5);
- } else if (key.equals(key3)) {
- return mapOf(key1, val1, key2, val2, key4, val4, key5, val5);
- } else if (key.equals(key4)) {
- return mapOf(key1, val1, key2, val2, key3, val3, key5, val5);
- } else if (key.equals(key5)) {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableMap __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return mapOf(key2, val2, key3, val3, key4, val4, key5, val5);
- } else if (cmp.compare(key, key2) == 0) {
- return mapOf(key1, val1, key3, val3, key4, val4, key5, val5);
- } else if (cmp.compare(key, key3) == 0) {
- return mapOf(key1, val1, key2, val2, key4, val4, key5, val5);
- } else if (cmp.compare(key, key4) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3, key5, val5);
- } else if (cmp.compare(key, key5) == 0) {
- return mapOf(key1, val1, key2, val2, key3, val3, key4, val4);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientMap asTransient() {
- return DefaultTrieMap.transientOf(key1, val1, key2, val2, key3, val3, key4, val4, key5,
- val5);
- }
-
- @Override
- public int hashCode() {
- return ((Objects.hashCode(key1) ^ Objects.hashCode(val1))
- + (Objects.hashCode(key2) ^ Objects.hashCode(val2))
- + (Objects.hashCode(key3) ^ Objects.hashCode(val3))
- + (Objects.hashCode(key4) ^ Objects.hashCode(val4)) + (Objects
- .hashCode(key5) ^ Objects.hashCode(val5)));
- }
-
- @Override
- public String toString() {
- return String.format("{%s=%s, %s=%s, %s=%s, %s=%s, %s=%s}", key1, val1, key2, val2, key3,
- val3, key4, val4, key5, val5);
- }
-
-}
diff --git a/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableSet.java b/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableSet.java
deleted file mode 100644
index e9367199d..000000000
--- a/capsule/src/main/java/io/usethesource/capsule/AbstractSpecialisedImmutableSet.java
+++ /dev/null
@@ -1,1269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013-2014 CWI
- * 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:
- *
- * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
- *******************************************************************************/
-package io.usethesource.capsule;
-
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.Set;
-
-public abstract class AbstractSpecialisedImmutableSet extends AbstractImmutableSet implements
- ImmutableSet, Cloneable {
-
- @SuppressWarnings("rawtypes")
- private static ImmutableSet EMPTY_SET = new Set0();
-
- @SuppressWarnings("unchecked")
- public static ImmutableSet setOf() {
- return EMPTY_SET;
- }
-
- public static ImmutableSet setOf(K key1) {
- return new Set1(key1);
- }
-
- public static ImmutableSet setOf(K key1, K key2) {
- return new Set2(key1, key2);
- }
-
- public static ImmutableSet setOf(K key1, K key2, K key3) {
- return new Set3(key1, key2, key3);
- }
-
- public static ImmutableSet setOf(K key1, K key2, K key3, K key4) {
- return new Set4(key1, key2, key3, key4);
- }
-
- public static ImmutableSet setOf(K key1, K key2, K key3, K key4, K key5) {
- return new Set5(key1, key2, key3, key4, key5);
- }
-
- public static ImmutableSet setOf(K key1, K key2, K key3, K key4, K key5, K key6) {
- final TransientSet tmp = DefaultTrieSet.transientOf(key1, key2, key3, key4, key5, key6);
- return tmp.freeze();
- }
-
- public static ImmutableSet setOf(Set set) {
- if (set instanceof AbstractSpecialisedImmutableSet) {
- return (ImmutableSet) set;
- } else {
- final TransientSet tmp = DefaultTrieSet.transientOf();
- // TODO check interface definition of ImmutableSet.__insertAll()
- for (K item : set) {
- tmp.__insert(item);
- }
- return tmp.freeze();
- }
- }
-
- @Override
- public boolean add(K k) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection extends K> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isEmpty() {
- return size() == 0;
- }
-
- @Override
- public Iterator iterator() {
- return keyIterator();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this)
- return true;
- if (other == null)
- return false;
-
- if (other instanceof Set) {
- try {
- @SuppressWarnings("unchecked")
- Set that = (Set) other;
-
- if (this.size() == that.size()) {
- for (K e : this)
- if (!that.contains(e))
- return false;
- return true;
- }
- } catch (ClassCastException unused) {
- return false;
- }
- }
-
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- @Override
- public boolean isTransientSupported() {
- return true;
- }
-
- @Override
- public ImmutableSet __insertAll(Set extends K> set) {
- TransientSet tmp = asTransient();
- if (tmp.__insertAll(set)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __insertAllEquivalent(Set extends K> set, Comparator cmp) {
- TransientSet tmp = asTransient();
- if (tmp.__insertAllEquivalent(set, cmp)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __retainAll(Set extends K> set) {
- TransientSet tmp = asTransient();
- if (tmp.__retainAll(set)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __retainAllEquivalent(TransientSet extends K> set,
- Comparator cmp) {
- TransientSet tmp = asTransient();
- if (tmp.__retainAllEquivalent(set, cmp)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __removeAll(Set extends K> set) {
- TransientSet tmp = asTransient();
- if (tmp.__removeAll(set)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __removeAllEquivalent(Set extends K> set, Comparator cmp) {
- TransientSet tmp = asTransient();
- if (tmp.__removeAllEquivalent(set, cmp)) {
- return tmp.freeze();
- } else {
- return this;
- }
- }
-}
-
-class Set0 extends AbstractSpecialisedImmutableSet {
-
- Set0() {
-
- }
-
- @Override
- public boolean contains(Object key) {
- return false;
- }
-
- @Override
- public boolean containsEquivalent(Object key, Comparator cmp) {
- return false;
- }
-
- @Override
- public K get(Object key) {
- return null;
- }
-
- @Override
- public K getEquivalent(Object key, Comparator cmp) {
- return null;
- }
-
- @Override
- public int size() {
- return 0;
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return EmptySupplierIterator.emptyIterator();
- }
-
- @Override
- public ImmutableSet __insert(K key) {
- return setOf(key);
- }
-
- @Override
- public ImmutableSet __insertEquivalent(K key, Comparator cmp) {
- return setOf(key);
- }
-
- @Override
- public ImmutableSet __remove(K key) {
- return this;
- }
-
- @Override
- public ImmutableSet __removeEquivalent(K key, Comparator cmp) {
- return this;
- }
-
- @Override
- public TransientSet asTransient() {
- return DefaultTrieSet.transientOf();
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- @Override
- public String toString() {
- return "{}";
- }
-
-}
-
-class Set1 extends AbstractSpecialisedImmutableSet {
-
- private final K key1;
-
- Set1(final K key1) {
- this.key1 = key1;
- }
-
- @Override
- public boolean contains(Object key) {
- if (key.equals(key1)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public K get(Object key) {
- if (key.equals(key1)) {
- return key1;
- } else {
- return null;
- }
- }
-
- @Override
- public K getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return key1;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 1;
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Set1.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public K get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return key1;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableSet __insert(K key) {
- if (key.equals(key1)) {
- return setOf(key);
- } else {
- return setOf(key1, key);
- }
- }
-
- @Override
- public ImmutableSet __insertEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf(key);
- } else {
- return setOf(key1, key);
- }
- }
-
- @Override
- public ImmutableSet __remove(K key) {
- if (key.equals(key1)) {
- return setOf();
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf();
- } else {
- return this;
- }
- }
-
- @Override
- public TransientSet asTransient() {
- return DefaultTrieSet.transientOf(key1);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key1);
- }
-
- @Override
- public String toString() {
- return String.format("{%s}", key1);
- }
-
-}
-
-class Set2 extends AbstractSpecialisedImmutableSet {
-
- private final K key1;
- private final K key2;
-
- Set2(final K key1, final K key2) {
- if (key1.equals(key2)) {
- throw new IllegalArgumentException(
- "Duplicate elements are not allowed in specialised set.");
- }
-
- this.key1 = key1;
-
- this.key2 = key2;
- }
-
- @Override
- public boolean contains(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public K get(Object key) {
- if (key.equals(key1)) {
- return key1;
- } else if (key.equals(key2)) {
- return key2;
- } else {
- return null;
- }
- }
-
- @Override
- public K getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return key1;
- } else if (cmp.compare(key, key2) == 0) {
- return key2;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 2;
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Set2.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public K get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return key1;
- case 2:
- return key2;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableSet __insert(K key) {
- if (key.equals(key1)) {
- return setOf(key, key2);
- } else if (key.equals(key2)) {
- return setOf(key1, key);
- } else {
- return setOf(key1, key2, key);
- }
- }
-
- @Override
- public ImmutableSet __insertEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf(key, key2);
- } else if (cmp.compare(key, key2) == 0) {
- return setOf(key1, key);
- } else {
- return setOf(key1, key2, key);
- }
- }
-
- @Override
- public ImmutableSet __remove(K key) {
- if (key.equals(key1)) {
- return setOf(key2);
- } else if (key.equals(key2)) {
- return setOf(key1);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf(key2);
- } else if (cmp.compare(key, key2) == 0) {
- return setOf(key1);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientSet asTransient() {
- return DefaultTrieSet.transientOf(key1, key2);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key1) + Objects.hashCode(key2);
- }
-
- @Override
- public String toString() {
- return String.format("{%s, %s}", key1, key2);
- }
-
-}
-
-class Set3 extends AbstractSpecialisedImmutableSet {
-
- private final K key1;
- private final K key2;
- private final K key3;
-
- Set3(final K key1, final K key2, final K key3) {
- if (key1.equals(key2) || key1.equals(key3) || key2.equals(key3)) {
- throw new IllegalArgumentException(
- "Duplicate elements are not allowed in specialised set.");
- }
-
- this.key1 = key1;
-
- this.key2 = key2;
-
- this.key3 = key3;
- }
-
- @Override
- public boolean contains(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else if (key.equals(key3)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else if (cmp.compare(key, key3) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public K get(Object key) {
- if (key.equals(key1)) {
- return key1;
- } else if (key.equals(key2)) {
- return key2;
- } else if (key.equals(key3)) {
- return key3;
- } else {
- return null;
- }
- }
-
- @Override
- public K getEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return key1;
- } else if (cmp.compare(key, key2) == 0) {
- return key2;
- } else if (cmp.compare(key, key3) == 0) {
- return key3;
- } else {
- return null;
- }
- }
-
- @Override
- public int size() {
- return 3;
- }
-
- @Override
- public SupplierIterator keyIterator() {
- return new SupplierIterator() {
- int cursor = 1;
- boolean hasGet;
-
- @Override
- public boolean hasNext() {
- return cursor <= Set3.this.size();
- }
-
- @Override
- public K next() {
- switch (cursor++) {
- case 1:
- return key1;
- case 2:
- return key2;
- case 3:
- return key3;
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- public K get() {
- if (hasGet) {
- hasGet = false;
-
- switch (cursor) {
- case 1:
- return key1;
- case 2:
- return key2;
- case 3:
- return key3;
- default:
- throw new IllegalStateException();
- }
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
-
- }
-
- @Override
- public ImmutableSet __insert(K key) {
- if (key.equals(key1)) {
- return setOf(key, key2, key3);
- } else if (key.equals(key2)) {
- return setOf(key1, key, key3);
- } else if (key.equals(key3)) {
- return setOf(key1, key2, key);
- } else {
- return setOf(key1, key2, key3, key);
- }
- }
-
- @Override
- public ImmutableSet __insertEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf(key, key2, key3);
- } else if (cmp.compare(key, key2) == 0) {
- return setOf(key1, key, key3);
- } else if (cmp.compare(key, key3) == 0) {
- return setOf(key1, key2, key);
- } else {
- return setOf(key1, key2, key3, key);
- }
- }
-
- @Override
- public ImmutableSet __remove(K key) {
- if (key.equals(key1)) {
- return setOf(key2, key3);
- } else if (key.equals(key2)) {
- return setOf(key1, key3);
- } else if (key.equals(key3)) {
- return setOf(key1, key2);
- } else {
- return this;
- }
- }
-
- @Override
- public ImmutableSet __removeEquivalent(K key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return setOf(key2, key3);
- } else if (cmp.compare(key, key2) == 0) {
- return setOf(key1, key3);
- } else if (cmp.compare(key, key3) == 0) {
- return setOf(key1, key2);
- } else {
- return this;
- }
- }
-
- @Override
- public TransientSet asTransient() {
- return DefaultTrieSet.transientOf(key1, key2, key3);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key1) + Objects.hashCode(key2) + Objects.hashCode(key3);
- }
-
- @Override
- public String toString() {
- return String.format("{%s, %s, %s}", key1, key2, key3);
- }
-
-}
-
-class Set4 extends AbstractSpecialisedImmutableSet {
-
- private final K key1;
- private final K key2;
- private final K key3;
- private final K key4;
-
- Set4(final K key1, final K key2, final K key3, final K key4) {
- if (key1.equals(key2) || key1.equals(key3) || key1.equals(key4) || key2.equals(key3)
- || key2.equals(key4) || key3.equals(key4)) {
- throw new IllegalArgumentException(
- "Duplicate elements are not allowed in specialised set.");
- }
-
- this.key1 = key1;
-
- this.key2 = key2;
-
- this.key3 = key3;
-
- this.key4 = key4;
- }
-
- @Override
- public boolean contains(Object key) {
- if (key.equals(key1)) {
- return true;
- } else if (key.equals(key2)) {
- return true;
- } else if (key.equals(key3)) {
- return true;
- } else if (key.equals(key4)) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean containsEquivalent(Object key, Comparator cmp) {
- if (cmp.compare(key, key1) == 0) {
- return true;
- } else if (cmp.compare(key, key2) == 0) {
- return true;
- } else if (cmp.compare(key, key3) == 0) {
- return true;
- } else if (cmp.compare(key, key4) == 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public K get(Object key) {
- if (key.equals(key1)) {
- return key1;
- } else if (key.equals(key2)) {
- return key2;
- } else if (key.equals(key3)) {
- return key3;
- } else if (key.equals(key4)) {
- return key4;
- } else {
- return null;
- }
- }
-
- @Override
- public K getEquivalent(Object key, Comparator