SoPlex
Toggle main menu visibility
Loading...
Searching...
No Matches
src
soplex
didxset.h
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
/**@file didxset.h
26
* @brief Dymnamic index set.
27
*/
28
#ifndef _DIDXSET_H_
29
#define _DIDXSET_H_
30
31
#include <assert.h>
32
33
#include "
soplex/idxset.h
"
34
35
namespace
soplex
36
{
37
38
/**@brief Dynamic index set.
39
@ingroup Elementary
40
41
Class DIdxSet provides dynamic IdxSet in the sense, that no
42
restrictions are posed on the use of methods add(). However, method
43
indexMem() has been moved to the private members. This is because
44
DIdxSet adds its own memory management to class IdxSet and the user must
45
not interfere with it.
46
47
Upon construction of an DIdxSet, memory is allocated automatically. The
48
memory consumption can be controlled with methods max() and setMax().
49
Finally, the destructor will release all allocated memory.
50
*/
51
class
DIdxSet
:
public
IdxSet
52
{
53
public
:
54
55
//-----------------------------------
56
/**@name Adding */
57
///@{
58
/// adds \p n uninitialized indices.
59
void
add
(
int
n)
60
{
61
if
(
max
() -
size
() < n)
62
setMax
(
size
() + n);
63
64
IdxSet::add
(n);
65
}
66
67
/// adds all indices from \p sv.
68
void
add
(
const
IdxSet
& sv)
69
{
70
int
n = sv.
size
();
71
72
if
(
max
() -
size
() < n)
73
setMax
(
size
() + n);
74
75
IdxSet::add
(sv);
76
}
77
78
/// adds \p n indices from \p i.
79
void
add
(
int
n,
const
int
* i)
80
{
81
if
(
max
() -
size
() < n)
82
setMax
(
size
() + n);
83
84
IdxSet::add
(n, i);
85
}
86
87
/// adds index \p i to the index set
88
void
addIdx
(
int
i)
89
{
90
if
(
max
() <=
size
())
91
setMax
(
size
() + 1);
92
93
IdxSet::addIdx
(i);
94
}
95
96
/// sets the maximum number of indices.
97
/** This methods resets the memory consumption of the DIdxSet to
98
* \p newmax. However, if \p newmax < size(), it is reset to size()
99
* only.
100
*/
101
void
setMax
(
int
newmax = 1);
102
///@}
103
104
//-----------------------------------
105
/**@name Construction / destruction */
106
///@{
107
/// default constructor. \p n gives the initial size of the index space.
108
explicit
DIdxSet
(
int
n = 8);
109
110
/// copy constructor from IdxSet.
111
explicit
DIdxSet
(
const
IdxSet
& old);
112
113
/// copy constructor from DIdxSet.
114
DIdxSet
(
const
DIdxSet
& old);
115
116
/// assignment operator from IdxSet
117
DIdxSet
&
operator=
(
const
IdxSet
& sv)
118
{
119
if
(
this
!= &sv)
120
{
121
setMax
(sv.
size
());
122
IdxSet::operator=
(sv);
123
}
124
125
return
*
this
;
126
}
127
/// assignment operator from DIdxSet
128
DIdxSet
&
operator=
(
const
DIdxSet
& sv)
129
{
130
if
(
this
!= &sv)
131
{
132
setMax
(sv.
size
());
133
IdxSet::operator=
(sv);
134
}
135
136
return
*
this
;
137
}
138
/// destructor.
139
virtual
~DIdxSet
();
140
///@}
141
};
142
143
}
// namespace soplex
144
#endif
// _DIDXSET_H_
soplex::DIdxSet
Dynamic index set.
Definition
didxset.h:52
soplex::DIdxSet::~DIdxSet
virtual ~DIdxSet()
destructor.
Definition
didxset.cpp:71
soplex::DIdxSet::operator=
DIdxSet & operator=(const DIdxSet &sv)
assignment operator from DIdxSet
Definition
didxset.h:128
soplex::DIdxSet::add
void add(int n, const int *i)
adds n indices from i.
Definition
didxset.h:79
soplex::DIdxSet::addIdx
void addIdx(int i)
adds index i to the index set
Definition
didxset.h:88
soplex::DIdxSet::operator=
DIdxSet & operator=(const IdxSet &sv)
assignment operator from IdxSet
Definition
didxset.h:117
soplex::DIdxSet::add
void add(int n)
adds n uninitialized indices.
Definition
didxset.h:59
soplex::DIdxSet::DIdxSet
DIdxSet(int n=8)
default constructor. n gives the initial size of the index space.
Definition
didxset.cpp:64
soplex::DIdxSet::add
void add(const IdxSet &sv)
adds all indices from sv.
Definition
didxset.h:68
soplex::DIdxSet::setMax
void setMax(int newmax=1)
sets the maximum number of indices.
Definition
didxset.cpp:31
soplex::IdxSet
Set of indices.
Definition
idxset.h:66
soplex::IdxSet::addIdx
void addIdx(int i)
appends index i.
Definition
idxset.h:174
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::add
void add(int n)
appends n uninitialized indices.
Definition
idxset.h:158
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
idxset.h
Set of indices.
soplex
Everything should be within this namespace.
Generated by
1.17.0