This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add a utility data structure named FixedVector.
ClosedPublic

Authored by sivachandra on Aug 7 2022, 11:15 PM.

Details

Summary

This data structure uses a backing cpp::array object and supports a
vector like push_back API. In comparison with a traditional vector
data structure, it is of a fixed capacity and cannot be resized.

Diff Detail

Event Timeline

sivachandra created this revision.Aug 7 2022, 11:15 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 7 2022, 11:15 PM
sivachandra requested review of this revision.Aug 7 2022, 11:15 PM
michaelrj added inline comments.Aug 8 2022, 11:04 AM
libc/src/__support/arraystore.h
15

Currently, there is no way to add or remove elements that aren't at the end of the array. I would say either add operator[] or rename this to ArrayStack.

sivachandra added inline comments.Aug 8 2022, 11:22 AM
libc/src/__support/arraystore.h
15

Currently, there is no way to add or remove elements that aren't at the end of the array.

What do you mean "at the end of the array"? This data structure is not to be used like an array. It's internal storage uses an array.

I would say either add operator[] or rename this to ArrayStack.

We normally add methods as required. There is no requirement for operator[] so it isn't present. Its not clear to me how the presence or absence of that method should affect the name. I am open to a better name though. The name ArrayStore was chosen in the same pattern as that of the current cpp::BlockStore. Some other languages have similar concepts named FixedVector. I can change the name to that if it sounds better.

Change the name of the data structure to FixedVector.

sivachandra retitled this revision from [libc] Add a utility data structure named ArrayStore. to [libc] Add a utility data structure named FixedVector..Aug 8 2022, 4:01 PM
sivachandra edited the summary of this revision. (Show Details)

I am going to submit this now in order to make progress with other things. Feel free to add comments and I will address them post commit.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 9 2022, 2:30 PM
This revision was automatically updated to reflect the committed changes.