SoPlex
|
Set of indices. More...
#include <idxset.h>
Public Member Functions | |
Construction / destruction | |
IdxSet (int n, int imem[], int l=0) | |
constructor. | |
IdxSet () | |
default constructor. | |
virtual | ~IdxSet () |
destructor. | |
IdxSet & | operator= (const IdxSet &set) |
assignment operator. | |
IdxSet (const IdxSet &) | |
copy constructor. | |
Access | |
int | index (int n) const |
access n 'th index. | |
int | size () const |
returns the number of used indices. | |
int | max () const |
returns the maximal number of indices which can be stored in IdxSet. | |
int | dim () const |
returns the maximal index. | |
int | pos (int i) const |
returns the position of index i . | |
Modification | |
void | add (int n) |
appends n uninitialized indices. | |
void | add (const IdxSet &set) |
appends all indices of set . | |
void | add (int n, const int i[]) |
appends n indices in i . | |
void | addIdx (int i) |
appends index i . | |
void | remove (int n, int m) |
removes indices at position numbers n through m . | |
void | remove (int n) |
removes n 'th index. | |
void | clear () |
removes all indices. | |
Consistency check | |
bool | isConsistent () const |
consistency check. | |
Protected Attributes | |
Data | |
int | num |
number of used indices | |
int | len |
length of array idx | |
int * | idx |
array of indices | |
bool | freeArray |
true iff idx should be freed inside of this object | |
Set of indices.
Class IdxSet provides a set of indices. At construction it must be given an array of int where to store the indice and its length. The array will from then on be managed by the IdxSet.
Indices are implicitely numbered from 0 thru size()-1. They can be accessed (and altered) via method index() with the desired index number as argument. Range checking is performed in the debug version.
Indices may be added or removed from the set, by calling add() or remove() methods, respectively. However, no IdxSet can hold more then max() indices, i.e. the number given at the constructor.
When removing indices, the remaining ones are renumbered. However, all indices before the first removed index keep their number unchanged.
The internal structure of an IdxSet consists of an array idx storing the indices, its length len, and the actually used number of indices num. The class IdxSet doesn't allocate memory for the idx array. Instead, the user has to provide an adequate buffer to the constructor.
An IdxSet cannot be extended to fit more than max() elements. If necessary, the user must explicitely provide the IdxSet with a suitable memory. Alternatively, one can use DIdxSets which provide the required memory managemant.
IdxSet | ( | int | n, |
int | imem[], | ||
int | l = 0 ) |
constructor.
The constructur receives the index memory imem
to use for saving its indices. This must be large enough to fit n
indices. l
can be given to construct an IdxSet initialized to the l
first indices in imem
.
Definition at line 89 of file idxset.h.
References freeArray, idx, isConsistent(), len, and num.
Referenced by DIdxSet::add(), add(), SSVectorBase< Real >::altIndices(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), IdxSet(), SSVectorBase< Real >::indices(), DIdxSet::operator=(), operator=(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), and SSVectorBase< Real >::SSVectorBase().
IdxSet | ( | ) |
|
virtual |
destructor.
Definition at line 107 of file idxset.h.
References freeArray, idx, and soplex::spx_free().
copy constructor.
Definition at line 110 of file idxset.cpp.
References freeArray, idx, IdxSet(), isConsistent(), len, max(), num, size(), and soplex::spx_alloc().
void add | ( | const IdxSet & | set | ) |
void add | ( | int | n | ) |
appends n
uninitialized indices.
Definition at line 158 of file idxset.h.
References max(), num, and size().
Referenced by DIdxSet::add(), DIdxSet::add(), DIdxSet::add(), add(), add(), and SSVectorBase< Real >::setValue().
void add | ( | int | n, |
const int | i[] ) |
void addIdx | ( | int | i | ) |
appends index i
.
Definition at line 174 of file idxset.h.
References idx, max(), num, and size().
Referenced by SSVectorBase< Real >::add(), and DIdxSet::addIdx().
void clear | ( | ) |
removes all indices.
Definition at line 193 of file idxset.h.
References num.
Referenced by SSVectorBase< Real >::clear(), and SSVectorBase< Real >::setup().
int dim | ( | ) | const |
returns the maximal index.
Definition at line 30 of file idxset.cpp.
Referenced by SSVectorBase< Real >::isConsistent().
int index | ( | int | n | ) | const |
access n
'th index.
Definition at line 127 of file idxset.h.
Referenced by SSVectorBase< Real >::index(), and isConsistent().
bool isConsistent | ( | ) | const |
consistency check.
Definition at line 126 of file idxset.cpp.
References idx, index(), len, size(), and SPX_MSG_INCONSISTENT.
Referenced by IdxSet(), IdxSet(), IdxSet(), SSVectorBase< Real >::isConsistent(), and operator=().
int max | ( | ) | const |
returns the maximal number of indices which can be stored in IdxSet.
Definition at line 138 of file idxset.h.
References len.
Referenced by DIdxSet::add(), DIdxSet::add(), DIdxSet::add(), add(), add(), DIdxSet::addIdx(), addIdx(), IdxSet(), SSVectorBase< Real >::isConsistent(), operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), DIdxSet::setMax(), SSVectorBase< Real >::setSize(), and SSVectorBase< Real >::setup_and_assign().
assignment operator.
The assignment operator copies all nonzeros of the right handside IdxSet to the left one. This implies, that the latter must have enough index memory.
Definition at line 80 of file idxset.cpp.
References freeArray, idx, IdxSet(), isConsistent(), len, max(), num, size(), soplex::spx_alloc(), and soplex::spx_free().
Referenced by DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), DIdxSet::operator=(), DIdxSet::operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::setup_and_assign(), SSVectorBase< Real >::SSVectorBase(), and SSVectorBase< Real >::SSVectorBase().
int pos | ( | int | i | ) | const |
returns the position of index i
.
Finds the position of the first index i
in the IdxSet. If no index i
is available in the IdxSet, -1 is returned. Otherwise, index(pos(i
)) == i
holds.
Definition at line 41 of file idxset.cpp.
Referenced by SSVectorBase< Real >::pos().
void remove | ( | int | n | ) |
void remove | ( | int | n, |
int | m ) |
removes indices at position numbers n
through m
.
Definition at line 60 of file idxset.cpp.
References idx, num, and size().
Referenced by SSVectorBase< Real >::clearIdx(), SSVectorBase< Real >::clearNum(), and SSVectorBase< Real >::reDim().
int size | ( | ) | const |
returns the number of used indices.
Definition at line 133 of file idxset.h.
References num.
Referenced by DIdxSet::add(), DIdxSet::add(), DIdxSet::add(), add(), add(), add(), DIdxSet::addIdx(), addIdx(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), dim(), IdxSet(), index(), isConsistent(), DIdxSet::operator=(), DIdxSet::operator=(), operator=(), pos(), SSVectorBase< Real >::reDim(), remove(), remove(), DIdxSet::setMax(), SSVectorBase< Real >::setMax(), and SSVectorBase< Real >::size().
|
protected |
|
protected |
array of indices
Definition at line 74 of file idxset.h.
Referenced by add(), add(), addIdx(), SSVectorBase< Real >::altIndexMem(), SSVectorBase< R >::assign2product1(), SSVectorBase< R >::assign2productAndSetup(), SSVectorBase< R >::assign2productFull(), SSVectorBase< R >::assign2productShort(), SSVectorBase< Real >::assign2productShort(), SSVectorBase< Real >::clear(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), dim(), IdxSet(), IdxSet(), IdxSet(), index(), SSVectorBase< Real >::indexMem(), isConsistent(), SSVectorBase< Real >::length2(), SSVectorBase< Real >::maxAbs(), operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), pos(), remove(), remove(), DIdxSet::setMax(), SSVectorBase< Real >::setMax(), SSVectorBase< Real >::setup(), SSVectorBase< Real >::setup_and_assign(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::value(), DIdxSet::~DIdxSet(), ~IdxSet(), and SSVectorBase< Real >::~SSVectorBase().
|
protected |
length of array idx
Definition at line 73 of file idxset.h.
Referenced by DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), DIdxSet::DIdxSet(), IdxSet(), IdxSet(), IdxSet(), isConsistent(), max(), operator=(), DIdxSet::setMax(), SSVectorBase< Real >::setMax(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), SSVectorBase< Real >::SSVectorBase(), and SSVectorBase< Real >::SSVectorBase().
|
protected |
number of used indices
Definition at line 72 of file idxset.h.
Referenced by add(), addIdx(), SSVectorBase< R >::assign(), SSVectorBase< Real >::assign(), SSVectorBase< R >::assign2product1(), SSVectorBase< R >::assign2productAndSetup(), SSVectorBase< R >::assign2productShort(), SSVectorBase< Real >::assign2productShort(), clear(), SSVectorBase< Real >::clear(), IdxSet(), IdxSet(), IdxSet(), SSVectorBase< Real >::length2(), SSVectorBase< Real >::maxAbs(), operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), remove(), remove(), SSVectorBase< Real >::setSize(), SSVectorBase< Real >::setup(), SSVectorBase< Real >::setup_and_assign(), and size().