diff --git a/Changelog.md b/Changelog.md index 857d7dd..15142f8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,4 +3,6 @@ ## Version 0.3.0 - Added: Stack.isEmpty was missing -- Changed: remove/removeLast/enqueue/enqueueFirst no longer use Type Suffixes \ No newline at end of file +- Changed: remove/removeLast/enqueue/enqueueFirst no longer use Type Suffixes +- Removed: Suffixes for unmodifiable & synchronize functions. +- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed. \ No newline at end of file diff --git a/src/builder/java/speiger/src/builder/GlobalVariables.java b/src/builder/java/speiger/src/builder/GlobalVariables.java index 68a8a9a..e7930bb 100644 --- a/src/builder/java/speiger/src/builder/GlobalVariables.java +++ b/src/builder/java/speiger/src/builder/GlobalVariables.java @@ -235,9 +235,6 @@ public class GlobalVariables addFunctionValueMapper("MERGE", "merge"); addFunctionMapper("NEXT", "next"); addFunctionMapper("PREVIOUS", "previous"); - addFunctionMapper("PEEK", "peek"); - addFunctionMapper("POP", "pop"); - addFunctionMapper("PUSH", "push"); addFunctionMapper("REMOVE_KEY", "rem"); addFunctionMapper("REMOVE_LAST", "removeLast"); addFunctionMapper("REMOVE", "remove"); @@ -246,7 +243,6 @@ public class GlobalVariables addFunctionMappers("SORT", "sort%ss"); addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream"); addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array"); - addFunctionMapper("TOP", "top"); return this; } diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Stack.template b/src/builder/resources/speiger/assets/collections/templates/collections/Stack.template index fc64cc4..974a59e 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Stack.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Stack.template @@ -5,14 +5,14 @@ import speiger.src.collections.utils.Stack; /** * A Type-Specific {@link Stack} that reduces (un)boxing */ -public interface STACK extends Stack +public interface STACK { /** * Inserts a given Object on top of the stack * @param e the Object to insert * @see Stack#push(Object) */ - public void PUSH(KEY_TYPE e); + public void push(KEY_TYPE e); /** * Removes the Object on top of the stack. @@ -20,7 +20,7 @@ public interface STACK extends Stack * @throws ArrayIndexOutOfBoundsException if the stack is empty * @see Stack#pop() */ - public KEY_TYPE POP(); + public KEY_TYPE pop(); /** * Provides the Object on top of the stack @@ -28,8 +28,8 @@ public interface STACK extends Stack * @throws ArrayIndexOutOfBoundsException if the stack is empty * @see Stack#top() */ - public default KEY_TYPE TOP() { - return PEEK(0); + public default KEY_TYPE top() { + return peek(0); } /** @@ -40,41 +40,23 @@ public interface STACK extends Stack * @throws ArrayIndexOutOfBoundsException if the index is out of bounds * @see Stack#peek(int) */ - public KEY_TYPE PEEK(int index); + public KEY_TYPE peek(int index); -#if !OBJECT_TYPE - /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ - @Override - @Deprecated - public default void push(CLASS_TYPE e) { PUSH(OBJ_TO_KEY(e)); } + /** + * Clears the stack + */ + public void clear(); - /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ - @Override - @Deprecated - public default CLASS_TYPE pop() { return KEY_TO_OBJ(POP()); } + /** + * Provides the amount of elements currently in the stack + * @return amount of elements in the list + */ + public int size(); - /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ - @Override - @Deprecated - public default CLASS_TYPE top() { - return peek(size() - 1); + /** + * @return if the stack is empty + */ + public default boolean isEmpty() { + return size() == 0; } - - /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ - @Override - @Deprecated - public default CLASS_TYPE peek(int index) { return KEY_TO_OBJ(PEEK(index)); } -#endif } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template index 1024dc2..bf3a726 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template @@ -201,7 +201,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE * @param e element to be appended to this Stack */ @Override - public void PUSH(KEY_TYPE e) { + public void push(KEY_TYPE e) { add(e); } @@ -543,7 +543,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE * @see speiger.src.collections.utils.Stack#peek(int) */ @Override - public KEY_TYPE PEEK(int index) { + public KEY_TYPE peek(int index) { checkRange((size() - 1) - index); return data[(size() - 1) - index]; } @@ -683,7 +683,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE * @throws IndexOutOfBoundsException if the index is out of range */ @Override - public KEY_TYPE POP() { + public KEY_TYPE pop() { return REMOVE(size() - 1); } diff --git a/src/test/java/speiger/src/collections/ints/base/IIntStackTests.java b/src/test/java/speiger/src/collections/ints/base/IIntStackTests.java index 93d860c..093e063 100644 --- a/src/test/java/speiger/src/collections/ints/base/IIntStackTests.java +++ b/src/test/java/speiger/src/collections/ints/base/IIntStackTests.java @@ -18,13 +18,13 @@ public interface IIntStackTests public default void testPush() { IntStack stacks = create(TEST_ARRAY); - stacks.pushInt(500); - Assert.assertEquals(500, stacks.topInt()); + stacks.push(500); + Assert.assertEquals(500, stacks.top()); } @Test public default void testPop() { - Assert.assertEquals(99, create(TEST_ARRAY).topInt()); + Assert.assertEquals(99, create(TEST_ARRAY).top()); } }