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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 #include "soplex/didxset.h"
26 #include "soplex/spxalloc.h"
27 
28 namespace soplex
29 {
30 
31 void DIdxSet::setMax(int newmax)
32 {
33  assert(idx != 0);
34  assert(max() > 0);
35 
36  len = (newmax < size()) ? size() : newmax;
37  len = (len < 1) ? 1 : len;
38 
39  assert(len > 0);
40 
42 }
43 
45  : IdxSet()
46 {
47  len = old.size();
48  len = (len < 1) ? 1 : len;
49  spx_alloc(idx, len);
50 
51  IdxSet::operator= (old);
52 }
53 
55  : IdxSet()
56 {
57  len = old.size();
58  len = (len < 1) ? 1 : len;
59  spx_alloc(idx, len);
60 
61  IdxSet::operator= (old);
62 }
63 
65  : IdxSet()
66 {
67  len = (n < 1) ? 1 : n;
68  spx_alloc(idx, len);
69 }
70 
72 {
73  if(idx)
74  spx_free(idx);
75 }
76 } // namespace soplex
DIdxSet(int n=8)
default constructor. n gives the initial size of the index space.
Definition: didxset.cpp:64
int * idx
array of indices
Definition: idxset.h:74
Memory allocation routines.
int max() const
returns the maximal number of indices which can be stored in IdxSet.
Definition: idxset.h:138
Dymnamic index set.
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:58
int size() const
returns the number of used indices.
Definition: idxset.h:133
int len
length of array idx
Definition: idxset.h:73
IdxSet & operator=(const IdxSet &set)
assignment operator.
Definition: idxset.cpp:80
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:51
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Definition: spxalloc.h:90
Everything should be within this namespace.
virtual ~DIdxSet()
destructor.
Definition: didxset.cpp:71
void setMax(int newmax=1)
sets the maximum number of indices.
Definition: didxset.cpp:31
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
Definition: idxset.h:65
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:121