Skip to content

Commit

Permalink
Remove 'using namespace std;'
Browse files Browse the repository at this point in the history
Fixes #201.
  • Loading branch information
a-andre authored and svigerske committed Jul 31, 2024
1 parent 6fa5d84 commit c53f0d7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 37 deletions.
16 changes: 7 additions & 9 deletions src/CoinAdjacencyVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ static void *xrealloc( void *ptr, const size_t size );

#define NEW_VECTOR(type, size) ((type *) xmalloc((sizeof(type))*(size)))

using namespace std;

CoinAdjacencyVector::CoinAdjacencyVector( size_t _nRows, size_t _iniRowSize )
: nRows_( _nRows )
, rows_( NEW_VECTOR( size_t *, (nRows_*2) ) )
Expand All @@ -47,10 +45,10 @@ CoinAdjacencyVector::CoinAdjacencyVector( size_t _nRows, size_t _iniRowSize )
for ( size_t i=1 ; (i<nRows_) ; ++i )
rows_[i] = rows_[i-1] + _iniRowSize;

fill( rowCap_, rowCap_+nRows_, _iniRowSize );
fill( notUpdated_, notUpdated_+nRows_, 0);
std::fill( rowCap_, rowCap_+nRows_, _iniRowSize );
std::fill( notUpdated_, notUpdated_+nRows_, 0);
memset( rowSize_, 0, sizeof(size_t)*nRows_ );
fill( expandedRows_, expandedRows_+nRows_, (size_t *)NULL);
std::fill( expandedRows_, expandedRows_+nRows_, (size_t *)NULL);
}

