Scippy

SoPlex

Sequential object-oriented simPlex

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