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

VectorBuilder should allow access to current element count #9904

Closed
scabug opened this issue Aug 25, 2016 · 9 comments
Closed

VectorBuilder should allow access to current element count #9904

scabug opened this issue Aug 25, 2016 · 9 comments

Comments

@scabug
Copy link

scabug commented Aug 25, 2016

Currently VectorBuilder doesn't allow access to the current element count which forces one to keep external counters in all cases where this information is important.

The proposal is to add these three methods to the VectorBuilder class:

    def size: Int = blockIndex + lo
    def isEmpty: Boolean = size == 0
    def nonEmpty: Boolean = size != 0
@scabug
Copy link
Author

scabug commented Aug 25, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9904?orig=1
Reporter: Mathias Doenitz (sirthias)
Assignee: @cbilgin
Affected Versions: 2.12.0-M5

@scabug
Copy link
Author

scabug commented Oct 31, 2016

@dragos said:
What are some cases where this information is needed?

@scabug
Copy link
Author

scabug commented Oct 31, 2016

Mathias Doenitz (sirthias) said:
One simple case for me:

Some code supports collecting elements into a builder up until a defined maximum size.
If this size is exceeded some error is to be raised.
Trivial if the builder allows access to the current element count.
In the current state I need to maintain an additional external counter.

@scabug
Copy link
Author

scabug commented Nov 17, 2016

@cbilgin said:
Hi all,

Can I assign this to myself and take shot it?

@scabug
Copy link
Author

scabug commented Nov 18, 2016

@retronym said:
Sure! You are now in the correct user group in JIRA to be assigned and otherwise manage tickets.

@scabug
Copy link
Author

scabug commented Nov 18, 2016

@retronym said:
Although, looks like someone has taken this up already: scala/scala#5489

Perhaps you can collaborate to look at the questions about whether and how this should be generalized to all Builders.

@eed3si9n
Copy link
Member

eed3si9n commented Feb 6, 2018

scala/scala#5489 was sent for this, and was closed:

All collections stuff is likely to get overhauled as part of the https://github.com/scala/collection-strawman, so at the moment, I don't think it would make sense to accept this (or to leave it in the queue). We can always revisit/reopen later.

@SethTisue
Copy link
Member

would someone like to look and see if this is already fixed in strawman or not...?

@NthPortal
Copy link

It is not yet fixed in strawman (as of now).

I can PR it if desired.

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

4 participants