Bonmin
1.8.8
src
Algorithms
QuadCuts
BonArraysHelpers.hpp
Go to the documentation of this file.
1
// (C) Copyright International Business Machines Corporation 2007
2
// All Rights Reserved.
3
// This code is published under the Eclipse Public License.
4
//
5
// Authors :
6
// Pierre Bonami, International Business Machines Corporation
7
//
8
// Date : 10/06/2007
9
10
#include "
CoinHelperFunctions.hpp
"
11
#ifndef BonArraysHelpers_H
12
#define BonArraysHelpers_H
13
14
namespace
Bonmin
{
15
template
<
class
X>
void
16
resizeAndCopyArray
(X *& array,
unsigned
int
oldSize,
unsigned
int
newSize){
17
if
(newSize == 0){
18
if
(oldSize > 0){
19
delete
[] array;
20
array = NULL;
21
}
22
return
;
23
}
24
X * buffy =
new
X[newSize];
25
if
(oldSize > 0){
26
if
(oldSize < newSize)
27
CoinCopyN
(array, oldSize, buffy);
28
else
29
CoinCopyN
(array, newSize, buffy);
30
delete
[] array;
31
}
32
array = buffy;
33
}
34
35
template
<
class
X>
void
36
resizeAndCopyArray
(X *& array,
unsigned
int
oldSize,
unsigned
int
newSize,
37
unsigned
int
& capacity){
38
if
(newSize > capacity){
39
X * buffy =
new
X[newSize];
40
if
(oldSize > 0){
41
CoinCopyN
(array, oldSize, buffy);
42
delete
[] array;
43
}
44
array = buffy;
45
}
46
else
{
47
newSize = oldSize;
48
}
49
}
50
}
// Ends Bonmin namespace
51
#endif
52
Bonmin
(C) Copyright International Business Machines Corporation 2007
Definition:
BonAmplSetup.hpp:15
Bonmin::resizeAndCopyArray
void resizeAndCopyArray(X *&array, unsigned int oldSize, unsigned int newSize)
Definition:
BonArraysHelpers.hpp:16
CoinCopyN
void CoinCopyN(const T *from, const CoinBigIndex size, T *to)
CoinHelperFunctions.hpp
Generated by
1.8.17