CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Types | Public Member Functions | Related Functions | List of all members
cs::point_set Class Reference

A set of points (point). More...

Public Types

typedef iterator const_iterator
 const iterator over the set contents. More...
 
typedef const pointconst_pointer
 const pointer to the type of the set elements. More...
 
typedef const pointconst_reference
 const reference to the type of the set elements. More...
 
typedef point_set_iterator iterator
 Iterator over the set contents. More...
 
typedef point key_type
 The type of the set elements. More...
 
typedef pointpointer
 Pointer to the type of the set elements. More...
 
typedef pointreference
 Reference to the type of the set elements. More...
 
typedef size_t size_type
 Type of set size (cardinality). More...
 
typedef point value_type
 The type of the set elements. More...
 

Public Member Functions

 point_set (const point_set &other)
 Copy constructor. More...
 
 point_set ()
 Construct an empty set. More...
 
 point_set (const std::vector< point_set > &v)
 Constructor: given a std::vector of sets, construct a set that is a multi-union of those sets. More...
 
 point_set (const std::vector< point > &v)
 Construct a set from a std::vector of elements. More...
 
 point_set (set_kind k)
 Construct an empty set of the specified kind. More...
 
bool add (const point &v)
 Add an element to the set. More...
 
std::string as_repr () const
 Get a representation of a set object that includes information useful for debugging.
 
std::string as_string () const
 Get a simple string representation of a set object. More...
 
iterator begin () const
 Get an iterator whose current position is the first element in the set. More...
 
compunit_points_vector categorize () const
 Categorize the points in a point_set by the compilation unit and procedure in which they are found. More...
 
compunit_points_pair_vector categorize_by_file () const
 Categorize the points in a point_set by the compilation unit in which they are found. More...
 
iterator cbegin () const
 Get an iterator whose current position is the first element in the set. More...
 
iterator cend () const
 Get an iterator whose current position is after the end of the set. More...
 
void clear ()
 Remove all elements from the set (that is, make it empty). More...
 
size_type count (const point &e) const
 Count the number of times the specified element appears in a set. More...
 
point_set difference (const point_set &b) const
 Set difference. More...
 
bool empty () const
 Check: is the set empty? More...
 
iterator end () const
 Get an iterator whose current position is after the end of the set. More...
 
size_type erase (const point &v)
 Remove an element from the set. More...
 
const_iterator find (const point &e) const
 Find element e in the set and return an iterator pointing to it if it is found. More...
 
cs_hash_t hash () const
 Get a hash of the set. More...
 
std::pair< iterator, bool > insert (const point &v)
 Insert an element into the set. More...
 
point_set intersect (const point_set &b) const
 Set intersection. More...
 
size_t intersect_size (const point_set &other) const
 Get the number of elements in the intersection of two point_set sets. More...
 
bool intersects_procedure (procedure p) const
 Check: does a point_set contain any points from the specified procedure? More...
 
set_kind kind () const
 Get the kind of a set. More...
 
point_setoperator= (point_set other)
 Assignment operator for point_set. More...
 
std::vector< procedureprocedures () const
 Get the procedures that contain one or more points in a point_set. More...
 
size_type size () const
 Get the set cardinality. More...
 
std::vector< pointsort () const
 Get a sorted std::vector of the points in a point_set. More...
 
std::vector< pointsort (const std::string &file_name) const
 Get a sorted std::vector of the points in a point_set, listing points from the specified file first. More...
 
void swap (point_set &other)
 Exchange the contents of this and other. More...
 
int_pair_set to_int_pair_set_in_sfileinst (sfileinst u) const
 Get the character positions in a specified source file instance of all points in a point_set. More...
 
std::vector< pointto_vector () const
 Get a std::vector of all the elements in the set. More...
 
point_set union_ (const point_set &b) const
 Set union. More...
 
void union_p (const point_set &b)
 Update a set to the union of itself and another set. More...
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const point_set &__x, const point_set &__y)
 Inequality operator for point_set. More...
 
std::ostream & operator<< (std::ostream &out, const point_set &a)
 Print a representation of a point_set object to the specified stream. More...
 
bool operator== (const point_set &__x, const point_set &__y)
 Equality operator for point_set. More...
 

Detailed Description

A set of points (point).

Use a point_set_iterator to iterate over a point_set. For example:

for (cs::point_set_iterator it = my_point_set.begin(); !it.at_end(); ++it){
std::cout << "point: " << *it;
}

Member Typedef Documentation

◆ const_iterator

typedef iterator cs::point_set::const_iterator
inherited

const iterator over the set contents.

◆ const_pointer