CoinAdjacencyVector::~CoinAdjacencyVector()
Expand All @@ -76,7 +74,7 @@ bool CoinAdjacencyVector::isNeighbor(size_t idxNode, size_t idxNeigh) const {
size_t *endR = rows_[idxNode] + rowSize_[idxNode];

#ifdef KEEP_SORTED
return binary_search(r, endR, idxNeigh);
return std::binary_search(r, endR, idxNeigh);
#else
for ( ; (r<endR) ; ++r )
if (*r == idxNeigh)
Expand Down Expand Up @@ -148,7 +146,7 @@ void CoinAdjacencyVector::checkCapNode( const size_t idxNode, const size_t newEl
return;

// for resizing
const size_t newIdxNodeCap = max( rowCap_[idxNode]*2, currSize+newEl );
const size_t newIdxNodeCap = std::max( rowCap_[idxNode]*2, currSize+newEl );

if ( expandedRows_[idxNode] ) {
// already outside initial vector
Expand Down Expand Up @@ -229,7 +227,7 @@ char CoinAdjacencyVector::tryAddElementSortedVector(size_t* el, size_t n, size_t
int l = 0;
int r = n - 1;
int m;
int ip = numeric_limits<int>::max(); /* insertion pos */
int ip = std::numeric_limits<int>::max(); /* insertion pos */

while (l <= r) {
m = (l + r) / 2;
Expand All @@ -249,7 +247,7 @@ char CoinAdjacencyVector::tryAddElementSortedVector(size_t* el, size_t n, size_t
}
}

if (ip == numeric_limits<int>::max()) {
if (ip == std::numeric_limits<int>::max()) {
ip = l;
}

Expand Down
14 changes: 6 additions & 8 deletions src/CoinConflictGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include "CoinAdjacencyVector.hpp"
#include "CoinTime.hpp"

using namespace std;

size_t CoinConflictGraph::minClqRow_ = 256;

static void *xmalloc(const size_t size);
Expand Down Expand Up @@ -84,7 +82,7 @@ bool CoinConflictGraph::conflicting(size_t n1, size_t n2) const {
nodeToSearch = n1;
}

if (binary_search(dc, dc + ndc, nodeToSearch))
if (std::binary_search(dc, dc + ndc, nodeToSearch))
return true;

return conflictInCliques(n1, n2);
Expand Down Expand Up @@ -113,8 +111,8 @@ static void *xcalloc(const size_t elements, const size_t size) {
void CoinConflictGraph::recomputeDegree() {
double start = CoinCpuTime();
this->nConflicts_ = 0;
minDegree_ = numeric_limits<size_t>::max();
maxDegree_ = numeric_limits<size_t>::min();
minDegree_ = std::numeric_limits<size_t>::max();
maxDegree_ = std::numeric_limits<size_t>::min();

char *iv = (char *) xcalloc(size_, sizeof(char));

Expand Down Expand Up @@ -155,8 +153,8 @@ void CoinConflictGraph::recomputeDegree() {

setDegree(i, dg);
setModifiedDegree(i, dg);
minDegree_ = min(minDegree_, dg);
maxDegree_ = max(maxDegree_, dg);
minDegree_ = std::min(minDegree_, dg);
maxDegree_ = std::max(maxDegree_, dg);
nConflicts_ += dg;
}

Expand Down Expand Up @@ -279,7 +277,7 @@ bool CoinConflictGraph::conflictInCliques(size_t n1, size_t n2) const {
size_t idxClq = nodeCliques(nnc)[i];
const size_t *clq = cliqueElements(idxClq);
size_t clqSize = cliqueSize(idxClq);
if (binary_search(clq, clq + clqSize, nodeToSearch))
if (std::binary_search(clq, clq + clqSize, nodeToSearch))
return true;
}

Expand Down
19 changes: 8 additions & 11 deletions src/CoinDynamicConflictGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ bool sort_columns(const std::pair< size_t, double > &left, const std::pair< size
}



using namespace std;

CoinDynamicConflictGraph::CoinDynamicConflictGraph ( size_t _size )
: CoinConflictGraph ( _size )
, conflicts( new CoinAdjacencyVector(_size, CG_INI_SPACE_NODE_CONFLICTS) )
Expand Down Expand Up @@ -239,17 +236,17 @@ CoinDynamicConflictGraph::CoinDynamicConflictGraph (
}

if (columns[j].first < (size_t) numCols) {
newBounds_.push_back(make_pair(columns[j].first, make_pair( 0.0, 0.0)));
newBounds_.push_back(std::make_pair(columns[j].first, std::make_pair( 0.0, 0.0)));
} else {
newBounds_.push_back(make_pair(columns[j].first - numCols, make_pair( 1.0, 1.0)));
newBounds_.push_back(std::make_pair(columns[j].first - numCols, std::make_pair( 1.0, 1.0)));
}
}

#ifdef DEBUGCG
assert(rhs >= 0.0);
#endif

maxNzOC = max(maxNzOC, nz);
maxNzOC = std::max(maxNzOC, nz);

this->addTmpRow( nz, &columns[0], rhs );

Expand Down Expand Up @@ -508,8 +505,8 @@ void CoinDynamicConflictGraph::printInfo() const
size_t maxClq = 0;

for ( size_t i=0 ; (i<this->nCliques()) ; ++i ) {
minClq = min( minClq, cliqueSize(i) );
maxClq = max( maxClq, cliqueSize(i) );
minClq = std::min( minClq, cliqueSize(i) );
maxClq = std::max( maxClq, cliqueSize(i) );
}

double totalDegree = 0.0;
Expand All @@ -518,8 +515,8 @@ void CoinDynamicConflictGraph::printInfo() const
for ( size_t i=0 ; (i<size()) ; ++i )
{
totalDegree += conflicts->rowSize(i);
minD = min( minD, conflicts->rowSize(i) );
maxD = max( maxD, conflicts->rowSize(i) );
minD = std::min( minD, conflicts->rowSize(i) );
maxD = std::max( maxD, conflicts->rowSize(i) );
}
double avd = totalDegree / ((double)size_);

Expand All @@ -532,7 +529,7 @@ void CoinDynamicConflictGraph::printInfo() const

void CoinDynamicConflictGraph::addTmpRow( size_t nz, const std::pair< size_t, double > *els, double rhs )
{
memcpy( tRowElements + tnEl, els, sizeof(pair< size_t, double>)*nz );
memcpy( tRowElements + tnEl, els, sizeof(std::pair< size_t, double>)*nz );

tnEl += nz;

Expand Down
1 change: 0 additions & 1 deletion src/CoinLpIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "CoinFinite.hpp"
#include "CoinSort.hpp"

using namespace std;
#define LPIO_MODIFY_MESSAGES 1
#if LPIO_MODIFY_MESSAGES == 0
#define CoinLpIOError(a,b,c,d,e) throw CoinError(a,b,c,d,e)
Expand Down
14 changes: 6 additions & 8 deletions src/CoinStaticConflictGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "CoinDynamicConflictGraph.hpp"
#include "CoinCliqueList.hpp"

using namespace std;

static void *xmalloc( const size_t size );

#define NEW_VECTOR(type, size) ((type *) xmalloc((sizeof(type))*(size)))
Expand Down Expand Up @@ -59,7 +57,7 @@ bool CoinStaticConflictGraph::nodeInClique( size_t idxClique, size_t node ) cons
{
const size_t *st = cliqueElements( idxClique );
const size_t *ed = st + cliqueSize_[idxClique];
return binary_search(st, ed, node);
return std::binary_search(st, ed, node);
}

CoinStaticConflictGraph *CoinStaticConflictGraph::clone() const
Expand Down Expand Up @@ -137,7 +135,7 @@ CoinStaticConflictGraph::CoinStaticConflictGraph( const CoinConflictGraph *cgrap
{
iniCoinConflictGraph( n );

#define REMOVED numeric_limits< size_t >::max()
#define REMOVED std::numeric_limits< size_t >::max()
nDirectConflicts_ = totalCliqueElements_ = nCliques_ = memSize_ = 0;

std::vector< size_t > newIdx( cgraph->size(), REMOVED );
Expand All @@ -150,7 +148,7 @@ CoinStaticConflictGraph::CoinStaticConflictGraph( const CoinConflictGraph *cgrap
abort();
}

vector< bool > ivNeighs;
std::vector< bool > ivNeighs;

// large and small cliques set
CoinCliqueList smallClqs( 4096, 32768 );
Expand Down Expand Up @@ -383,9 +381,9 @@ void CoinStaticConflictGraph::iniCoinStaticConflictGraph(const CoinConflictGraph
startClique_ = cliqueSize_ + nCliques_;
cliques_ = startClique_ + nCliques_ + 1;

fill( nConflictsNode_, nConflictsNode_+(3*size_), 0); // clears nConflictsNode, degree and modified degree
fill( nNodeCliques_, nNodeCliques_+size_, 0); // clears the number of cliques each node appears
fill( cliqueSize_, cliqueSize_+nCliques_, 0);
std::fill( nConflictsNode_, nConflictsNode_+(3*size_), 0); // clears nConflictsNode, degree and modified degree
std::fill( nNodeCliques_, nNodeCliques_+size_, 0); // clears the number of cliques each node appears
std::fill( cliqueSize_, cliqueSize_+nCliques_, 0);
startNodeCliques_[0] = 0;
startClique_[0] = 0;

Expand Down

0 comments on commit c53f0d7

Please sign in to comment.