Skip to content

Commit

Permalink
Add dyninstAPI/BPatch_Set.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent b6b926c commit 9967012
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 78 deletions.
13 changes: 8 additions & 5 deletions docs/dyninstAPI/public/BPatch_Set.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
BPatch_Set.h
############

.. cpp:class:: BPatch_Set
.. cpp:class:: template<class Key, class Compare = comparison<Key>> BPatch_Set
**BPatch_Set** is another container class, similar to the set class in
the STL. THIS CLASS HAS BEEN DEPRECATED AND WILL BE REMOVED IN THE NEXT
RELEASE. In addition the methods provided by std::set, it provides the
following compatibility methods:
**A tree-like container**

.. cpp:function:: BPatch_Set::BPatch_Set()

Expand Down Expand Up @@ -78,3 +75,9 @@ BPatch_Set.h
.. cpp:function:: BPatch_Set<T,Compare> operator- (const BPatch_Set<T,Compare>&)

Set difference operator.


.. cpp:struct:: template <class T> comparison

.. cpp:function:: bool operator() (const T&l, const T&r) const

73 changes: 0 additions & 73 deletions dyninstAPI/h/BPatch_Set.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#ifndef _BPatch_Set_h_
#define _BPatch_Set_h_

/*******************************************************/
/* header files */
/*******************************************************/

#include <assert.h>
#include <stdlib.h>
#include <set>
Expand All @@ -59,10 +55,6 @@ class BPatch_function;
class BPatch_flowGraph;
class BPatch;

/** template struct that will be used for default compare
* class for BPatch_Set operations.
*/

template <class T>
struct comparison {
bool operator() (const T&l, const T&r) const { return l < r; }
Expand Down Expand Up @@ -99,103 +91,58 @@ class BPATCH_DLL_EXPORT BPatch_Set {

DO_INLINE_F BPatch_Set(int_t s) : int_set(s) {}

/** copy constructor.
* @param newBPatch_Set the BPatch_Set which will be copied
*/
DO_INLINE_F BPatch_Set(const BPatch_Set<Key,Compare>& rhs){
int_set = rhs.int_set;
}

/** returns the cardinality of the tree , number of elements */
DO_INLINE_F unsigned int size() const { return int_set.size(); }

/** returns true if tree is empty */
DO_INLINE_F bool empty() const { return int_set.empty(); }

/** inserts the element in the tree
* @param 1 element that will be inserted
*/
DO_INLINE_F void insert(const Key &k) { int_set.insert(k); }

/** removes the element in the tree
* @param 1 element that will be removed
*/
DO_INLINE_F void remove(const Key &k) { int_set.erase(k); }
DO_INLINE_F void erase(const Key &k) { int_set.erase(k); }

/** returns true if the argument is member of the BPatch_Set
* @param e the element that will be searched for
*/
DO_INLINE_F bool contains(const Key &key) const { return int_set.find(key) != int_set.end(); }

/** fill an buffer array with the sorted
* elements of the BPatch_Set in ascending order according to comparison function
* if the BPatch_Set is empty it retuns NULL, other wise it returns
* the input argument.
*/
DO_INLINE_F Key* elements(Key *a) const {
std::copy(begin(), end(), a);
return a;
}

/** Like the above, but put things in a vector.
*/
DO_INLINE_F void elements(BPatch_Vector<Key> &v) {
std::copy(begin(), end(), std::back_inserter(v));
}

/** returns the minimum valued member in the BPatch_Set according to the
* comparison function supplied. If the BPatch_Set is empty it retuns
* any number. Not safe to use for empty sets
*/
DO_INLINE_F Key minimum() const {
if (empty()) return Key();
return *begin();
}

/** returns the maximum valued member in the BPatch_Set according to the
* comparison function supplied. If the BPatch_Set is empty it retuns
* any number. Not safe to use for empty sets
*/
DO_INLINE_F Key maximum() const {
if (empty()) return Key();
return *(--end());
}

/** assignment operator for BPatch_Set. It replicate sthe tree
* structure into the new BPatch_Set.
* @param 1 BPatch_Set that will be used in assignment
*/
DO_INLINE_F BPatch_Set<Key,Compare>& operator= (const BPatch_Set<Key,Compare>&rhs) {
int_set = rhs.int_set;
return *this;
}

/** equality comparison for the BPatch_Set
* @param 1 BPatch_Set that will be used equality check
*/
DO_INLINE_F bool operator== (const BPatch_Set<Key,Compare>&rhs) const {
return int_set == rhs.int_set;
}

/** inequality comparison for the BPatch_Set
* @param 1 BPatch_Set that will be used inequality check
*/
DO_INLINE_F bool operator!= (const BPatch_Set<Key,Compare>&rhs) const {
return int_set != rhs.int_set;
}

/** insertion in to the BPatch_Set
* @param 1 element that will be inserted
*/
DO_INLINE_F BPatch_Set<Key,Compare>& operator+= (const Key &k) {
int_set.insert(k);
return *this;
}

/** union operation with this BPatch_Set
* @param 1 BPatch_Set that will be used in union operation
*/
DO_INLINE_F BPatch_Set<Key,Compare>& operator|= (const BPatch_Set<Key,Compare> &rhs) {
Compare comp;
std::set<Key, Compare> tmp;
Expand All @@ -206,9 +153,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
}


/** intersection operation with this BPatch_Set
* @param 1 BPatch_Set that will be used in intersection operation
*/
DO_INLINE_F BPatch_Set<Key,Compare>& operator&= (const BPatch_Set<Key,Compare>&rhs) {
Compare comp;
std::set<Key, Compare> tmp;
Expand All @@ -218,9 +162,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
return *this;
}

/** difference operation with this BPatch_Set
* @param 1 BPatch_Set that will be used in difference operation
*/
DO_INLINE_F BPatch_Set<Key,Compare>& operator-= (const BPatch_Set<Key,Compare>&rhs) {
Compare comp;
std::set<Key, Compare> tmp;
Expand All @@ -230,9 +171,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
return *this;
}

/** union operation
* @param 1 BPatch_Set that will be used in union operation
*/
DO_INLINE_F BPatch_Set<Key,Compare> operator| (const BPatch_Set<Key,Compare>&rhs) const {
Compare comp;
BPatch_Set<Key, Compare> tmp;
Expand All @@ -241,9 +179,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
return tmp;
}

/** intersection operation
* @param 1 BPatch_Set that will be used in intersection operation
*/
DO_INLINE_F BPatch_Set<Key,Compare> operator& (const BPatch_Set<Key,Compare>&rhs) const {
Compare comp;
BPatch_Set<Key, Compare> tmp;
Expand All @@ -252,9 +187,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
return tmp;
}

/** difference operation
* @param 1 BPatch_Set that will be used in difference operation
*/
DO_INLINE_F BPatch_Set<Key,Compare> operator- (const BPatch_Set<Key,Compare>&rhs) const {
Compare comp;
BPatch_Set<Key, Compare> tmp;
Expand All @@ -263,11 +195,6 @@ class BPATCH_DLL_EXPORT BPatch_Set {
return tmp;
}

/** removes the element in the root of the tree
* if the BPatch_Set is empty it return false
* @param e refernce to the element that the value of removed
* element will be copied.
*/
DO_INLINE_F bool extract(Key&k) {
if (empty()) return false;
iterator iter = begin();
Expand Down

0 comments on commit 9967012

Please sign in to comment.