Scippy

SoPlex

Sequential object-oriented simPlex

didxset.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 #include "soplex/didxset.h"
17 #include "soplex/spxalloc.h"
18 
19 namespace soplex
20 {
21 
22 void DIdxSet::setMax(int newmax)
23 {
24  assert(idx != 0);
25  assert(max() > 0);
26 
27  len = (newmax < size()) ? size() : newmax;
28  len = (len < 1) ? 1 : len;
29 
30  assert(len > 0);
31 
33 }
34 
36  : IdxSet()
37 {
38  len = old.size();
39  len = (len < 1) ? 1 : len;
40  spx_alloc(idx, len);
41 
42  IdxSet::operator= (old);
43 }
44 
46  : IdxSet()
47 {
48  len = old.size();
49  len = (len < 1) ? 1 : len;
50  spx_alloc(idx, len);
51 
52  IdxSet::operator= (old);
53 }
54 
56  : IdxSet()
57 {
58  len = (n < 1) ? 1 : n;
59  spx_alloc(idx, len);
60 }
61 
63 {
64  if(idx)
65  spx_free(idx);
66 }
67 } // namespace soplex
DIdxSet(int n=8)
default constructor. n gives the initial size of the index space.
Definition: didxset.cpp:55
int * idx
array of indices
Definition: idxset.h:65
Memory allocation routines.
int max() const
returns the maximal number of indices which can be stored in IdxSet.
Definition: idxset.h:129
Dymnamic index set.
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:48
int size() const
returns the number of used indices.
Definition: idxset.h:124
int len
length of array idx
Definition: idxset.h:64
IdxSet & operator=(const IdxSet &set)
assignment operator.
Definition: idxset.cpp:71
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Definition: spxalloc.h:79
Everything should be within this namespace.
virtual ~DIdxSet()
destructor.
Definition: didxset.cpp:62
void setMax(int newmax=1)
sets the maximum number of indices.
Definition: didxset.cpp:22
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
Definition: idxset.h:56
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:110