Skip to content

Implement mutable vectors using arrays#173

Merged
utdemir merged 3 commits intomasterfrom
ud/vectors-from-arrays
Sep 9, 2020
Merged

Implement mutable vectors using arrays#173
utdemir merged 3 commits intomasterfrom
ud/vectors-from-arrays

Conversation

@utdemir
Copy link
Copy Markdown
Contributor

@utdemir utdemir commented Sep 7, 2020

This PR implements mutable vectors in terms of mutable arrays; removing the duplicated logic and some unsafe calls. The existing tests pass, and the module still provides the same interface.

Here are the major changes:

  • Mutable arrays now expose readUnsafe and writeUnsafe functions which omit bounds-checking.
  • Mutable vectors now only store their size instead of a tuple of (size, capacity). The capacity now can be obtained from the size of the underlying array.

Closes #144. Also, a prerequisite of #165.

This removes a bounds check when the user is sure that the given
index is within bounds. This is the case with vectors, since it
does its own bounds-checking.
Copy link
Copy Markdown
Contributor

@Divesh-Otwani Divesh-Otwani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor changes -- feel free to merge directly after addressing them 😄

@utdemir utdemir merged commit c560df8 into master Sep 9, 2020
@utdemir utdemir deleted the ud/vectors-from-arrays branch September 9, 2020 22:50
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.

Implement mutable Vector's using mutable Array's

2 participants