133 T* newelem =
create(newkey);
135 assert(newelem !=
nullptr);
144 assert(newelem !=
nullptr);
153 assert(
num() + n <=
max());
155 for(
int i = 0; i < n; ++i)
156 add(newkey[i], item[i]);
160 void add(
const T* items,
int n)
163 assert(
num() + n <=
max());
165 for(
int i = 0; i < n; ++i)
174 for(
int i = 0; i < set.
num(); ++i)
175 add(newkey[i], set[i]);
183 for(
int i = 0; i < set.
num(); ++i)
273 int k, j, first = -1;
276 for(k = j = 0; k <
num(); ++k)
293 for(k = first, j =
num(); k < j; ++k)
310 assert(perm !=
nullptr);
312 for(
int i =
num() - 1; i >= 0; --i)
316 perm[
number(keys[n])] = -1;
327 void remove(
const int* nums,
int n,
int* perm)
329 assert(perm !=
nullptr);
331 for(
int i =
num() - 1; i >= 0; --i)
366 assert(n >= 0 && n <
thenum);
372 assert(n >= 0 && n <
thenum);
414 assert(n >= 0 && n <
num());
421 assert(
number(item) >= 0);
440 ptrdiff_t idx =
reinterpret_cast<const struct
Item*
>(item) -
theitem;
442 if(idx < 0 || idx >=
size())
457 return (n >= 0 && n <
num());
461 bool has(
const T* item)
const
492 Item* newMem =
nullptr;
493 newmax = (newmax <
size()) ?
size() : newmax;
497 while(*lastfree != -
themax - 1)
500 *lastfree = -newmax - 1;
505 for(i = 0; i <
max(); i++)
512 for(; i < newmax; i++)
513 new(&(newMem[i]))
Item();
516 ptrdiff_t pshift =
reinterpret_cast<char*
>(newMem) -
reinterpret_cast<char*
>(
theitem);
531#ifdef ENABLE_CONSISTENCY_CHECKS
545 for(
int i = 0; i <
thenum; ++i)
563 ,
themax(pmax < 1 ? 8 : pmax)
573 for(
int i = 0; i <
themax; i++)
606 for(i = 0; i < old.
thenum; i++)
610 for(; i < old.
themax; i++)
645 for(i = 0; i < rhs.
size(); ++i)
648 for(i = 0; i < rhs.
num(); ++i)
Save arrays of arbitrary types.
Save arrays of data objects.
void remove(const int *nums, int n)
remove n elements with numbers nums.
ClassSet(const ClassSet &old)
copy constructor.
T * create(DataKey &newkey)
creates new class element in ClassSet.
void remove(int removenum)
removes the removenum 'th element.
bool has(int n) const
Is n a valid number of an element in ClassSet?
ClassSet(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.
struct soplex::ClassSet::Item * theitem
array of elements in the ClassSet
int themax
length of arrays theitem and thekey
void add(const ClassSet< T > &set)
adds all elements of set.
void add(DataKey newkey[], const ClassSet< T > &set)
adds several new items.
void add(DataKey &newkey, const T &item)
adds an element.
int number(const T *item) const
returns the number of element item in ClassSet, throws exception if it doesn't exist.
void remove(int perm[])
remove multiple elements.
T & operator[](const DataKey &k)
int firstfree
first unused element in theitem
const T & operator[](const DataKey &k) const
returns element with DataKey k.
int number(const DataKey &k) const
returns the number of the element with DataKey k in ClassSet or -1, if it doesn't exist.
void add(DataKey newkey[], const T *item, int n)
add several items.
int max() const
returns maximum number of elements that would fit into ClassSet.
DataKey key(const T *item) const
returns DataKey of element item in ClassSet.
ptrdiff_t reMax(int newmax=0)
resets max() to newmax.
T * create()
creates new (uninitialized) class element in ClassSet.
void add(const T &item)
adds element item.
int num() const
returns number of elements currently in ClassSet.
int thesize
highest used element in theitem
bool has(const T *item) const
Does item belong to ClassSet?
bool has(const DataKey &k) const
Is k a valid DataKey of an element in ClassSet?
DataKey * thekey
DataKey::idx's of elements.
void add(const T *items, int n)
adds n elements from items.
void clear()
remove all elements.
const T & operator[](int n) const
returns element number n.
DataKey key(int n) const
returns DataKey of n 'th element in ClassSet.
void remove(const DataKey *keys, int n, int *perm)
remove n elements given by keys and perm.
int thenum
number of elements in ClassSet
ClassSet< T > & operator=(const ClassSet< T > &rhs)
assignment operator.
int size() const
returns the maximum DataKey::idx currently in ClassSet.
void remove(const int *nums, int n, int *perm)
remove n elements given by nums and perm.
T * get_ptr()
get a C pointer to the data.
Entry identifier class for items of a DataSet.
int idx
(locally) unique key index
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