Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create primitiveStream methods for IntSet, LongSet and DoubleSet #1454

Open
donraab opened this issue Apr 16, 2023 · 4 comments
Open

Create primitiveStream methods for IntSet, LongSet and DoubleSet #1454

donraab opened this issue Apr 16, 2023 · 4 comments

Comments

@donraab
Copy link
Contributor

donraab commented Apr 16, 2023

Since 10.0, we have had primitiveStream on IntList, LongList and DoubleList. This makes the following possible:

List<String> list = IntLists.immutable.of(1, 2, 3)
        .primitiveStream()
        .mapToObj(Integer::toString)
        .toList();

Assertions.assertEquals(List.of("1", "2", "3"), list);

There is no equivalent for IntSet, LongSet, and DoubleSet today. This will additionally require creating spliterator() for each of these.

@Novmbrain
Copy link

Hi @donraab I am happy to take a look at this !

@donraab
Copy link
Contributor Author

donraab commented Apr 21, 2023

Thanks for volunteering @Novmbrain ! I have assigned the issue to you.

@Novmbrain
Copy link

Hi @donraab , I am working on this issue. So far, I forked the repository, build the project locally and try to understand the mission.

Referring to the way how primitiveStream was implemented on IntList, LongList and DoubleList , I declared an abstract method in primitiveSet.stg and two default methods.

    /**
     * @since 12.0
     */
    Spliterator.Of<name> spliterator();

    /**
     * @since 12.0
     */
    default <name>Stream primitiveStream()
    {
        return StreamSupport.<type>Stream(this.spliterator(), false);
    }

    /**
     * @since 12.0
     */
    default <name>Stream primitiveParallelStream()
    {
        return StreamSupport.<type>Stream(this.spliterator(), true);
   

Afterwards, I implemented the abstract method spliterator() in

  • eclipse-collections-code-generator/src/main/resources/impl/set/immutable/immutablePrimitiveEmptySet.stg
  • eclipse-collections-code-generator/src/main/resources/impl/set/immutable/immutablePrimitiveSingletonSet.stg
  • eclipse-collections-code-generator/src/main/resources/impl/set/mutable/primitiveHashSet.stg
  • eclipse-collections-code-generator/src/main/resources/impl/set/mutable/synchronizedPrimitiveSet.stg
  • eclipse-collections-code-generator/src/main/resources/impl/set/mutable/unmodifiablePrimitiveSet.stg

I guess I still need to update the files under packageeclipse-collections-code-generator/src/main/resources/impl/map,

  • eclipse-collections-code-generator/src/main/resources/impl/map/abstractMutablePrimitiveKeySet.stg
  • eclipse-collections-code-generator/src/main/resources/impl/map/mutable/immutablePrimitiveMapKeySet.stg

Do I misunderstand or miss something?

Thanks and looking forward to your reply :)

@BrijeshPatra
Copy link

Hi @Novmbrain I am happy to work on this can you please give me a clue or something about the package or class I completed the setup of this project in my Local IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants