53 T **newvals =
new T* [new_asize];
56 for ( ;
asize<new_asize;
asize++) *newvals++ = NULL;
59 values = newvals-new_asize;
63 memset (
values+newsize, 0, (
asize-newsize)*
sizeof(T*));
69 if (new_asize ==
asize)
return;
77 if (new_asize <=
asize)
169 for (
long ii=
size; ii>=i; ii--)
177 T **newa =
new T* [++
size];
180 ;
asize++; *newa++ = val;
184 delete [] (
values-size+1);
197 for (
long i=0; i<
size; i++)
212 const T**
v (
void)
const {
return const_cast<const T**
>(
values); }
236 return ( (i<0 || i>=
size ) ? NULL :
values[i]);
285 if (
size != s)
return false;
288 const T **vals =
new T* [
size];
289 for (i=0; i<
size; i++) vals[i] = one[i];
291 for (i=0; i<
size; i++) {
292 for (j=0; j<
size; j++)
293 if (vals[j] &&
values[i] == vals[j]) {
298 if (j == size)
break;
303 return (i == size) ?
true :
false;
316 for (j=0; j<size; j++)
317 if (values[j] == NULL)
break;
319 for (i=j+1; i<size; i++)
321 values[j++] = values[i];
332 this->realloc(size+src());
334 for (
long i=0; i<src(); i++)
335 if (! this->is_member (src[i]))
336 values[size++] = src[i];
338 if (asize-size>100 && asize>1.5*size)
errol;
344 #endif // MIDAS_GPA_H
void reallocplus(long d)
reallocate receiver to the new size
bool same_array_elements_asym(long nx, const ArgType *x, long ny, const ArgType *y, bool same_dim=false)
Function finds out whether every element of the array 'x' is in the array 'y'.
long give_num_nonNULL_ptrs2() const
get sum of nonNULL pointers in two levels
long arrays_arenot_identical(long n, ArgType *a1, ArgType *a2)
void free_ptrs_core(long newsize)
reallocate down (free pointers) receiver without checking of sizes
void delete_objects(void)
Delete all objects pointed by pointers. The pointers are set to NULL.
long is_member_of_array(ArgType val, long n, const ArgType *array)
check out "val" is member of "array"
T * at_or_null(long i) const
long give_asize(void) const
void initialize(long s, long ds=0)
GPA(const GPA< T > *src)
CONSTRUCTOR COPY.
long give_num_nonNULL_ptrs() const
get sum of nonNULL pointers in two levels
bool is_unique(void) const
bool members_are_unique(long n, const ArgType *array)
check out all members of array "a" are uniq
void realloc(long new_asize)
reallocate up receiver with checking the new size
T * operator[](long i) const
bool has_these_members(long s, const T **one) const
GPA(long s, long ds=1)
CONSTRUCTOR.
void realloc_core(long new_asize)
reallocate up receiver without checking of sizes
void be_copy_of(const GPA< T > *src)
void resizeup(long newsize)
long operator()(void) const
void add_unique(T *src)
add new pointer "src" if unique
GPA - Generic Pointer Array, template class manages 1d array of pointers to objects of type T...
void resize(long newsize)
reallocate receiver to the new size
bool has_these_members(const GPA< T > &one) const
bool is_member(T *val) const
void assign(long i, T *val)
void reallocdown(long new_asize)
reallocate up receiver with checking the new size
void reallocup(long new_asize)
reallocate up receiver with checking the new size
void resizedown(long newsize)
long give_size(void) const
bool has_same_members_as(const GPA< T > &one) const
T * add(T *val)
add (assign) new pointer to the end; enlarge the receiver if too small
bool is_identical_with(const GPA< T > &one) const
T * wedge(long i, T *val)
void delete_object(long i)
Delete object pointed by the i-th pointer. The pointer is set to NULL.
bool replace_member_by(T *oldv, T *newv)