Mark one-parameter constructors as explicit & use override where possible

This commit marks (hopefully) ever one-parameter constructor as explicit.

It also uses override in (hopefully) all circumstances where a virtual
method is overridden.

There are a very few other minor changes - most of them were necessary
to get everything to compile (like one additional constructor). In one
case I changed an implicit operation to an explicit string conversion -
I think the automatically chosen conversion was much more convoluted.

This took longer than I want to admit but not as long as I feared :)
This commit is contained in:
Johanna Amann 2018-03-16 22:14:22 -07:00
parent 1f2bf50b49
commit 6d612ced3d
173 changed files with 1052 additions and 1046 deletions

View file

@ -19,7 +19,7 @@ public:
/**
* Destructor.
*/
virtual ~BloomFilter();
~BloomFilter() override;
/**
* Adds an element to the Bloom filter.
@ -103,7 +103,7 @@ protected:
*
* @param hasher The hasher to use for this Bloom filter.
*/
BloomFilter(const Hasher* hasher);
explicit BloomFilter(const Hasher* hasher);
const Hasher* hasher;
};
@ -127,7 +127,7 @@ public:
/**
* Destructor.
*/
~BasicBloomFilter();
~BasicBloomFilter() override;
/**
* Computes the number of cells based on a given false positive rate
@ -158,11 +158,11 @@ public:
static size_t K(size_t cells, size_t capacity);
// Overridden from BloomFilter.
virtual bool Empty() const override;
virtual void Clear() override;
virtual bool Merge(const BloomFilter* other) override;
virtual BasicBloomFilter* Clone() const override;
virtual string InternalState() const override;
bool Empty() const override;
void Clear() override;
bool Merge(const BloomFilter* other) override;
BasicBloomFilter* Clone() const override;
string InternalState() const override;
protected:
DECLARE_SERIAL(BasicBloomFilter);
@ -173,8 +173,8 @@ protected:
BasicBloomFilter();
// Overridden from BloomFilter.
virtual void Add(const HashKey* key) override;
virtual size_t Count(const HashKey* key) const override;
void Add(const HashKey* key) override;
size_t Count(const HashKey* key) const override;
private:
BitVector* bits;
@ -200,14 +200,14 @@ public:
/**
* Destructor.
*/
~CountingBloomFilter();
~CountingBloomFilter() override;
// Overridden from BloomFilter.
virtual bool Empty() const override;
virtual void Clear() override;
virtual bool Merge(const BloomFilter* other) override;
virtual CountingBloomFilter* Clone() const override;
virtual string InternalState() const override;
bool Empty() const override;
void Clear() override;
bool Merge(const BloomFilter* other) override;
CountingBloomFilter* Clone() const override;
string InternalState() const override;
protected:
DECLARE_SERIAL(CountingBloomFilter);
@ -218,8 +218,8 @@ protected:
CountingBloomFilter();
// Overridden from BloomFilter.
virtual void Add(const HashKey* key) override;
virtual size_t Count(const HashKey* key) const override;
void Add(const HashKey* key) override;
size_t Count(const HashKey* key) const override;
private:
CounterVector* cells;

View file

@ -26,7 +26,7 @@ public:
*
* @pre `cells > 0 && width > 0`
*/
CounterVector(size_t width, size_t cells = 1024);
explicit CounterVector(size_t width, size_t cells = 1024);
/**
* Copy-constructs a counter vector.
@ -38,7 +38,7 @@ public:
/**
* Destructor.
*/
~CounterVector();
~CounterVector() override;
/**
* Increments a given cell.

View file

@ -43,7 +43,7 @@ public:
/**
* Destructor.
*/
virtual ~Hasher() { }
~Hasher() override { }
/**
* Computes hash values for an element.
@ -138,7 +138,7 @@ public:
*
* @param arg_seed The seed to use for this instance.
*/
UHF(Hasher::seed_t arg_seed);
explicit UHF(Hasher::seed_t arg_seed);
template <typename T>
Hasher::digest operator()(const T& x) const
@ -204,9 +204,9 @@ public:
DefaultHasher(size_t k, Hasher::seed_t seed);
// Overridden from Hasher.
virtual digest_vector Hash(const void* x, size_t n) const final;
virtual DefaultHasher* Clone() const final;
virtual bool Equals(const Hasher* other) const final;
digest_vector Hash(const void* x, size_t n) const final;
DefaultHasher* Clone() const final;
bool Equals(const Hasher* other) const final;
DECLARE_SERIAL(DefaultHasher);
@ -232,9 +232,9 @@ public:
DoubleHasher(size_t k, Hasher::seed_t seed);
// Overridden from Hasher.
virtual digest_vector Hash(const void* x, size_t n) const final;
virtual DoubleHasher* Clone() const final;
virtual bool Equals(const Hasher* other) const final;
digest_vector Hash(const void* x, size_t n) const final;
DoubleHasher* Clone() const final;
bool Equals(const Hasher* other) const final;
DECLARE_SERIAL(DoubleHasher);

View file

@ -45,12 +45,12 @@ public:
*
* @return A newly initialized TopkVal
*/
TopkVal(uint64 size);
explicit TopkVal(uint64 size);
/**
* Destructor.
*/
~TopkVal();
~TopkVal() override;
/**
* Call this when a new value is encountered. Note that on the first