98 static_assert(std::is_trivially_copyable<DATA>::value,
99 "Only trivially copyable types are allowed with DataSet, since it does memcopy");
137 DATA* data =
create(newkey);
146 void add(
const DATA& item)
159 assert(
num() + n <=
max());
161 for(
int i = 0; i < n; ++i)
162 add(newkey[i], item[i]);
166 void add(
const DATA* items,
int n)
169 assert(
num() + n <=
max());
171 for(
int i = 0; i < n; ++i)
180 for(
int i = 0; i < set.
num(); ++i)
181 add(newkey[i], set[i]);
189 for(
int i = 0; i < set.
num(); ++i)
279 int k, j, first = -1;
282 for(k = j = 0; k <
num(); ++k)
299 for(k = first, j =
num(); k < j; ++k)
318 for(
int i =
num() - 1; i >= 0; --i)
322 perm[
number(keys[n])] = -1;
333 void remove(
const int* nums,
int n,
int* perm)
337 for(
int i =
num() - 1; i >= 0; --i)
372 assert(n >= 0 && n <
thenum);
378 assert(n >= 0 && n <
thenum);
420 assert(n >= 0 && n <
num());
427 assert(
number(item) >= 0);
446 ptrdiff_t idx =
reinterpret_cast<const struct
Item*
>(item) -
theitem;
448 if(idx < 0 || idx >=
size())
463 return (n >= 0 && n <
num());
467 bool has(
const DATA* item)
const
498 newmax = (newmax <
size()) ?
size() : newmax;
502 while(*lastfree != -
themax - 1)
505 *lastfree = -newmax - 1;
511 return reinterpret_cast<char*
>(
theitem)
512 -
reinterpret_cast<char*
>(old_theitem);
518#ifdef ENABLE_CONSISTENCY_CHECKS
532 for(
int i = 0; i <
thenum; ++i)
550 ,
themax(pmax < 1 ? 8 : pmax)
619 for(i = 0; i < rhs.
size(); ++i)
622 for(i = 0; i < rhs.
num(); ++i)
Save arrays of arbitrary types.
Safe arrays of data objects.
T * get_ptr()
get a C pointer to the data.
Entry identifier class for items of a DataSet.
int idx
(locally) unique key index
void remove(const int *nums, int n)
remove n elements with numbers nums.
void remove(int removenum)
removes the removenum 'th 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(int pmax=8)
default constructor.
void remove(const DataKey &removekey)
removes element with key removekey.
void remove(const DataKey *keys, int n)
remove n elements given by keys.
bool isConsistent() const
consistency check.
void add(DataKey newkey[], const DataSet< DATA > &set)
adds several new items.
int number(const DATA *item) const
returns the number of element item in DataSet, throws exception if it doesn't exist.
void add(DataKey &newkey, const DATA &item)
adds an element.
DataSet(const DataSet &old)
copy constructor.
int themax
length of arrays theitem and thekey
void add(const DATA *items, int n)
adds n elements from items.
void add(const DataSet< DATA > &set)
adds all elements of set.
void remove(int perm[])
remove multiple elements.
int firstfree
first unused element in theitem
DATA * create(DataKey &newkey)
creates new data element in 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.
const DATA & operator[](int n) const
returns element number n.
int max() const
returns maximum number of elements that would fit into DataSet.
void add(const DATA &item)
adds element item.
ptrdiff_t reMax(int newmax=0)
resets max() to newmax.
struct soplex::DataSet::Item * theitem
array of elements in the DataSet
int num() const
returns number of elements currently in DataSet.
DATA & operator[](const DataKey &k)
int thesize
highest used element in theitem
bool has(const DataKey &k) const
Is k a valid DataKey of an element in DataSet?
DataKey * thekey
DataKey::idx's of elements.
bool has(const DATA *item) const
Does item belong to DataSet?
void add(DataKey newkey[], const DATA *item, int n)
add several items.
void clear()
remove all elements.
DataSet< DATA > & operator=(const DataSet< DATA > &rhs)
assignment operator.
DataKey key(int n) const
returns DataKey of n 'th element in DataSet.
const DATA & operator[](const DataKey &k) const
returns element with DataKey k.
void remove(const DataKey *keys, int n, int *perm)
remove n elements given by keys and perm.
DataKey key(const DATA *item) const
returns DataKey of element item in DataSet.
int thenum
number of elements in DataSet
int size() const
returns the maximum DataKey::idx currently in DataSet.
void remove(const int *nums, int n, int *perm)
remove n elements given by nums and perm.
Exception class for out of memory exceptions.
Save arrays of data objects.
Entry identifier class for items of a DataSet.
Exception classes for SoPlex.
Everything should be within this namespace.
void spx_realloc(T &p, int n)
Change amount of allocated memory.
void spx_free(T &p)
Release memory.
void spx_alloc(T &p, int n=1)
Allocate memory.
Memory allocation routines.
#define SPX_MSG_INCONSISTENT(name)
int info
element number. info [0,thesize-1] iff element is used