Skip to content

Commit

Permalink
Collection Module Works now. (Least Configurable for obvious Reasons)
Browse files Browse the repository at this point in the history
  • Loading branch information
Speiger committed Dec 7, 2022
1 parent 3ce5266 commit 342b0ce
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 131 deletions.
250 changes: 143 additions & 107 deletions ModulSettings.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected void loadFunctions() {}
@Override
protected void loadBlockades() {
if(!isModuleEnabled()) {
addBlockedFiles("AsyncBuilder");
addBlockedFiles("AsyncBuilder", "Task");
}
}
@Override
Expand Down
30 changes: 27 additions & 3 deletions src/builder/java/speiger/src/builder/modules/CollectionModule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package speiger.src.builder.modules;

import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

import speiger.src.builder.ClassType;

@SuppressWarnings("javadoc")
Expand All @@ -12,12 +16,32 @@ public class CollectionModule extends BaseModule
@Override
protected void loadVariables() {}
@Override
protected void loadFlags() {}
@Override
public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); }

@Override
protected void loadBlockades()
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType)
{
return new TreeSet<>(Arrays.asList("Streams", "Splititerators", "IArray", "Strategy"));
}

@Override
protected void loadFlags() {
if(isModuleEnabled()) addKeyFlag("COLLECTION_MODULE");
if(isModuleEnabled("Streams")) addKeyFlag("STREAM_FEATURE");
if(isModuleEnabled("Splititerators")) addKeyFlag("SPLIT_ITERATOR_FEATURE");
if(isModuleEnabled("IArray")) addKeyFlag("IARRAY_FEATURE");
}

@Override
protected void loadBlockades() {
if(!isModuleEnabled()) {
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
}
if(!isModuleEnabled("Splititerators")) addBlockedFiles("Splititerator", "Splititerators");
if(!isModuleEnabled("IArray")) addBlockedFiles("IArray");
if(!isModuleEnabled("Strategy")) addBlockedFiles("Strategy");

if(keyType.isObject()) {
addBlockedFiles("Stack");
addBlockedFiles("CollectionStreamTester");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import java.util.Collection;
import java.util.Objects;
import java.util.function.JAVA_PREDICATE;
import java.util.function.Predicate;
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
import java.util.stream.JAVA_STREAM;
import java.util.stream.StreamSupport;
#endif
#endif
#if TYPE_OBJECT
import java.util.function.Consumer;
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
#else
import speiger.src.collections.PACKAGE.functions.CONSUMER;
#endif
#if SPLIT_ITERATOR_FEATURE
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
#endif
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
import speiger.src.collections.utils.ISizeProvider;
import speiger.src.collections.utils.SanityChecks;
Expand Down Expand Up @@ -291,6 +295,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
*/
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }

#if SPLIT_ITERATOR_FEATURE
#if PRIMITIVES
/**
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
Expand All @@ -303,11 +308,15 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
* @return a Stream of the closest java type
*/
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }

#endif
#if STREAM_FEATURE
/**
* A Type Specific Type Splititerator to reduce boxing/unboxing
* @return type specific splititerator
*/
@Override
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
#endif
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
#if ASYNC_MODULE
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
#endif
#if SPLIT_ITERATOR_FEATURE
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
#endif
import speiger.src.collections.PACKAGE.utils.ITERABLES;
import speiger.src.collections.PACKAGE.utils.ITERATORS;
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
Expand Down Expand Up @@ -114,13 +116,15 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
iterator().forEachRemaining(input, action);
}

#if SPLIT_ITERATOR_FEATURE
/**
* A Type Specific Type Splititerator to reduce boxing/unboxing
* @return type specific splititerator
*/
@Override
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }

