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

Simple implementation of SmartVector. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bbelovic
Copy link
Collaborator

Hello everyone,
it is late evening and I have just implemented simple Smartvector.

It uses linked list under the hood. Implementation passes tests we developed on last Wednesday, but it fails a new test I added today. It turns out that storing indexes into bitmap is somehow flawed. It can return wrong value for requested index depending on how we grow linked list, this is demonstrated in fourth test case called TestStoreBothDifferentAndEqualAdjacentValues.

This test case adds 4 values to SmartVector:

v.Set(0, 10)
v.Set(1, 11)
v.Set(2, 12)
v.Set(5, 10)

which result in linked list with following structure

[101:10]->[001:11]->[010:12]

then we query for value at index 1 (binary 001) we get value 10 from the vector which is wrong as we should get value 11.

As I said results depend on how we grow underlying linked list.

@rhcarvalho
Copy link
Member

@bbelovic how about we add this new code to a new directory? Something like 2017/2017-03-08/smartvector_bbelovic/...?

@bbelovic
Copy link
Collaborator Author

Ok, no problem we can move the code to a new directory.

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

Successfully merging this pull request may close these issues.

None yet

2 participants