typedef const point * cs::point_set::const_pointer
inherited

const pointer to the type of the set elements.

◆ const_reference

typedef const point & cs::point_set::const_reference
inherited

const reference to the type of the set elements.

◆ iterator

typedef point_set_iterator cs::point_set::iterator
inherited

Iterator over the set contents.

◆ key_type

typedef point cs::point_set::key_type
inherited

The type of the set elements.

◆ pointer

typedef point * cs::point_set::pointer
inherited

Pointer to the type of the set elements.

◆ reference

typedef point & cs::point_set::reference
inherited

Reference to the type of the set elements.

◆ size_type

typedef size_t cs::point_set::size_type
inherited

Type of set size (cardinality).

◆ value_type

typedef point cs::point_set::value_type
inherited

The type of the set elements.

Constructor & Destructor Documentation

◆ point_set() [1/5]

cs::point_set::point_set ( const point_set other)

Copy constructor.

◆ point_set() [2/5]

cs::point_set::point_set ( )

Construct an empty set.

◆ point_set() [3/5]

cs::point_set::point_set ( set_kind  k)

Construct an empty set of the specified kind.

Parameters
[in]kThe set kind.
Exceptions
result::ERROR_CODESURFER_ONLYif k is set_kind::TRIE, which is only available in CodeSurfer.

◆ point_set() [4/5]

cs::point_set::point_set ( const std::vector< point_set > &  v)

Constructor: given a std::vector of sets, construct a set that is a multi-union of those sets.

◆ point_set() [5/5]

cs::point_set::point_set ( const std::vector< point > &  v)

Construct a set from a std::vector of elements.

Parameters
[in]vThe set elements.

Member Function Documentation

◆ add()

bool cs::point_set::add ( const point v)
inlineinherited

Add an element to the set.

Parameters
[in]vThe element to add.
Returns
true if v was not already present in the set, false if it was already present.

◆ as_string()

std::string cs::point_set::as_string ( ) const
inlineinherited

Get a simple string representation of a set object.

◆ begin()

iterator cs::point_set::begin ( ) const
inlineinherited

Get an iterator whose current position is the first element in the set.

Returns
The iterator.

◆ categorize()

compunit_points_vector cs::point_set::categorize ( ) const
inherited

Categorize the points in a point_set by the compilation unit and procedure in which they are found.

Returns
A std::vector in which the points (point) in the set are categorized by compilation unit (compunit) and, within each compilation unit, by procedure.
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ categorize_by_file()

compunit_points_pair_vector cs::point_set::categorize_by_file ( ) const
inherited

Categorize the points in a point_set by the compilation unit in which they are found.

Returns
A std::vector in which the points (point) in the set are categorized by compilation unit (compunit).
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ cbegin()

iterator cs::point_set::cbegin ( ) const
inlineinherited

Get an iterator whose current position is the first element in the set.

Returns
The iterator.

◆ cend()

iterator cs::point_set::cend ( ) const
inlineinherited

Get an iterator whose current position is after the end of the set.

Returns
The iterator.

◆ clear()

void cs::point_set::clear ( )
inlineinherited

Remove all elements from the set (that is, make it empty).

Returns
void

◆ count()

size_type cs::point_set::count ( const point e) const
inlineinherited

Count the number of times the specified element appears in a set.

Parameters
[in]eThe element of interest.
Returns
1 if e is present in the set, 0 otherwise.

◆ difference()

point_set cs::point_set::difference ( const point_set b) const
inlineinherited

Set difference.

Parameters
[in]bThe set to subtract from this.
Returns
A set containing this - b.

The returned set contains the elements in this that are not in b.

◆ empty()

bool cs::point_set::empty ( ) const
inlineinherited

Check: is the set empty?

Returns
true if the set is empty, false otherwise.

◆ end()

iterator cs::point_set::end ( ) const
inlineinherited

Get an iterator whose current position is after the end of the set.

Returns
The iterator.

◆ erase()

size_type cs::point_set::erase ( const point v)
inlineinherited

Remove an element from the set.

Parameters
[in]vThe element to remove.
Returns
The number of elements deleted:
  • 1 if v was present in the set.
  • 0 if v was not present in the set.

◆ find()

const_iterator cs::point_set::find ( const point e) const
inlineinherited

Find element e in the set and return an iterator pointing to it if it is found.

Returns
An iterator whose current position is:
  • the set element matching e if e is present in the set,
  • after the end of the set otherwise.

◆ hash()

cs_hash_t cs::point_set::hash ( ) const
inlineinherited

Get a hash of the set.

Returns
The hash value for the set.

◆ insert()

