https://github.com/blackbaroness/fastutil-extender
Library built under the fastutil which offers various methods for creating collections, which makes your code more efficient and faster
https://github.com/blackbaroness/fastutil-extender
boilerplate collections fastutil java library optimization primitive-collections
Last synced: 2 months ago
JSON representation
Library built under the fastutil which offers various methods for creating collections, which makes your code more efficient and faster
- Host: GitHub
- URL: https://github.com/blackbaroness/fastutil-extender
- Owner: BlackBaroness
- License: mit
- Created: 2023-03-17T20:54:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T01:41:28.000Z (4 months ago)
- Last Synced: 2025-03-26T18:21:20.629Z (3 months ago)
- Topics: boilerplate, collections, fastutil, java, library, optimization, primitive-collections
- Language: Java
- Homepage:
- Size: 332 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Extension built under a [fastutil](https://github.com/vigna/fastutil) library
Don't waste your time by specifying a load factor, creating convertation algorithms,
collectors and other boring boilerplate things!You need Java 8+ to use this.
## Import to your project
Maven:
```xml
io.github.blackbaroness
fastutil-extender-common
1.2.0```
Gradle (Groovy SDK):
```groovy
implementation 'io.github.blackbaroness:fastutil-extender-common:1.2.0'
```Gradle (Kotlin SDK):
```kotlin
implementation("io.github.blackbaroness:fastutil-extender-common:1.2.0")
```## Features
### 1. Fastest load factors by default
While doing benchmarks, I realized that load factor 0.25 significantly speeds up
hash-based collections, wasting just a bit of RAM. If you don't feel sorry for the
extra 1MB of RAM, this library is for you.### 2. Cool stateless factories for lists and sets
```java
IntListFactory factory = FastList.ints;// default
factory.create();// with size
factory.create(10);// of array of boxed types
factory.of(1, 2, 3);// of array of primitive types
factory.ofArray(1, 2, 3);// convert from another type
List stringList = FastList.objects.of("1", "2", "3");
factory.convert(stringList, Integer::parseInt);// make unmodifiable of synchronized
factory.unmodifiable(factory.create());
factory.synchronize(factory.create());// use collectors for streams
IntStream.of(1, 2, 3).boxed().collect(factory.collector());
IntStream.of(1, 2, 3).boxed().collect(factory.unmodifiableCollector());// or use super cool builders
IntList list = factory.builder()
.size(100)
.content(1, 2, 3)
.threadsafe()
.unmodifiable()
.build();
```### 3. Simple map factory
```java
// default
FastMap.newMap();// with size
FastMap.newByte2ShortSortedMap(30);// of pairs (currently only for objects)
FastMap.newMap(
Pair.of("s1", "s2")
);// make unmodifiable or synchronized
FastMap.unmodifiable(FastMap.newInt2IntMap());
FastMap.synchronize(FastMap.newByte2FloatMap());
```### 4. Guice support
You must add `fastutil-extender-guice` module for this.
Combine your modules with fastutil-extender:
```java
Module module = Modules.combine(/* your modules */, new FastUtilExtenderFactoriesModule());
```Now factories will be injected into your classes:
```java
class Example {
private final List list;@Inject
public Example(BooleanListFactory booleanListFactory) {
this.list = booleanListFactory.builder().threadsafe().build();
}
}
```