All Projects → amaembo → Streamex

amaembo / Streamex

Licence: apache-2.0
Enhancing Java Stream API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Streamex

Awesome Flutter
An awesome list that curates the best Flutter libraries, tools, tutorials, articles and more.
Stars: ✭ 38,582 (+2067.53%)
Mutual labels:  collections
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (-36.63%)
Mutual labels:  collections
Best Of Python
🏆 A ranked list of awesome Python open-source libraries and tools. Updated weekly.
Stars: ✭ 1,869 (+5%)
Mutual labels:  collections
Collecterator
Generator based PHP Collections
Stars: ✭ 33 (-98.15%)
Mutual labels:  collections
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-96.8%)
Mutual labels:  collections
Vvedenie Mashinnoe Obuchenie
📝 Подборка ресурсов по машинному обучению
Stars: ✭ 1,282 (-27.98%)
Mutual labels:  collections
Goodies
Useful stuff missing from .NET for example duck typing, CSP channels, caching, money, typed ids...
Stars: ✭ 11 (-99.38%)
Mutual labels:  collections
Dictomaton
Finite state dictionaries in Java
Stars: ✭ 124 (-93.03%)
Mutual labels:  collections
Amazing Windows Apps
📗Introduce you amazing Windows apps🕶READ ONLINE 👉
Stars: ✭ 1,102 (-38.09%)
Mutual labels:  collections
F
Functional stuff for Python
Stars: ✭ 113 (-93.65%)
Mutual labels:  collections
Mtgdesktopcompanion
Cards manager for magic the gathering
Stars: ✭ 44 (-97.53%)
Mutual labels:  collections
Phpcollections
A set of collections for PHP.
Stars: ✭ 53 (-97.02%)
Mutual labels:  collections
Ext Collections
Array manipulation extension for PHP.
Stars: ✭ 94 (-94.72%)
Mutual labels:  collections
Awesome Seo
Google SEO研究及流量变现
Stars: ✭ 942 (-47.08%)
Mutual labels:  collections
Utils.js
Useful JavaScript Functions Collection 一些很实用的JavaScript函数封装集合
Stars: ✭ 121 (-93.2%)
Mutual labels:  collections
Koloboke
Java Collections till the last breadcrumb of memory and performance
Stars: ✭ 909 (-48.93%)
Mutual labels:  collections
Cyclops
An advanced, but easy to use, platform for writing functional applications in Java 8.
Stars: ✭ 1,180 (-33.71%)
Mutual labels:  collections
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-92.98%)
Mutual labels:  collections
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (-93.2%)
Mutual labels:  collections
Miniboxing Plugin
Miniboxing is a program transformation that improves the performance of Scala generics when used with primitive types. It can speed up generic collections by factors between 1.5x and 22x, while maintaining bytecode duplication to a minimum. You can easily add miniboxing to your sbt project:
Stars: ✭ 106 (-94.04%)
Mutual labels:  collections

StreamEx 0.8.1

Enhancing Java Stream API.

Maven Central Javadocs Build Status Coverage Status

This library defines four classes: StreamEx, IntStreamEx, LongStreamEx, DoubleStreamEx which are fully compatible with Java 8 stream classes and provide many additional useful methods. Also EntryStream class is provided which represents the stream of map entries and provides additional functionality for this case. Finally, there are some new useful collectors defined in MoreCollectors class as well as primitive collectors concept.

Full API documentation is available here.

Take a look at the Cheatsheet for brief introduction to the StreamEx!

Before updating StreamEx check the migration notes and full list of changes.

StreamEx library main points are following:

  • Shorter and convenient ways to do the common tasks.
  • Better interoperability with older code.
  • 100% compatibility with original JDK streams.
  • Friendliness for parallel processing: any new feature takes the advantage on parallel streams as much as possible.
  • Performance and minimal overhead. If StreamEx allows to solve the task using less code compared to standard Stream, it should not be significantly slower than the standard way (and sometimes it's even faster).

Examples

Collector shortcut methods (toList, toSet, groupingBy, joining, etc.)

List<String> userNames = StreamEx.of(users).map(User::getName).toList();
Map<Role, List<User>> role2users = StreamEx.of(users).groupingBy(User::getRole);
StreamEx.of(1,2,3).joining("; "); // "1; 2; 3"

Selecting stream elements of specific type

public List<Element> elementsOf(NodeList nodeList) {
    return IntStreamEx.range(nodeList.getLength())
      .mapToObj(nodeList::item).select(Element.class).toList();
}

Adding elements to stream

public List<String> getDropDownOptions() {
    return StreamEx.of(users).map(User::getName).prepend("(none)").toList();
}

public int[] addValue(int[] arr, int value) {
    return IntStreamEx.of(arr).append(value).toArray();
}

Removing unwanted elements and using the stream as Iterable:

public void copyNonEmptyLines(Reader reader, Writer writer) throws IOException {
    for(String line : StreamEx.ofLines(reader).remove(String::isEmpty)) {
        writer.write(line);
        writer.write(System.lineSeparator());
    }
}

Selecting map keys by value predicate:

Map<String, Role> nameToRole;

public Set<String> getEnabledRoleNames() {
    return StreamEx.ofKeys(nameToRole, Role::isEnabled).toSet();
}

Operating on key-value pairs:

public Map<String, List<String>> invert(Map<String, List<String>> map) {
    return EntryStream.of(map).flatMapValues(List::stream).invert().grouping();
}

public Map<String, String> stringMap(Map<Object, Object> map) {
    return EntryStream.of(map).mapKeys(String::valueOf)
        .mapValues(String::valueOf).toMap();
}

Map<String, Group> nameToGroup;

public Map<String, List<User>> getGroupMembers(Collection<String> groupNames) {
    return StreamEx.of(groupNames).mapToEntry(nameToGroup::get)
        .nonNullValues().mapValues(Group::getMembers).toMap();
}

Pairwise differences:

DoubleStreamEx.of(input).pairMap((a, b) -> b-a).toArray();

Support of byte/char/short/float types:

short[] multiply(short[] src, short multiplier) {
    return IntStreamEx.of(src).map(x -> x*multiplier).toShortArray(); 
}

Define custom lazy intermediate operation recursively:

static <T> StreamEx<T> scanLeft(StreamEx<T> input, BinaryOperator<T> operator) {
        return input.headTail((head, tail) -> scanLeft(tail.mapFirst(cur -> operator.apply(head, cur)), operator)
                .prepend(head));
}

And more!

License

This project is licensed under Apache License, version 2.0

Installation

Releases are available in Maven Central

Before updating StreamEx check the migration notes and full list of changes.

Maven

Add this snippet to the pom.xml dependencies section:

<dependency>
  <groupId>one.util</groupId>
  <artifactId>streamex</artifactId>
  <version>0.8.1</version>
</dependency>

Gradle

Add this snippet to the build.gradle dependencies section:

implementation 'one.util:streamex:0.8.1'

Pull requests are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].