Scippy

SCIP

Solving Constraint Integer Programs

stpvector.h File Reference

Detailed Description

header only, simple implementation of an STL like vector

Author
Daniel Rehfeldt

STP vector (basically a much simplified replication of the C++ std::vector) Usage: define with STP_Vectype(template) myvec = NULL;

for example: STP_Vectype(int) myvec = NULL;

Vector needs to be freed!

Definition in file stpvector.h.

#include "scip/scip.h"

Go to the source code of this file.

Macros

#define STP_Vectype(type)   type*
 
#define vecinternalSetCapacity(vec, _size_)
 
#define vecinternalSetSize(vec, _size_)
 
#define vecinternalIncrementSize(vec)
 
#define vecinternalDecrementSize(vec)
 
#define vecinternalGetCapacity(vec)   ((vec) ? ((int*) (vec))[-2] : (int) 0)
 
#define vecinternalGetSize(vec)   ((vec) ? ((int*) (vec))[-1] : (int) 0)
 
#define vecinternalComputeNBytes(size, vec)   (size * sizeof(*(vec)) + (sizeof(int) * 2))
 
#define vecinternalIncreaseCapacity(scip, vec, cap)
 
#define StpVecGetcapacity(vec)   (vecinternalGetCapacity(vec))
 
#define StpVecClear(vec)   vecinternalSetSize(vec, (int)0)
 
#define StpVecGetSize(vec)   vecinternalGetSize(vec)
 
#define StpVecTop(vec)   vec[StpVecGetSize(vec) - 1]
 
#define StpVecIsEmpty(vec)   (vecinternalGetSize(vec) == 0)
 
#define StpVecFree(scip, vec)
 
#define StpVecPushBack(scip, vec, value)
 
#define StpVecPopBack(vec)   vecinternalDecrementSize((vec))
 
#define StpVecReserve(scip, vec, _size_)
 

Macro Definition Documentation

◆ STP_Vectype

◆ vecinternalSetCapacity

#define vecinternalSetCapacity (   vec,
  _size_ 
)
Value:
do \
{ \
assert(_size_ >= 0); \
assert(vec); \
((int*) (vec))[-2] = (_size_); \
} while( 0 )

internal method

Definition at line 48 of file stpvector.h.

◆ vecinternalSetSize

#define vecinternalSetSize (   vec,
  _size_ 
)
Value:
do \
{ \
assert(_size_ >= 0); \
assert(vec); \
((int*) (vec))[-1] = (_size_); \
} while( 0 )

internal method

Definition at line 58 of file stpvector.h.

◆ vecinternalIncrementSize

#define vecinternalIncrementSize (   vec)
Value:
do \
{ \
assert(vec); \
((int*) (vec))[-1]++; \
} while( 0 )

internal method

Definition at line 68 of file stpvector.h.

◆ vecinternalDecrementSize

#define vecinternalDecrementSize (   vec)
Value:
do \
{ \
assert(vec); \
assert(((int*) (vec))[-1] >= 1); \
((int*) (vec))[-1]--; \
} while( 0 )

internal method

Definition at line 77 of file stpvector.h.

◆ vecinternalGetCapacity

#define vecinternalGetCapacity (   vec)    ((vec) ? ((int*) (vec))[-2] : (int) 0)

internal method

Definition at line 87 of file stpvector.h.

◆ vecinternalGetSize

#define vecinternalGetSize (   vec)    ((vec) ? ((int*) (vec))[-1] : (int) 0)

internal method

Definition at line 92 of file stpvector.h.

◆ vecinternalComputeNBytes

#define vecinternalComputeNBytes (   size,
  vec 
)    (size * sizeof(*(vec)) + (sizeof(int) * 2))

internal method

Definition at line 97 of file stpvector.h.

◆ vecinternalIncreaseCapacity

#define vecinternalIncreaseCapacity (   scip,
  vec,
  cap 
)
Value:
do \
{ \
const int _nbytes_new_ = vecinternalComputeNBytes((cap), (vec)); \
assert(_nbytes_new_ >= ((int) sizeof(int) * 2)); \
if( !(vec) ) \
{ \
char* _p_; \
SCIP_CALL_ABORT( SCIPallocBlockMemoryArray((scip), &_p_, _nbytes_new_) ); \
(vec) = (void*) (&_p_[sizeof(int) * 2]); \
vecinternalSetCapacity((vec), (cap)); \
vecinternalSetSize((vec), 0); \
} \
else \
{ \
const int _cap_old_ = vecinternalGetCapacity((vec)); \
const int _nbytes_old_ = vecinternalComputeNBytes(_cap_old_, (vec)); \
char* _p_ = &((char*) (vec))[(int) sizeof(int) * (-2)]; \
assert(_nbytes_old_ < _nbytes_new_); \
SCIP_CALL_ABORT( SCIPreallocBlockMemoryArray((scip), &_p_, _nbytes_old_, _nbytes_new_) ); \
(vec) = (void*)(&_p_[sizeof(int) * 2]); \
vecinternalSetCapacity((vec), (cap)); \
} \
} while( 0 )
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
Definition: scip_mem.h:90
#define SCIPallocBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:84
#define vecinternalComputeNBytes(size, vec)
Definition: stpvector.h:97
#define vecinternalGetCapacity(vec)
Definition: stpvector.h:87

internal method

Definition at line 102 of file stpvector.h.

◆ StpVecGetcapacity

#define StpVecGetcapacity (   vec)    (vecinternalGetCapacity(vec))

gets _cap_acity of the vector

Definition at line 129 of file stpvector.h.

Referenced by cutNodesProcessNext(), graph_tpathsGetProfitNodes(), and stpbitset_getCapacity().

◆ StpVecClear

◆ StpVecGetSize

#define StpVecGetSize (   vec)    vecinternalGetSize(vec)

gets size of the vector (number of elements)

Definition at line 139 of file stpvector.h.

Referenced by addLeaf(), addLevelFirst(), addNonPathNode(), addPathNode(), bidecomposition_cutnodesCompute(), borderBuildCharDists(), borderBuildCharMap(), borderNodesCollect(), borderNodesContract(), bpartitionsCompute(), bpartitionsDebugPrintTop(), bpartitionsFree(), bsubpartAdd(), computeOrderingFromNode(), computeSteinerTree_execDirected(), connectivityDataKeyElimUpdate(), cutNodesComputePostProcess(), cutNodesGetLastCutnode(), cutNodesProcessComponent(), cutNodesProcessNext(), cutNodesTreeBuildSteinerTree(), cutNodesTreeMakeTerms(), decomposeGetFirstMarked(), dpborder_free(), dpborder_getPredLevel(), dpborder_getTopDelimiter(), dpborder_getTopLevel(), dpborder_markSolNodes(), dpborder_partGetIdxNewExclusive(), dpiterAddNewPrepare(), dpiterPopSol(), dpmiscFree(), dpsolverGetSolution(), dpterms_intersectsEqualNaive(), dpterms_streeFree(), enumExec(), extensionHasImplicationConflict(), extreduce_extCompClean(), generalStarCheckExit(), generalStarCheckInit(), generalStarSetUp(), getOrderedRootIndices(), graph_tpathsGetProfitNodes(), impliedNodesRemoveTerm(), insertData(), mincutFree(), pathExend(), pathExendPrepare(), pathGetHead(), pathneighborsCollect(), pathneighborsUpdateDistances(), prClean(), processPath(), redsolGetNlevels(), reduce_impliedNodesIsValid(), reduce_impliedProfitBasedRpc(), reduce_nonTerminalComponents(), reduce_sl(), reduce_solFree(), reduce_starResetWithEdges(), reducePcMw(), reinsertSubgraph(), reinsertSubgraphTransferEdges(), ruleOutFromHead(), sdgraphUpdateDistgraphFromTpaths(), sepafullAddSingleSolcandEdges(), sepafullAddSolForCand(), sepafullFree(), sepafullReduceFromSols(), sepaspecial_vtimplicationsSeparate(), setSubBottleneckEdges(), STP_Vectype(), stpbitset_and(), stpbitset_areEqual(), stpbitset_getCapacity(), stpbitset_getPopcount(), stpbitset_GT(), stpbitset_haveIntersection(), stpbitset_LT(), stpbitset_newCopy(), stpbitset_newNot(), stpbitset_newXor(), stpbitset_or(), stpbitset_setsAreCompatible(), subgraphBuild(), subgraphIdentify(), subSolIsRedundant(), subsolUpdate(), subtreesAddNew(), subtreesAddNewFinalize(), subtreesBuild(), subtreesRemoveNonValids(), termsepaCutIsCorrect(), termsepaTraverseSinkComp(), tpathsRepairExit(), tpathsRepairExitLevel(), tpathsRepairTraverse1st(), tpathsRepairTraverseLevelWithStack(), tpathsRepairTraverseStackAddBelow(), tpathsRepairUpdate1st(), tpathsRepairUpdateLevel(), trailGraphWithStates(), treenodeIsInRange(), updateBorder(), updateFromPartition(), updateIncumbent(), updateTerminalSource(), vnoiDataRepairPreprocess(), vnoiDataReset(), and vnoiDataRestore().

◆ StpVecTop

#define StpVecTop (   vec)    vec[StpVecGetSize(vec) - 1]

gets top element of the vector

Definition at line 143 of file stpvector.h.

◆ StpVecIsEmpty

#define StpVecIsEmpty (   vec)    (vecinternalGetSize(vec) == 0)

is the vector empty?

Definition at line 148 of file stpvector.h.

Referenced by decomposeGetFirstMarked(), reduce_solFree(), tpathsRepairTraverse1st(), and tpathsRepairTraverseLevelWithStack().

◆ StpVecFree

#define StpVecFree (   scip,
  vec 
)
Value:
do \
{ \
if( (vec) ) \
{ \
char* _p_ = &((char*) (vec))[(int) sizeof(int) * (-2)]; \
const int _nbytes_ = vecinternalComputeNBytes(vecinternalGetCapacity((vec)), (vec)); \
SCIPfreeBlockMemoryArray((scip), &_p_, _nbytes_); \
(vec) = NULL; \
} \
} while( 0 )
#define NULL
Definition: lpi_spx1.cpp:155
#define vecinternalComputeNBytes(size, vec)
Definition: stpvector.h:97
#define vecinternalGetCapacity(vec)
Definition: stpvector.h:87

frees vector

Definition at line 153 of file stpvector.h.

Referenced by bidecomposition_cutnodesFree(), bpartitionsFree(), combineWithIntersecting(), computeOrderingFromNode(), computeSteinerTree_execDirected(), cutNodesGetLastCutnode(), cutNodesTreeBuildSteinerTree(), decomposeGetFirstMarked(), dpborder_dpblevelFree(), dpborder_free(), dpiterFree(), dpmiscFree(), dpsolverFreeData(), dpterms_dpsubsolFree(), dpterms_intersectsEqualNaive(), dpterms_streeFree(), enumExec(), extreduce_extCompClean(), extreduce_extPermaFree(), generalStarExit(), graph_subinoutFree(), localKeyVertexHeuristics(), mincutFree(), prFree(), reduce_impliedProfitBasedRpc(), reduce_sl(), reduce_solFree(), reduce_termcompFree(), reducePcMw(), sdgraphUpdateDistgraphFromTpaths(), sepafullAddSingleSolcandEdges(), sepafullFree(), sepaspecial_vtimplicationsFree(), stpbitset_free(), subsolUpdate(), subtreesAddNew(), termsepaCutIsCorrect(), termsepaTraverseSinkComp(), tpathsRepairExit(), trailGraphWithStates(), updateFromPartition(), and updateTerminalSource().

◆ StpVecPushBack

#define StpVecPushBack (   scip,
  vec,
  value 
)
Value:
do \
{ \
const int _cap_ = vecinternalGetCapacity((vec)); \
const int _size_ = vecinternalGetSize((vec)); \
if( _cap_ <= _size_ ) \
{ \
vecinternalIncreaseCapacity((scip), (vec), ((_cap_ == 0) ? 2 : _cap_ * 2)); \
} \
vec[_size_] = (value); \
vecinternalIncrementSize((vec)); \
} while( 0 )
#define vecinternalGetSize(vec)
Definition: stpvector.h:92
#define vecinternalGetCapacity(vec)
Definition: stpvector.h:87

adds (appends) element

Definition at line 167 of file stpvector.h.

Referenced by addLeaf(), addLevel(), addLevelFirst(), addNonPathNode(), addPathHeadEdge(), addPathNode(), borderNodesCollect(), bottleneckMarkEqualityEdge(), bottleneckMarkEqualityPath(), bpartitionsCompute(), bsubpartAdd(), computeOrderingFromNode(), computeSteinerTree_execDirected(), connectivityDataInit(), cutNodesGetLastCutnode(), cutNodesProcessComponent(), cutNodesProcessNext(), cutNodesTreeBuildSteinerTree(), decomposeGetFirstMarked(), dpborder_partGetIdxNew(), dpborder_partGetIdxNewExclusive(), dpiterAddNewPrepare(), dpmiscInit(), dpsolverInitData(), generalStarCheckInit(), generalStarSetUp(), graph_tpathsGetProfitNodes(), impliedNodesAddTerm(), insertData(), lca(), mincutFree(), nsvEdgeContract(), pathExendPrepare(), pathneighborsCollect(), pathneighborsUpdateDistances(), reduce_sl(), reduce_solInit(), reduce_solLevelAdd(), reducePcMw(), reinsertSubgraphDeleteOldEdges(), sepafullAddSingleSolcandEdges(), sepafullAddSolForCand(), sepaspecial_vtimplicationsInit(), STP_Vectype(), stpbitset_new(), streeCollectIntersects(), subgraphIdentify(), subsolUpdate(), subtreesAddNewFinalize(), subtreesBuild(), subtreesRemoveNonValids(), termsepaCutIsCorrect(), termsepaTraverseSinkComp(), tpathsScan1st(), tpathsScan2nd(), tpathsScan3rd(), tpathsScan4th(), trailGraphWithStates(), updateBorder(), and updateTerminalSource().

◆ StpVecPopBack

◆ StpVecReserve

#define StpVecReserve (   scip,
  vec,
  _size_ 
)
Value:
do \
{ \
const int _cap_ = vecinternalGetCapacity(vec); \
if( _cap_ < _size_ ) \
{ \
vecinternalIncreaseCapacity(scip, (vec), _size_); \
} \
} while( 0 )
#define vecinternalGetCapacity(vec)
Definition: stpvector.h:87

reserves space

Definition at line 186 of file stpvector.h.

Referenced by bidecomposition_cutnodesInit(), computeOrderingFromNode(), cutNodesGetLastCutnode(), cutNodesTreeBuildSteinerTree(), dpiterInit(), generalStarInit(), mincutFree(), prInit(), sdgraphUpdateDistgraphFromTpaths(), stpbitset_new(), subgraphIdentify(), termsepaCutIsCorrect(), termsepaTraverseSinkComp(), tpathsRepairInit(), trailGraphWithStates(), and updateTerminalSource().