* include/cln/GV.h: Preceed inherited members with this->.
* include/cln/SV.h: Likewise.
* include/cln/object.h: Likewise.
* src/base/hash/cl_hash1.h: Likewise.
* src/base/hash/cl_hash1weak.h: Likewise.
* src/base/hash/cl_hash2.h: Likewise.
* src/base/hash/cl_hashuniq.h: Likewise.
* src/base/hash/cl_hash.h: Make lookup of static member function
explicit.
* src/base/hash/cl_hash2weak.h: Likewise.
* src/base/hash/cl_hashuniqweak.h: Likewise.
* src/modinteger/cl_MI.cc: Make shell-comment a C-comment. Geez.
+2003-06-29 Richard Kreckel <kreckel@ginac.de>
+
+ Dependent base resolution needed for GCC-3.4
+ * include/cln/GV.h: Preceed inherited members with this->.
+ * include/cln/SV.h: Likewise.
+ * include/cln/object.h: Likewise.
+ * src/base/hash/cl_hash1.h: Likewise.
+ * src/base/hash/cl_hash1weak.h: Likewise.
+ * src/base/hash/cl_hash2.h: Likewise.
+ * src/base/hash/cl_hashuniq.h: Likewise.
+ * src/base/hash/cl_hash.h: Make lookup of static member function
+ explicit.
+ * src/base/hash/cl_hash2weak.h: Likewise.
+ * src/base/hash/cl_hashuniqweak.h: Likewise.
+ * src/modinteger/cl_MI.cc: Make shell-comment a C-comment. Geez.
+
2003-02-24 Bruno Haible <bruno@clisp.org>
* src/base/random/cl_random_from.cc (random_state::random_state): Add
// Length.
uintL length () const
{
- return ((const cl_heap_GV<T> *) pointer)->v.length();
+ return ((const cl_heap_GV<T> *) this->pointer)->v.length();
}
// Reference. Forbid modification of `const cl_GV&' arguments.
const cl_GV_constindex<T> operator[] (unsigned long index) const
{
- return ((const cl_heap_GV<T> *) pointer)->v[index];
+ return ((const cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_index<T> operator[] (unsigned long index)
{
- return ((cl_heap_GV<T> *) pointer)->v[index];
+ return ((cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_constindex<T> operator[] (long index) const
{ return operator[]((unsigned long)index); }
template <class T, class BASE>
inline CL_GV(T,BASE)::operator cl_heap_GV<T>* () const
{
- cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)pointer;
+ cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)this->pointer;
cl_inc_refcount(*this);
return hpointer;
}
// Length.
uintL length () const
{
- return ((const cl_heap_SV<T> *) pointer)->v.length();
+ return ((const cl_heap_SV<T> *) this->pointer)->v.length();
}
// Reference. Forbid modification of `const cl_SV&' arguments.
const T & operator[] (unsigned long index) const
{
- return ((const cl_heap_SV<T> *) pointer)->v[index];
+ return ((const cl_heap_SV<T> *) this->pointer)->v[index];
}
T & operator[] (unsigned long index)
{
- return ((cl_heap_SV<T> *) pointer)->v[index];
+ return ((cl_heap_SV<T> *) this->pointer)->v[index];
}
// New ANSI C++ compilers also want the following.
const T & operator[] (unsigned int index) const
{ \
cl_uint x_word = x.word; \
cl_inc_refcount(x); \
- word = x_word; \
+ this->word = x_word; \
}
// The declaration of a copy constructor.
cl_uint x_word = x.word; \
cl_inc_refcount(x); \
cl_dec_refcount(*this); \
- word = x_word; \
+ this->word = x_word; \
return *this; \
}
template <class htentry>
struct cl_heap_hashtable : public cl_heap {
- friend struct _cl_hashtable_iterator<htentry>;
+ friend struct _cl_hashtable_iterator<htentry>;
protected:
typedef struct htxentry {
long next; // > 0: pseudo-list continues at next-1
void operator delete (void* ptr) { free_hook(ptr); }
// Constructor: build a new, empty table.
cl_heap_hashtable (long initial_size = 5) : cl_heap (),
- _size (initial_size), _count (0), _garcol_fun (no_garcol)
+ _size (initial_size), _count (0), _garcol_fun (cl_heap_hashtable<htentry>::no_garcol)
{
_modulus = compute_modulus(_size);
_total_vector = malloc_hook(_modulus*sizeof(long) + _size*sizeof(htxentry));
// if it is not NULL.
value_type* get (const key1_type& key)
{
- var long index = _slots[hashcode(key) % _modulus] - 1;
+ var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,_entries[index].entry.key))
- return &_entries[index].entry.val;
- index = _entries[index].next - 1;
+ if (equal(key,this->_entries[index].entry.key))
+ return &this->_entries[index].entry.val;
+ index = this->_entries[index].next - 1;
}
return NULL;
}
var unsigned long hcode = hashcode(key);
// Search whether it is already there.
{
- var long index = _slots[hcode % _modulus] - 1;
+ var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,_entries[index].entry.key)) {
- _entries[index].entry.val = val;
+ if (equal(key,this->_entries[index].entry.key)) {
+ this->_entries[index].entry.val = val;
return;
}
- index = _entries[index].next - 1;
+ index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
- var long hindex = hcode % _modulus; // _modulus may have changed!
+ var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
- new (&_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
- _entries[index].next = _slots[hindex];
- _slots[hindex] = 1+index;
- _count++;
+ new (&this->_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
+ this->_entries[index].next = this->_slots[hindex];
+ this->_slots[hindex] = 1+index;
+ this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key)
{
- var long* _index = &_slots[hashcode(key) % _modulus];
+ var long* _index = &this->_slots[hashcode(key) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,_entries[index].entry.key)) {
+ if (equal(key,this->_entries[index].entry.key)) {
// Remove _entries[index].entry
- *_index = _entries[index].next;
- _entries[index].~htxentry();
+ *_index = this->_entries[index].next;
+ this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
- _count--;
+ this->_count--;
return;
}
- _index = &_entries[index].next;
+ _index = &this->_entries[index].next;
}
}
// Iterate through the table.
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
- if (_freelist < -1)
+ if (this->_freelist < -1)
return;
// Can we make room?
- if (_garcol_fun(this))
- if (_freelist < -1)
+ if (this->_garcol_fun(this))
+ if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
- if (_freelist >= -1) {
- if (!_garcol_fun(this) || (_freelist >= -1))
+ if (this->_freelist >= -1) {
+ if (!this->_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
- var long new_size = _size + (_size >> 1) + 1; // _size*1.5
+ var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
- var htxentry* old_entries = _entries;
- for (var long old_index = 0; old_index < _size; old_index++)
+ var htxentry* old_entries = this->_entries;
+ for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var key1_type& key = old_entries[old_index].entry.key;
var value_type& val = old_entries[old_index].entry.val;
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
- free_hook(_total_vector);
- _modulus = new_modulus;
- _size = new_size;
- _freelist = free_list_head;
- _slots = new_slots;
- _entries = new_entries;
- _total_vector = new_total_vector;
+ free_hook(this->_total_vector);
+ this->_modulus = new_modulus;
+ this->_size = new_size;
+ this->_freelist = free_list_head;
+ this->_slots = new_slots;
+ this->_entries = new_entries;
+ this->_total_vector = new_total_vector;
}
};
: cl_heap_hashtable_1 <key1_type,value_type> (),
_maygc_htentry (maygc_htentry)
{
- _garcol_fun = garcol;
+ this->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol;
}
private:
// Garbage collection.
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
- ht->_garcol_fun = garcol_nexttime;
+ ht->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
{
var cl_heap_weak_hashtable_1* ht = (cl_heap_weak_hashtable_1*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
- ht->_garcol_fun = garcol;
+ ht->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol;
return cl_false;
}
};
// if it is not NULL.
value_type* get (const key1_type& key1, const key2_type& key2)
{
- var long index = _slots[hashcode(key1,key2) % _modulus] - 1;
+ var long index = this->_slots[hashcode(key1,key2) % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key1,_entries[index].entry.key1)
- && equal(key2,_entries[index].entry.key2))
- return &_entries[index].entry.val;
- index = _entries[index].next - 1;
+ if (equal(key1,this->_entries[index].entry.key1)
+ && equal(key2,this->_entries[index].entry.key2))
+ return &this->_entries[index].entry.val;
+ index = this->_entries[index].next - 1;
}
return NULL;
}
var unsigned long hcode = hashcode(key1,key2);
// Search whether it is already there.
{
- var long index = _slots[hcode % _modulus] - 1;
+ var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key1,_entries[index].entry.key1)
- && equal(key2,_entries[index].entry.key2)) {
- _entries[index].entry.val = val;
+ if (equal(key1,this->_entries[index].entry.key1)
+ && equal(key2,this->_entries[index].entry.key2)) {
+ this->_entries[index].entry.val = val;
return;
}
- index = _entries[index].next - 1;
+ index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
- var long hindex = hcode % _modulus; // _modulus may have changed!
+ var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
- new (&_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
- _entries[index].next = _slots[hindex];
- _slots[hindex] = 1+index;
- _count++;
+ new (&this->_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
+ this->_entries[index].next = this->_slots[hindex];
+ this->_slots[hindex] = 1+index;
+ this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key1, const key2_type& key2)
{
- var long* _index = &_slots[hashcode(key1,key2) % _modulus];
+ var long* _index = &this->_slots[hashcode(key1,key2) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key1,_entries[index].entry.key1)
- && equal(key2,_entries[index].entry.key2)) {
+ if (equal(key1,this->_entries[index].entry.key1)
+ && equal(key2,this->_entries[index].entry.key2)) {
// Remove _entries[index].entry
- *_index = _entries[index].next;
- _entries[index].~htxentry();
+ *_index = this->_entries[index].next;
+ this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
- _count--;
+ this->_count--;
return;
}
- _index = &_entries[index].next;
+ _index = &this->_entries[index].next;
}
}
// Iterate through the table.
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
- if (_freelist < -1)
+ if (this->_freelist < -1)
return;
// Can we make room?
if (_garcol_fun(this))
- if (_freelist < -1)
+ if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
- if (_freelist >= -1) {
- if (!_garcol_fun(this) || (_freelist >= -1))
+ if (this->_freelist >= -1) {
+ if (!_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
- var long new_size = _size + (_size >> 1) + 1; // _size*1.5
+ var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
- var htxentry* old_entries = _entries;
- for (var long old_index = 0; old_index < _size; old_index++)
+ var htxentry* old_entries = this->_entries;
+ for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var key1_type& key1 = old_entries[old_index].entry.key1;
var key2_type& key2 = old_entries[old_index].entry.key2;
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
- free_hook(_total_vector);
- _modulus = new_modulus;
- _size = new_size;
- _freelist = free_list_head;
- _slots = new_slots;
- _entries = new_entries;
- _total_vector = new_total_vector;
+ free_hook(this->_total_vector);
+ this->_modulus = new_modulus;
+ this->_size = new_size;
+ this->_freelist = free_list_head;
+ this->_slots = new_slots;
+ this->_entries = new_entries;
+ this->_total_vector = new_total_vector;
}
};
: cl_heap_hashtable_2 <key1_type,key2_type,value_type> (),
_maygc_htentry (maygc_htentry)
{
- _garcol_fun = garcol;
+ this->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol;
}
private:
// Garbage collection.
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
- ht->_garcol_fun = garcol_nexttime;
+ ht->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
{
var cl_heap_weak_hashtable_2* ht = (cl_heap_weak_hashtable_2*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
- ht->_garcol_fun = garcol;
+ ht->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol;
return cl_false;
}
};
// if it is not NULL.
value_type * get (const key1_type& key)
{
- var long index = _slots[hashcode(key) % _modulus] - 1;
+ var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,hashkey(_entries[index].entry.val)))
- return &_entries[index].entry.val;
- index = _entries[index].next - 1;
+ if (equal(key,hashkey(this->_entries[index].entry.val)))
+ return &this->_entries[index].entry.val;
+ index = this->_entries[index].next - 1;
}
return NULL;
}
var unsigned long hcode = hashcode(key);
// Search whether it is already there.
{
- var long index = _slots[hcode % _modulus] - 1;
+ var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,hashkey(_entries[index].entry.val)))
+ if (equal(key,hashkey(this->_entries[index].entry.val)))
return;
- index = _entries[index].next - 1;
+ index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
- var long hindex = hcode % _modulus; // _modulus may have changed!
+ var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
- new (&_entries[index].entry) cl_htuniqentry<key1_type,value_type> (value_type((struct hashuniq *)0, key));
- _entries[index].next = _slots[hindex];
- _slots[hindex] = 1+index;
- _count++;
+ new (&this->_entries[index].entry) cl_htuniqentry<key1_type,value_type> (value_type((struct hashuniq *)0, key));
+ this->_entries[index].next = this->_slots[hindex];
+ this->_slots[hindex] = 1+index;
+ this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key)
{
- var long* _index = &_slots[hashcode(key) % _modulus];
+ var long* _index = &this->_slots[hashcode(key) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
- if (!(index < _size))
+ if (!(index < this->_size))
cl_abort();
- if (equal(key,hashkey(_entries[index].entry.val))) {
+ if (equal(key,hashkey(this->_entries[index].entry.val))) {
// Remove _entries[index].entry
- *_index = _entries[index].next;
- _entries[index].~htxentry();
+ *_index = this->_entries[index].next;
+ this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
- _count--;
+ this->_count--;
return;
}
- _index = &_entries[index].next;
+ _index = &this->_entries[index].next;
}
}
// Iterate through the table.
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
- if (_freelist < -1)
+ if (this->_freelist < -1)
return;
// Can we make room?
if (_garcol_fun(this))
- if (_freelist < -1)
+ if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
- if (_freelist >= -1) {
- if (!_garcol_fun(this) || (_freelist >= -1))
+ if (this->_freelist >= -1) {
+ if (!_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
- var long new_size = _size + (_size >> 1) + 1; // _size*1.5
+ var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
- var htxentry* old_entries = _entries;
- for (var long old_index = 0; old_index < _size; old_index++)
+ var htxentry* old_entries = this->_entries;
+ for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var value_type& val = old_entries[old_index].entry.val;
var long hindex = hashcode(hashkey(val)) % new_modulus;
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
- free_hook(_total_vector);
- _modulus = new_modulus;
- _size = new_size;
- _freelist = free_list_head;
- _slots = new_slots;
- _entries = new_entries;
- _total_vector = new_total_vector;
+ free_hook(this->_total_vector);
+ this->_modulus = new_modulus;
+ this->_size = new_size;
+ this->_freelist = free_list_head;
+ this->_slots = new_slots;
+ this->_entries = new_entries;
+ this->_total_vector = new_total_vector;
}
};
cl_heap_weak_hashtable_uniq ()
: cl_heap_hashtable_uniq <key1_type,value_type> ()
{
- _garcol_fun = garcol;
+ this->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol;
}
private:
// Garbage collection.
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
- ht->_garcol_fun = garcol_nexttime;
+ ht->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
{
var cl_heap_weak_hashtable_uniq* ht = (cl_heap_weak_hashtable_uniq*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
- ht->_garcol_fun = garcol;
+ ht->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol;
return cl_false;
}
};
#include "cln/abort.h"
#include "cl_alloca.h"
-# MacOS X does "#define _R 0x00040000L"
-# Grr...
+// MacOS X does "#define _R 0x00040000L"
+// Grr...
#undef _R
namespace cln {