Index: src/main/java/org/apache/commons/collections4/list/MapUniqueList.java =================================================================== --- src/main/java/org/apache/commons/collections4/list/MapUniqueList.java (revision 1760323) +++ src/main/java/org/apache/commons/collections4/list/MapUniqueList.java (working copy) @@ -18,10 +18,11 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Map; import java.util.Set; import org.apache.commons.collections4.ListUtils; @@ -31,16 +32,16 @@ /** * Decorates a List to ensure that no duplicates are present much - * like a Set. + * like a Map. *

* The List interface makes certain assumptions/requirements. This * implementation breaks these in certain ways, but this is merely the result of * rejecting duplicates. Each violation is explained in the method, but it - * should not affect you. Bear in mind that Sets require immutable objects to + * should not affect you. Bear in mind that Maps require immutable objects to * function correctly. *

- * The {@link org.apache.commons.collections4.set.ListOrderedSet ListOrderedSet} - * class provides an alternative approach, by wrapping an existing Set and + * The {@link org.apache.commons.collections4.set.ListOrderedMap ListOrderedMap} + * class provides an alternative approach, by wrapping an existing Map and * retaining insertion order in the iterator. *

* This class is Serializable from Commons Collections 3.1. @@ -48,56 +49,58 @@ * @since 3.0 * @version $Id$ */ -public class SetUniqueList extends AbstractSerializableListDecorator { +public class MapUniqueList extends AbstractSerializableListDecorator { /** Serialization version. */ - private static final long serialVersionUID = 7196982186153478694L; + private static final long serialVersionUID = 5539814519665417789L; - /** Internal Set to maintain uniqueness. */ - private final Set set; + /** Internal Map to maintain uniqueness. */ + private final Map map; /** - * Factory method to create a SetList using the supplied list to retain order. + * Factory method to create a MapList using the supplied list to retain order. *

* If the list contains duplicates, these are removed (first indexed one - * kept). A HashSet is used for the set behaviour. + * kept). A HashMap is used for the set behaviour. The map + * also gives better performance for indexOf, contains(E), and get(E). * * @param the element type * @param list the list to decorate, must not be null - * @return a new {@link SetUniqueList} + * @return a new {@link MapUniqueList} * @throws NullPointerException if list is null - * @since 4.0 + * @since FIXME */ - public static SetUniqueList setUniqueList(final List list) { + public static MapUniqueList mapUniqueList(final List list) { if (list == null) { throw new NullPointerException("List must not be null"); } + final Map map = new HashMap(); if (list.isEmpty()) { - return new SetUniqueList(list, new HashSet()); + return new MapUniqueList(list, map); } final List temp = new ArrayList(list); list.clear(); - final SetUniqueList sl = new SetUniqueList(list, new HashSet()); - sl.addAll(temp); - return sl; + final MapUniqueList maplist = new MapUniqueList(list, map); + maplist.addAll(temp); + return maplist; } // ----------------------------------------------------------------------- /** - * Constructor that wraps (not copies) the List and specifies the set to use. + * Constructor that wraps (not copies) the List and specifies the map to use. *

- * The set and list must both be correctly initialised to the same elements. + * The map and list must both be correctly initialised to the same elements. * - * @param set the set to decorate, must not be null + * @param map the map to decorate, must not be null * @param list the list to decorate, must not be null - * @throws NullPointerException if set or list is null + * @throws NullPointerException if map or list is null */ - protected SetUniqueList(final List list, final Set set) { + protected MapUniqueList(final List list, final Map map) { super(list); - if (set == null) { - throw new NullPointerException("Set must not be null"); + if (map == null) { + throw new NullPointerException("Map must not be null"); } - this.set = set; + this.map = map; } // ----------------------------------------------------------------------- @@ -107,7 +110,7 @@ * @return an unmodifiable set view */ public Set asSet() { - return UnmodifiableSet.unmodifiableSet(set); + return UnmodifiableSet.unmodifiableSet(map.keySet()); } // ----------------------------------------------------------------------- @@ -116,7 +119,7 @@ *

* (Violation) The List interface requires that this * method returns true always. However this class may return - * false because of the Set behaviour. + * false because of the uniqueness criteria. * * @param object the object to add * @return true if object was added @@ -147,9 +150,9 @@ @Override public void add(final int index, final E object) { // adds element if it is not contained already - if (set.contains(object) == false) { + if (map.containsKey(object) == false) { super.add(index, object); - set.add(object); + map.put(object, index); } } @@ -168,7 +171,12 @@ */ @Override public boolean addAll(final Collection coll) { - return addAll(size(), coll); + //return addAll(size(), coll); + boolean changed = false; + for (E e : coll) { + changed |= add(e); + } + return changed; } /** @@ -188,13 +196,23 @@ */ @Override public boolean addAll(final int index, final Collection coll) { - final List temp = new ArrayList(); + /*final List temp = new ArrayList(); for (final E e : coll) { - if (set.add(e)) { + if (map.add(e)) { temp.add(e); } } - return super.addAll(index, temp); + return super.addAll(index, temp);*/ + boolean changed = false; + int i = index; + for (E e : coll) { + if (!map.containsKey(e)) { + add(i, e); + i++; + changed = true; + } + } + return changed; } // ----------------------------------------------------------------------- @@ -220,15 +238,15 @@ super.remove(pos); // remove the duplicate by index } - set.remove(removed); // remove the item deleted by the set - set.add(object); // add the new item to the unique set + map.remove(removed); // remove the item deleted by the map + map.put(object, index); // add the new item to the unique map - return removed; // return the item deleted by the set + return removed; // return the item deleted by the map } @Override public boolean remove(final Object object) { - final boolean result = set.remove(object); + final boolean result = map.remove(object) != null; if (result) { super.remove(object); } @@ -238,7 +256,7 @@ @Override public E remove(final int index) { final E result = super.remove(index); - set.remove(result); + map.remove(result); return result; } @@ -262,6 +280,7 @@ */ @Override public boolean retainAll(final Collection coll) { + final Set set = map.keySet(); boolean result = set.retainAll(coll); if (result == false) { return false; @@ -269,7 +288,7 @@ if (set.size() == 0) { super.clear(); } else { - // use the set as parameter for the call to retainAll to improve performance + // use the map as parameter for the call to retainAll to improve performance super.retainAll(set); } return result; @@ -278,32 +297,32 @@ @Override public void clear() { super.clear(); - set.clear(); + map.clear(); } @Override public boolean contains(final Object object) { - return set.contains(object); + return map.containsKey(object); } @Override public boolean containsAll(final Collection coll) { - return set.containsAll(coll); + return map.keySet().containsAll(coll); } @Override public Iterator iterator() { - return new SetListIterator(super.iterator(), set); + return new MapListIterator(super.iterator(), map); } @Override public ListIterator listIterator() { - return new SetListListIterator(super.listIterator(), set); + return new MapListListIterator(super.listIterator(), map); } @Override public ListIterator listIterator(final int index) { - return new SetListListIterator(super.listIterator(index), set); + return new MapListListIterator(super.listIterator(index), map); } /** @@ -315,35 +334,40 @@ @Override public List subList(final int fromIndex, final int toIndex) { final List superSubList = super.subList(fromIndex, toIndex); - final Set subSet = createSetBasedOnList(set, superSubList); - return ListUtils.unmodifiableList(new SetUniqueList(superSubList, subSet)); + final Map subMap = createMapBasedOnList(map, superSubList); + return ListUtils.unmodifiableList(new MapUniqueList(superSubList, subMap)); } /** - * Create a new {@link Set} with the same type as the provided {@code set} + * Create a new {@link Map} with the same type as the provided {@code map} * and populate it with all elements of {@code list}. * - * @param set the {@link Set} to be used as return type, must not be null - * @param list the {@link List} to populate the {@link Set} - * @return a new {@link Set} populated with all elements of the provided + * @param map the {@link Map} to be used as return type, must not be null + * @param list the {@link List} to populate the {@link Map} + * @return a new {@link Map} populated with all elements of the provided * {@link List} */ @SuppressWarnings("unchecked") - protected Set createSetBasedOnList(final Set set, final List list) { - Set subSet; - if (set.getClass().equals(HashSet.class)) { - subSet = new HashSet(list.size()); + protected Map createMapBasedOnList(final Map map, final List list) { + Map subMap; + if (map.getClass().equals(HashMap.class)) { + subMap = new HashMap(list.size()); } else { try { - subSet = set.getClass().newInstance(); + subMap = map.getClass().newInstance(); } catch (final InstantiationException ie) { - subSet = new HashSet(); + subMap = new HashMap(); } catch (final IllegalAccessException iae) { - subSet = new HashSet(); + subMap = new HashMap(); } } - subSet.addAll(list); - return subSet; + assert subMap.isEmpty(); + for (E e : list) { + if (! subMap.containsKey(e)) { + subMap.put(e, subMap.size()); + } + } + return subMap; } // ----------------------------------------------------------------------- @@ -350,14 +374,14 @@ /** * Inner class iterator. */ - static class SetListIterator extends AbstractIteratorDecorator { + static class MapListIterator extends AbstractIteratorDecorator { - private final Set set; + private final Map map; private E last = null; - protected SetListIterator(final Iterator it, final Set set) { + protected MapListIterator(final Iterator it, final Map map) { super(it); - this.set = set; + this.map = map; } @Override @@ -369,7 +393,7 @@ @Override public void remove() { super.remove(); - set.remove(last); + map.remove(last); last = null; } } @@ -377,15 +401,15 @@ /** * Inner class iterator. */ - static class SetListListIterator extends + static class MapListListIterator extends AbstractListIteratorDecorator { - private final Set set; + private final Map map; private E last = null; - protected SetListListIterator(final ListIterator it, final Set set) { + protected MapListListIterator(final ListIterator it, final Map map) { super(it); - this.set = set; + this.map = map; } @Override @@ -403,15 +427,15 @@ @Override public void remove() { super.remove(); - set.remove(last); + map.remove(last); last = null; } @Override public void add(final E object) { - if (set.contains(object) == false) { + if (map.containsKey(object) == false) { super.add(object); - set.add(object); + map.put(object, map.size()); } } Index: src/test/java/org/apache/commons/collections4/list/MapUniqueListTest.java =================================================================== --- src/test/java/org/apache/commons/collections4/list/MapUniqueListTest.java (revision 1760323) +++ src/test/java/org/apache/commons/collections4/list/MapUniqueListTest.java (working copy) @@ -19,21 +19,21 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; -import java.util.Set; +import java.util.Map; /** * JUnit tests. * - * @since 3.0 + * @since FIXME * @version $Id$ */ -public class SetUniqueListTest extends AbstractListTest { +public class MapUniqueListTest extends AbstractListTest { - public SetUniqueListTest(final String testName) { + public MapUniqueListTest(final String testName) { super(testName); } @@ -40,7 +40,7 @@ //----------------------------------------------------------------------- @Override public List makeObject() { - return new SetUniqueList(new ArrayList(), new HashSet()); + return new MapUniqueList(new ArrayList(), new HashMap()); } //----------------------------------------------------------------------- @@ -83,7 +83,7 @@ @Override public void testListIteratorAdd() { - // override to cope with Set behaviour + // override to cope with Map behaviour resetEmpty(); final List list1 = getCollection(); final List list2 = getConfirmed(); @@ -112,7 +112,7 @@ @Override public void testCollectionAddAll() { - // override for set behaviour + // override for map behaviour resetEmpty(); E[] elements = getFullElements(); boolean r = getCollection().addAll(Arrays.asList(elements)); @@ -140,8 +140,10 @@ } public void testIntCollectionAddAll() { - // make a SetUniqueList with one element - final List list = new SetUniqueList(new ArrayList(), new HashSet()); + // make a MapUniqueList with one element + final List alist = new ArrayList(); + final Map map = new HashMap(); + final List list = new MapUniqueList(alist, map); final Integer existingElement = Integer.valueOf(1); list.add(existingElement); @@ -167,7 +169,7 @@ @Override @SuppressWarnings("unchecked") public void testListSetByIndex() { - // override for set behaviour + // override for map behaviour resetFull(); final int size = getCollection().size(); getCollection().set(0, (E) new Long(1000)); @@ -175,7 +177,7 @@ getCollection().set(2, (E) new Long(1000)); assertEquals(size - 1, getCollection().size()); - assertEquals(new Long(1000), getCollection().get(1)); // set into 2, but shifted down to 1 + assertEquals(new Long(1000), getCollection().get(1)); // map into 2, but shifted down to 1 } boolean extraVerify = true; @@ -211,11 +213,11 @@ public void testFactory() { final Integer[] array = new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; final ArrayList list = new ArrayList(Arrays.asList(array)); - final SetUniqueList lset = SetUniqueList.setUniqueList(list); + final MapUniqueList lmap = MapUniqueList.mapUniqueList(list); - assertEquals("Duplicate element was added.", 2, lset.size()); - assertEquals(Integer.valueOf(1), lset.get(0)); - assertEquals(Integer.valueOf(2), lset.get(1)); + assertEquals("Duplicate element was added.", 2, lmap.size()); + assertEquals(Integer.valueOf(1), lmap.get(0)); + assertEquals(Integer.valueOf(2), lmap.get(1)); assertEquals(Integer.valueOf(1), list.get(0)); assertEquals(Integer.valueOf(2), list.get(1)); } @@ -222,32 +224,32 @@ @SuppressWarnings("unchecked") public void testAdd() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final MapUniqueList lmap = new MapUniqueList(new ArrayList(), new HashMap()); // Duplicate element final E obj = (E) Integer.valueOf(1); - lset.add(obj); - lset.add(obj); - assertEquals("Duplicate element was added.", 1, lset.size()); + lmap.add(obj); + lmap.add(obj); + assertEquals("Duplicate element was added.", 1, lmap.size()); // Unique element - lset.add((E) Integer.valueOf(2)); - assertEquals("Unique element was not added.", 2, lset.size()); + lmap.add((E) Integer.valueOf(2)); + assertEquals("Unique element was not added.", 2, lmap.size()); } @SuppressWarnings("unchecked") public void testAddAll() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final MapUniqueList lmap = new MapUniqueList(new ArrayList(), new HashMap()); - lset.addAll( + lmap.addAll( Arrays.asList((E[]) new Integer[] { Integer.valueOf(1), Integer.valueOf(1)})); - assertEquals("Duplicate element was added.", 1, lset.size()); + assertEquals("Duplicate element was added.", 1, lmap.size()); } @SuppressWarnings("unchecked") - public void testSet() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + public void testMap() { + final MapUniqueList lmap = new MapUniqueList(new ArrayList(), new HashMap()); // Duplicate element final E obj1 = (E) Integer.valueOf(1); @@ -254,47 +256,47 @@ final E obj2 = (E) Integer.valueOf(2); final E obj3 = (E) Integer.valueOf(3); - lset.add(obj1); - lset.add(obj2); - lset.set(0, obj1); - assertEquals(2, lset.size()); - assertSame(obj1, lset.get(0)); - assertSame(obj2, lset.get(1)); + lmap.add(obj1); + lmap.add(obj2); + lmap.set(0, obj1); + assertEquals(2, lmap.size()); + assertSame(obj1, lmap.get(0)); + assertSame(obj2, lmap.get(1)); - lset.clear(); - lset.add(obj1); - lset.add(obj2); - lset.set(0, obj2); - assertEquals(1, lset.size()); - assertSame(obj2, lset.get(0)); + lmap.clear(); + lmap.add(obj1); + lmap.add(obj2); + lmap.set(0, obj2); + assertEquals(1, lmap.size()); + assertSame(obj2, lmap.get(0)); - lset.clear(); - lset.add(obj1); - lset.add(obj2); - lset.set(0, obj3); - assertEquals(2, lset.size()); - assertSame(obj3, lset.get(0)); - assertSame(obj2, lset.get(1)); + lmap.clear(); + lmap.add(obj1); + lmap.add(obj2); + lmap.set(0, obj3); + assertEquals(2, lmap.size()); + assertSame(obj3, lmap.get(0)); + assertSame(obj2, lmap.get(1)); - lset.clear(); - lset.add(obj1); - lset.add(obj2); - lset.set(1, obj1); - assertEquals(1, lset.size()); - assertSame(obj1, lset.get(0)); + lmap.clear(); + lmap.add(obj1); + lmap.add(obj2); + lmap.set(1, obj1); + assertEquals(1, lmap.size()); + assertSame(obj1, lmap.get(0)); } @SuppressWarnings("unchecked") public void testListIterator() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final MapUniqueList lmap = new MapUniqueList(new ArrayList(), new HashMap()); final E obj1 = (E) Integer.valueOf(1); final E obj2 = (E) Integer.valueOf(2); - lset.add(obj1); - lset.add(obj2); + lmap.add(obj1); + lmap.add(obj2); // Attempts to add a duplicate object - for (final ListIterator it = lset.listIterator(); it.hasNext();) { + for (final ListIterator it = lmap.listIterator(); it.hasNext();) { it.next(); if (!it.hasNext()) { @@ -303,12 +305,12 @@ } } - assertEquals("Duplicate element was added", 2, lset.size()); + assertEquals("Duplicate element was added", 2, lmap.size()); } @SuppressWarnings("unchecked") public void testUniqueListReInsert() { - final List l = SetUniqueList.setUniqueList(new LinkedList()); + final List l = MapUniqueList.mapUniqueList(new LinkedList()); l.add((E) new Object()); l.add((E) new Object()); @@ -325,7 +327,7 @@ @SuppressWarnings("unchecked") public void testUniqueListDoubleInsert() { - final List l = SetUniqueList.setUniqueList(new LinkedList()); + final List l = MapUniqueList.mapUniqueList(new LinkedList()); l.add((E) new Object()); l.add((E) new Object()); @@ -339,16 +341,16 @@ } @SuppressWarnings("unchecked") - public void testSetDownwardsInList() { + public void testMapDownwardsInList() { /* * Checks the following semantics * [a,b] - * set(0,b): [b]->a + * map(0,b): [b]->a * So UniqList contains [b] and a is returned */ final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final HashMap m = new HashMap(); + final MapUniqueList ul = new MapUniqueList(l, m); final E a = (E) new Object(); final E b = (E) new Object(); @@ -356,28 +358,28 @@ ul.add(b); assertEquals(a, l.get(0)); assertEquals(b, l.get(1)); - assertTrue(s.contains(a)); - assertTrue(s.contains(b)); + assertTrue(m.containsKey(a)); + assertTrue(m.containsKey(b)); assertEquals(a, ul.set(0, b)); - assertEquals(1, s.size()); + assertEquals(1, m.size()); assertEquals(1, l.size()); assertEquals(b, l.get(0)); - assertTrue(s.contains(b)); - assertFalse(s.contains(a)); + assertTrue(m.containsKey(b)); + assertFalse(m.containsKey(a)); } @SuppressWarnings("unchecked") - public void testSetInBiggerList() { + public void testMapInBiggerList() { /* * Checks the following semantics * [a,b,c] - * set(0,b): [b,c]->a + * map(0,b): [b,c]->a * So UniqList contains [b,c] and a is returned */ final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final HashMap m = new HashMap(); + final MapUniqueList ul = new MapUniqueList(l, m); final E a = (E) new Object(); final E b = (E) new Object(); @@ -389,31 +391,31 @@ assertEquals(a, l.get(0)); assertEquals(b, l.get(1)); assertEquals(c, l.get(2)); - assertTrue(s.contains(a)); - assertTrue(s.contains(b)); - assertTrue(s.contains(c)); + assertTrue(m.containsKey(a)); + assertTrue(m.containsKey(b)); + assertTrue(m.containsKey(c)); assertEquals(a, ul.set(0, b)); - assertEquals(2, s.size()); + assertEquals(2, m.size()); assertEquals(2, l.size()); assertEquals(b, l.get(0)); assertEquals(c, l.get(1)); - assertFalse(s.contains(a)); - assertTrue(s.contains(b)); - assertTrue(s.contains(c)); + assertFalse(m.containsKey(a)); + assertTrue(m.containsKey(b)); + assertTrue(m.containsKey(c)); } @SuppressWarnings("unchecked") - public void testSetUpwardsInList() { + public void testMapUpwardsInList() { /* * Checks the following semantics * [a,b,c] - * set(1,a): [a,c]->b + * map(1,a): [a,c]->b * So UniqList contains [a,c] and b is returned */ final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final HashMap s = new HashMap(); + final MapUniqueList ul = new MapUniqueList(l, s); final E a = (E) new String("A"); final E b = (E) new String("B"); @@ -425,9 +427,9 @@ assertEquals(a, l.get(0)); assertEquals(b, l.get(1)); assertEquals(c, l.get(2)); - assertTrue(s.contains(a)); - assertTrue(s.contains(b)); - assertTrue(s.contains(c)); + assertTrue(s.containsKey(a)); + assertTrue(s.containsKey(b)); + assertTrue(s.containsKey(c)); assertEquals(b, ul.set(1, a)); assertEquals(2, s.size()); @@ -434,14 +436,14 @@ assertEquals(2, l.size()); assertEquals(a, l.get(0)); assertEquals(c, l.get(1)); - assertTrue(s.contains(a)); - assertFalse(s.contains(b)); - assertTrue(s.contains(c)); + assertTrue(s.containsKey(a)); + assertFalse(s.containsKey(b)); + assertTrue(s.containsKey(c)); } public void testCollections304() { final List list = new LinkedList(); - final SetUniqueList decoratedList = SetUniqueList.setUniqueList(list); + final MapUniqueList decoratedList = MapUniqueList.mapUniqueList(list); final String s1 = "Apple"; final String s2 = "Lemon"; final String s3 = "Orange"; @@ -475,7 +477,7 @@ @SuppressWarnings("unchecked") public void testCollections307() { List list = new ArrayList(); - List uniqueList = SetUniqueList.setUniqueList(list); + List uniqueList = MapUniqueList.mapUniqueList(list); final String hello = "Hello"; final String world = "World"; @@ -493,10 +495,10 @@ assertFalse(subList.contains("World")); // passes assertFalse(subUniqueList.contains("World")); // fails - // repeat the test with a different class than HashSet; - // which means subclassing SetUniqueList below + // repeat the test with a different class than HashMap; + // which means subclassing MapUniqueList below list = new ArrayList(); - uniqueList = new SetUniqueList307(list, new java.util.TreeSet()); + uniqueList = new MapUniqueList307(list, new java.util.TreeMap()); uniqueList.add((E) hello); uniqueList.add((E) world); @@ -516,7 +518,7 @@ @SuppressWarnings("unchecked") public void testRetainAll() { final List list = new ArrayList(10); - final SetUniqueList uniqueList = SetUniqueList.setUniqueList(list); + final MapUniqueList uniqueList = MapUniqueList.mapUniqueList(list); for (int i = 0; i < 10; ++i) { uniqueList.add((E)Integer.valueOf(i)); } @@ -542,7 +544,7 @@ for (int i = 0; i < 5; ++i) { list.add((E)Integer.valueOf(i)); } - final SetUniqueList uniqueList = SetUniqueList.setUniqueList(list); + final MapUniqueList uniqueList = MapUniqueList.mapUniqueList(list); for (int i = 5; i < 10; ++i) { uniqueList.add((E)Integer.valueOf(i)); } @@ -561,32 +563,34 @@ assertTrue(uniqueList.contains(Integer.valueOf(8))); } - public void testSetCollections444() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + public void testMapCollections444() { + final List list = new ArrayList(); + final Map map = new HashMap(); + final MapUniqueList lmap = new MapUniqueList(list, map); // Duplicate element final Integer obj1 = Integer.valueOf(1); final Integer obj2 = Integer.valueOf(2); - lset.add(obj1); - lset.add(obj2); - lset.set(0, obj1); - assertEquals(2, lset.size()); - assertSame(obj1, lset.get(0)); - assertSame(obj2, lset.get(1)); + lmap.add(obj1); + lmap.add(obj2); + lmap.set(0, obj1); + assertEquals(2, lmap.size()); + assertSame(obj1, lmap.get(0)); + assertSame(obj2, lmap.get(1)); - assertTrue(lset.contains(obj1)); - assertTrue(lset.contains(obj2)); + assertTrue(lmap.contains(obj1)); + assertTrue(lmap.contains(obj2)); } - class SetUniqueList307 extends SetUniqueList { + class MapUniqueList307 extends MapUniqueList { /** * Generated serial version ID. */ private static final long serialVersionUID = 1415013031022962158L; - public SetUniqueList307(final List list, final Set set) { - super(list, set); + public MapUniqueList307(final List list, final Map map) { + super(list, map); } } @@ -593,14 +597,14 @@ //----------------------------------------------------------------------- @Override public String getCompatibilityVersion() { - return "4"; + return "4.FIXME"; } -// public void testCreate() throws Exception { -// resetEmpty(); -// writeExternalFormToDisk((java.io.Serializable) getCollection(), "src/test/resources/data/test/SetUniqueList.emptyCollection.version4.obj"); -// resetFull(); -// writeExternalFormToDisk((java.io.Serializable) getCollection(), "src/test/resources/data/test/SetUniqueList.fullCollection.version4.obj"); -// } + public void testCreate() throws Exception { + resetEmpty(); + writeExternalFormToDisk((java.io.Serializable) getCollection(), "src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj"); + resetFull(); + writeExternalFormToDisk((java.io.Serializable) getCollection(), "src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj"); + } } Index: src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj =================================================================== --- src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj (revision 0) +++ src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj (working copy) Property changes on: src/test/resources/data/test/MapUniqueList.emptyCollection.version4.FIXME.obj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj =================================================================== --- src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj (revision 0) +++ src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj (working copy) Property changes on: src/test/resources/data/test/MapUniqueList.fullCollection.version4.FIXME.obj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property