#endif
#if ASYNC_MODULE
/**
* Creates a Async Builder for moving work of the thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Objects;
#if TYPE_OBJECT
#if IARRAY_FEATURE || TYPE_OBJECT
import java.util.function.Consumer;
#endif

import java.util.function.BiFunction;
#endif
import java.util.function.Predicate;
Expand Down Expand Up @@ -38,33 +41,38 @@ import speiger.src.collections.utils.Stack;
#else
import speiger.src.collections.objects.utils.ObjectArrays;
#endif
#if PRIMITIVES
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
import java.util.stream.JAVA_STREAM;
import java.util.stream.StreamSupport;
#endif
#if IARRAY_FEATURE
import speiger.src.collections.PACKAGE.utils.IARRAY;
#endif
#if SPLIT_ITERATOR_FEATURE
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
#endif
#if !IARRAY_FEATURE
import speiger.src.collections.utils.IArray;
#endif
import speiger.src.collections.utils.SanityChecks;

#if TYPE_OBJECT
/**
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
*
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link Stack}
#if IARRAY_FEATURE
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
#else
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IArray}, {@link STACK}
#endif
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
*
*
* @Type(T)
*/
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY<KEY_TYPE>, Stack<KEY_TYPE>
#if IARRAY_FEATURE
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
#else
/**
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
*
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
*/
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY, STACK
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IArray, STACK KEY_GENERIC_TYPE
#endif
{
static final int DEFAULT_ARRAY_SIZE = 10;
Expand Down Expand Up @@ -587,6 +595,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
return data[(size() - 1) - index];
}

#if IARRAY_FEATURE
/**
* Provides the Underlying Array in the Implementation
* @return underlying Array
Expand All @@ -606,6 +615,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
return data.getClass() != Object[].class;
}

#endif
#endif
/**
* A Type Specific foreach function that reduces (un)boxing
Expand Down Expand Up @@ -1159,8 +1169,8 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}

#if PRIMITIVES
#if SPLIT_ITERATOR_FEATURE
#if PRIMITIVES && STREAM_FEATURE
/**
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
* @return a Stream of the closest java type
Expand All @@ -1177,4 +1187,5 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
*/
@Override
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, size, 16464); }
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ import speiger.src.collections.utils.Stack;
#else
import speiger.src.collections.objects.utils.ObjectArrays;
#endif
#if PRIMITIVES
#if PRIMITIVES && STREAM_FEATURE && SPLIT_ITERATOR_FEATURE
import java.util.stream.JAVA_STREAM;
import java.util.stream.StreamSupport;
#endif
#if SPLIT_ITERATOR_FEATURE
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
#endif
import speiger.src.collections.utils.ITrimmable;
import speiger.src.collections.utils.SanityChecks;

Expand Down Expand Up @@ -1408,8 +1410,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
if (index < 0 || index > data.length)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
}

#if PRIMITIVES

#if SPLIT_ITERATOR_FEATURE
#if PRIMITIVES && STREAM_FEATURE
/**
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
* @return a Stream of the closest java type
Expand All @@ -1427,6 +1430,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
@Override
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }

#endif
static final class COWIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
{
KEY_TYPE[] data;
Expand Down Expand Up @@ -2080,9 +2084,11 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
}
}

#if SPLIT_ITERATOR_FEATURE
@Override
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 16464); }

#endif
@Override
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.objects.utils.ObjectArrays;
import speiger.src.collections.PACKAGE.utils.ITERATORS;
#if PRIMITIVES
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
import java.util.stream.JAVA_STREAM;
import java.util.stream.StreamSupport;
#endif
#if SPLIT_ITERATOR_FEATURE
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
#endif
import speiger.src.collections.utils.SanityChecks;

#if TYPE_OBJECT
Expand Down Expand Up @@ -487,7 +489,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
}

#if PRIMITIVES
#if SPLIT_ITERATOR_FEATURE
#if PRIMITIVES && STREAM_FEATURE
/**
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
* @return a Stream of the closest java type
Expand All @@ -505,6 +508,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
@Override
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }

#endif
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
int index;

Expand Down
Loading

0 comments on commit 342b0ce

Please sign in to comment.