134 void add(
const DATA& item)
147 assert(
num() + n <=
max());
149 for(
int i = 0; i < n; ++i)
150 add(newkey[i], item[i]);
154 void add(
const DATA* items,
int n)
157 assert(
num() + n <=
max());
159 for(
int i = 0; i < n; ++i)
168 for(
int i = 0; i <
set.num(); ++i)
169 add(newkey[i],
set[i]);
177 for(
int i = 0; i <
set.num(); ++i)
188 if(firstfree != -themax - 1)
190 newkey.
idx = -firstfree - 1;
194 newkey.
idx = thesize++;
229 void remove(
int removenum)
233 int idx = thekey[removenum].
idx;
236 firstfree = -idx - 1;
238 while(-firstfree == thesize)
246 if(removenum != thenum)
248 thekey[removenum] = thekey[
thenum];
257 remove(
number(removekey));
265 void remove(
int perm[])
267 int k, j, first = -1;
270 for(k = j = 0; k <
num(); ++k)
276 int idx = thekey[k].
idx;
278 firstfree = -idx - 1;
287 for(k = first, j =
num(); k < j; ++k)
291 thekey[perm[k]] = thekey[k];
302 void remove(
const DataKey* keys,
int n,
int* perm)
306 for(
int i =
num() - 1; i >= 0; --i)
310 perm[
number(keys[n])] = -1;
318 remove(keys, n, perm.
get_ptr());
321 void remove(
const int* nums,
int n,
int* perm)
325 for(
int i =
num() - 1; i >= 0; --i)
334 void remove(
const int* nums,
int n)
337 remove(nums, n, perm.
get_ptr());
345 firstfree = -themax - 1;
360 assert(n >= 0 && n < thenum);
366 assert(n >= 0 && n < thenum);
373 assert(k.
idx < thesize);
379 assert(k.
idx < thesize);
408 assert(n >= 0 && n <
num());
415 assert(
number(item) >= 0);
416 return thekey[
number(item)];
434 ptrdiff_t idx =
reinterpret_cast<const struct Item*
>(item) -
theitem;
436 if(idx < 0 || idx >=
size())
451 return (n >= 0 && n <
num());
455 bool has(
const DATA* item)
const 485 struct Item* old_theitem =
theitem;
486 newmax = (newmax <
size()) ?
size() : newmax;
490 while(*lastfree != -themax - 1)
493 *lastfree = -newmax - 1;
499 return reinterpret_cast<char*
>(
theitem)
500 - reinterpret_cast<char*>(old_theitem);
506 #ifdef ENABLE_CONSISTENCY_CHECKS 508 if(
theitem == 0 || thekey == 0)
511 if(thesize > themax || thenum > themax || thenum > thesize)
514 if(thesize == thenum && firstfree != -themax - 1)
517 if(thesize != thenum && firstfree == -themax - 1)
520 for(
int i = 0; i <
thenum; ++i)
538 , themax(pmax < 1 ? 8 : pmax)
543 firstfree = -themax - 1;
565 , thesize(old.thesize)
585 memcpy(thekey, old.
thekey, themax *
sizeof(*thekey));
607 for(i = 0; i < rhs.
size(); ++i)
610 for(i = 0; i < rhs.
num(); ++i)
611 thekey[i] = rhs.
thekey[i];
614 firstfree = -themax - 1;
648 #endif // _DATASET_H_ DataKey * thekey
DataKey::idx's of elements.
int thenum
number of elements in DataSet
struct soplex::DataSet::Item * theitem
array of elements in the DataSet
DATA & operator[](const DataKey &k)
DataKey key(int n) const
returns DataKey of n 'th element in DataSet.
Entry identifier class for items of a DataSet.
void add(const DATA *items, int n)
adds n elements from items.
Memory allocation routines.
void add(const DataSet< DATA > &set)
adds all elements of set.
T * get_ptr()
get a C pointer to the data.
Exception classes for SoPlex.
ptrdiff_t reMax(int newmax=0)
resets max() to newmax.
int info
element number. info [0,thesize-1] iff element is used
int number(const DATA *item) const
returns the number of element item in DataSet, throws exception if it doesn't exist.
bool has(const DATA *item) const
Does item belong to DataSet?
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
Exception class for out of memory exceptions.This class is derived from the SoPlex exception base cla...
void spx_alloc(T &p, int n=1)
Allocate memory.
Set of data objects.Class DataSet manages of sets of data objects of a template type DATA...
DataSet(const DataSet &old)
copy constructor.
void add(DataKey &newkey, const DATA &item)
adds an element.
DATA * create()
creates new (uninitialized) data element in DataSet.
bool has(int n) const
Is n a valid number of an element in DataSet?
DataSet< DATA > & operator=(const DataSet< DATA > &rhs)
assignment operator.
int thesize
highest used element in theitem
void clear()
remove all elements.
bool isConsistent() const
consistency check.
DataKey key(const DATA *item) const
returns DataKey of element item in DataSet.
int firstfree
first unused element in theitem
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Exception base class.This class implements a base class for our SoPlex exceptions We provide a what()...
Everything should be within this namespace.
bool has(const DataKey &k) const
Is k a valid DataKey of an element in DataSet?
DataSet(int pmax=8)
default constructor.
void add(DataKey newkey[], const DataSet< DATA > &set)
adds several new items.
int size() const
returns the maximum DataKey::idx currently in DataSet.
const DATA & operator[](const DataKey &k) const
returns element with DataKey k.
int max() const
returns maximum number of elements that would fit into DataSet.
int number(const DataKey &k) const
returns the number of the element with DataKey k in DataSet or -1, if it doesn't exist.
DATA * create(DataKey &newkey)
creates new data element in DataSet.
#define MSGinconsistent(name)
Save arrays of data objects.
void add(const DATA &item)
adds element item.
int num() const
returns number of elements currently in DataSet.
int idx
(locally) unique key index
void spx_free(T &p)
Release memory.
const DATA & operator[](int n) const
returns element number n.
void add(DataKey newkey[], const DATA *item, int n)
add several items.
int themax
length of arrays theitem and thekey