Skip to content

Commit

Permalink
First draft of the 0.8.0 patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Speiger committed Dec 19, 2022
1 parent 96458bd commit efd29bb
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog of versions

### Version 0.8.0 (Unreleased)
### Version 0.8.0
- Added: ISizeProvider interface (Optimization Helper)
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
Expand All @@ -11,6 +11,7 @@
- Added: Optimizations for HashUtils next power of function.
- Added: toArray() now returns a cached empty array if the collection is empty.
- Added: toArray function for AsyncBuilder
- Added: Modularization to the library where feature can be disabled as needed. (Requires Self-Compilation)
- Fixed: putIfAbsent now replaces defaultValues
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
Expand Down
41 changes: 41 additions & 0 deletions EXTRAS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
### Extra Features

Primitive Collections comes with a few extra features that are disabled by default.
These will be enabled as soon they become relevant or never at all.

But some of these can be already unlocked when the target version changes.

If you compile the library for yourself you will automatically gain access to said features.

### Java17 Exclusive Features
Java17 has some new features that can sadly not really be back-ported but the library still supports them if it is compiled with java17

- RandomGenerator: Java17 has added [RandomGenerator.class](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/RandomGenerator.html).
This allows to use custom random implementations without having to re-implement them yourselves.


### ModuleSettings
Primitive Collections is a huge library.
But maybe you only use like 5-10 different classes.
Normally you would use tools like "Proguard" to get rid of classes that you don't use.
But since a lot of classes have dependencies on each other this would only do so much.

This is where the [ModuleSettings](ModuleSettings.json) come into play.
It allows you to turn of implementations as you wish and adjusts the code that everything still works.

There is 3 layers of control inside of the ModuleSettings.
- Modules directly at the top that turn off everything.
- Type Specific configurations, where you can for example turn of everything thats "Long" based.
- And then there is each type specific module settings.

Allowing for greater control without having to edit hundreds of lines of code.
On top of that:
Any Setting that isn't "Present" is counted as "Enabled".
So if you want to disable just 1 thing you can keep that 1 thing and delete the rest of the Setting.
It will still work as the same.
The default settings just come with everything so you can see what is controllable.

How to compile the Code with the ModuleSettings enabled:
```
/gradlew.bat generateLimitSource build -x test
```
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Benchmarks can be found here: [[Charts]](https://github.com/Speiger/Primitive-Co
[Here](features.md) you find a set of features added to Primitive Collections.
These are designed to improve performance or to provide Quality of Life.

[Here](EXTRAS.md) you also find features that can be used when you compile the library for yourself.
These features are not used by default to have a wider range of compat, or require self compilation.
Such as pruning classes that are not needed in your code.

## Main Features:
- ArrayLists / LinkedLists / CopyOnWriteLists
- HashSets/Maps (Linked & HashControl)
Expand Down Expand Up @@ -71,7 +75,11 @@ Please if you want to contribute follow the [Rule-Sheet](RuleSheet.md). It keeps
# How to Build

The SourceCode can be generated via:
```
/gradlew.bat generateSource
```

to generate SourceCode and build the jar:
/gradlew.bat build
```
/gradlew.bat build
```
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ task generateTestSource(type: JavaExec) {
args = ['tests', 'silent']
}

task generateLimitSource(type: JavaExec) {
group = 'internal'
description = 'Builds the Sourcecode with the ModuleSettings.json applied'
classpath = sourceSets.builder.runtimeClasspath
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
args = ['silent', 'load']
}

task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
setResult(wrapper.TO_ARRAY());
#endif
wrapper = null;
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_BOOLEAN
import speiger.src.collections.utils.HashUtil;
Expand Down Expand Up @@ -777,6 +778,8 @@ public class COLLECTIONS
@Override
public void forEach(Consumer<? super CLASS_TYPE> action) { synchronized(mutex) { c.forEach(action); } }
#endif
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { synchronized(mutex) { c.forEachIndexed(action); } }
@Override
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
@Override
Expand Down Expand Up @@ -902,6 +905,8 @@ public class COLLECTIONS
@Override
public void forEach(Consumer<? super CLASS_TYPE> action) { c.forEach(action); }
#endif
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { c.forEachIndexed(action); }
@Override
public int hashCode() { return c.hashCode(); }
@Override
Expand Down

0 comments on commit efd29bb

Please sign in to comment.