Giter VIP home page Giter VIP logo

jenumerable's Introduction

Java Enumerable

This is an implementation of deferred lazy collections using Java. Inspired by F#, C#, and Haskell. The goal is to make working with iterable items easier. Most list processing is a series of transformations and iterations. By leveraging simple and composable functions you can reduce edge cases, off by 1 errors, extraneous processing and unintentional performance bottlenecks. Also, you can easily create (and end) infinite lazy streams.

Currently JEnumerable provides

  • Map
  • Zip
  • Zip3
  • Filter
  • FlatMap
  • Order
  • OrderBy
  • OrderDesc
  • OrderByDesc
  • Take
  • TakeWhile
  • Skip
  • SkipWhile
  • Iter
  • Iteri
  • DistinctUnion
  • Distinct
  • DistinctBy
  • Intersect
  • Except
  • First
  • Last
  • Nth
  • Fold
  • FoldWithDefaultSeed
  • Any
  • All
  • Windowed
  • Tails
  • Pairwise
  • GroupRuns
  • Intersperse
  • Intercalate
  • ToDictionary
  • ToGroupedDictionary
  • Range
  • Min
  • Max
  • MinBy
  • MaxBy

And infinite sequence generation with

  • Yield
  • Yield break
  • Yield bang

Some functionality exists in Java 8 streams, but more is here. Initial benchmarks show that JEnumerable is comporable in speed to JDK8 streams. JDK8 streams, however, does parallelized optimizations which this does not, so can be bettter performant sometimes.

Check here for examples.

Benchmarks

Initial benchmarks are as follows. The first element is the native streams function. The second element is JEnumerable's performance in milliseconds. As you can see JEnumerable is reasonably comporable, sometimes slower, sometimes faster, but for reasonably sized lists the performance is equal. This is just an example, since many functions in JEnumerable are not duplicated in Java 8 streams and so can't be comporably benchmarked.

Element# Reduce Map Min Order Distinct Filter
1 (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
10 (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
100 (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
1000 (0,0) (0,0) (0,0) (0,2) (1,1) (0,0)
10000 (1,2) (1,2) (0,3) (2,14) (3,3) (1,2)
100000 (3,10) (6,9) (1,14) (9,92) (7,11) (2,4)
1000000 (11,20) (16,73) (13, 22) (41, 1080) (386, 75) (15, 26)
10000000 (555,437) (10253, 636) (118, 184) (165, 15122) (1485, 4417) (146, 266)

Check here for the benchmark code

jenumerable's People

Contributors

devshorts avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.