Commit 3372ca7d authored by Millian Poquet's avatar Millian Poquet

[code] intervalset: fix memleak + add missing doc

parent 0d33c9c6
......@@ -238,25 +238,40 @@ bool MachineRange::operator==(const MachineRange &other)
return set == other.set;
}
MachineRange & intersection(const MachineRange & one, const MachineRange & other)
MachineRange intersection(const MachineRange & one, const MachineRange & other)
{
MachineRange * result = new MachineRange();
result->set = one.set & other.set;
return *result;
MachineRange result;
result.set = one.set & other.set;
return result;
}
MachineRange & difference(const MachineRange & one, const MachineRange &other)
MachineRange operator&(const MachineRange & one, const MachineRange & other)
{
MachineRange * result = new MachineRange();
result->set = one.set - other.set;
return *result;
return intersection(one, other);
}
MachineRange & union_itvs(const MachineRange & one, const MachineRange &other)
MachineRange difference(const MachineRange & one, const MachineRange &other)
{
MachineRange * result = new MachineRange();
result->set = one.set + other.set;
return *result;
MachineRange result;
result.set = one.set - other.set;
return result;
}
MachineRange operator-(const MachineRange & one, const MachineRange &other)
{
return one - other;
}
MachineRange union_itvs(const MachineRange & one, const MachineRange &other)
{
MachineRange result;
result.set = one.set + other.set;
return result;
}
MachineRange operator|(const MachineRange & one, const MachineRange &other)
{
return union_itvs(one, other);
}
MachineRange & MachineRange::operator&=(const MachineRange & other)
......@@ -271,6 +286,12 @@ MachineRange & MachineRange::operator-=(const MachineRange &other)
return *this;
}
MachineRange &MachineRange::operator|=(const MachineRange &other)
{
set |= other.set;
return *this;
}
int MachineRange::operator[](int index) const
{
xbt_assert(index >= 0 && index < (int)this->size(),
......
......@@ -185,28 +185,25 @@ public:
bool operator==(const MachineRange & other);
/**
* @breif Returns the intersection of two MachineRange
*/
//MachineRange & operator&(const MachineRange & other);
/**
* @breif Returns the difference of two MachineRange
* @brief In-place set intersection operation.
* @param[in] other The other MachineRange
* @return The current MachineRange after the intersection.
*/
//MachineRange & operator-(const MachineRange & other);
MachineRange & operator&=(const MachineRange & other);
/**
* @brief Sets the set as the intersection between itself and another MachineRange
* @brief In-place set difference operation.
* @param[in] other The other MachineRange
* @return The current MachineRange after the operation
* @return The current MachineRange after the difference
*/
MachineRange & operator &=(const MachineRange & other);
MachineRange & operator-=(const MachineRange & other);
/**
* @brief Sets the set as the difference between itself and another MachineRange
* @brief In-place set union operation.
* @param[in] other The other MachineRange
* @return The current MachineRange after the operation
* @return The current MachineRange after the union.
*/
MachineRange & operator-=(const MachineRange & other);
MachineRange & operator|=(const MachineRange & other);
/**
* @brief Returns the index-th machine of the MachineRange
......@@ -233,9 +230,50 @@ public:
Set set; //!< The internal set of machines
};
/**
* @brief Returns the (set) intersection of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The intersection of the two given MachineRange
*/
MachineRange intersection(const MachineRange & one, const MachineRange & other);
/**
* @brief Returns the (set) intersection of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The intersection of the two given MachineRange
*/
MachineRange operator&(const MachineRange & one, const MachineRange & other);
MachineRange & difference(const MachineRange & one, const MachineRange & other);
/**
* @brief Returns the (set) difference of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The difference (one \ other) of the two given MachineRange
*/
MachineRange difference(const MachineRange & one, const MachineRange &other);
MachineRange & intersection(const MachineRange & one, const MachineRange & other);
/**
* @brief Returns the (set) difference of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The difference (one \ other) of the two given MachineRange
*/
MachineRange operator-(const MachineRange & one, const MachineRange &other);
MachineRange & union_itvs(const MachineRange & one, const MachineRange & other);
/**
* @brief Returns the (set) union of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The union of the two given MachineRange
*/
MachineRange union_itvs(const MachineRange & one, const MachineRange &other);
/**
* @brief Returns the (set) union of two MachineRange
* @param[in] one A MachineRange
* @param[in] other Another MachineRange
* @return The union of the two given MachineRange
*/
MachineRange operator|(const MachineRange & one, const MachineRange &other);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment