SoPlex
Toggle main menu visibility
Loading...
Searching...
No Matches
src
soplex
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-2026 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
!=
nullptr
);
34
assert(
max
() > 0);
35
36
len
= (newmax <
size
()) ?
size
() : newmax;
37
len
= (
len
< 1) ? 1 :
len
;
38
39
assert(
len
> 0);
40
41
spx_realloc
(
idx
,
len
);
42
}
43
44
DIdxSet::DIdxSet
(
const
IdxSet
& old)
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
54
DIdxSet::DIdxSet
(
const
DIdxSet
& old)
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
64
DIdxSet::DIdxSet
(
int
n)
65
:
IdxSet
()
66
{
67
len
= (n < 1) ? 1 : n;
68
spx_alloc
(
idx
,
len
);
69
}
70
71
DIdxSet::~DIdxSet
()
72
{
73
if
(
idx
)
74
spx_free
(
idx
);
75
}
76
}
// namespace soplex
soplex::DIdxSet::~DIdxSet
virtual ~DIdxSet()
destructor.
Definition
didxset.cpp:71
soplex::DIdxSet::DIdxSet
DIdxSet(int n=8)
default constructor. n gives the initial size of the index space.
Definition
didxset.cpp:64
soplex::DIdxSet::setMax
void setMax(int newmax=1)
sets the maximum number of indices.
Definition
didxset.cpp:31
soplex::IdxSet::max
int max() const
returns the maximal number of indices which can be stored in IdxSet.
Definition
idxset.h:138
soplex::IdxSet::IdxSet
IdxSet(int n, int imem[], int l=0)
constructor.
Definition
idxset.h:89
soplex::IdxSet::idx
int * idx
array of indices
Definition
idxset.h:74
soplex::IdxSet::size
int size() const
returns the number of used indices.
Definition
idxset.h:133
soplex::IdxSet::operator=
IdxSet & operator=(const IdxSet &set)
assignment operator.
Definition
idxset.cpp:80
soplex::IdxSet::len
int len
length of array idx
Definition
idxset.h:73
didxset.h
Dymnamic index set.
soplex
Everything should be within this namespace.
soplex::spx_alloc
void spx_alloc(T &p, size_t n=1)
Allocate memory.
Definition
spxalloc.h:58
soplex::spx_free
void spx_free(T &p)
Release memory.
Definition
spxalloc.h:118
soplex::spx_realloc
void spx_realloc(T &p, size_t n)
Change amount of allocated memory.
Definition
spxalloc.h:89
spxalloc.h
Memory allocation routines.
Generated by
1.17.0