Commit 8acad618 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Apply changes from clang-tidy readability-container-size-empty.

parent 9f49657e
......@@ -76,7 +76,7 @@ void SaveNXTomo::exec() {
} catch (...) {
}
if (m_workspaces.size() != 0)
if (!m_workspaces.empty())
processAll();
}
......@@ -96,7 +96,7 @@ bool SaveNXTomo::processGroups() {
} catch (...) {
}
if (m_workspaces.size() != 0)
if (!m_workspaces.empty())
processAll();
return true;
......
......@@ -378,7 +378,7 @@ TMDE(bool MDBox)::isDataAdded() const {
if (m_Saveable->isLoaded())
return data.size() != m_Saveable->getFileSize();
}
return (data.size() != 0);
return (!data.empty());
}
//-----------------------------------------------------------------------------------------------
......
......@@ -1973,7 +1973,7 @@ void EventList::histogramForWeightsHelper(const std::vector<T> &events,
//---------------------------------
// Do we even have any events to do?
if (events.size() > 0) {
if (!events.empty()) {
// Iterate through all events (sorted by tof)
auto itev = findFirstEvent(events, X[0]);
auto itev_end = events.cend();
......@@ -2167,7 +2167,7 @@ void EventList::generateCountsHistogramPulseTime(const MantidVec &X,
//---------------------- Histogram without weights
//---------------------------------
if (this->events.size() > 0) {
if (!this->events.empty()) {
// Iterate through all events (sorted by pulse time)
auto itev = findFirstPulseEvent(this->events, X[0]);
auto itev_end = events.cend(); // cache for speed
......@@ -2239,7 +2239,7 @@ void EventList::generateCountsHistogramTimeAtSample(
//---------------------- Histogram without weights
//---------------------------------
if (this->events.size() > 0) {
if (!this->events.empty()) {
// Iterate through all events (sorted by pulse time)
auto itev =
findFirstTimeAtSampleEvent(this->events, X[0], tofFactor, tofOffset);
......@@ -2311,7 +2311,7 @@ void EventList::generateCountsHistogram(const MantidVec &X,
//---------------------------------
// Do we even have any events to do?
if (this->events.size() > 0) {
if (!this->events.empty()) {
// Iterate through all events (sorted by tof)
std::vector<TofEvent>::const_iterator itev =
findFirstEvent(this->events, X[0]);
......@@ -2407,7 +2407,7 @@ void EventList::integrateHelper(std::vector<T> &events, const double minX,
sum = 0;
error = 0;
// Nothing in the list?
if (events.size() == 0)
if (events.empty())
return;
// Iterators for limits - whole range by default
......@@ -3986,7 +3986,7 @@ void EventList::splitByTime(Kernel::TimeSplitterType &splitter,
}
// Do nothing if there are no entries
if (splitter.size() <= 0)
if (splitter.empty())
return;
switch (eventType) {
......@@ -4131,7 +4131,7 @@ void EventList::splitByFullTime(Kernel::TimeSplitterType &splitter,
}
// Do nothing if there are no entries
if (splitter.size() <= 0) {
if (splitter.empty()) {
// 3A. Copy all events to group workspace = -1
(*outputs[-1]) = (*this);
// this->duplicate(outputs[-1]);
......@@ -4263,7 +4263,7 @@ std::string EventList::splitByFullTimeMatrixSplitter(
std::string debugmessage("");
// Do nothing if there are no entries
if (vecgroups.size() == 0) {
if (vecgroups.empty()) {
// Copy all events to group workspace = -1
(*vec_outputEventList[-1]) = (*this);
// this->duplicate(outputs[-1]);
......@@ -4383,7 +4383,7 @@ void EventList::splitByPulseTime(Kernel::TimeSplitterType &splitter,
}
// Split
if (splitter.size() <= 0) {
if (splitter.empty()) {
// No splitter: copy all events to group workspace = -1
(*outputs[-1]) = (*this);
} else {
......
......@@ -107,7 +107,7 @@ size_t Workspace2D::size() const { return data.size() * blocksize(); }
/// get the size of each vector
size_t Workspace2D::blocksize() const {
return (data.size() > 0)
return (!data.empty())
? static_cast<ISpectrum const *>(data[0])->dataY().size()
: 0;
}
......
......@@ -7,7 +7,7 @@ namespace Geometry {
/** @return the top-level component created */
Component *ComponentParser::getComponent() {
if (m_current.size() > 0)
if (!m_current.empty())
return m_current[0];
else
return nullptr;
......
......@@ -128,7 +128,7 @@ bool Group::isGroup() const {
/// empty.
void Group::setSymmetryOperations(
const std::vector<SymmetryOperation> &symmetryOperations) {
if (symmetryOperations.size() < 1) {
if (symmetryOperations.empty()) {
throw std::invalid_argument("Group needs at least one element.");
}
......
......@@ -1925,7 +1925,7 @@ double IndexingUtils::IndexingError(const DblMatrix &UB,
total_error += h_error + k_error + l_error;
}
if (hkls.size() > 0)
if (!hkls.empty())
return total_error / (3.0 * static_cast<double>(hkls.size()));
else
return 0;
......@@ -2522,11 +2522,11 @@ int IndexingUtils::SelectDirection(V3D &best_direction,
const std::vector<V3D> direction_list,
double plane_spacing,
double required_tolerance) {
if (q_vectors.size() == 0) {
if (q_vectors.empty()) {
throw std::invalid_argument("SelectDirection(): No Q vectors specified");
}
if (direction_list.size() == 0) {
if (direction_list.empty()) {
throw std::invalid_argument(
"SelectDirection(): List of possible directions has zero length");
}
......
......@@ -263,7 +263,7 @@ ConventionalCell ScalarUtils::GetCellForForm(const DblMatrix &UB,
*/
void ScalarUtils::RemoveHighErrorForms(std::vector<ConventionalCell> &list,
double level) {
if (list.size() <= 0) // nothing to do
if (list.empty()) // nothing to do
return;
std::vector<ConventionalCell> new_list;
......@@ -293,7 +293,7 @@ void ScalarUtils::RemoveHighErrorForms(std::vector<ConventionalCell> &list,
ConventionalCell
ScalarUtils::GetCellBestError(const std::vector<ConventionalCell> &list,
bool use_triclinic) {
if (list.size() == 0) {
if (list.empty()) {
throw std::invalid_argument("GetCellBestError(): list is empty");
}
......
......@@ -90,7 +90,7 @@ std::string Goniometer::axesInfo() {
std::vector<GoniometerAxis>::iterator it;
std::string strCW("CW"), strCCW("CCW"), sense;
if (motors.size() == 0) {
if (motors.empty()) {
info << "No axis is found\n";
} else {
info << "Name \t Direction \t Sense \t Angle \n";
......
......@@ -417,7 +417,7 @@ InstrumentDefinitionParser::parseXML(Kernel::ProgressBase *prog) {
if (!pElem->hasAttribute("idlist")) {
g_log.error("No detector ID list found for detectors of type " +
pElem->getAttribute("type"));
} else if (idList.vec.size() == 0) {
} else if (idList.vec.empty()) {
g_log.error("No detector IDs found for detectors in list " +
pElem->getAttribute("idlist") + "for detectors of type" +
pElem->getAttribute("type"));
......@@ -1339,7 +1339,7 @@ void InstrumentDefinitionParser::appendLeaf(Geometry::ICompAssembly *parent,
name);
throw Kernel::Exception::InstrumentDefinitionError(
"Detector location element " + name + " has no idlist.", filename);
} else if (idList.vec.size() == 0) {
} else if (idList.vec.empty()) {
g_log.error("No detector IDs found for detectors in list " +
idList.idname);
} else {
......
......@@ -16,7 +16,7 @@ MDImplicitFunction::MDImplicitFunction() : m_nd(0), m_numPlanes(0) {}
*/
void MDImplicitFunction::addPlane(const MDPlane &plane) {
// Number of dimensions must match
if (m_planes.size() > 0) {
if (!m_planes.empty()) {
if (m_nd != plane.getNumDims())
throw std::invalid_argument("MDImplicitFunction::addPlane(): cannot add "
"a plane with different number of dimensions "
......
......@@ -536,7 +536,7 @@ A. This will make the form DNF.
{
Units.clear();
deleteComp();
if (A.size() == 0)
if (A.empty())
return;
if (A.size() == 1) // special case for single intersection
......@@ -566,7 +566,7 @@ A. This will make the form DNF.
{
Units.clear();
deleteComp();
if (A.size() == 0)
if (A.empty())
return;
if (A.size() == 1) // special case for single union
......@@ -663,7 +663,7 @@ int Acomp::isNull() const
@return 1 if there are no memebers
*/
{
return ((!Units.size() && !Comp.size()) ? 1 : 0);
return ((Units.empty() && Comp.empty()) ? 1 : 0);
}
int Acomp::isDNF() const
......@@ -888,7 +888,7 @@ It is set on exit (to the EPI)
*/
{
const int debug(0);
if (!PIform.size())
if (PIform.empty())
return 0;
std::vector<BnId> EPI; // Created Here.
......@@ -1358,7 +1358,7 @@ singles exist and up-promotes them.
const Acomp *Lower = itemC(0); // returns pointer
Units.clear();
Intersect = Lower->Intersect;
if (Lower->Units.size()) {
if (!Lower->Units.empty()) {
Units.resize(Lower->Units.size());
copy(Lower->Units.begin(), Lower->Units.end(), Units.begin());
}
......
......@@ -94,7 +94,7 @@ public:
Unit_sptr getYUnit() const { return m_yUnit; };
/// return false if no data has been added
bool containData() const { return m_x.size() ? true : false; }
bool containData() const { return !m_x.empty() ? true : false; }
/// Prints object to stream
void printSelf(std::ostream &os) const;
......
......@@ -169,7 +169,7 @@ public:
m_queueLock.lock();
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if (m_queue.size() > 0) {
if (!m_queue.empty()) {
// TODO: Would a try/catch block be smart here?
temp = m_queue.front();
m_queue.pop_front();
......@@ -222,7 +222,7 @@ class MANTID_KERNEL_DLL ThreadSchedulerLIFO : public ThreadSchedulerFIFO {
m_queueLock.lock();
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if (m_queue.size() > 0) {
if (!m_queue.empty()) {
// TODO: Would a try/catch block be smart here?
temp = m_queue.back();
m_queue.pop_back();
......@@ -274,7 +274,7 @@ public:
m_queueLock.lock();
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if (m_map.size() > 0) {
if (!m_map.empty()) {
// Since the map is sorted by cost, we want the LAST item.
std::multimap<double, Task *>::iterator it = m_map.end();
it--;
......
......@@ -50,7 +50,7 @@ public:
std::lock_guard<std::mutex> lock(m_queueLock);
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if (m_supermap.size() > 0) {
if (!m_supermap.empty()) {
// We iterate in reverse as to take the NULL mutex last, even if no mutex
// is busy
SuperMap::iterator it = m_supermap.begin();
......@@ -63,7 +63,7 @@ public:
// The mutex of this map is free!
InnerMap &map = it->second;
if (map.size() > 0) {
if (!map.empty()) {
// Look for the largest cost item in it.
InnerMap::iterator it2 = it->second.end();
it2--;
......@@ -81,7 +81,7 @@ public:
SuperMap::iterator it = m_supermap.begin();
SuperMap::iterator it_end = m_supermap.end();
for (; it != it_end; it++) {
if (it->second.size() > 0) {
if (!it->second.empty()) {
InnerMap &map = it->second;
// Use the first one
temp = map.begin()->second;
......
......@@ -98,7 +98,7 @@ BinFinder::BinFinder(const std::vector<double> &binParams) {
* which should be == to the size of the X axis.
*/
int BinFinder::lastBinIndex() {
if (endBinIndex.size() > 0)
if (!endBinIndex.empty())
return endBinIndex[endBinIndex.size() - 1];
else
return -1;
......
......@@ -79,7 +79,7 @@ std::istream &RemoteJobManager::httpGet(const std::string &path,
// session cookie.
std::vector<Poco::Net::HTTPCookie> newCookies;
m_response.getCookies(newCookies);
if (newCookies.size() > 0) {
if (!newCookies.empty()) {
m_cookies = newCookies;
}
......@@ -168,7 +168,7 @@ std::istream &RemoteJobManager::httpPost(const std::string &path,
// session cookie.
std::vector<Poco::Net::HTTPCookie> newCookies;
m_response.getCookies(newCookies);
if (newCookies.size() > 0) {
if (!newCookies.empty()) {
m_cookies = newCookies;
}
......
......@@ -232,7 +232,7 @@ Rfactor getRFactor(const std::vector<double> &obsI,
<< ") have different number of elements.";
throw std::runtime_error(errss.str());
}
if (obsI.size() == 0) {
if (obsI.empty()) {
throw std::runtime_error("getRFactor(): the input arrays are empty.");
}
......
......@@ -824,7 +824,7 @@ TimeSeriesProperty<TYPE>::valueAsCorrectMap() const {
// 2. Data Strcture
std::map<DateAndTime, TYPE> asMap;
if (m_values.size() > 0) {
if (!m_values.empty()) {
for (size_t i = 0; i < m_values.size(); i++)
asMap[m_values[i].time()] = m_values[i].value();
}
......@@ -860,7 +860,7 @@ std::multimap<DateAndTime, TYPE>
TimeSeriesProperty<TYPE>::valueAsMultiMap() const {
std::multimap<DateAndTime, TYPE> asMultiMap;
if (m_values.size() > 0) {
if (!m_values.empty()) {
for (size_t i = 0; i < m_values.size(); i++)
asMultiMap.insert(
std::make_pair(m_values[i].time(), m_values[i].value()));
......@@ -987,7 +987,7 @@ void TimeSeriesProperty<TYPE>::addValues(
}
}
if (values.size() > 0)
if (!values.empty())
m_propSortedFlag = TimeSeriesSortStatus::TSUNKNOWN;
return;
......@@ -1012,7 +1012,7 @@ void TimeSeriesProperty<TYPE>::replaceValues(
*/
template <typename TYPE>
DateAndTime TimeSeriesProperty<TYPE>::lastTime() const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("lastTime(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1028,7 +1028,7 @@ DateAndTime TimeSeriesProperty<TYPE>::lastTime() const {
* @return Value
*/
template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::firstValue() const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("firstValue(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1045,7 +1045,7 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::firstValue() const {
*/
template <typename TYPE>
DateAndTime TimeSeriesProperty<TYPE>::firstTime() const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("firstTime(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1062,7 +1062,7 @@ DateAndTime TimeSeriesProperty<TYPE>::firstTime() const {
* @return Value
*/
template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::lastValue() const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("lastValue(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1156,7 +1156,7 @@ std::map<DateAndTime, TYPE> TimeSeriesProperty<TYPE>::valueAsMap() const {
// 2. Build map
std::map<DateAndTime, TYPE> asMap;
if (m_values.size() == 0)
if (m_values.empty())
return asMap;
TYPE d = m_values[0].value();
......@@ -1288,7 +1288,7 @@ void TimeSeriesProperty<TYPE>::create(const std::vector<DateAndTime> &new_times,
*/
template <typename TYPE>
TYPE TimeSeriesProperty<TYPE>::getSingleValue(const DateAndTime &t) const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("getSingleValue(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1337,7 +1337,7 @@ TYPE TimeSeriesProperty<TYPE>::getSingleValue(const DateAndTime &t) const {
template <typename TYPE>
TYPE TimeSeriesProperty<TYPE>::getSingleValue(const DateAndTime &t,
int &index) const {
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("getSingleValue(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1393,7 +1393,7 @@ TYPE TimeSeriesProperty<TYPE>::getSingleValue(const DateAndTime &t,
template <typename TYPE>
TimeInterval TimeSeriesProperty<TYPE>::nthInterval(int n) const {
// 0. Throw exception
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("nthInterval(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1407,7 +1407,7 @@ TimeInterval TimeSeriesProperty<TYPE>::nthInterval(int n) const {
Kernel::TimeInterval deltaT;
if (m_filter.size() == 0) {
if (m_filter.empty()) {
// I. No filter
if (n >= static_cast<int>(m_values.size()) ||
(n == static_cast<int>(m_values.size()) - 1 && m_values.size() == 1)) {
......@@ -1512,7 +1512,7 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::nthValue(int n) const {
TYPE value;
// 1. Throw error if property is empty
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("nthValue(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1522,7 +1522,7 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::nthValue(int n) const {
// 2. Sort and apply filter
sort();
if (m_filter.size() == 0) {
if (m_filter.empty()) {
// 3. Situation 1: No filter
if (static_cast<size_t>(n) < m_values.size()) {
TimeValueUnit<TYPE> entry = m_values[static_cast<std::size_t>(n)];
......@@ -1568,7 +1568,7 @@ template <typename TYPE>
Kernel::DateAndTime TimeSeriesProperty<TYPE>::nthTime(int n) const {
sort();
if (m_values.size() == 0) {
if (m_values.empty()) {
const std::string error("nthTime(): TimeSeriesProperty '" + name() +
"' is empty");
g_log.debug(error);
......@@ -1683,7 +1683,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::clearFilter() {
* Updates size()
*/
template <typename TYPE> void TimeSeriesProperty<TYPE>::countSize() const {
if (m_filter.size() == 0) {
if (m_filter.empty()) {
// 1. Not filter
m_size = int(m_values.size());
} else {
......@@ -1883,7 +1883,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::sort() const {
template <typename TYPE>
int TimeSeriesProperty<TYPE>::findIndex(Kernel::DateAndTime t) const {
// 0. Return with an empty container
if (m_values.size() == 0)
if (m_values.empty())
return 0;
// 1. Sort
......@@ -1965,7 +1965,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::applyFilter() const {
// 1. Check and reset
if (m_filterApplied)
return;
if (m_filter.size() == 0)
if (m_filter.empty())
return;
m_filterQuickRef.clear();
......@@ -1985,7 +1985,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::applyFilter() const {
if (icurlog < 0) {
// i. If it is out of lower boundary, add filter time, add 0 time
if (m_filterQuickRef.size() > 0)
if (!m_filterQuickRef.empty())
throw std::logic_error(
"return log index < 0 only occurs with the first log entry");
......@@ -2004,7 +2004,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::applyFilter() const {
} else {
// iii. The returned value is in the boundary.
size_t numintervals = 0;
if (m_filterQuickRef.size() > 0) {
if (!m_filterQuickRef.empty()) {
numintervals = m_filterQuickRef.back().second;
}
if (m_filter[ift].first <
......@@ -2084,7 +2084,7 @@ size_t TimeSeriesProperty<TYPE>::findNthIndexFromQuickRef(int n) const {
// 1. Do check
if (n < 0)
throw std::invalid_argument("Unable to take into account negative index. ");
else if (m_filterQuickRef.size() == 0)
else if (m_filterQuickRef.empty())
throw std::runtime_error("Quick reference is not established. ");
// 2. Return...
......
......@@ -139,7 +139,7 @@ TimeSplitterType operator&(const TimeSplitterType &a,
TimeSplitterType out;
// If either is empty, then no entries in the filter (aka everything is
// removed)
if ((a.size() == 0) || (b.size() == 0))
if ((a.empty()) || (b.empty()))
return out;
TimeSplitterType::const_iterator ait;
......@@ -241,7 +241,7 @@ TimeSplitterType operator~(const TimeSplitterType &a) {
temp = removeFilterOverlap(a);
// No entries: then make a "filter" that keeps everything
if ((temp.size() == 0)) {
if ((temp.empty())) {
out.push_back(
SplittingInterval(DateAndTime::minimum(), DateAndTime::maximum(), 0));
return out;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment