Go to the documentation of this file. 35 #ifndef APPLICATIONS_STP_SRC_STPVECTOR_H_ 36 #define APPLICATIONS_STP_SRC_STPVECTOR_H_ 44 #define STP_Vectype(type) type* 48 #define vecinternalSetCapacity(vec, _size_) \ 51 assert(_size_ >= 0); \ 53 ((int*) (vec))[-2] = (_size_); \ 58 #define vecinternalSetSize(vec, _size_) \ 61 assert(_size_ >= 0); \ 63 ((int*) (vec))[-1] = (_size_); \ 68 #define vecinternalIncrementSize(vec) \ 72 ((int*) (vec))[-1]++; \ 77 #define vecinternalDecrementSize(vec) \ 81 assert(((int*) (vec))[-1] >= 1); \ 82 ((int*) (vec))[-1]--; \ 87 #define vecinternalGetCapacity(vec) \ 88 ((vec) ? ((int*) (vec))[-2] : (int) 0) 92 #define vecinternalGetSize(vec) \ 93 ((vec) ? ((int*) (vec))[-1] : (int) 0) 97 #define vecinternalComputeNBytes(size, vec) \ 98 (size * sizeof(*(vec)) + (sizeof(int) * 2)) 102 #define vecinternalIncreaseCapacity(scip, vec, cap) \ 105 const int _nbytes_new_ = vecinternalComputeNBytes((cap), (vec)); \ 106 assert(_nbytes_new_ >= ((int) sizeof(int) * 2)); \ 110 SCIP_CALL_ABORT( SCIPallocBlockMemoryArray((scip), &_p_, _nbytes_new_) ); \ 111 (vec) = (void*) (&_p_[sizeof(int) * 2]); \ 112 vecinternalSetCapacity((vec), (cap)); \ 113 vecinternalSetSize((vec), 0); \ 117 const int _cap_old_ = vecinternalGetCapacity((vec)); \ 118 const int _nbytes_old_ = vecinternalComputeNBytes(_cap_old_, (vec)); \ 119 char* _p_ = &((char*) (vec))[(int) sizeof(int) * (-2)]; \ 120 assert(_nbytes_old_ < _nbytes_new_); \ 121 SCIP_CALL_ABORT( SCIPreallocBlockMemoryArray((scip), &_p_, _nbytes_old_, _nbytes_new_) ); \ 122 (vec) = (void*)(&_p_[sizeof(int) * 2]); \ 123 vecinternalSetCapacity((vec), (cap)); \ 129 #define StpVecGetcapacity(vec) \ 130 (vecinternalGetCapacity(vec)) 134 #define StpVecClear(vec) \ 135 vecinternalSetSize(vec, (int)0) 139 #define StpVecGetSize(vec) \ 140 vecinternalGetSize(vec) 144 #define StpVecIsEmpty(vec) \ 145 (vecinternalGetSize(vec) == 0) 149 #define StpVecFree(scip, vec) \ 154 char* _p_ = &((char*) (vec))[(int) sizeof(int) * (-2)]; \ 155 const int _nbytes_ = vecinternalComputeNBytes(vecinternalGetCapacity((vec)), (vec)); \ 156 SCIPfreeBlockMemoryArray((scip), &_p_, _nbytes_); \ 163 #define StpVecPushBack(scip, vec, value) \ 166 const int _cap_ = vecinternalGetCapacity((vec)); \ 167 const int _size_ = vecinternalGetSize((vec)); \ 168 if( _cap_ <= _size_ ) \ 170 vecinternalIncreaseCapacity((scip), (vec), ((_cap_ == 0) ? 2 : _cap_ * 2)); \ 172 vec[_size_] = (value); \ 173 vecinternalIncrementSize((vec)); \ 178 #define StpVecPopBack(vec) \ 179 vecinternalDecrementSize((vec)) 182 #define StpVecReserve(scip, vec, _size_) \ 185 const int _cap_ = vecinternalGetCapacity(vec); \ 186 if( _cap_ < _size_ ) \ 188 vecinternalIncreaseCapacity(scip, (vec), _size_); \