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

Add EnumArray #1314

Closed
wants to merge 2 commits into from
Closed

Add EnumArray #1314

wants to merge 2 commits into from

Conversation

dangleptr
Copy link
Contributor

@dangleptr dangleptr commented Nov 22, 2019

It will save lots of space occupied when the Enum has only few values.

@nebula-community-bot
Copy link
Member

Unit testing passed.

class isPowerTwo {
public:
enum {
ret = (n != 0) && !(n & (n - 1)),
Copy link
Contributor

Choose a reason for hiding this comment

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

this mean ret is true just when n=1,2,4,8,16... like 0x100000...0000?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, it just handles the unsigned integer.

auto bIdx = blockIndex(idx);
auto offset = bitOffset(idx);
uint64_t mask = v << offset;
blocks_[bIdx] |= mask;
Copy link
Contributor

Choose a reason for hiding this comment

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

is need set 0 to blocks_[bIdx]? if call put with same idx but diffirent e, then maybe can not get correct e?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! We need to handle it.

@nebula-community-bot
Copy link
Member

Unit testing passed.

@dangleptr dangleptr closed this Dec 27, 2019
jievince added a commit to jievince/nebula that referenced this pull request Aug 25, 2021
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Jan 31, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>

Co-authored-by: Lipeng Zhu <lipzhu@icloud.com>
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants