GithubHelp home page GithubHelp logo

jcornaz / collekt Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 0.0 313 KB

Persistent (immutable) collections for Kotlin

License: MIT License

Kotlin 100.00%
functional-programming immutable-collections kotlin library persistent-data-structure

collekt's People

Contributors

dependabot[bot] avatar jcornaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

collekt's Issues

Make the immutable collections implement standard collection interfaces

Pros

  • Smoother integration with any other library/codebase
  • No need to maintain (document and test) helpers like first, forEach, any in this project. (less code = less bugs)

Cons

  • explicit import of com.github.jcornaz.collekt.* may be necessary for ractive operator like filter, map, etc.

Overall the advantages seems bigger, especially, if we consider the explicit import is not necessary for + and -, and forgetting it for reactive operator like filter, map etc. would not affect correctness (only performances).

filter/map operators

Here is the minimum operator list that should be available for immutable collections:

  • filter
  • filterIsInstance
  • filterNotNull
  • map
  • mapNotNull
  • flatMap

Remove dexx

Dexx is obviously discontinued and should be removed from this project.

Alternatives:

Paguro provide efficient implementations for Java 8+. This project show some activity, and was very quick to fix the only issue reported.

As PCollection don't support null elements, and vavri.io is not compatible with java version prior to 8, the best is probably to drop Java 6/7 support for now.

Remove irrelevant member function from interfaces

  • contains belongs to sets only. Other collection type should use any, none or all extension functions
  • iterator() could be extracted to a Traversable interface (name may be improved).
  • size and isEmpty could be extracted to a Sized interface
  • There could be a difference between Immutable and Persistent to not force immutable implementations to implement plus/minus

Add empty() member in persistent interfaces

Currently the only way to perform an equivalent of clear is to use an emptyPersistent*() function. But this completely ignore the persistent data structure used. So an empty method present in the persistent interface would make possible to get an empty version of the same implementation.

Check support of null elements

If null elements are supported, it should be tested.
If null elements are not supported, non-null element types should be enforced by the compiler.

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.