Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SoPlex 6.0.3
SoPlex 5.0.2
SoPlex 4.0.2
SoPlex 3.1.0
SoPlex 3.0.1
SoPlex 2.2.1
SoPlex
Sequential object-oriented simPlex
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
soplex-repo
src
datakey.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-2015 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 datakey.h
17
* @brief Entry identifier class for items of a DataSet.
18
*/
19
#ifndef _DATAKEY_H_
20
#define _DATAKEY_H_
21
22
#include <assert.h>
23
24
namespace
soplex
25
{
26
/**@brief Entry identifier class for items of a DataSet.
27
@ingroup Elementary
28
29
Every item in a DataSet is assigned a DataKey by which it can be
30
accessed (using DataSet::operator[]()). A DataKey consists of an integer
31
member #idx, which is a positive number for any valid DataKey. No
32
#idx of an element in a DataSet may exceed the sets max().
33
This property may be used to build arrays with additional information to
34
the elements of a DataSet.
35
36
In addition, #DataKey%s provide a member #info which can be used to store
37
further information.
38
39
Each DataKey is unique for one DataSet but different DataSets may (and
40
generally will) manage the same #DataKey%s. When an element is removed from
41
a DataSet its DataKey may (and generally will) be reused for other
42
elements added to the DataSet later on.
43
44
@todo data members should be private.
45
*/
46
class
DataKey
47
{
48
public
:
49
50
//-------------------------------------
51
/**@name Data */
52
//@{
53
/* This was originally implemented as bitfield "signed int info: 2; signed int idx: (8 * sizeof(int) - 2);",
54
however, this seems to trigger a bug with old versions of GCC/glibc on 32bit machines. */
55
int
info
;
///< user information to store values -1, 0, +1
56
int
idx
;
///< (locally) unique key index
57
//@}
58
59
public
:
60
61
//-------------------------------------
62
/**@name Constructors / destructors */
63
//@{
64
/// Default constructor. Constructs an invalid DataKey.
65
DataKey
()
66
:
info
(0),
idx
(-1)
67
{}
68
// Full constructor
69
DataKey
(
int
p_info,
int
p_idx)
70
:
info
(p_info)
71
,
idx
(p_idx)
72
{
73
assert( p_info <= 1 && p_info >= -1 );
74
}
75
/// Assignment operator.
76
DataKey
&
operator=
(
const
DataKey
& rhs)
77
{
78
if
(
this
!= &rhs ) {
79
info
= rhs.
info
;
80
idx
= rhs.
idx
;
81
}
82
83
return
*
this
;
84
}
85
/// Copy constructor.
86
DataKey
(
const
DataKey
& old)
87
:
info
(old.
info
)
88
,
idx
(old.
idx
)
89
{}
90
//@}
91
92
//-------------------------------------
93
/**@name Access / modification */
94
//@{
95
/// gets the index number (\ref soplex::DataKey::idx "idx") of the DataKey.
96
inline
int
getIdx
()
const
97
{
98
return
idx
;
99
}
100
/// sets the index number (\ref soplex::DataKey::idx "idx") of the DataKey.
101
inline
void
setIdx
(
int
p_idx)
102
{
103
idx
= p_idx;
104
}
105
/// returns TRUE, iff the DataKey is valid.
106
inline
bool
isValid
()
const
107
{
108
return
idx
>= 0;
109
}
110
/// makes the DataKey invalid and clears the \ref soplex::DataKey::info "info" field.
111
inline
void
inValidate
()
112
{
113
idx
= -1;
114
info
= 0;
115
}
116
//@}
117
118
};
119
120
}
// namespace soplex
121
#endif // _DATAKEY_H_