size() method from fcf::NTest::HistogramBasic class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.5
Returns the number of bins (size of the internal vector) or resizes the histogram.
The
- Read Mode: When called without arguments, it returns the current number of bins in the histogram.
- Write Mode: When called with a
size_t argument, it resizes the histogram to the specified number of bins, rebuilding the internal data distribution.
Arguments
- The desired new number of bins. Must be greater than 1.
Result
- The current number of bins.
Example: Checking and Resizing Histogram
Demonstrating how to get the current size and then resize the histogram.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
FCF_TEST_DEFINE ("HistogramDemo", "SizeTest", "Resize") {
fcf::NTest::HistogramBasic <int> hist(10);
// 1. Get current size
size_t currentSize = hist.size ();
fcf::NTest::log () << "Current size: " << currentSize << std::endl;
// 2. Resize the histogram
hist.size (50);
fcf::NTest::log () << "New size: " << hist.size () << std::endl;
FCF_TEST (currentSize == 10 && hist.size () == 50);
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
Performing the test: "HistogramDemo" -> "SizeTest" -> "Resize" ...
> Current size: 10
> New size: 50
[SUCCESS] Test completed successfully (0.000`027`863 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`027`863 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.