Fixed Bugs found with wrapper collections

-Fixed: AbstractCollection.Iterator was changing the pointer before validating if the element was added. (ImmutableLists)
-Fixed: EmptyCollections containsAll should return true if it is compared against a emptyCollection.
-Fixed: HashCode/Equals for the Lists/Sets implementations.
-Changed: Iterators.wrap(Array) allows now dynamic arrays.
This commit is contained in:
2022-06-02 11:02:19 +02:00
parent 9eb220194f
commit 1e7da394a1
6 changed files with 43 additions and 9 deletions
@@ -1,6 +1,7 @@
package speiger.src.collections.PACKAGE.utils;
import java.util.NoSuchElementException;
import java.util.Set;
#if TYPE_BOOLEAN
import speiger.src.collections.booleans.collections.BooleanIterator;
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
@@ -242,6 +243,13 @@ public class SETS
@Override
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
#endif
@Override
public boolean equals(Object o) {
if(o == this) return true;
if(!(o instanceof Set)) return false;
return ((Set<?>)o).isEmpty();
}
@Override
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
}