forked from lix-project/lix
* ATermMap needs an assignment operator, otherwise we are screwed.
This commit is contained in:
parent
77557a6f06
commit
426593162e
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
ATermMap::ATermMap(unsigned int initialSize, unsigned int maxLoadPct)
|
ATermMap::ATermMap(unsigned int initialSize, unsigned int maxLoadPct)
|
||||||
|
: table(0)
|
||||||
{
|
{
|
||||||
this->maxLoadPct = maxLoadPct;
|
this->maxLoadPct = maxLoadPct;
|
||||||
table = ATtableCreate(initialSize, maxLoadPct);
|
table = ATtableCreate(initialSize, maxLoadPct);
|
||||||
|
@ -16,6 +17,36 @@ ATermMap::ATermMap(unsigned int initialSize, unsigned int maxLoadPct)
|
||||||
|
|
||||||
ATermMap::ATermMap(const ATermMap & map)
|
ATermMap::ATermMap(const ATermMap & map)
|
||||||
: table(0)
|
: table(0)
|
||||||
|
{
|
||||||
|
copy(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ATermMap::~ATermMap()
|
||||||
|
{
|
||||||
|
free();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ATermMap & ATermMap::operator = (const ATermMap & map)
|
||||||
|
{
|
||||||
|
if (this == &map) return *this;
|
||||||
|
free();
|
||||||
|
copy(map);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ATermMap::free()
|
||||||
|
{
|
||||||
|
if (table) {
|
||||||
|
ATtableDestroy(table);
|
||||||
|
table = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ATermMap::copy(const ATermMap & map)
|
||||||
{
|
{
|
||||||
ATermList keys = map.keys();
|
ATermList keys = map.keys();
|
||||||
|
|
||||||
|
@ -28,12 +59,6 @@ ATermMap::ATermMap(const ATermMap & map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ATermMap::~ATermMap()
|
|
||||||
{
|
|
||||||
if (table) ATtableDestroy(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ATermMap::set(ATerm key, ATerm value)
|
void ATermMap::set(ATerm key, ATerm value)
|
||||||
{
|
{
|
||||||
return ATtablePut(table, key, value);
|
return ATtablePut(table, key, value);
|
||||||
|
|
|
@ -29,6 +29,8 @@ public:
|
||||||
ATermMap(const ATermMap & map);
|
ATermMap(const ATermMap & map);
|
||||||
~ATermMap();
|
~ATermMap();
|
||||||
|
|
||||||
|
ATermMap & ATermMap::operator = (const ATermMap & map);
|
||||||
|
|
||||||
void set(ATerm key, ATerm value);
|
void set(ATerm key, ATerm value);
|
||||||
void set(const string & key, ATerm value);
|
void set(const string & key, ATerm value);
|
||||||
|
|
||||||
|
@ -46,6 +48,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void add(const ATermMap & map, ATermList & keys);
|
void add(const ATermMap & map, ATermList & keys);
|
||||||
|
|
||||||
|
void free();
|
||||||
|
void copy(const ATermMap & map);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue