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

Why doesn't IntArrayList allow wrapping for int array less than 10 elements? #182

Closed
happy15 opened this issue Sep 22, 2019 · 2 comments
Closed

Comments

@happy15
Copy link

happy15 commented Sep 22, 2019

Hi there,

I am new to agrona and tried to feel the usage of IntArrayList. Below is what I tried:

int[] a = new int[]{1,2,3};
IntArrayList ial = new IntArrayList();
ial.wrap(a, a.length);

Of cause this code complains about illegal initial array length 3, minimum required is 10.

I read the code and I can see how this happens. What I don't understand are:

  1. why do I need to provide initial size to wrap an existing int array? since it can be figured out by a.length.
  2. why can't I wrap a int array less than 10 elements? since IMHO the requirements to capacity are to be big enough to contain the data and to auto increase/decrease on demand.

Anything I missed here? Looking forward to the rationale.

@mjpt777
Copy link
Contributor

mjpt777 commented Sep 22, 2019

It was a pragmatic lower bound and having to deal with a special case of a zero length array when resizing. It is all that was required for our use. I've made it more flexible with the latest change.

@mjpt777 mjpt777 closed this as completed Sep 22, 2019
@happy15
Copy link
Author

happy15 commented Sep 22, 2019

Good to know and thanks for the reply.

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

No branches or pull requests

2 participants