This default implementation delegates to the corresponding type-specific function. + * @deprecated Please use the corresponding type-specific function instead. + */ + @Override + @Deprecated + default void addFirst(CLASS_TYPE e) { + addFirst(OBJ_TO_KEY(e)); + } + /** {@inheritDoc} + *
This default implementation delegates to the corresponding type-specific function. + * @deprecated Please use the corresponding type-specific function instead. + */ + @Override + @Deprecated + default void addLast(CLASS_TYPE e) { + addLast(OBJ_TO_KEY(e)); } +#endif + @Override + @Deprecated + default CLASS_TYPE getFirst() { + return KEY_TO_OBJ(GET_FIRST_KEY()); + } + + @Override + @Deprecated + default CLASS_TYPE getLast() { + return KEY_TO_OBJ(GET_LAST_KEY()); + } + + @Override + @Deprecated + default CLASS_TYPE removeFirst() { + return KEY_TO_OBJ(REMOVE_FIRST_KEY()); + } + + @Override + @Deprecated + default CLASS_TYPE removeLast() { + return KEY_TO_OBJ(REMOVE_LAST_KEY()); + } + +#endif /** {@inheritDoc} *
This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
@@ -558,7 +624,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
@Override
@Deprecated
public default boolean contains(Object o) {
- return COLLECTION.super.contains(o);
+ return ORDERED_COLLECTION.super.contains(o);
}
/** {@inheritDoc}
@@ -568,7 +634,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
@Override
@Deprecated
public default boolean remove(Object o) {
- return COLLECTION.super.remove(o);
+ return ORDERED_COLLECTION.super.remove(o);
}
/** {@inheritDoc}
diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template
index 29e0b4d..32aab8d 100644
--- a/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template
+++ b/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template
@@ -14,6 +14,15 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
#endif
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
+#if ORDERED_MAP_FEATURE
+import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
+import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
+import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
+#if !TYPE_OBJECT
+import speiger.src.collections.objects.sets.AbstractObjectSet;
+import speiger.src.collections.objects.sets.ObjectOrderedSet;
+#endif
+#endif
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.SET;
#if MAPS_FEATURE
@@ -119,7 +128,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default void addFirst(CLASS_TYPE e) { addAndMoveToFirst(OBJ_TO_KEY(e)); }
+
+ /** {@inheritDoc}
+ * This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default void addLast(CLASS_TYPE e) { addAndMoveToLast(OBJ_TO_KEY(e)); }
+
+ /** {@inheritDoc}
+ * This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default CLASS_TYPE getFirst() { return GET_FIRST_KEY(); }
+
+ /** {@inheritDoc}
+ * This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default CLASS_TYPE getLast() { return GET_LAST_KEY(); }
+
+ /** {@inheritDoc}
+ * This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default CLASS_TYPE removeFirst() { return REMOVE_FIRST_KEY(); }
+
+ /** {@inheritDoc}
+ * This default implementation delegates to the corresponding type-specific function.
+ * @deprecated Please use the corresponding type-specific function instead.
+ */
+ @Override
+ @Deprecated
+ default CLASS_TYPE removeLast() { return REMOVE_LAST_KEY(); }
+
+#endif
+ @Java21
+ public default ORDERED_SET KEY_GENERIC_TYPE reversed() { return new REVERSED_ORDERED_SETBRACES(this); }
+
#if SETS_FEATURE
/**
* Creates a Wrapped OrderedSet that is Synchronized
diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template
index f8a98a4..200f46c 100644
--- a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template
+++ b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template
@@ -23,6 +23,9 @@ import java.util.function.Consumer;
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
import speiger.src.collections.PACKAGE.collections.COLLECTION;
+#if ORDERED_MAP_FEATURE
+import speiger.src.collections.PACKAGE.collections.ORDERED_COLLECTION;
+#endif
import speiger.src.collections.PACKAGE.collections.ITERATOR;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
@@ -76,6 +79,37 @@ public class COLLECTIONS
return c instanceof UnmodifiableCollection ? c : new UnmodifiableCollectionBRACES(c);
}
+ /**
+ * Returns a Immutable Ordered Collection instance based on the instance given.
+ * @param c that should be made immutable/unmodifiable
+ * @Type(T)
+ * @return a unmodifiable Ordered collection wrapper. If the Collection already a unmodifiable wrapper then it just returns itself.
+ */
+ public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE unmodifiable(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
+ return c instanceof UnmodifiableOrderedCollection ? c : new UnmodifiableOrderedCollectionBRACES(c);
+ }
+
+ /**
+ * Returns a synchronized ordered Collection instance based on the instance given.
+ * @param c that should be synchronized
+ * @Type(T)
+ * @return a synchronized ordered collection wrapper. If the Collection already a synchronized wrapper then it just returns itself.
+ */
+ public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE synchronize(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
+ return c instanceof SynchronizedOrderedCollection ? c : new SynchronizedOrderedCollectionBRACES(c);
+ }
+
+ /**
+ * Returns a synchronized ordered Collection instance based on the instance given.
+ * @param c that should be synchronized
+ * @param mutex is the controller of the synchronization block.
+ * @Type(T)
+ * @return a synchronized ordered collection wrapper. If the Collection already a synchronized wrapper then it just returns itself.
+ */
+ public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE synchronize(ORDERED_COLLECTION KEY_GENERIC_TYPE c, Object mutex) {
+ return c instanceof SynchronizedOrderedCollection ? c : new SynchronizedOrderedCollectionBRACES(c, mutex);
+ }
+
/**
* Returns a synchronized Collection instance based on the instance given.
* @param c that should be synchronized
@@ -668,6 +702,38 @@ public class COLLECTIONS
@Override
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
}
+ /**
+ * Synchronized Ordered Collection Wrapper for the synchronizedCollection function
+ * @Type(T)
+ */
+ public static class SynchronizedOrderedCollection KEY_GENERIC_TYPE extends SynchronizedCollection KEY_GENERIC_TYPE implements ORDERED_COLLECTION KEY_GENERIC_TYPE {
+ ORDERED_COLLECTION KEY_GENERIC_TYPE c;
+
+ SynchronizedOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c, Object mutex) {
+ super(c, mutex);
+ this.c = c;
+ }
+
+ SynchronizedOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
+ super(c);
+ this.c = c;
+ }
+
+ @Override
+ public ORDERED_COLLECTION KEY_GENERIC_TYPE reversed() { return COLLECTIONS.synchronize(c.reversed(), mutex); }
+ @Override
+ public void addFirst(KEY_TYPE e) { synchronized(mutex) { this.c.addFirst(e); } }
+ @Override
+ public void addLast(KEY_TYPE e) { synchronized(mutex) { this.c.addLast(e); } }
+ @Override
+ public KEY_TYPE GET_FIRST_KEY() { synchronized(mutex) { return this.c.GET_FIRST_KEY(); } }
+ @Override
+ public KEY_TYPE REMOVE_FIRST_KEY() { synchronized(mutex) { return this.c.REMOVE_FIRST_KEY(); } }
+ @Override
+ public KEY_TYPE GET_LAST_KEY() { synchronized(mutex) { return this.c.GET_LAST_KEY(); } }
+ @Override
+ public KEY_TYPE REMOVE_LAST_KEY() { synchronized(mutex) { return this.c.REMOVE_LAST_KEY(); } }
+ }
/**
* Synchronized Collection Wrapper for the synchronizedCollection function
@@ -810,6 +876,34 @@ public class COLLECTIONS
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
}
+ /**
+ * Unmodifyable Ordered Collection Wrapper for the unmodifyableCollection method
+ * @Type(T)
+ */
+ public static class UnmodifiableOrderedCollection KEY_GENERIC_TYPE extends UnmodifiableCollection KEY_GENERIC_TYPE implements ORDERED_COLLECTION KEY_GENERIC_TYPE {
+ ORDERED_COLLECTION KEY_GENERIC_TYPE c;
+
+ UnmodifiableOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
+ super(c);
+ this.c = c;
+ }
+
+ @Override
+ public ORDERED_COLLECTION KEY_GENERIC_TYPE reversed() { return COLLECTIONS.unmodifiable(c.reversed()); }
+ @Override
+ public void addFirst(KEY_TYPE e) { throw new UnsupportedOperationException(); }
+ @Override
+ public void addLast(KEY_TYPE e) { throw new UnsupportedOperationException(); }
+ @Override
+ public KEY_TYPE GET_FIRST_KEY() { return c.GET_FIRST_KEY(); }
+ @Override
+ public KEY_TYPE REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
+ @Override
+ public KEY_TYPE GET_LAST_KEY() { return c.GET_LAST_KEY(); }
+ @Override
+ public KEY_TYPE REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
+ }
+
/**
* Unmodifyable Collection Wrapper for the unmodifyableCollection method
* @Type(T)
diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template
index 302fae7..c0b5da2 100644
--- a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template
+++ b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template
@@ -65,7 +65,7 @@ public class ITERATORS
* @Type(T)
* @return an empty iterator
*/
- public static GENERIC_KEY_BRACES EmptyIterator KEY_GENERIC_TYPE empty() {
+ public static GENERIC_KEY_BRACES LIST_ITERATOR KEY_GENERIC_TYPE empty() {
#if TYPE_OBJECT
return (EmptyIterator