Small fixes

-Fixed: NavigableMap.keySet is now a NavigableSet instead of a sorted one.
-Started: Trying to fix wrappers.
This commit is contained in:
Speiger 2022-06-02 14:59:39 +02:00
parent 1e7da394a1
commit 086d933a0d
7 changed files with 50 additions and 24 deletions

View File

@ -18,7 +18,7 @@ repositories {
} }
archivesBaseName = 'Primitive Collections' archivesBaseName = 'Primitive Collections'
version = '0.6.2.8-SNAPSHOT'; version = '0.6.2.10-SNAPSHOT';
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current(); sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();

View File

@ -30,8 +30,9 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#if TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
import speiger.src.collections.PACKAGE.sets.SORTED_SET; #endif
import speiger.src.collections.PACKAGE.utils.maps.MAPS; import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
@ -682,7 +683,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
} }
@Override @Override
public SORTED_SET KEY_GENERIC_TYPE keySet() { public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet(); return navigableKeySet();
} }
@ -1474,7 +1475,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
} }
@Override @Override
public SET KEY_GENERIC_TYPE keySet() { public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet(); return navigableKeySet();
} }

View File

@ -30,8 +30,9 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#if TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
import speiger.src.collections.PACKAGE.sets.SORTED_SET; #endif
import speiger.src.collections.PACKAGE.utils.maps.MAPS; import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
@ -685,7 +686,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
} }
@Override @Override
public SORTED_SET KEY_GENERIC_TYPE keySet() { public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet(); return navigableKeySet();
} }
@ -1310,6 +1311,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
return keySet; return keySet;
} }
@Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet();
}
@Override @Override
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
@ -1396,6 +1402,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
return keySet; return keySet;
} }
@Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet();
}
@Override @Override
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
@ -1531,7 +1542,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
} }
@Override @Override
public SET KEY_GENERIC_TYPE keySet() { public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
return navigableKeySet(); return navigableKeySet();
} }

View File

