r/ProgrammerHumor • • 15d ago

Meme cppAndItsVectorBooleans

Post image
3.4k Upvotes

214 comments sorted by

View all comments

Show parent comment

2

u/Mountain-Ox 14d ago

The case I had at a previous job was we need to know if a retailer was available at a given time. We need to be able to check a lot of them very quickly. So we had a string of 1s and 0s, each one indicated a 15 minute segment of the week. That's too many bits to fit in an integer for a simple bitwise operator. I don't recall the implementation details anymore, but we the I/O for loading thousands of these strings for processing was kind of slow. It was PHP which didn't help.

2

u/autumnal-lights 14d ago edited 14d ago

? i mean isn't this perfect for bits tho? like

~ A & ~ B and then just like

a ~ custom u number_large_enough;

the scans are trivial tho :shrug:

and like workday perfectly fits into u64, and 3 u64's perfectly align with the 24 hours? like? that's perf?

1

u/amshegarh 14d ago

That is interesting, but you can directly use pg for that (assuming you had one?)

Otherwise its just an array of ints (instead of one) + bitwise logic

1

u/Mountain-Ox 14d ago

We were on MySQL, this was during the lamp stack days. And I don't know if MySQL ever added features like that. I don't think it had native json support.

1

u/autumnal-lights 13d ago

not sure why you're being downvoted, array is on the stack, it's the same as a class which packs like 3 ints?