Questions tagged [count]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
4 answers

API design: Should a count() of a set of consecutively-id'ed elements return a size type?

I'm writing C++ code, where the standard library has an idiomatic type for representing sizes: std::size_t. Now, I'm writing a function which counts certain kinds of objects; and these objects have ...
einpoklum's user avatar
  • 2,496
0 votes
3 answers

Frequency distribution by range algorithm

I have an array of unsorted positive real numbers. I need to create a frequency distribution by their ranges. The simplest approach goes like this for num in numbers if (num > 0 and num < 10) ...
Sudhanshu 'Sid' Vishnoi's user avatar
3 votes
2 answers

Explanation to why Counting bits set, Brian Kernighan's way works

I found this link to count number of bits in a variable. I think it is pretty cool, but I can't figure out why it works. Can someone offer an explanation? Here is the code unsigned int v; // count ...
flashburn's user avatar
  • 147
2 votes
3 answers

Count unique visitors by group of visited places

I'm facing the problem of counting the unique visitors of groups of places. Here is the situation: I have visitors that can visit places. For example, that can be internet users visiting web pages, ...
Mathieu's user avatar
  • 980
7 votes
2 answers

Is checking count/size/length less than 0 necessary in modern languages?

Is checking count/size/length less than 0 necessary in modern languages anymore? For instance, in C# I quote often will check if a collection's count is less than or equal to 0. I assume that this ...
TruthOf42's user avatar
  • 762
14 votes
4 answers

Number of Classes in a Namespace - Code Smell?

I have a C# library that's used by several executables. There's only a couple namespaces in the library, and I just noticed that one of the namespaces has quite a few classes in it. I've always ...
Tim Claason's user avatar