@ -34,7 +34,9 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
/** @return a Type Specific pollLastEntry */ /** @return a Type Specific pollLastEntry */
@Override @Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry(); public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry();
/** @return a Type Specific Navigable Key Set */
@Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
/** /**
* Creates a Wrapped NavigableMap that is Synchronized * Creates a Wrapped NavigableMap that is Synchronized
* @return a new NavigableMap that is synchronized * @return a new NavigableMap that is synchronized

View File

@ -9,9 +9,11 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
#if !TYPE_OBJECT #if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif #endif
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SORTED_SET;
import speiger.src.collections.PACKAGE.utils.maps.MAPS; import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#if !TYPE_OBJECT
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectSortedSet;
#endif
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator; import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
/** /**
@ -31,7 +33,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy(); public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy();
@Override @Override
public SET KEY_GENERIC_TYPE keySet(); public SORTED_SET KEY_GENERIC_TYPE keySet();
@Override @Override
public VALUE_COLLECTION VALUE_GENERIC_TYPE values(); public VALUE_COLLECTION VALUE_GENERIC_TYPE values();

View File

@ -185,8 +185,8 @@ public class COLLECTIONS
#endif #endif
@Override @Override
public int hashCode() { synchronized(mutex) { return c.hashCode(); } } public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
@Override // @Override
public boolean equals(Object obj) { synchronized(mutex) { return c.equals(obj); } } // public boolean equals(Object obj) { synchronized(mutex) { return c.equals(obj); } }
@Override @Override
public String toString() { synchronized(mutex) { return c.toString(); } } public String toString() { synchronized(mutex) { return c.toString(); } }
@Override @Override
@ -307,8 +307,8 @@ public class COLLECTIONS
#endif #endif
@Override @Override
public int hashCode() { return c.hashCode(); } public int hashCode() { return c.hashCode(); }
@Override // @Override
public boolean equals(Object obj) { return c.equals(obj); } // public boolean equals(Object obj) { return c.equals(obj); }
@Override @Override
public String toString() { return c.toString(); } public String toString() { return c.toString(); }
@Override @Override

View File

@ -34,6 +34,7 @@ import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
#if !TYPE_OBJECT #if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
import speiger.src.collections.PACKAGE.utils.SETS; import speiger.src.collections.PACKAGE.utils.SETS;
@ -413,6 +414,8 @@ public class MAPS
@Override @Override
public NAVIGABLE_SET KEY_GENERIC_TYPE navigableKeySet() { return SETS.unmodifiable(map.navigableKeySet()); } public NAVIGABLE_SET KEY_GENERIC_TYPE navigableKeySet() { return SETS.unmodifiable(map.navigableKeySet()); }
@Override @Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() { return SETS.unmodifiable(map.keySet()); }
@Override
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { return SETS.unmodifiable(map.descendingKeySet()); } public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { return SETS.unmodifiable(map.descendingKeySet()); }
@Override @Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return MAPS.unmodifiable(map.firstEntry()); } public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return MAPS.unmodifiable(map.firstEntry()); }
@ -461,7 +464,7 @@ public class MAPS
@Override @Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return MAPS.unmodifiable(map.ceilingEntry(key)); } public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return MAPS.unmodifiable(map.ceilingEntry(key)); }
@Override @Override
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
} }
/** /**
@ -502,7 +505,7 @@ public class MAPS
@Override @Override
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); } public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
@Override @Override
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
} }
/** /**
@ -526,6 +529,9 @@ public class MAPS
public SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey) { return MAPS.unmodifiable(map.headMap(toKey)); } public SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey) { return MAPS.unmodifiable(map.headMap(toKey)); }
@Override @Override
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { return MAPS.unmodifiable(map.tailMap(fromKey)); } public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { return MAPS.unmodifiable(map.tailMap(fromKey)); }
@Override
public SORTED_SET KEY_GENERIC_TYPE keySet() { return SETS.unmodifiable(map.keySet()); }
@Override @Override
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); } public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
@Override @Override
@ -539,7 +545,7 @@ public class MAPS
@Override @Override
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); } public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
@Override @Override
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
} }
/** /**
@ -582,7 +588,7 @@ public class MAPS
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); } public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
#endif #endif
@Override @Override
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
@Override @Override
public SET KEY_GENERIC_TYPE keySet() { public SET KEY_GENERIC_TYPE keySet() {
@ -661,6 +667,8 @@ public class MAPS
@Override @Override
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { synchronized(mutex) { return SETS.synchronize(map.descendingKeySet(), mutex); } } public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { synchronized(mutex) { return SETS.synchronize(map.descendingKeySet(), mutex); } }
@Override @Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() { synchronized(mutex) { return SETS.synchronize(map.keySet(), mutex); } }
@Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { synchronized(mutex) { return map.firstEntry(); } } public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { synchronized(mutex) { return map.firstEntry(); } }
@Override @Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { synchronized(mutex) { return map.firstEntry(); } } public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { synchronized(mutex) { return map.firstEntry(); } }
@ -697,7 +705,7 @@ public class MAPS
@Override @Override
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } } public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
@Override @Override
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
#if !TYPE_OBJECT #if !TYPE_OBJECT
@Override @Override
@Deprecated @Deprecated
@ -795,7 +803,7 @@ public class MAPS
@Override @Override
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } } public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
@Override @Override
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
} }
/** /**
@ -825,6 +833,8 @@ public class MAPS
@Override @Override
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { synchronized(mutex) { return MAPS.synchronize(map.tailMap(fromKey), mutex); } } public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { synchronized(mutex) { return MAPS.synchronize(map.tailMap(fromKey), mutex); } }
@Override @Override
public SORTED_SET KEY_GENERIC_TYPE keySet() { synchronized(mutex) { return SETS.synchronize(map.keySet(), mutex); } }
@Override
public KEY_TYPE FIRST_ENTRY_KEY() { synchronized(mutex) { return map.FIRST_ENTRY_KEY(); } } public KEY_TYPE FIRST_ENTRY_KEY() { synchronized(mutex) { return map.FIRST_ENTRY_KEY(); } }
@Override @Override
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_FIRST_ENTRY_KEY(); } } public KEY_TYPE POLL_FIRST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_FIRST_ENTRY_KEY(); } }
@ -837,7 +847,7 @@ public class MAPS
@Override @Override
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } } public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
@Override @Override
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
#if !TYPE_OBJECT #if !TYPE_OBJECT
@Override @Override
@Deprecated @Deprecated
@ -951,9 +961,9 @@ public class MAPS
@Override @Override
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) { synchronized(mutex) { map.forEach(action); } } public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) { synchronized(mutex) { map.forEach(action); } }
@Override @Override
public int size() { synchronized(mutex) { return super.size(); } } public int size() { synchronized(mutex) { return map.size(); } }
@Override @Override
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } public MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
@Override @Override
public SET KEY_GENERIC_TYPE keySet() { public SET KEY_GENERIC_TYPE keySet() {
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex); if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);