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);
139 assert(data !=
nullptr);
144 void add(
const DATA& item)
148 assert(data !=
nullptr);
157 assert(
num() + n <=
max());
159 for(
int i = 0; i < n; ++i)
160 add(newkey[i], item[i]);
164 void add(
const DATA* items,
int n)
167 assert(
num() + n <=
max());
169 for(
int i = 0; i < n; ++i)
178 for(
int i = 0; i < set.
num(); ++i)
179 add(newkey[i], set[i]);
187 for(
int i = 0; i < set.
num(); ++i)
277 int k, j, first = -1;
280 for(k = j = 0; k <
num(); ++k)
297 for(k = first, j =
num(); k < j; ++k)
314 assert(perm !=
nullptr);
316 for(
int i =
num() - 1; i >= 0; --i)
320 perm[
number(keys[n])] = -1;
331 void remove(
const int* nums,
int n,
int* perm)
333 assert(perm !=
nullptr);
335 for(
int i =
num() - 1; i >= 0; --i)
370 assert(n >= 0 && n <
thenum);
376 assert(n >= 0 && n <
thenum);
418 assert(n >= 0 && n <
num());
425 assert(
number(item) >= 0);
444 ptrdiff_t idx =
reinterpret_cast<const struct
Item*
>(item) -
theitem;
446 if(idx < 0 || idx >=
size())
461 return (n >= 0 && n <
num());
465 bool has(
const DATA* item)
const
496 newmax = (newmax <
size()) ?
size() : newmax;
500 while(*lastfree != -
themax - 1)
503 *lastfree = -newmax - 1;
509 return reinterpret_cast<char*
>(
theitem)
510 -
reinterpret_cast<char*
>(old_theitem);
516#ifdef ENABLE_CONSISTENCY_CHECKS
530 for(
int i = 0; i <
thenum; ++i)
548 ,
themax(pmax < 1 ? 8 : pmax)
617 for(i = 0; i < rhs.
size(); ++i)
620 for(i = 0; i < rhs.
num(); ++i)
Save arrays of arbitrary types.
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_free(T &p)
Release memory.
void spx_alloc(T &p, int n=1)
Allocate memory.
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Memory allocation routines.
#define SPX_MSG_INCONSISTENT(name)
int info
element number. info [0,thesize-1] iff element is used