std::pair<iterator, bool> cs::point_set::insert ( const point v)
inlineinherited

Insert an element into the set.

Parameters
[in]vThe element to add.
Returns
A pair (itr,b), where
  • itr points to the newly inserted element (or the element whose key is equivalent, if it was already present).
  • b is true if v was not already present in the set, false if it was already present.

◆ intersect()

point_set cs::point_set::intersect ( const point_set b) const
inlineinherited

Set intersection.

Parameters
[in]bThe other operand for the intersection operation.
Returns
A set containing this INTERSECT b.

The returned set contains the elements that are in both this and b.

◆ intersect_size()

size_t cs::point_set::intersect_size ( const point_set other) const
inlineinherited

Get the number of elements in the intersection of two point_set sets.

Parameters
[in]otherThe point_set to intersect with.
Returns
The number of elements in the intersection with other.

◆ intersects_procedure()

bool cs::point_set::intersects_procedure ( procedure  p) const
inherited

Check: does a point_set contain any points from the specified procedure?

Parameters
[in]pThe procedure of interest.
Returns
true if the point_set contains any points from p, false otherwise.
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ kind()

set_kind cs::point_set::kind ( ) const
inlineinherited

Get the kind of a set.

Returns
The set kind (cs::set_kind).
Exceptions
result::ELEMENT_NOT_PRESENTif the set was constructed with the default constructor and no elements have been added yet.

◆ operator=()

point_set& cs::point_set::operator= ( point_set  other)

Assignment operator for point_set.

◆ procedures()

std::vector<procedure> cs::point_set::procedures ( ) const
inherited

Get the procedures that contain one or more points in a point_set.

Returns
A std::vector containing all procedures (procedure) that contain one or more of the points (point) in the point_set.
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ size()

size_type cs::point_set::size ( ) const
inlineinherited

Get the set cardinality.

Returns
The number of elements in the set.

◆ sort() [1/2]

std::vector<point> cs::point_set::sort ( ) const
inherited

Get a sorted std::vector of the points in a point_set.

Returns
A std::vector containing all points (point) in the point_set, sorted first by the alphabetical order of the file in which they occur, secondly by the position of the text they represent in the source file, and thirdly by the vertex kind.
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ sort() [2/2]

std::vector<point> cs::point_set::sort ( const std::string &  file_name) const
inherited

Get a sorted std::vector of the points in a point_set, listing points from the specified file first.

Parameters
[in]file_nameThe name of a file. Points from this file will appear before any other points in the sorted list. If file_name is an empty string, behavior is the same as for sort().
Returns
A std::vector containing all points (point) in the point_set, sorted first by file - with points in the file named file_name first, and thereafter by file name in alphabetical order, secondly by the position of the text they represent in the source file, and thirdly by the vertex kind.
Exceptions
result::ERROR_SDG_NOT_PRESENTif no project is loaded.

◆ swap()

void cs::point_set::swap ( point_set other)
inlineinherited

Exchange the contents of this and other.

◆ to_int_pair_set_in_sfileinst()

int_pair_set cs::point_set::to_int_pair_set_in_sfileinst ( sfileinst  u) const
inherited

Get the character positions in a specified source file instance of all points in a point_set.

Parameters
[in]uThe source file instance (sfileinst) of interest.
Returns
A new int_pair_set representing the character positions in source file instance u of the points in the point_set.

◆ to_vector()

std::vector<point > cs::point_set::to_vector ( ) const
inlineinherited

Get a std::vector of all the elements in the set.

Returns
A std::vector containing all the elements in the set.

◆ union_()

point_set cs::point_set::union_ ( const point_set b) const
inlineinherited

Set union.

Parameters
[in]bThe other operand for the union operation.
Returns
A set containing this UNION b.

The returned set contains the elements that are in this, b, or both.

◆ union_p()

void cs::point_set::union_p ( const point_set b)
inlineinherited

Update a set to the union of itself and another set.

Parameters
[in]bThe set whose elements are to be added.
Returns
void

this is updated to contain this UNION b.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const point_set __x,
const point_set __y 
)
related

Inequality operator for point_set.

Parameters
[in]__xThe set to compare.
[in]__yThe set to compare against.
Returns
false if __x equal to __y according to operator==(), true otherwise.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const point_set a 
)
related

Print a representation of a point_set object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]aThe point_set object to print.
Returns
void

◆ operator==()

bool operator== ( const point_set __x,
const point_set __y 
)
related

Equality operator for point_set.

Parameters
[in]__xThe set to compare.
[in]__yThe set to compare against.
Returns
true if __x equal to __y, false otherwise.

The documentation for this class was generated from the following file: