Another set of changes.

- Changed: Maps.remove function is no longer using Suffixes unless its
absolutely necessary.
- Changed: ObjectList methods are no longer marked Deprecated even so it
was for primitive ones.
This commit is contained in:
Speiger 2021-06-23 19:58:31 +02:00
parent ce8f49cd1f
commit b55b049508
15 changed files with 58 additions and 49 deletions

View File

@ -7,4 +7,6 @@
- Removed: Suffixes for unmodifiable & synchronize functions.
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
- Changed: PriorityQueues no longer extends Object Variant.
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
- Changed: Maps.remove function is no longer using Suffixes unless its absolutely necessary.
- Changed: ObjectList methods are no longer marked Deprecated even so it was for primitive ones.

View File

@ -65,6 +65,14 @@ task generateSource(type: JavaExec) {
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
}
task forceGenerateSource(type: JavaExec) {
group = 'internal'
description = 'Builds the sourcecode forceful'
classpath = sourceSets.builder.runtimeClasspath
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
args = ['true']
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'

View File

@ -236,6 +236,8 @@ public class GlobalVariables
addFunctionValueMapper("MERGE", "merge");
addFunctionMapper("NEXT", "next");
addFunctionMapper("PREVIOUS", "previous");
if(type.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
else addSimpleMapper("REMOVE_VALUE", "remove");
addFunctionMapper("REMOVE_KEY", "rem");
addFunctionMapper("REMOVE_LAST", "removeLast");
addFunctionMapper("REMOVE", "remove");

View File

@ -149,9 +149,13 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
{
if(args.length == 0) {
new PrimitiveCollectionsBuilder().process(false);
} else if(args.length == 1) {
new PrimitiveCollectionsBuilder().process(Boolean.parseBoolean(args[0]));
} else if(args.length == 3) {
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
} else {
} else if(args.length == 4) {
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
} else {
System.out.println("Invalid argument count passed in");
System.exit(1);
}

View File

@ -55,8 +55,6 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
return false;
}
#endif
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
@ -67,6 +65,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
{
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
}
#endif
/**
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.

View File

@ -381,7 +381,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* A function to find if the Element is present in this list.
* @param o the element that is searched for
* @return if the element was found.
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
*/
@Override
@Primitive
@ -393,7 +392,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* A function to find the index of a given element
* @param o the element that is searched for
* @return the index of the element if found. (if not found then -1)
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
*/
@Override
@Primitive
@ -417,7 +415,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* A function to find the last index of a given element
* @param o the element that is searched for
* @return the last index of the element if found. (if not found then -1)
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
*/
@Override
@Primitive
@ -693,7 +690,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* @param c the elements that should be removed
* @return true if the collection was modified
* @throws NullPointerException if the collection is null
* @deprecated if the collection is type-specific
*/
@Override
@Primitive
@ -718,7 +714,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* @param c the elements that should be kept. If empty, ARRAY_LIST#clear is called.
* @return true if the collection was modified
* @throws NullPointerException if the collection is null
* @deprecated if the collection is type-specific
*/
@Override
@Primitive
@ -745,7 +740,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
* A optimized List#removeIf(Predicate) that more quickly removes elements from the list then the ArrayList implementation
* @param filter the filter to remove elements
* @return true if the list was modified
* @deprecated if Type-Specific, use #remIf instead
*/
@Override
@Primitive

View File

@ -291,14 +291,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
int slot = findIndex(key);
if(slot < 0) return getDefaultReturnValue();
return removeIndex(slot);
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
int slot = findIndex(key);
if(slot < 0) return defaultValue;
return removeIndex(slot);

View File

@ -262,14 +262,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
int slot = findIndex(key);
if(slot < 0) return getDefaultReturnValue();
return removeIndex(slot);
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
int slot = findIndex(key);
if(slot < 0) return defaultValue;
return removeIndex(slot);

View File

@ -352,7 +352,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
int index = findIndex(key);
if(index < 0) return getDefaultReturnValue();
VALUE_TYPE value = values[index];
@ -361,7 +361,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
int index = findIndex(key);
if(index < 0) return defaultValue;
VALUE_TYPE value = values[index];
@ -861,7 +861,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
int index = findIndex(key);
if(index < 0) return getDefaultReturnValue();
VALUE_TYPE value = values[index];
@ -871,7 +871,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
int index = findIndex(key);
if(index < 0) return defaultValue;
VALUE_TYPE value = values[index];

View File

@ -421,7 +421,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
if(entry == null) return getDefaultReturnValue();
VALUE_TYPE value = entry.value;
@ -430,7 +430,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
if(entry == null) return defaultValue;
VALUE_TYPE value = entry.value;
@ -1205,13 +1205,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
#endif
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
return inRange(key) ? m.REMOVE_KEY(key) : getDefaultReturnValue();
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
return inRange(key) ? m.REMOVE_VALUE(key) : getDefaultReturnValue();
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
return inRange(key) ? m.REMOVE_KEY(key) : defaultValue;
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
return inRange(key) ? m.REMOVE_VALUE(key) : defaultValue;
}
#if TYPE_OBJECT && VALUE_OBJECT

View File

@ -420,7 +420,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
}
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
if(entry == null) return getDefaultReturnValue();
VALUE_TYPE value = entry.value;
@ -429,7 +429,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
if(entry == null) return defaultValue;
VALUE_TYPE value = entry.value;
@ -1262,13 +1262,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
#endif
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
return inRange(key) ? m.REMOVE_KEY(key) : getDefaultReturnValue();
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
return inRange(key) ? m.REMOVE_VALUE(key) : getDefaultReturnValue();
}
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
return inRange(key) ? m.REMOVE_KEY(key) : defaultValue;
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
return inRange(key) ? m.REMOVE_VALUE(key) : defaultValue;
}
#if TYPE_OBJECT && VALUE_OBJECT

View File

@ -156,7 +156,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
* @param key the element that should be removed
* @return the value that was removed or default return value
*/
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key);
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key);
/**
* @see Map#remove(Object)
@ -167,9 +167,9 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
@Override
public default CLASS_VALUE_TYPE remove(Object key) {
#if TYPE_OBJECT
return VALUE_TO_OBJ(REMOVE_KEY((CLASS_TYPE)key));
return VALUE_TO_OBJ(REMOVE_VALUE((CLASS_TYPE)key));
#else
return key instanceof CLASS_TYPE ? VALUE_TO_OBJ(REMOVE_KEY(CLASS_TO_KEY(key))) : VALUE_TO_OBJ(getDefaultReturnValue());
return key instanceof CLASS_TYPE ? VALUE_TO_OBJ(REMOVE_VALUE(CLASS_TO_KEY(key))) : VALUE_TO_OBJ(getDefaultReturnValue());
#endif
}
@ -208,7 +208,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
* @param defaultValue the value that should be returned if the entry doesn't exist
* @return the value that was removed or default value
*/
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue);
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue);
/**
* A Type Specific replace method to replace an existing value
* @param key the element that should be searched for

View File

@ -265,9 +265,9 @@ public class MAPS
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
#endif
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { throw new UnsupportedOperationException(); }
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
#if !TYPE_OBJECT || !VALUE_OBJECT
@Override
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
@ -311,9 +311,9 @@ public class MAPS
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
#endif
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { throw new UnsupportedOperationException(); }
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
#if !TYPE_OBJECT || !VALUE_OBJECT
@Override
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
@ -489,9 +489,9 @@ public class MAPS
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
#endif
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { throw new UnsupportedOperationException(); }
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { throw new UnsupportedOperationException(); }
#if !TYPE_OBJECT || !VALUE_OBJECT
@Override
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
@ -798,9 +798,9 @@ public class MAPS
@Override
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { synchronized(mutex) { return map.GET_VALUE(key); } }
@Override
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) { synchronized(mutex) { return map.REMOVE_KEY(key); } }
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { synchronized(mutex) { return map.REMOVE_VALUE(key); } }
@Override
public VALUE_TYPE REMOVE_KEYOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { synchronized(mutex) { return map.REMOVE_KEYOrDefault(key, defaultValue); } }
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { synchronized(mutex) { return map.REMOVE_VALUEOrDefault(key, defaultValue); } }
#if !TYPE_OBJECT || !VALUE_OBJECT
@Override
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.remove(key, value); } }

View File

@ -131,7 +131,7 @@ public abstract class BaseInt2IntMapTest
{
if(!getValidMapTests().contains(MapTests.REMOVE)) return;
Int2IntMap map = createMap(PUT_VALUE_ARRAY, PUT_ARRAY);
Assert.assertEquals(PUT_ARRAY[50], map.remInt(PUT_VALUE_ARRAY[50]));
Assert.assertEquals(PUT_ARRAY[50], map.remove(PUT_VALUE_ARRAY[50]));
Assert.assertTrue(map.remove(PUT_VALUE_ARRAY[51], PUT_ARRAY[51]));
}

View File

@ -87,8 +87,8 @@ public abstract class BaseInt2IntSortedMapTest extends BaseInt2IntMapTest
if(!getValidSortedMapTests().contains(SortedMapTests.SUB_MAP)) return;
Int2IntSortedMap map = createMap(TEST_ARRAY, TEST_ARRAY);
Int2IntSortedMap subMap = map.subMap(25, 75);
Assert.assertEquals(50, subMap.remInt(50));
Assert.assertNotEquals(50, subMap.remInt(50));
Assert.assertEquals(50, subMap.remove(50));
Assert.assertNotEquals(50, subMap.remove(50));
Assert.assertFalse(subMap.containsKey(20));
Assert.assertFalse(subMap.containsKey(80));
}
@ -99,8 +99,8 @@ public abstract class BaseInt2IntSortedMapTest extends BaseInt2IntMapTest
if(!getValidSortedMapTests().contains(SortedMapTests.HEAD_MAP)) return;
Int2IntSortedMap map = createMap(TEST_ARRAY, TEST_ARRAY);
Int2IntSortedMap subMap = map.headMap(75);
Assert.assertEquals(50, subMap.remInt(50));
Assert.assertNotEquals(50, subMap.remInt(50));
Assert.assertEquals(50, subMap.remove(50));
Assert.assertNotEquals(50, subMap.remove(50));
Assert.assertFalse(subMap.containsKey(80));
}
@ -110,8 +110,8 @@ public abstract class BaseInt2IntSortedMapTest extends BaseInt2IntMapTest
if(!getValidSortedMapTests().contains(SortedMapTests.TAIL_MAP)) return;
Int2IntSortedMap map = createMap(TEST_ARRAY, TEST_ARRAY);
Int2IntSortedMap subMap = map.tailMap(25);
Assert.assertEquals(50, subMap.remInt(50));
Assert.assertNotEquals(50, subMap.remInt(50));
Assert.assertEquals(50, subMap.remove(50));
Assert.assertNotEquals(50, subMap.remove(50));
Assert.assertFalse(subMap.containsKey(20));
}
}