bitset

Auto increment in MongoDB to store sequence of Unique User ID

纵然是瞬间 提交于 2019-11-26 05:36:18
问题 I am making a analytics system, the API call would provide a Unique User ID, but it\'s not in sequence and too sparse. I need to give each Unique User ID an auto increment id to mark a analytics datapoint in a bitarray/bitset. So the first user encounters would corresponding to the first bit of the bitarray, second user would be the second bit in the bitarray, etc. So is there a solid and fast way to generate incremental Unique User IDs in MongoDB? 回答1: You can, but you should not https://web

Define bitset size at initialization?

一笑奈何 提交于 2019-11-26 02:24:28
问题 I want to make a bitset in C++. I did a bit of research. All examples I found where like this: bitset<6> myBitset; // do something with it But I don\'t know the size of the bitset when I define the variable in my class: #include <bitset> class Test { public: std::bitset *myBitset; } This won\'t compile... And initializing like this also doesn\'t work: int size = getDependentSizeForBitset(); myBitset = new bitset<size>(); 回答1: Boost has a dynamic_bitset you can use. Alternatively, you can use